babylon.d.ts 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. }
  182. }
  183. interface Window {
  184. mozIndexedDB: IDBFactory;
  185. webkitIndexedDB: IDBFactory;
  186. msIndexedDB: IDBFactory;
  187. webkitURL: typeof URL;
  188. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  189. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  190. WebGLRenderingContext: WebGLRenderingContext;
  191. MSGesture: MSGesture;
  192. CANNON: any;
  193. AudioContext: AudioContext;
  194. webkitAudioContext: AudioContext;
  195. PointerEvent: any;
  196. Math: Math;
  197. Uint8Array: Uint8ArrayConstructor;
  198. Float32Array: Float32ArrayConstructor;
  199. mozURL: typeof URL;
  200. msURL: typeof URL;
  201. VRFrameData: any;
  202. DracoDecoderModule: any;
  203. }
  204. interface WebGLRenderingContext {
  205. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  206. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  207. vertexAttribDivisor(index: number, divisor: number): void;
  208. createVertexArray(): any;
  209. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  210. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  211. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  212. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  213. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  214. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  215. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  216. createQuery(): WebGLQuery;
  217. deleteQuery(query: WebGLQuery): void;
  218. beginQuery(target: number, query: WebGLQuery): void;
  219. endQuery(target: number): void;
  220. getQueryParameter(query: WebGLQuery, pname: number): any;
  221. getQuery(target: number, pname: number): any;
  222. MAX_SAMPLES: number;
  223. RGBA8: number;
  224. READ_FRAMEBUFFER: number;
  225. DRAW_FRAMEBUFFER: number;
  226. UNIFORM_BUFFER: number;
  227. HALF_FLOAT_OES: number;
  228. RGBA16F: number;
  229. RGBA32F: number;
  230. R32F: number;
  231. RG32F: number;
  232. RGB32F: number;
  233. RED: number;
  234. RG: number;
  235. UNSIGNED_INT_24_8: number;
  236. DEPTH24_STENCIL8: number;
  237. drawBuffers(buffers: number[]): void;
  238. readBuffer(src: number): void;
  239. readonly COLOR_ATTACHMENT0: number;
  240. readonly COLOR_ATTACHMENT1: number;
  241. readonly COLOR_ATTACHMENT2: number;
  242. readonly COLOR_ATTACHMENT3: number;
  243. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  244. ANY_SAMPLES_PASSED: number;
  245. QUERY_RESULT_AVAILABLE: number;
  246. QUERY_RESULT: number;
  247. }
  248. interface Document {
  249. mozCancelFullScreen(): void;
  250. msCancelFullScreen(): void;
  251. mozFullScreen: boolean;
  252. msIsFullScreen: boolean;
  253. fullscreen: boolean;
  254. mozPointerLockElement: HTMLElement;
  255. msPointerLockElement: HTMLElement;
  256. webkitPointerLockElement: HTMLElement;
  257. }
  258. interface HTMLCanvasElement {
  259. msRequestPointerLock?(): void;
  260. mozRequestPointerLock?(): void;
  261. webkitRequestPointerLock?(): void;
  262. }
  263. interface CanvasRenderingContext2D {
  264. msImageSmoothingEnabled: boolean;
  265. }
  266. interface WebGLBuffer {
  267. references: number;
  268. capacity: number;
  269. is32Bits: boolean;
  270. }
  271. interface WebGLProgram {
  272. transformFeedback?: WebGLTransformFeedback | null;
  273. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  274. }
  275. interface MouseEvent {
  276. mozMovementX: number;
  277. mozMovementY: number;
  278. webkitMovementX: number;
  279. webkitMovementY: number;
  280. msMovementX: number;
  281. msMovementY: number;
  282. }
  283. interface Navigator {
  284. mozGetVRDevices: (any: any) => any;
  285. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  286. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  287. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  288. webkitGetGamepads(): Gamepad[];
  289. msGetGamepads(): Gamepad[];
  290. webkitGamepads(): Gamepad[];
  291. }
  292. interface HTMLVideoElement {
  293. mozSrcObject: any;
  294. }
  295. interface Screen {
  296. orientation: string;
  297. mozOrientation: string;
  298. }
  299. interface Math {
  300. fround(x: number): number;
  301. imul(a: number, b: number): number;
  302. }
  303. interface EXT_disjoint_timer_query {
  304. QUERY_COUNTER_BITS_EXT: number;
  305. TIME_ELAPSED_EXT: number;
  306. TIMESTAMP_EXT: number;
  307. GPU_DISJOINT_EXT: number;
  308. QUERY_RESULT_EXT: number;
  309. QUERY_RESULT_AVAILABLE_EXT: number;
  310. queryCounterEXT(query: WebGLQuery, target: number): void;
  311. createQueryEXT(): WebGLQuery;
  312. beginQueryEXT(target: number, query: WebGLQuery): void;
  313. endQueryEXT(target: number): void;
  314. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  315. deleteQueryEXT(query: WebGLQuery): void;
  316. }
  317. interface WebGLUniformLocation {
  318. _currentState: any;
  319. }
  320. declare module BABYLON {
  321. /**
  322. * Node is the basic class for all scene objects (Mesh, Light Camera).
  323. */
  324. class Node {
  325. /**
  326. * Gets or sets the name of the node
  327. */
  328. name: string;
  329. /**
  330. * Gets or sets the id of the node
  331. */
  332. id: string;
  333. /**
  334. * Gets or sets the unique id of the node
  335. */
  336. uniqueId: number;
  337. /**
  338. * Gets or sets a string used to store user defined state for the node
  339. */
  340. state: string;
  341. /**
  342. * Gets or sets an object used to store user defined information for the node
  343. */
  344. metadata: any;
  345. /**
  346. * Gets or sets a boolean used to define if the node must be serialized
  347. */
  348. doNotSerialize: boolean;
  349. /** @hidden */
  350. _isDisposed: boolean;
  351. /**
  352. * Gets a list of Animations associated with the node
  353. */
  354. animations: Animation[];
  355. private _ranges;
  356. /**
  357. * Callback raised when the node is ready to be used
  358. */
  359. onReady: (node: Node) => void;
  360. private _isEnabled;
  361. private _isReady;
  362. /** @hidden */
  363. _currentRenderId: number;
  364. private _parentRenderId;
  365. protected _childRenderId: number;
  366. /** @hidden */
  367. _waitingParentId: Nullable<string>;
  368. private _scene;
  369. /** @hidden */
  370. _cache: any;
  371. private _parentNode;
  372. private _children;
  373. /**
  374. * Gets a boolean indicating if the node has been disposed
  375. * @returns true if the node was disposed
  376. */
  377. isDisposed(): boolean;
  378. /**
  379. * Gets or sets the parent of the node
  380. */
  381. parent: Nullable<Node>;
  382. private _animationPropertiesOverride;
  383. /**
  384. * Gets or sets the animation properties override
  385. */
  386. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  387. /**
  388. * Gets a string idenfifying the name of the class
  389. * @returns "Node" string
  390. */
  391. getClassName(): string;
  392. /**
  393. * An event triggered when the mesh is disposed
  394. */
  395. onDisposeObservable: Observable<Node>;
  396. private _onDisposeObserver;
  397. /**
  398. * Sets a callback that will be raised when the node will be disposed
  399. */
  400. onDispose: () => void;
  401. /**
  402. * Creates a new Node
  403. * @param {string} name - the name and id to be given to this node
  404. * @param {BABYLON.Scene} the scene this node will be added to
  405. */
  406. constructor(name: string, scene?: Nullable<Scene>);
  407. /**
  408. * Gets the scene of the node
  409. * @returns a {BABYLON.Scene}
  410. */
  411. getScene(): Scene;
  412. /**
  413. * Gets the engine of the node
  414. * @returns a {BABYLON.Engine}
  415. */
  416. getEngine(): Engine;
  417. private _behaviors;
  418. /**
  419. * Attach a behavior to the node
  420. * @see http://doc.babylonjs.com/features/behaviour
  421. * @param behavior defines the behavior to attach
  422. * @returns the current Node
  423. */
  424. addBehavior(behavior: Behavior<Node>): Node;
  425. /**
  426. * Remove an attached behavior
  427. * @see http://doc.babylonjs.com/features/behaviour
  428. * @param behavior defines the behavior to attach
  429. * @returns the current Node
  430. */
  431. removeBehavior(behavior: Behavior<Node>): Node;
  432. /**
  433. * Gets the list of attached behaviors
  434. * @see http://doc.babylonjs.com/features/behaviour
  435. */
  436. readonly behaviors: Behavior<Node>[];
  437. /**
  438. * Gets an attached behavior by name
  439. * @param name defines the name of the behavior to look for
  440. * @see http://doc.babylonjs.com/features/behaviour
  441. * @returns null if behavior was not found else the requested behavior
  442. */
  443. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  444. /**
  445. * Returns the world matrix of the node
  446. * @returns a matrix containing the node's world matrix
  447. */
  448. getWorldMatrix(): Matrix;
  449. /** @hidden */
  450. _getWorldMatrixDeterminant(): number;
  451. /** @hidden */
  452. _initCache(): void;
  453. /** @hidden */
  454. updateCache(force?: boolean): void;
  455. /** @hidden */
  456. _updateCache(ignoreParentClass?: boolean): void;
  457. /** @hidden */
  458. _isSynchronized(): boolean;
  459. /** @hidden */
  460. _markSyncedWithParent(): void;
  461. /** @hidden */
  462. isSynchronizedWithParent(): boolean;
  463. /** @hidden */
  464. isSynchronized(updateCache?: boolean): boolean;
  465. /** @hidden */
  466. hasNewParent(update?: boolean): boolean;
  467. /**
  468. * Is this node ready to be used/rendered
  469. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  470. * @return true if the node is ready
  471. */
  472. isReady(completeCheck?: boolean): boolean;
  473. /**
  474. * Is this node enabled?
  475. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  476. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  477. * @return whether this node (and its parent) is enabled
  478. */
  479. isEnabled(checkAncestors?: boolean): boolean;
  480. /**
  481. * Set the enabled state of this node
  482. * @param value defines the new enabled state
  483. */
  484. setEnabled(value: boolean): void;
  485. /**
  486. * Is this node a descendant of the given node?
  487. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  488. * @param ancestor defines the parent node to inspect
  489. * @returns a boolean indicating if this node is a descendant of the given node
  490. */
  491. isDescendantOf(ancestor: Node): boolean;
  492. /** @hidden */
  493. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  494. /**
  495. * Will return all nodes that have this node as ascendant
  496. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  497. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  498. * @return all children nodes of all types
  499. */
  500. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  501. /**
  502. * Get all child-meshes of this node
  503. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  504. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  505. * @returns an array of {BABYLON.AbstractMesh}
  506. */
  507. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  508. /**
  509. * Get all child-transformNodes of this node
  510. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  511. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  512. * @returns an array of {BABYLON.TransformNode}
  513. */
  514. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  515. /**
  516. * Get all direct children of this node
  517. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  518. * @returns an array of {BABYLON.Node}
  519. */
  520. getChildren(predicate?: (node: Node) => boolean): Node[];
  521. /** @hidden */
  522. _setReady(state: boolean): void;
  523. /**
  524. * Get an animation by name
  525. * @param name defines the name of the animation to look for
  526. * @returns null if not found else the requested animation
  527. */
  528. getAnimationByName(name: string): Nullable<Animation>;
  529. /**
  530. * Creates an animation range for this node
  531. * @param name defines the name of the range
  532. * @param from defines the starting key
  533. * @param to defines the end key
  534. */
  535. createAnimationRange(name: string, from: number, to: number): void;
  536. /**
  537. * Delete a specific animation range
  538. * @param name defines the name of the range to delete
  539. * @param deleteFrames defines if animation frames from the range must be deleted as well
  540. */
  541. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  542. /**
  543. * Get an animation range by name
  544. * @param name defines the name of the animation range to look for
  545. * @returns null if not found else the requested animation range
  546. */
  547. getAnimationRange(name: string): Nullable<AnimationRange>;
  548. /**
  549. * Will start the animation sequence
  550. * @param name defines the range frames for animation sequence
  551. * @param loop defines if the animation should loop (false by default)
  552. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  553. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  554. * @returns the object created for this animation. If range does not exist, it will return null
  555. */
  556. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  557. /**
  558. * Serialize animation ranges into a JSON compatible object
  559. * @returns serialization object
  560. */
  561. serializeAnimationRanges(): any;
  562. /**
  563. * Computes the world matrix of the node
  564. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  565. * @returns the world matrix
  566. */
  567. computeWorldMatrix(force?: boolean): Matrix;
  568. /**
  569. * Releases resources associated with this node.
  570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  572. */
  573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  574. /**
  575. * Parse animation range data from a serialization object and store them into a given node
  576. * @param node defines where to store the animation ranges
  577. * @param parsedNode defines the serialization object to read data from
  578. * @param scene defines the hosting scene
  579. */
  580. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  581. }
  582. }
  583. declare module BABYLON {
  584. /**
  585. * Define an interface for all classes that will hold resources
  586. */
  587. interface IDisposable {
  588. /**
  589. * Releases all held resources
  590. */
  591. dispose(): void;
  592. }
  593. /**
  594. * Interface used to let developers provide their own mesh selection mechanism
  595. */
  596. interface IActiveMeshCandidateProvider {
  597. /**
  598. * Return the list of active meshes
  599. * @param scene defines the current scene
  600. * @returns the list of active meshes
  601. */
  602. getMeshes(scene: Scene): AbstractMesh[];
  603. /**
  604. * Indicates if the meshes have been checked to make sure they are isEnabled()
  605. */
  606. readonly checksIsEnabled: boolean;
  607. }
  608. /**
  609. * This class is used by the onRenderingGroupObservable
  610. */
  611. class RenderingGroupInfo {
  612. /**
  613. * The Scene that being rendered
  614. */
  615. scene: Scene;
  616. /**
  617. * The camera currently used for the rendering pass
  618. */
  619. camera: Nullable<Camera>;
  620. /**
  621. * The ID of the renderingGroup being processed
  622. */
  623. renderingGroupId: number;
  624. /**
  625. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  626. */
  627. renderStage: number;
  628. /**
  629. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  630. * This stage will be fired no matter what
  631. */
  632. static STAGE_PRECLEAR: number;
  633. /**
  634. * Called before opaque object are rendered.
  635. * This stage will be fired only if there's 3D Opaque content to render
  636. */
  637. static STAGE_PREOPAQUE: number;
  638. /**
  639. * Called after the opaque objects are rendered and before the transparent ones
  640. * This stage will be fired only if there's 3D transparent content to render
  641. */
  642. static STAGE_PRETRANSPARENT: number;
  643. /**
  644. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  645. * This stage will be fired no matter what
  646. */
  647. static STAGE_POSTTRANSPARENT: number;
  648. }
  649. /**
  650. * Represents a scene to be rendered by the engine.
  651. * @see http://doc.babylonjs.com/features/scene
  652. */
  653. class Scene implements IAnimatable {
  654. private static _FOGMODE_NONE;
  655. private static _FOGMODE_EXP;
  656. private static _FOGMODE_EXP2;
  657. private static _FOGMODE_LINEAR;
  658. private static _uniqueIdCounter;
  659. /**
  660. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  662. */
  663. static MinDeltaTime: number;
  664. /**
  665. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  667. */
  668. static MaxDeltaTime: number;
  669. /** The fog is deactivated */
  670. static readonly FOGMODE_NONE: number;
  671. /** The fog density is following an exponential function */
  672. static readonly FOGMODE_EXP: number;
  673. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  674. static readonly FOGMODE_EXP2: number;
  675. /** The fog density is following a linear function. */
  676. static readonly FOGMODE_LINEAR: number;
  677. /**
  678. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  679. */
  680. autoClear: boolean;
  681. /**
  682. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  683. */
  684. autoClearDepthAndStencil: boolean;
  685. /**
  686. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  687. */
  688. clearColor: Color4;
  689. /**
  690. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  691. */
  692. ambientColor: Color3;
  693. /** @hidden */
  694. _environmentBRDFTexture: BaseTexture;
  695. /** @hidden */
  696. protected _environmentTexture: BaseTexture;
  697. /**
  698. * Texture used in all pbr material as the reflection texture.
  699. * As in the majority of the scene they are the same (exception for multi room and so on),
  700. * this is easier to reference from here than from all the materials.
  701. */
  702. /**
  703. * Texture used in all pbr material as the reflection texture.
  704. * As in the majority of the scene they are the same (exception for multi room and so on),
  705. * this is easier to set here than in all the materials.
  706. */
  707. environmentTexture: BaseTexture;
  708. /** @hidden */
  709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  710. /**
  711. * Default image processing configuration used either in the rendering
  712. * Forward main pass or through the imageProcessingPostProcess if present.
  713. * As in the majority of the scene they are the same (exception for multi camera),
  714. * this is easier to reference from here than from all the materials and post process.
  715. *
  716. * No setter as we it is a shared configuration, you can set the values instead.
  717. */
  718. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  719. private _forceWireframe;
  720. /**
  721. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  722. */
  723. forceWireframe: boolean;
  724. private _forcePointsCloud;
  725. /**
  726. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  727. */
  728. forcePointsCloud: boolean;
  729. /**
  730. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  731. */
  732. forceShowBoundingBoxes: boolean;
  733. /**
  734. * Gets or sets the active clipplane
  735. */
  736. clipPlane: Nullable<Plane>;
  737. /**
  738. * Gets or sets a boolean indicating if animations are enabled
  739. */
  740. animationsEnabled: boolean;
  741. private _animationPropertiesOverride;
  742. /**
  743. * Gets or sets the animation properties override
  744. */
  745. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  746. /**
  747. * Gets or sets a boolean indicating if a constant deltatime has to be used
  748. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  749. */
  750. useConstantAnimationDeltaTime: boolean;
  751. /**
  752. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  753. * Please note that it requires to run a ray cast through the scene on every frame
  754. */
  755. constantlyUpdateMeshUnderPointer: boolean;
  756. /**
  757. * Defines the HTML cursor to use when hovering over interactive elements
  758. */
  759. hoverCursor: string;
  760. /**
  761. * Defines the HTML default cursor to use (empty by default)
  762. */
  763. defaultCursor: string;
  764. /**
  765. * This is used to call preventDefault() on pointer down
  766. * in order to block unwanted artifacts like system double clicks
  767. */
  768. preventDefaultOnPointerDown: boolean;
  769. /**
  770. * Gets or sets user defined metadata
  771. */
  772. metadata: any;
  773. /**
  774. * Gets the name of the plugin used to load this scene (null by default)
  775. */
  776. loadingPluginName: string;
  777. /**
  778. * Use this array to add regular expressions used to disable offline support for specific urls
  779. */
  780. disableOfflineSupportExceptionRules: RegExp[];
  781. private _spritePredicate;
  782. /**
  783. * An event triggered when the scene is disposed.
  784. */
  785. onDisposeObservable: Observable<Scene>;
  786. private _onDisposeObserver;
  787. /** Sets a function to be executed when this scene is disposed. */
  788. onDispose: () => void;
  789. /**
  790. * An event triggered before rendering the scene (right after animations and physics)
  791. */
  792. onBeforeRenderObservable: Observable<Scene>;
  793. private _onBeforeRenderObserver;
  794. /** Sets a function to be executed before rendering this scene */
  795. beforeRender: Nullable<() => void>;
  796. /**
  797. * An event triggered after rendering the scene
  798. */
  799. onAfterRenderObservable: Observable<Scene>;
  800. private _onAfterRenderObserver;
  801. /** Sets a function to be executed after rendering this scene */
  802. afterRender: Nullable<() => void>;
  803. /**
  804. * An event triggered before animating the scene
  805. */
  806. onBeforeAnimationsObservable: Observable<Scene>;
  807. /**
  808. * An event triggered after animations processing
  809. */
  810. onAfterAnimationsObservable: Observable<Scene>;
  811. /**
  812. * An event triggered before draw calls are ready to be sent
  813. */
  814. onBeforeDrawPhaseObservable: Observable<Scene>;
  815. /**
  816. * An event triggered after draw calls have been sent
  817. */
  818. onAfterDrawPhaseObservable: Observable<Scene>;
  819. /**
  820. * An event triggered when physic simulation is about to be run
  821. */
  822. onBeforePhysicsObservable: Observable<Scene>;
  823. /**
  824. * An event triggered when physic simulation has been done
  825. */
  826. onAfterPhysicsObservable: Observable<Scene>;
  827. /**
  828. * An event triggered when the scene is ready
  829. */
  830. onReadyObservable: Observable<Scene>;
  831. /**
  832. * An event triggered before rendering a camera
  833. */
  834. onBeforeCameraRenderObservable: Observable<Camera>;
  835. private _onBeforeCameraRenderObserver;
  836. /** Sets a function to be executed before rendering a camera*/
  837. beforeCameraRender: () => void;
  838. /**
  839. * An event triggered after rendering a camera
  840. */
  841. onAfterCameraRenderObservable: Observable<Camera>;
  842. private _onAfterCameraRenderObserver;
  843. /** Sets a function to be executed after rendering a camera*/
  844. afterCameraRender: () => void;
  845. /**
  846. * An event triggered when active meshes evaluation is about to start
  847. */
  848. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when active meshes evaluation is done
  851. */
  852. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  853. /**
  854. * An event triggered when particles rendering is about to start
  855. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  856. */
  857. onBeforeParticlesRenderingObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when particles rendering is done
  860. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  861. */
  862. onAfterParticlesRenderingObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when sprites rendering is about to start
  865. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  866. */
  867. onBeforeSpritesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when sprites rendering is done
  870. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  871. */
  872. onAfterSpritesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  875. */
  876. onDataLoadedObservable: Observable<Scene>;
  877. /**
  878. * An event triggered when a camera is created
  879. */
  880. onNewCameraAddedObservable: Observable<Camera>;
  881. /**
  882. * An event triggered when a camera is removed
  883. */
  884. onCameraRemovedObservable: Observable<Camera>;
  885. /**
  886. * An event triggered when a light is created
  887. */
  888. onNewLightAddedObservable: Observable<Light>;
  889. /**
  890. * An event triggered when a light is removed
  891. */
  892. onLightRemovedObservable: Observable<Light>;
  893. /**
  894. * An event triggered when a geometry is created
  895. */
  896. onNewGeometryAddedObservable: Observable<Geometry>;
  897. /**
  898. * An event triggered when a geometry is removed
  899. */
  900. onGeometryRemovedObservable: Observable<Geometry>;
  901. /**
  902. * An event triggered when a transform node is created
  903. */
  904. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  905. /**
  906. * An event triggered when a transform node is removed
  907. */
  908. onTransformNodeRemovedObservable: Observable<TransformNode>;
  909. /**
  910. * An event triggered when a mesh is created
  911. */
  912. onNewMeshAddedObservable: Observable<AbstractMesh>;
  913. /**
  914. * An event triggered when a mesh is removed
  915. */
  916. onMeshRemovedObservable: Observable<AbstractMesh>;
  917. /**
  918. * An event triggered when render targets are about to be rendered
  919. * Can happen multiple times per frame.
  920. */
  921. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  922. /**
  923. * An event triggered when render targets were rendered.
  924. * Can happen multiple times per frame.
  925. */
  926. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  927. /**
  928. * An event triggered before calculating deterministic simulation step
  929. */
  930. onBeforeStepObservable: Observable<Scene>;
  931. /**
  932. * An event triggered after calculating deterministic simulation step
  933. */
  934. onAfterStepObservable: Observable<Scene>;
  935. /**
  936. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  937. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  938. * 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)
  939. */
  940. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  941. /**
  942. * Gets a list of Animations associated with the scene
  943. */
  944. animations: Animation[];
  945. private _registeredForLateAnimationBindings;
  946. /**
  947. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  948. */
  949. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  950. /**
  951. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  952. */
  953. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  954. /**
  955. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  956. */
  957. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  958. private _onPointerMove;
  959. private _onPointerDown;
  960. private _onPointerUp;
  961. /** Deprecated. Use onPointerObservable instead */
  962. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  963. /** Deprecated. Use onPointerObservable instead */
  964. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  965. /** Deprecated. Use onPointerObservable instead */
  966. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  967. /** Deprecated. Use onPointerObservable instead */
  968. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  969. private _gamepadManager;
  970. /**
  971. * Gets the gamepad manager associated with the scene
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  973. */
  974. readonly gamepadManager: GamepadManager;
  975. /**
  976. * 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).
  977. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  978. */
  979. onPrePointerObservable: Observable<PointerInfoPre>;
  980. /**
  981. * Observable event triggered each time an input event is received from the rendering canvas
  982. */
  983. onPointerObservable: Observable<PointerInfo>;
  984. /**
  985. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  986. */
  987. readonly unTranslatedPointer: Vector2;
  988. /** The distance in pixel that you have to move to prevent some events */
  989. static DragMovementThreshold: number;
  990. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  991. static LongPressDelay: number;
  992. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  993. static DoubleClickDelay: number;
  994. /** If you need to check double click without raising a single click at first click, enable this flag */
  995. static ExclusiveDoubleClickMode: boolean;
  996. private _initClickEvent;
  997. private _initActionManager;
  998. private _delayedSimpleClick;
  999. private _delayedSimpleClickTimeout;
  1000. private _previousDelayedSimpleClickTimeout;
  1001. private _meshPickProceed;
  1002. private _previousButtonPressed;
  1003. private _currentPickResult;
  1004. private _previousPickResult;
  1005. private _totalPointersPressed;
  1006. private _doubleClickOccured;
  1007. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1008. cameraToUseForPointers: Nullable<Camera>;
  1009. private _pointerX;
  1010. private _pointerY;
  1011. private _unTranslatedPointerX;
  1012. private _unTranslatedPointerY;
  1013. private _startingPointerPosition;
  1014. private _previousStartingPointerPosition;
  1015. private _startingPointerTime;
  1016. private _previousStartingPointerTime;
  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. /**
  1101. * All of the lights added to this scene
  1102. * @see http://doc.babylonjs.com/babylon101/lights
  1103. */
  1104. lights: Light[];
  1105. /** All of the cameras added to this scene.
  1106. * @see http://doc.babylonjs.com/babylon101/cameras
  1107. */
  1108. cameras: Camera[];
  1109. /** All of the active cameras added to this scene. */
  1110. activeCameras: Camera[];
  1111. /** The current active camera */
  1112. activeCamera: Nullable<Camera>;
  1113. /**
  1114. * All of the tranform nodes added to this scene
  1115. * @see http://doc.babylonjs.com/how_to/transformnode
  1116. */
  1117. transformNodes: TransformNode[];
  1118. /**
  1119. * All of the (abstract) meshes added to this scene
  1120. */
  1121. meshes: AbstractMesh[];
  1122. /**
  1123. * All of the animation groups added to this scene
  1124. * @see http://doc.babylonjs.com/how_to/group
  1125. */
  1126. animationGroups: AnimationGroup[];
  1127. private _geometries;
  1128. /**
  1129. * All of the materials added to this scene
  1130. * @see http://doc.babylonjs.com/babylon101/materials
  1131. */
  1132. materials: Material[];
  1133. /**
  1134. * All of the multi-materials added to this scene
  1135. * @see http://doc.babylonjs.com/how_to/multi_materials
  1136. */
  1137. multiMaterials: MultiMaterial[];
  1138. private _defaultMaterial;
  1139. /** The default material used on meshes when no material is affected */
  1140. /** The default material used on meshes when no material is affected */
  1141. defaultMaterial: Material;
  1142. private _texturesEnabled;
  1143. /**
  1144. * Gets or sets a boolean indicating if textures are enabled on this scene
  1145. */
  1146. texturesEnabled: boolean;
  1147. /**
  1148. * All of the textures added to this scene
  1149. */
  1150. textures: BaseTexture[];
  1151. /**
  1152. * Gets or sets a boolean indicating if particles are enabled on this scene
  1153. */
  1154. particlesEnabled: boolean;
  1155. /**
  1156. * All of the particle systems added to this scene
  1157. * @see http://doc.babylonjs.com/babylon101/particles
  1158. */
  1159. particleSystems: IParticleSystem[];
  1160. /**
  1161. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1162. */
  1163. spritesEnabled: boolean;
  1164. /**
  1165. * All of the sprite managers added to this scene
  1166. * @see http://doc.babylonjs.com/babylon101/sprites
  1167. */
  1168. spriteManagers: SpriteManager[];
  1169. /**
  1170. * The list of layers (background and foreground) of the scene
  1171. */
  1172. layers: Layer[];
  1173. /**
  1174. * The list of effect layers (highlights/glow) added to the scene
  1175. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1176. * @see http://doc.babylonjs.com/how_to/glow_layer
  1177. */
  1178. effectLayers: EffectLayer[];
  1179. private _skeletonsEnabled;
  1180. /**
  1181. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1182. */
  1183. skeletonsEnabled: boolean;
  1184. /**
  1185. * The list of skeletons added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1187. */
  1188. skeletons: Skeleton[];
  1189. /**
  1190. * The list of morph target managers added to the scene
  1191. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1192. */
  1193. morphTargetManagers: MorphTargetManager[];
  1194. /**
  1195. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1196. */
  1197. lensFlaresEnabled: boolean;
  1198. /**
  1199. * The list of lens flare system added to the scene
  1200. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1201. */
  1202. lensFlareSystems: LensFlareSystem[];
  1203. /**
  1204. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1206. */
  1207. collisionsEnabled: boolean;
  1208. private _workerCollisions;
  1209. /** @hidden */
  1210. collisionCoordinator: ICollisionCoordinator;
  1211. /**
  1212. * Defines the gravity applied to this scene (used only for collisions)
  1213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1214. */
  1215. gravity: Vector3;
  1216. /**
  1217. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1218. */
  1219. postProcessesEnabled: boolean;
  1220. /**
  1221. * The list of postprocesses added to the scene
  1222. */
  1223. postProcesses: PostProcess[];
  1224. /**
  1225. * Gets the current postprocess manager
  1226. */
  1227. postProcessManager: PostProcessManager;
  1228. private _postProcessRenderPipelineManager;
  1229. /**
  1230. * Gets the postprocess render pipeline manager
  1231. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1232. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1233. */
  1234. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1235. /**
  1236. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1237. */
  1238. renderTargetsEnabled: boolean;
  1239. /**
  1240. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1241. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1242. */
  1243. dumpNextRenderTargets: boolean;
  1244. /**
  1245. * The list of user defined render targets added to the scene
  1246. */
  1247. customRenderTargets: RenderTargetTexture[];
  1248. /**
  1249. * Defines if texture loading must be delayed
  1250. * If true, textures will only be loaded when they need to be rendered
  1251. */
  1252. useDelayedTextureLoading: boolean;
  1253. /**
  1254. * Gets the list of meshes imported to the scene through SceneLoader
  1255. */
  1256. importedMeshesFiles: String[];
  1257. /**
  1258. * Gets or sets a boolean indicating if probes are enabled on this scene
  1259. */
  1260. probesEnabled: boolean;
  1261. /**
  1262. * The list of reflection probes added to the scene
  1263. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1264. */
  1265. reflectionProbes: ReflectionProbe[];
  1266. /**
  1267. * @hidden
  1268. */
  1269. database: Database;
  1270. /**
  1271. * Gets or sets the action manager associated with the scene
  1272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1273. */
  1274. actionManager: ActionManager;
  1275. /** @hidden */
  1276. _actionManagers: ActionManager[];
  1277. private _meshesForIntersections;
  1278. /**
  1279. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1280. */
  1281. proceduralTexturesEnabled: boolean;
  1282. /**
  1283. * The list of procedural textures added to the scene
  1284. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1285. */
  1286. proceduralTextures: ProceduralTexture[];
  1287. private _mainSoundTrack;
  1288. /**
  1289. * The list of sound tracks added to the scene
  1290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1291. */
  1292. soundTracks: SoundTrack[];
  1293. private _audioEnabled;
  1294. private _headphone;
  1295. /**
  1296. * Gets the main soundtrack associated with the scene
  1297. */
  1298. readonly mainSoundTrack: SoundTrack;
  1299. /**
  1300. * Gets or sets the VRExperienceHelper attached to the scene
  1301. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1302. * @ignorenaming
  1303. */
  1304. VRHelper: VRExperienceHelper;
  1305. /**
  1306. * Gets or sets the simplification queue attached to the scene
  1307. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1308. */
  1309. simplificationQueue: SimplificationQueue;
  1310. private _engine;
  1311. private _totalVertices;
  1312. /** @hidden */
  1313. _activeIndices: PerfCounter;
  1314. /** @hidden */
  1315. _activeParticles: PerfCounter;
  1316. /** @hidden */
  1317. _activeBones: PerfCounter;
  1318. private _animationRatio;
  1319. private _animationTimeLast;
  1320. private _animationTime;
  1321. /**
  1322. * Gets or sets a general scale for animation speed
  1323. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1324. */
  1325. animationTimeScale: number;
  1326. /** @hidden */
  1327. _cachedMaterial: Nullable<Material>;
  1328. /** @hidden */
  1329. _cachedEffect: Nullable<Effect>;
  1330. /** @hidden */
  1331. _cachedVisibility: Nullable<number>;
  1332. private _renderId;
  1333. private _executeWhenReadyTimeoutId;
  1334. private _intermediateRendering;
  1335. private _viewUpdateFlag;
  1336. private _projectionUpdateFlag;
  1337. private _alternateViewUpdateFlag;
  1338. private _alternateProjectionUpdateFlag;
  1339. /** @hidden */
  1340. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1341. private _activeRequests;
  1342. private _pendingData;
  1343. private _isDisposed;
  1344. /**
  1345. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1346. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1347. */
  1348. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1349. private _activeMeshes;
  1350. private _processedMaterials;
  1351. private _renderTargets;
  1352. /** @hidden */
  1353. _activeParticleSystems: SmartArray<IParticleSystem>;
  1354. private _activeSkeletons;
  1355. private _softwareSkinnedMeshes;
  1356. private _renderingManager;
  1357. private _physicsEngine;
  1358. /** @hidden */
  1359. _activeAnimatables: Animatable[];
  1360. private _transformMatrix;
  1361. private _sceneUbo;
  1362. private _alternateSceneUbo;
  1363. private _pickWithRayInverseMatrix;
  1364. private _boundingBoxRenderer;
  1365. private _outlineRenderer;
  1366. private _viewMatrix;
  1367. private _projectionMatrix;
  1368. private _alternateViewMatrix;
  1369. private _alternateProjectionMatrix;
  1370. private _alternateTransformMatrix;
  1371. private _useAlternateCameraConfiguration;
  1372. private _alternateRendering;
  1373. /** @hidden */
  1374. _forcedViewPosition: Nullable<Vector3>;
  1375. /** @hidden */
  1376. readonly _isAlternateRenderingEnabled: boolean;
  1377. private _frustumPlanes;
  1378. /**
  1379. * Gets the list of frustum planes (built from the active camera)
  1380. */
  1381. readonly frustumPlanes: Plane[];
  1382. /**
  1383. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1384. * This is useful if there are more lights that the maximum simulteanous authorized
  1385. */
  1386. requireLightSorting: boolean;
  1387. private _selectionOctree;
  1388. private _pointerOverMesh;
  1389. private _pointerOverSprite;
  1390. private _debugLayer;
  1391. private _depthRenderer;
  1392. private _geometryBufferRenderer;
  1393. /**
  1394. * Gets the current geometry buffer associated to the scene.
  1395. */
  1396. /**
  1397. * Sets the current geometry buffer for the scene.
  1398. */
  1399. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1400. private _pickedDownMesh;
  1401. private _pickedUpMesh;
  1402. private _pickedDownSprite;
  1403. private _externalData;
  1404. private _uid;
  1405. /**
  1406. * Creates a new Scene
  1407. * @param engine defines the engine to use to render this scene
  1408. */
  1409. constructor(engine: Engine);
  1410. /**
  1411. * Gets the debug layer associated with the scene
  1412. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1413. */
  1414. readonly debugLayer: DebugLayer;
  1415. /**
  1416. * Gets a boolean indicating if collisions are processed on a web worker
  1417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1418. */
  1419. workerCollisions: boolean;
  1420. /**
  1421. * Gets the octree used to boost mesh selection (picking)
  1422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1423. */
  1424. readonly selectionOctree: Octree<AbstractMesh>;
  1425. /**
  1426. * Gets the mesh that is currently under the pointer
  1427. */
  1428. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1429. /**
  1430. * Gets the current on-screen X position of the pointer
  1431. */
  1432. readonly pointerX: number;
  1433. /**
  1434. * Gets the current on-screen Y position of the pointer
  1435. */
  1436. readonly pointerY: number;
  1437. /**
  1438. * Gets the cached material (ie. the latest rendered one)
  1439. * @returns the cached material
  1440. */
  1441. getCachedMaterial(): Nullable<Material>;
  1442. /**
  1443. * Gets the cached effect (ie. the latest rendered one)
  1444. * @returns the cached effect
  1445. */
  1446. getCachedEffect(): Nullable<Effect>;
  1447. /**
  1448. * Gets the cached visibility state (ie. the latest rendered one)
  1449. * @returns the cached visibility state
  1450. */
  1451. getCachedVisibility(): Nullable<number>;
  1452. /**
  1453. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1454. * @param material defines the current material
  1455. * @param effect defines the current effect
  1456. * @param visibility defines the current visibility state
  1457. * @returns true if one parameter is not cached
  1458. */
  1459. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1460. /**
  1461. * Gets the bounding box renderer associated with the scene
  1462. * @returns a BoundingBoxRenderer
  1463. */
  1464. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1465. /**
  1466. * Gets the outline renderer associated with the scene
  1467. * @returns a OutlineRenderer
  1468. */
  1469. getOutlineRenderer(): OutlineRenderer;
  1470. /**
  1471. * Gets the engine associated with the scene
  1472. * @returns an Engine
  1473. */
  1474. getEngine(): Engine;
  1475. /**
  1476. * Gets the total number of vertices rendered per frame
  1477. * @returns the total number of vertices rendered per frame
  1478. */
  1479. getTotalVertices(): number;
  1480. /**
  1481. * Gets the performance counter for total vertices
  1482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1483. */
  1484. readonly totalVerticesPerfCounter: PerfCounter;
  1485. /**
  1486. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1487. * @returns the total number of active indices rendered per frame
  1488. */
  1489. getActiveIndices(): number;
  1490. /**
  1491. * Gets the performance counter for active indices
  1492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1493. */
  1494. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1495. /**
  1496. * Gets the total number of active particles rendered per frame
  1497. * @returns the total number of active particles rendered per frame
  1498. */
  1499. getActiveParticles(): number;
  1500. /**
  1501. * Gets the performance counter for active particles
  1502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1503. */
  1504. readonly activeParticlesPerfCounter: PerfCounter;
  1505. /**
  1506. * Gets the total number of active bones rendered per frame
  1507. * @returns the total number of active bones rendered per frame
  1508. */
  1509. getActiveBones(): number;
  1510. /**
  1511. * Gets the performance counter for active bones
  1512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1513. */
  1514. readonly activeBonesPerfCounter: PerfCounter;
  1515. /** @hidden */
  1516. getInterFramePerfCounter(): number;
  1517. /** @hidden */
  1518. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1519. /** @hidden */
  1520. getLastFrameDuration(): number;
  1521. /** @hidden */
  1522. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1523. /** @hidden */
  1524. getEvaluateActiveMeshesDuration(): number;
  1525. /** @hidden */
  1526. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1527. /**
  1528. * Gets the array of active meshes
  1529. * @returns an array of AbstractMesh
  1530. */
  1531. getActiveMeshes(): SmartArray<AbstractMesh>;
  1532. /** @hidden */
  1533. getRenderTargetsDuration(): number;
  1534. /** @hidden */
  1535. getRenderDuration(): number;
  1536. /** @hidden */
  1537. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1538. /** @hidden */
  1539. getParticlesDuration(): number;
  1540. /** @hidden */
  1541. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1542. /** @hidden */
  1543. getSpritesDuration(): number;
  1544. /** @hidden */
  1545. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1546. /**
  1547. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1548. * @returns a number
  1549. */
  1550. getAnimationRatio(): number;
  1551. /**
  1552. * Gets an unique Id for the current frame
  1553. * @returns a number
  1554. */
  1555. getRenderId(): number;
  1556. /** Call this function if you want to manually increment the render Id*/
  1557. incrementRenderId(): void;
  1558. private _updatePointerPosition(evt);
  1559. private _createUbo();
  1560. private _createAlternateUbo();
  1561. /**
  1562. * Use this method to simulate a pointer move on a mesh
  1563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1566. * @returns the current scene
  1567. */
  1568. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1569. private _processPointerMove(pickResult, evt);
  1570. /**
  1571. * Use this method to simulate a pointer down on a mesh
  1572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1575. * @returns the current scene
  1576. */
  1577. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1578. private _processPointerDown(pickResult, evt);
  1579. /**
  1580. * Use this method to simulate a pointer up on a mesh
  1581. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1582. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1583. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1584. * @returns the current scene
  1585. */
  1586. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1587. private _processPointerUp(pickResult, evt, clickInfo);
  1588. /**
  1589. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1590. * @param attachUp defines if you want to attach events to pointerup
  1591. * @param attachDown defines if you want to attach events to pointerdown
  1592. * @param attachMove defines if you want to attach events to pointermove
  1593. */
  1594. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1595. /** Detaches all event handlers*/
  1596. detachControl(): void;
  1597. /**
  1598. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1599. * Delay loaded resources are not taking in account
  1600. * @return true if all required resources are ready
  1601. */
  1602. isReady(): boolean;
  1603. /** Resets all cached information relative to material (including effect and visibility) */
  1604. resetCachedMaterial(): void;
  1605. /**
  1606. * Registers a function to be called before every frame render
  1607. * @param func defines the function to register
  1608. */
  1609. registerBeforeRender(func: () => void): void;
  1610. /**
  1611. * Unregisters a function called before every frame render
  1612. * @param func defines the function to unregister
  1613. */
  1614. unregisterBeforeRender(func: () => void): void;
  1615. /**
  1616. * Registers a function to be called after every frame render
  1617. * @param func defines the function to register
  1618. */
  1619. registerAfterRender(func: () => void): void;
  1620. /**
  1621. * Unregisters a function called after every frame render
  1622. * @param func defines the function to unregister
  1623. */
  1624. unregisterAfterRender(func: () => void): void;
  1625. private _executeOnceBeforeRender(func);
  1626. /**
  1627. * The provided function will run before render once and will be disposed afterwards.
  1628. * A timeout delay can be provided so that the function will be executed in N ms.
  1629. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1630. * @param func The function to be executed.
  1631. * @param timeout optional delay in ms
  1632. */
  1633. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1634. /** @hidden */
  1635. _addPendingData(data: any): void;
  1636. /** @hidden */
  1637. _removePendingData(data: any): void;
  1638. /**
  1639. * Returns the number of items waiting to be loaded
  1640. * @returns the number of items waiting to be loaded
  1641. */
  1642. getWaitingItemsCount(): number;
  1643. /**
  1644. * Returns a boolean indicating if the scene is still loading data
  1645. */
  1646. readonly isLoading: boolean;
  1647. /**
  1648. * Registers a function to be executed when the scene is ready
  1649. * @param {Function} func - the function to be executed
  1650. */
  1651. executeWhenReady(func: () => void): void;
  1652. /**
  1653. * Returns a promise that resolves when the scene is ready
  1654. * @returns A promise that resolves when the scene is ready
  1655. */
  1656. whenReadyAsync(): Promise<void>;
  1657. /** @hidden */
  1658. _checkIsReady(): void;
  1659. /**
  1660. * Will start the animation sequence of a given target
  1661. * @param target defines the target
  1662. * @param from defines from which frame should animation start
  1663. * @param to defines until which frame should animation run.
  1664. * @param weight defines the weight to apply to the animation (1.0 by default)
  1665. * @param loop defines if the animation loops
  1666. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1667. * @param onAnimationEnd defines the function to be executed when the animation ends
  1668. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1669. * @returns the animatable object created for this animation
  1670. */
  1671. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1672. /**
  1673. * Will start the animation sequence of a given target
  1674. * @param target defines the target
  1675. * @param from defines from which frame should animation start
  1676. * @param to defines until which frame should animation run.
  1677. * @param loop defines if the animation loops
  1678. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1679. * @param onAnimationEnd defines the function to be executed when the animation ends
  1680. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1681. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1682. * @returns the animatable object created for this animation
  1683. */
  1684. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1685. /**
  1686. * Begin a new animation on a given node
  1687. * @param target defines the target where the animation will take place
  1688. * @param animations defines the list of animations to start
  1689. * @param from defines the initial value
  1690. * @param to defines the final value
  1691. * @param loop defines if you want animation to loop (off by default)
  1692. * @param speedRatio defines the speed ratio to apply to all animations
  1693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1694. * @returns the list of created animatables
  1695. */
  1696. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1697. /**
  1698. * Begin a new animation on a given node and its hierarchy
  1699. * @param target defines the root node where the animation will take place
  1700. * @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.
  1701. * @param animations defines the list of animations to start
  1702. * @param from defines the initial value
  1703. * @param to defines the final value
  1704. * @param loop defines if you want animation to loop (off by default)
  1705. * @param speedRatio defines the speed ratio to apply to all animations
  1706. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1707. * @returns the list of animatables created for all nodes
  1708. */
  1709. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1710. /**
  1711. * Gets the animatable associated with a specific target
  1712. * @param target defines the target of the animatable
  1713. * @returns the required animatable if found
  1714. */
  1715. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1716. /**
  1717. * Gets all animatables associated with a given target
  1718. * @param target defines the target to look animatables for
  1719. * @returns an array of Animatables
  1720. */
  1721. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1722. /**
  1723. * Gets all animatable attached to the scene
  1724. */
  1725. readonly animatables: Animatable[];
  1726. /**
  1727. * Will stop the animation of the given target
  1728. * @param target - the target
  1729. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1730. */
  1731. stopAnimation(target: any, animationName?: string): void;
  1732. /**
  1733. * Stops and removes all animations that have been applied to the scene
  1734. */
  1735. stopAllAnimations(): void;
  1736. private _animate();
  1737. /** @hidden */
  1738. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1739. private _processLateAnimationBindingsForMatrices(holder, originalValue);
  1740. private _processLateAnimationBindings();
  1741. /** @hidden */
  1742. _switchToAlternateCameraConfiguration(active: boolean): void;
  1743. /**
  1744. * Gets the current view matrix
  1745. * @returns a Matrix
  1746. */
  1747. getViewMatrix(): Matrix;
  1748. /**
  1749. * Gets the current projection matrix
  1750. * @returns a Matrix
  1751. */
  1752. getProjectionMatrix(): Matrix;
  1753. /**
  1754. * Gets the current transform matrix
  1755. * @returns a Matrix made of View * Projection
  1756. */
  1757. getTransformMatrix(): Matrix;
  1758. /**
  1759. * Sets the current transform matrix
  1760. * @param view defines the View matrix to use
  1761. * @param projection defines the Projection matrix to use
  1762. */
  1763. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1764. /** @hidden */
  1765. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1766. /**
  1767. * Gets the uniform buffer used to store scene data
  1768. * @returns a UniformBuffer
  1769. */
  1770. getSceneUniformBuffer(): UniformBuffer;
  1771. /**
  1772. * Gets an unique (relatively to the current scene) Id
  1773. * @returns an unique number for the scene
  1774. */
  1775. getUniqueId(): number;
  1776. /**
  1777. * Add a mesh to the list of scene's meshes
  1778. * @param newMesh defines the mesh to add
  1779. */
  1780. addMesh(newMesh: AbstractMesh): void;
  1781. /**
  1782. * Remove a mesh for the list of scene's meshes
  1783. * @param toRemove defines the mesh to remove
  1784. * @param recursive if all child meshes should also be removed from the scene
  1785. * @returns the index where the mesh was in the mesh list
  1786. */
  1787. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1788. /**
  1789. * Add a transform node to the list of scene's transform nodes
  1790. * @param newTransformNode defines the transform node to add
  1791. */
  1792. addTransformNode(newTransformNode: TransformNode): void;
  1793. /**
  1794. * Remove a transform node for the list of scene's transform nodes
  1795. * @param toRemove defines the transform node to remove
  1796. * @returns the index where the transform node was in the transform node list
  1797. */
  1798. removeTransformNode(toRemove: TransformNode): number;
  1799. /**
  1800. * Remove a skeleton for the list of scene's skeletons
  1801. * @param toRemove defines the skeleton to remove
  1802. * @returns the index where the skeleton was in the skeleton list
  1803. */
  1804. removeSkeleton(toRemove: Skeleton): number;
  1805. /**
  1806. * Remove a morph target for the list of scene's morph targets
  1807. * @param toRemove defines the morph target to remove
  1808. * @returns the index where the morph target was in the morph target list
  1809. */
  1810. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1811. /**
  1812. * Remove a light for the list of scene's lights
  1813. * @param toRemove defines the light to remove
  1814. * @returns the index where the light was in the light list
  1815. */
  1816. removeLight(toRemove: Light): number;
  1817. /**
  1818. * Remove a camera for the list of scene's cameras
  1819. * @param toRemove defines the camera to remove
  1820. * @returns the index where the camera was in the camera list
  1821. */
  1822. removeCamera(toRemove: Camera): number;
  1823. /**
  1824. * Remove a particle system for the list of scene's particle systems
  1825. * @param toRemove defines the particle system to remove
  1826. * @returns the index where the particle system was in the particle system list
  1827. */
  1828. removeParticleSystem(toRemove: IParticleSystem): number;
  1829. /**
  1830. * Remove a animation for the list of scene's animations
  1831. * @param toRemove defines the animation to remove
  1832. * @returns the index where the animation was in the animation list
  1833. */
  1834. removeAnimation(toRemove: Animation): number;
  1835. /**
  1836. * Removes the given animation group from this scene.
  1837. * @param toRemove The animation group to remove
  1838. * @returns The index of the removed animation group
  1839. */
  1840. removeAnimationGroup(toRemove: AnimationGroup): number;
  1841. /**
  1842. * Removes the given multi-material from this scene.
  1843. * @param toRemove The multi-material to remove
  1844. * @returns The index of the removed multi-material
  1845. */
  1846. removeMultiMaterial(toRemove: MultiMaterial): number;
  1847. /**
  1848. * Removes the given material from this scene.
  1849. * @param toRemove The material to remove
  1850. * @returns The index of the removed material
  1851. */
  1852. removeMaterial(toRemove: Material): number;
  1853. /**
  1854. * Removes the given lens flare system from this scene.
  1855. * @param toRemove The lens flare system to remove
  1856. * @returns The index of the removed lens flare system
  1857. */
  1858. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1859. /**
  1860. * Removes the given action manager from this scene.
  1861. * @param toRemove The action manager to remove
  1862. * @returns The index of the removed action manager
  1863. */
  1864. removeActionManager(toRemove: ActionManager): number;
  1865. /**
  1866. * Removes the given effect layer from this scene.
  1867. * @param toRemove defines the effect layer to remove
  1868. * @returns the index of the removed effect layer
  1869. */
  1870. removeEffectLayer(toRemove: EffectLayer): number;
  1871. /**
  1872. * Removes the given texture from this scene.
  1873. * @param toRemove The texture to remove
  1874. * @returns The index of the removed texture
  1875. */
  1876. removeTexture(toRemove: BaseTexture): number;
  1877. /**
  1878. * Adds the given light to this scene
  1879. * @param newLight The light to add
  1880. */
  1881. addLight(newLight: Light): void;
  1882. /**
  1883. * Sorts the list list based on light priorities
  1884. */
  1885. sortLightsByPriority(): void;
  1886. /**
  1887. * Adds the given camera to this scene
  1888. * @param newCamera The camera to add
  1889. */
  1890. addCamera(newCamera: Camera): void;
  1891. /**
  1892. * Adds the given skeleton to this scene
  1893. * @param newSkeleton The skeleton to add
  1894. */
  1895. addSkeleton(newSkeleton: Skeleton): void;
  1896. /**
  1897. * Adds the given particle system to this scene
  1898. * @param newParticleSystem The particle system to add
  1899. */
  1900. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1901. /**
  1902. * Adds the given animation to this scene
  1903. * @param newAnimation The animation to add
  1904. */
  1905. addAnimation(newAnimation: Animation): void;
  1906. /**
  1907. * Adds the given animation group to this scene.
  1908. * @param newAnimationGroup The animation group to add
  1909. */
  1910. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1911. /**
  1912. * Adds the given multi-material to this scene
  1913. * @param newMultiMaterial The multi-material to add
  1914. */
  1915. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1916. /**
  1917. * Adds the given material to this scene
  1918. * @param newMaterial The material to add
  1919. */
  1920. addMaterial(newMaterial: Material): void;
  1921. /**
  1922. * Adds the given morph target to this scene
  1923. * @param newMorphTargetManager The morph target to add
  1924. */
  1925. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1926. /**
  1927. * Adds the given geometry to this scene
  1928. * @param newGeometry The geometry to add
  1929. */
  1930. addGeometry(newGeometry: Geometry): void;
  1931. /**
  1932. * Adds the given lens flare system to this scene
  1933. * @param newLensFlareSystem The lens flare system to add
  1934. */
  1935. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1936. /**
  1937. * Adds the given effect layer to this scene
  1938. * @param newEffectLayer defines the effect layer to add
  1939. */
  1940. addEffectLayer(newEffectLayer: EffectLayer): void;
  1941. /**
  1942. * Adds the given action manager to this scene
  1943. * @param newActionManager The action manager to add
  1944. */
  1945. addActionManager(newActionManager: ActionManager): void;
  1946. /**
  1947. * Adds the given texture to this scene.
  1948. * @param newTexture The texture to add
  1949. */
  1950. addTexture(newTexture: BaseTexture): void;
  1951. /**
  1952. * Switch active camera
  1953. * @param newCamera defines the new active camera
  1954. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1955. */
  1956. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1957. /**
  1958. * sets the active camera of the scene using its ID
  1959. * @param id defines the camera's ID
  1960. * @return the new active camera or null if none found.
  1961. */
  1962. setActiveCameraByID(id: string): Nullable<Camera>;
  1963. /**
  1964. * sets the active camera of the scene using its name
  1965. * @param name defines the camera's name
  1966. * @returns the new active camera or null if none found.
  1967. */
  1968. setActiveCameraByName(name: string): Nullable<Camera>;
  1969. /**
  1970. * get an animation group using its name
  1971. * @param name defines the material's name
  1972. * @return the animation group or null if none found.
  1973. */
  1974. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1975. /**
  1976. * get a material using its id
  1977. * @param id defines the material's ID
  1978. * @return the material or null if none found.
  1979. */
  1980. getMaterialByID(id: string): Nullable<Material>;
  1981. /**
  1982. * Gets a material using its name
  1983. * @param name defines the material's name
  1984. * @return the material or null if none found.
  1985. */
  1986. getMaterialByName(name: string): Nullable<Material>;
  1987. /**
  1988. * Gets a lens flare system using its name
  1989. * @param name defines the name to look for
  1990. * @returns the lens flare system or null if not found
  1991. */
  1992. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1993. /**
  1994. * Gets a lens flare system using its id
  1995. * @param id defines the id to look for
  1996. * @returns the lens flare system or null if not found
  1997. */
  1998. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1999. /**
  2000. * Gets a camera using its id
  2001. * @param id defines the id to look for
  2002. * @returns the camera or null if not found
  2003. */
  2004. getCameraByID(id: string): Nullable<Camera>;
  2005. /**
  2006. * Gets a camera using its unique id
  2007. * @param uniqueId defines the unique id to look for
  2008. * @returns the camera or null if not found
  2009. */
  2010. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2011. /**
  2012. * Gets a camera using its name
  2013. * @param name defines the camera's name
  2014. * @return the camera or null if none found.
  2015. */
  2016. getCameraByName(name: string): Nullable<Camera>;
  2017. /**
  2018. * Gets a bone using its id
  2019. * @param id defines the bone's id
  2020. * @return the bone or null if not found
  2021. */
  2022. getBoneByID(id: string): Nullable<Bone>;
  2023. /**
  2024. * Gets a bone using its id
  2025. * @param name defines the bone's name
  2026. * @return the bone or null if not found
  2027. */
  2028. getBoneByName(name: string): Nullable<Bone>;
  2029. /**
  2030. * Gets a light node using its name
  2031. * @param name defines the the light's name
  2032. * @return the light or null if none found.
  2033. */
  2034. getLightByName(name: string): Nullable<Light>;
  2035. /**
  2036. * Gets a light node using its id
  2037. * @param id defines the light's id
  2038. * @return the light or null if none found.
  2039. */
  2040. getLightByID(id: string): Nullable<Light>;
  2041. /**
  2042. * Gets a light node using its scene-generated unique ID
  2043. * @param uniqueId defines the light's unique id
  2044. * @return the light or null if none found.
  2045. */
  2046. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2047. /**
  2048. * Gets a particle system by id
  2049. * @param id defines the particle system id
  2050. * @return the corresponding system or null if none found
  2051. */
  2052. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2053. /**
  2054. * Gets a geometry using its ID
  2055. * @param id defines the geometry's id
  2056. * @return the geometry or null if none found.
  2057. */
  2058. getGeometryByID(id: string): Nullable<Geometry>;
  2059. /**
  2060. * Add a new geometry to this scene
  2061. * @param geometry defines the geometry to be added to the scene.
  2062. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2063. * @return a boolean defining if the geometry was added or not
  2064. */
  2065. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2066. /**
  2067. * Removes an existing geometry
  2068. * @param geometry defines the geometry to be removed from the scene
  2069. * @return a boolean defining if the geometry was removed or not
  2070. */
  2071. removeGeometry(geometry: Geometry): boolean;
  2072. /**
  2073. * Gets the list of geometries attached to the scene
  2074. * @returns an array of Geometry
  2075. */
  2076. getGeometries(): Geometry[];
  2077. /**
  2078. * Gets the first added mesh found of a given ID
  2079. * @param id defines the id to search for
  2080. * @return the mesh found or null if not found at all
  2081. */
  2082. getMeshByID(id: string): Nullable<AbstractMesh>;
  2083. /**
  2084. * Gets a list of meshes using their id
  2085. * @param id defines the id to search for
  2086. * @returns a list of meshes
  2087. */
  2088. getMeshesByID(id: string): Array<AbstractMesh>;
  2089. /**
  2090. * Gets the first added transform node found of a given ID
  2091. * @param id defines the id to search for
  2092. * @return the found transform node or null if not found at all.
  2093. */
  2094. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2095. /**
  2096. * Gets a list of transform nodes using their id
  2097. * @param id defines the id to search for
  2098. * @returns a list of transform nodes
  2099. */
  2100. getTransformNodesByID(id: string): Array<TransformNode>;
  2101. /**
  2102. * Gets a mesh with its auto-generated unique id
  2103. * @param uniqueId defines the unique id to search for
  2104. * @return the found mesh or null if not found at all.
  2105. */
  2106. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2107. /**
  2108. * Gets a the last added mesh using a given id
  2109. * @param id defines the id to search for
  2110. * @return the found mesh or null if not found at all.
  2111. */
  2112. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2113. /**
  2114. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2115. * @param id defines the id to search for
  2116. * @return the found node or null if not found at all
  2117. */
  2118. getLastEntryByID(id: string): Nullable<Node>;
  2119. /**
  2120. * Gets a node (Mesh, Camera, Light) using a given id
  2121. * @param id defines the id to search for
  2122. * @return the found node or null if not found at all
  2123. */
  2124. getNodeByID(id: string): Nullable<Node>;
  2125. /**
  2126. * Gets a node (Mesh, Camera, Light) using a given name
  2127. * @param name defines the name to search for
  2128. * @return the found node or null if not found at all.
  2129. */
  2130. getNodeByName(name: string): Nullable<Node>;
  2131. /**
  2132. * Gets a mesh using a given name
  2133. * @param name defines the name to search for
  2134. * @return the found mesh or null if not found at all.
  2135. */
  2136. getMeshByName(name: string): Nullable<AbstractMesh>;
  2137. /**
  2138. * Gets a transform node using a given name
  2139. * @param name defines the name to search for
  2140. * @return the found transform node or null if not found at all.
  2141. */
  2142. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2143. /**
  2144. * Gets a sound using a given name
  2145. * @param name defines the name to search for
  2146. * @return the found sound or null if not found at all.
  2147. */
  2148. getSoundByName(name: string): Nullable<Sound>;
  2149. /**
  2150. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2151. * @param id defines the id to search for
  2152. * @return the found skeleton or null if not found at all.
  2153. */
  2154. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2155. /**
  2156. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2157. * @param id defines the id to search for
  2158. * @return the found skeleton or null if not found at all.
  2159. */
  2160. getSkeletonById(id: string): Nullable<Skeleton>;
  2161. /**
  2162. * Gets a skeleton using a given name
  2163. * @param name defines the name to search for
  2164. * @return the found skeleton or null if not found at all.
  2165. */
  2166. getSkeletonByName(name: string): Nullable<Skeleton>;
  2167. /**
  2168. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2169. * @param id defines the id to search for
  2170. * @return the found morph target manager or null if not found at all.
  2171. */
  2172. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2173. /**
  2174. * Gets a boolean indicating if the given mesh is active
  2175. * @param mesh defines the mesh to look for
  2176. * @returns true if the mesh is in the active list
  2177. */
  2178. isActiveMesh(mesh: AbstractMesh): boolean;
  2179. /**
  2180. * Return a the first highlight layer of the scene with a given name.
  2181. * @param name The name of the highlight layer to look for.
  2182. * @return The highlight layer if found otherwise null.
  2183. */
  2184. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2185. /**
  2186. * Return a the first highlight layer of the scene with a given name.
  2187. * @param name The name of the highlight layer to look for.
  2188. * @return The highlight layer if found otherwise null.
  2189. */
  2190. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2191. /**
  2192. * Return a unique id as a string which can serve as an identifier for the scene
  2193. */
  2194. readonly uid: string;
  2195. /**
  2196. * Add an externaly attached data from its key.
  2197. * This method call will fail and return false, if such key already exists.
  2198. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2199. * @param key the unique key that identifies the data
  2200. * @param data the data object to associate to the key for this Engine instance
  2201. * @return true if no such key were already present and the data was added successfully, false otherwise
  2202. */
  2203. addExternalData<T>(key: string, data: T): boolean;
  2204. /**
  2205. * Get an externaly attached data from its key
  2206. * @param key the unique key that identifies the data
  2207. * @return the associated data, if present (can be null), or undefined if not present
  2208. */
  2209. getExternalData<T>(key: string): Nullable<T>;
  2210. /**
  2211. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2212. * @param key the unique key that identifies the data
  2213. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2214. * @return the associated data, can be null if the factory returned null.
  2215. */
  2216. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2217. /**
  2218. * Remove an externaly attached data from the Engine instance
  2219. * @param key the unique key that identifies the data
  2220. * @return true if the data was successfully removed, false if it doesn't exist
  2221. */
  2222. removeExternalData(key: string): boolean;
  2223. private _evaluateSubMesh(subMesh, mesh);
  2224. /**
  2225. * Clear the processed materials smart array preventing retention point in material dispose.
  2226. */
  2227. freeProcessedMaterials(): void;
  2228. /**
  2229. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2230. */
  2231. freeActiveMeshes(): void;
  2232. /**
  2233. * Clear the info related to rendering groups preventing retention points during dispose.
  2234. */
  2235. freeRenderingGroups(): void;
  2236. /** @hidden */
  2237. _isInIntermediateRendering(): boolean;
  2238. private _activeMeshCandidateProvider;
  2239. /**
  2240. * Defines the current active mesh candidate provider
  2241. * @param provider defines the provider to use
  2242. */
  2243. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2244. /**
  2245. * Gets the current active mesh candidate provider
  2246. * @returns the current active mesh candidate provider
  2247. */
  2248. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2249. private _activeMeshesFrozen;
  2250. /**
  2251. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2252. * @returns the current scene
  2253. */
  2254. freezeActiveMeshes(): Scene;
  2255. /**
  2256. * Use this function to restart evaluating active meshes on every frame
  2257. * @returns the current scene
  2258. */
  2259. unfreezeActiveMeshes(): Scene;
  2260. private _evaluateActiveMeshes();
  2261. private _activeMesh(sourceMesh, mesh);
  2262. /**
  2263. * Update the transform matrix to update from the current active camera
  2264. * @param force defines a boolean used to force the update even if cache is up to date
  2265. */
  2266. updateTransformMatrix(force?: boolean): void;
  2267. /**
  2268. * 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)
  2269. * @param alternateCamera defines the camera to use
  2270. */
  2271. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2272. private _renderForCamera(camera, rigParent?);
  2273. private _processSubCameras(camera);
  2274. private _checkIntersections();
  2275. /**
  2276. * Render the scene
  2277. */
  2278. render(): void;
  2279. private _updateAudioParameters();
  2280. /**
  2281. * Gets or sets if audio support is enabled
  2282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2283. */
  2284. audioEnabled: boolean;
  2285. private _disableAudio();
  2286. private _enableAudio();
  2287. /**
  2288. * Gets or sets if audio will be output to headphones
  2289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2290. */
  2291. headphone: boolean;
  2292. private _switchAudioModeForHeadphones();
  2293. private _switchAudioModeForNormalSpeakers();
  2294. /**
  2295. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2296. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2297. * @returns the created depth renderer
  2298. */
  2299. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2300. /**
  2301. * Disables a depth renderer for a given camera
  2302. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2303. */
  2304. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2305. /**
  2306. * Enables a GeometryBufferRender and associates it with the scene
  2307. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2308. * @returns the GeometryBufferRenderer
  2309. */
  2310. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2311. /**
  2312. * Disables the GeometryBufferRender associated with the scene
  2313. */
  2314. disableGeometryBufferRenderer(): void;
  2315. /**
  2316. * Freeze all materials
  2317. * A frozen material will not be updatable but should be faster to render
  2318. */
  2319. freezeMaterials(): void;
  2320. /**
  2321. * Unfreeze all materials
  2322. * A frozen material will not be updatable but should be faster to render
  2323. */
  2324. unfreezeMaterials(): void;
  2325. /**
  2326. * Releases all held ressources
  2327. */
  2328. dispose(): void;
  2329. /**
  2330. * Gets if the scene is already disposed
  2331. */
  2332. readonly isDisposed: boolean;
  2333. /**
  2334. * Releases sounds & soundtracks
  2335. */
  2336. disposeSounds(): void;
  2337. /**
  2338. * Get the world extend vectors with an optional filter
  2339. *
  2340. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2341. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2342. */
  2343. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2344. min: Vector3;
  2345. max: Vector3;
  2346. };
  2347. /**
  2348. * Creates or updates the octree used to boost selection (picking)
  2349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2350. * @param maxCapacity defines the maximum capacity per leaf
  2351. * @param maxDepth defines the maximum depth of the octree
  2352. * @returns an octree of AbstractMesh
  2353. */
  2354. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2355. /**
  2356. * Creates a ray that can be used to pick in the scene
  2357. * @param x defines the x coordinate of the origin (on-screen)
  2358. * @param y defines the y coordinate of the origin (on-screen)
  2359. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2360. * @param camera defines the camera to use for the picking
  2361. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2362. * @returns a Ray
  2363. */
  2364. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2365. /**
  2366. * Creates a ray that can be used to pick in the scene
  2367. * @param x defines the x coordinate of the origin (on-screen)
  2368. * @param y defines the y coordinate of the origin (on-screen)
  2369. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2370. * @param result defines the ray where to store the picking ray
  2371. * @param camera defines the camera to use for the picking
  2372. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2373. * @returns the current scene
  2374. */
  2375. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2376. /**
  2377. * Creates a ray that can be used to pick in the scene
  2378. * @param x defines the x coordinate of the origin (on-screen)
  2379. * @param y defines the y coordinate of the origin (on-screen)
  2380. * @param camera defines the camera to use for the picking
  2381. * @returns a Ray
  2382. */
  2383. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2384. /**
  2385. * Creates a ray that can be used to pick in the scene
  2386. * @param x defines the x coordinate of the origin (on-screen)
  2387. * @param y defines the y coordinate of the origin (on-screen)
  2388. * @param result defines the ray where to store the picking ray
  2389. * @param camera defines the camera to use for the picking
  2390. * @returns the current scene
  2391. */
  2392. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2393. private _internalPick(rayFunction, predicate?, fastCheck?);
  2394. private _internalMultiPick(rayFunction, predicate?);
  2395. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2396. private _tempPickingRay;
  2397. /** Launch a ray to try to pick a mesh in the scene
  2398. * @param x position on screen
  2399. * @param y position on screen
  2400. * @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
  2401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2402. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2403. * @returns a PickingInfo
  2404. */
  2405. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2406. /** Launch a ray to try to pick a sprite in the scene
  2407. * @param x position on screen
  2408. * @param y position on screen
  2409. * @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
  2410. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2411. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2412. * @returns a PickingInfo
  2413. */
  2414. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2415. private _cachedRayForTransform;
  2416. /** Use the given ray to pick a mesh in the scene
  2417. * @param ray The ray to use to pick meshes
  2418. * @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
  2419. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2420. * @returns a PickingInfo
  2421. */
  2422. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2423. /**
  2424. * Launch a ray to try to pick a mesh in the scene
  2425. * @param x X position on screen
  2426. * @param y Y position on screen
  2427. * @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
  2428. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2429. * @returns an array of PickingInfo
  2430. */
  2431. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2432. /**
  2433. * Launch a ray to try to pick a mesh in the scene
  2434. * @param ray Ray to use
  2435. * @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
  2436. * @returns an array of PickingInfo
  2437. */
  2438. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2439. /**
  2440. * Force the value of meshUnderPointer
  2441. * @param mesh defines the mesh to use
  2442. */
  2443. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2444. /**
  2445. * Gets the mesh under the pointer
  2446. * @returns a Mesh or null if no mesh is under the pointer
  2447. */
  2448. getPointerOverMesh(): Nullable<AbstractMesh>;
  2449. /**
  2450. * Force the sprite under the pointer
  2451. * @param sprite defines the sprite to use
  2452. */
  2453. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2454. /**
  2455. * Gets the sprite under the pointer
  2456. * @returns a Sprite or null if no sprite is under the pointer
  2457. */
  2458. getPointerOverSprite(): Nullable<Sprite>;
  2459. /**
  2460. * Gets the current physics engine
  2461. * @returns a PhysicsEngine or null if none attached
  2462. */
  2463. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2464. /**
  2465. * Enables physics to the current scene
  2466. * @param gravity defines the scene's gravity for the physics engine
  2467. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2468. * @return a boolean indicating if the physics engine was initialized
  2469. */
  2470. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2471. /**
  2472. * Disables and disposes the physics engine associated with the scene
  2473. */
  2474. disablePhysicsEngine(): void;
  2475. /**
  2476. * Gets a boolean indicating if there is an active physics engine
  2477. * @returns a boolean indicating if there is an active physics engine
  2478. */
  2479. isPhysicsEnabled(): boolean;
  2480. /**
  2481. * Deletes a physics compound impostor
  2482. * @param compound defines the compound to delete
  2483. */
  2484. deleteCompoundImpostor(compound: any): void;
  2485. /** @hidden */
  2486. _rebuildGeometries(): void;
  2487. /** @hidden */
  2488. _rebuildTextures(): void;
  2489. /**
  2490. * Creates a default light for the scene.
  2491. * @param replace Whether to replace the existing lights in the scene.
  2492. */
  2493. createDefaultLight(replace?: boolean): void;
  2494. /**
  2495. * Creates a default camera for the scene.
  2496. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2497. * @param replace Whether to replace the existing active camera in the scene.
  2498. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2499. */
  2500. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2501. /**
  2502. * Creates a default camera and a default light
  2503. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2504. * @param replace defines if the camera and/or light will replace the existing ones
  2505. * @param attachCameraControls defines if attachControl will be called on the new camera
  2506. */
  2507. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2508. /**
  2509. * Creates a new sky box
  2510. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2511. * @param environmentTexture defines the texture to use as environment texture
  2512. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2513. * @param scale defines the overall scale of the skybox
  2514. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2515. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2516. * @returns a new mesh holding the sky box
  2517. */
  2518. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2519. /**
  2520. * Creates a new environment
  2521. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2522. * @param options defines the options you can use to configure the environment
  2523. * @returns the new EnvironmentHelper
  2524. */
  2525. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2526. /**
  2527. * Creates a new VREXperienceHelper
  2528. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2529. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2530. * @returns a new VREXperienceHelper
  2531. */
  2532. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2533. private _getByTags(list, tagsQuery, forEach?);
  2534. /**
  2535. * Get a list of meshes by tags
  2536. * @param tagsQuery defines the tags query to use
  2537. * @param forEach defines a predicate used to filter results
  2538. * @returns an array of Mesh
  2539. */
  2540. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2541. /**
  2542. * Get a list of cameras by tags
  2543. * @param tagsQuery defines the tags query to use
  2544. * @param forEach defines a predicate used to filter results
  2545. * @returns an array of Camera
  2546. */
  2547. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2548. /**
  2549. * Get a list of lights by tags
  2550. * @param tagsQuery defines the tags query to use
  2551. * @param forEach defines a predicate used to filter results
  2552. * @returns an array of Light
  2553. */
  2554. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2555. /**
  2556. * Get a list of materials by tags
  2557. * @param tagsQuery defines the tags query to use
  2558. * @param forEach defines a predicate used to filter results
  2559. * @returns an array of Material
  2560. */
  2561. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2562. /**
  2563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2564. * This allowed control for front to back rendering or reversly depending of the special needs.
  2565. *
  2566. * @param renderingGroupId The rendering group id corresponding to its index
  2567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2570. */
  2571. 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;
  2572. /**
  2573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2574. *
  2575. * @param renderingGroupId The rendering group id corresponding to its index
  2576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2577. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2578. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2579. */
  2580. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2581. /**
  2582. * Will flag all materials as dirty to trigger new shader compilation
  2583. * @param flag defines the flag used to specify which material part must be marked as dirty
  2584. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2585. */
  2586. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2587. /** @hidden */
  2588. _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;
  2589. /** @hidden */
  2590. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2591. }
  2592. }
  2593. declare module BABYLON {
  2594. type Nullable<T> = T | null;
  2595. type float = number;
  2596. type double = number;
  2597. type int = number;
  2598. type FloatArray = number[] | Float32Array;
  2599. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2600. /**
  2601. * Alias for types that can be used by a Buffer or VertexBuffer.
  2602. */
  2603. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2604. }
  2605. declare module BABYLON {
  2606. /**
  2607. * The action to be carried out following a trigger
  2608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2609. */
  2610. class Action {
  2611. /** the trigger, with or without parameters, for the action */
  2612. triggerOptions: any;
  2613. /**
  2614. * Trigger for the action
  2615. */
  2616. trigger: number;
  2617. /**
  2618. * Internal only - manager for action
  2619. * @hidden
  2620. */
  2621. _actionManager: ActionManager;
  2622. private _nextActiveAction;
  2623. private _child;
  2624. private _condition?;
  2625. private _triggerParameter;
  2626. /**
  2627. * An event triggered prior to action being executed.
  2628. */
  2629. onBeforeExecuteObservable: Observable<Action>;
  2630. /**
  2631. * Creates a new Action
  2632. * @param triggerOptions the trigger, with or without parameters, for the action
  2633. * @param condition an optional determinant of action
  2634. */
  2635. constructor(
  2636. /** the trigger, with or without parameters, for the action */
  2637. triggerOptions: any, condition?: Condition);
  2638. /**
  2639. * Internal only
  2640. * @hidden
  2641. */
  2642. _prepare(): void;
  2643. /**
  2644. * Gets the trigger parameters
  2645. * @returns the trigger parameters
  2646. */
  2647. getTriggerParameter(): any;
  2648. /**
  2649. * Internal only - executes current action event
  2650. * @hidden
  2651. */
  2652. _executeCurrent(evt?: ActionEvent): void;
  2653. /**
  2654. * Execute placeholder for child classes
  2655. * @param evt optional action event
  2656. */
  2657. execute(evt?: ActionEvent): void;
  2658. /**
  2659. * Skips to next active action
  2660. */
  2661. skipToNextActiveAction(): void;
  2662. /**
  2663. * Adds action to chain of actions, may be a DoNothingAction
  2664. * @param action defines the next action to execute
  2665. * @returns The action passed in
  2666. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2667. */
  2668. then(action: Action): Action;
  2669. /**
  2670. * Internal only
  2671. * @hidden
  2672. */
  2673. _getProperty(propertyPath: string): string;
  2674. /**
  2675. * Internal only
  2676. * @hidden
  2677. */
  2678. _getEffectiveTarget(target: any, propertyPath: string): any;
  2679. /**
  2680. * Serialize placeholder for child classes
  2681. * @param parent of child
  2682. * @returns the serialized object
  2683. */
  2684. serialize(parent: any): any;
  2685. /**
  2686. * Internal only called by serialize
  2687. * @hidden
  2688. */
  2689. protected _serialize(serializedAction: any, parent?: any): any;
  2690. /**
  2691. * Internal only
  2692. * @hidden
  2693. */
  2694. static _SerializeValueAsString: (value: any) => string;
  2695. /**
  2696. * Internal only
  2697. * @hidden
  2698. */
  2699. static _GetTargetProperty: (target: Scene | Node) => {
  2700. name: string;
  2701. targetType: string;
  2702. value: string;
  2703. };
  2704. }
  2705. }
  2706. declare module BABYLON {
  2707. /**
  2708. * ActionEvent is the event being sent when an action is triggered.
  2709. */
  2710. class ActionEvent {
  2711. /** The mesh or sprite that triggered the action */
  2712. source: any;
  2713. /** The X mouse cursor position at the time of the event */
  2714. pointerX: number;
  2715. /** The Y mouse cursor position at the time of the event */
  2716. pointerY: number;
  2717. /** The mesh that is currently pointed at (can be null) */
  2718. meshUnderPointer: Nullable<AbstractMesh>;
  2719. /** the original (browser) event that triggered the ActionEvent */
  2720. sourceEvent: any;
  2721. /** additional data for the event */
  2722. additionalData: any;
  2723. /**
  2724. * Creates a new ActionEvent
  2725. * @param source The mesh or sprite that triggered the action
  2726. * @param pointerX The X mouse cursor position at the time of the event
  2727. * @param pointerY The Y mouse cursor position at the time of the event
  2728. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2729. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2730. * @param additionalData additional data for the event
  2731. */
  2732. constructor(
  2733. /** The mesh or sprite that triggered the action */
  2734. source: any,
  2735. /** The X mouse cursor position at the time of the event */
  2736. pointerX: number,
  2737. /** The Y mouse cursor position at the time of the event */
  2738. pointerY: number,
  2739. /** The mesh that is currently pointed at (can be null) */
  2740. meshUnderPointer: Nullable<AbstractMesh>,
  2741. /** the original (browser) event that triggered the ActionEvent */
  2742. sourceEvent?: any,
  2743. /** additional data for the event */
  2744. additionalData?: any);
  2745. /**
  2746. * Helper function to auto-create an ActionEvent from a source mesh.
  2747. * @param source The source mesh that triggered the event
  2748. * @param evt The original (browser) event
  2749. * @param additionalData additional data for the event
  2750. * @returns the new ActionEvent
  2751. */
  2752. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2753. /**
  2754. * Helper function to auto-create an ActionEvent from a source sprite
  2755. * @param source The source sprite that triggered the event
  2756. * @param scene Scene associated with the sprite
  2757. * @param evt The original (browser) event
  2758. * @param additionalData additional data for the event
  2759. * @returns the new ActionEvent
  2760. */
  2761. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2762. /**
  2763. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2764. * @param scene the scene where the event occurred
  2765. * @param evt The original (browser) event
  2766. * @returns the new ActionEvent
  2767. */
  2768. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2769. /**
  2770. * Helper function to auto-create an ActionEvent from a primitive
  2771. * @param prim defines the target primitive
  2772. * @param pointerPos defines the pointer position
  2773. * @param evt The original (browser) event
  2774. * @param additionalData additional data for the event
  2775. * @returns the new ActionEvent
  2776. */
  2777. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2778. }
  2779. /**
  2780. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2781. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2783. */
  2784. class ActionManager {
  2785. private static _NothingTrigger;
  2786. private static _OnPickTrigger;
  2787. private static _OnLeftPickTrigger;
  2788. private static _OnRightPickTrigger;
  2789. private static _OnCenterPickTrigger;
  2790. private static _OnPickDownTrigger;
  2791. private static _OnDoublePickTrigger;
  2792. private static _OnPickUpTrigger;
  2793. private static _OnLongPressTrigger;
  2794. private static _OnPointerOverTrigger;
  2795. private static _OnPointerOutTrigger;
  2796. private static _OnEveryFrameTrigger;
  2797. private static _OnIntersectionEnterTrigger;
  2798. private static _OnIntersectionExitTrigger;
  2799. private static _OnKeyDownTrigger;
  2800. private static _OnKeyUpTrigger;
  2801. private static _OnPickOutTrigger;
  2802. /**
  2803. * Nothing
  2804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2805. */
  2806. static readonly NothingTrigger: number;
  2807. /**
  2808. * On pick
  2809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2810. */
  2811. static readonly OnPickTrigger: number;
  2812. /**
  2813. * On left pick
  2814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2815. */
  2816. static readonly OnLeftPickTrigger: number;
  2817. /**
  2818. * On right pick
  2819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2820. */
  2821. static readonly OnRightPickTrigger: number;
  2822. /**
  2823. * On center pick
  2824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2825. */
  2826. static readonly OnCenterPickTrigger: number;
  2827. /**
  2828. * On pick down
  2829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2830. */
  2831. static readonly OnPickDownTrigger: number;
  2832. /**
  2833. * On double pick
  2834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2835. */
  2836. static readonly OnDoublePickTrigger: number;
  2837. /**
  2838. * On pick up
  2839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2840. */
  2841. static readonly OnPickUpTrigger: number;
  2842. /**
  2843. * On pick out.
  2844. * This trigger will only be raised if you also declared a OnPickDown
  2845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2846. */
  2847. static readonly OnPickOutTrigger: number;
  2848. /**
  2849. * On long press
  2850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2851. */
  2852. static readonly OnLongPressTrigger: number;
  2853. /**
  2854. * On pointer over
  2855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2856. */
  2857. static readonly OnPointerOverTrigger: number;
  2858. /**
  2859. * On pointer out
  2860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2861. */
  2862. static readonly OnPointerOutTrigger: number;
  2863. /**
  2864. * On every frame
  2865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2866. */
  2867. static readonly OnEveryFrameTrigger: number;
  2868. /**
  2869. * On intersection enter
  2870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2871. */
  2872. static readonly OnIntersectionEnterTrigger: number;
  2873. /**
  2874. * On intersection exit
  2875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2876. */
  2877. static readonly OnIntersectionExitTrigger: number;
  2878. /**
  2879. * On key down
  2880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2881. */
  2882. static readonly OnKeyDownTrigger: number;
  2883. /**
  2884. * On key up
  2885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2886. */
  2887. static readonly OnKeyUpTrigger: number;
  2888. /** Gets the list of active triggers */
  2889. static Triggers: {
  2890. [key: string]: number;
  2891. };
  2892. /** Gets the list of actions */
  2893. actions: Action[];
  2894. /** Gets the cursor to use when hovering items */
  2895. hoverCursor: string;
  2896. private _scene;
  2897. /**
  2898. * Creates a new action manager
  2899. * @param scene defines the hosting scene
  2900. */
  2901. constructor(scene: Scene);
  2902. /**
  2903. * Releases all associated resources
  2904. */
  2905. dispose(): void;
  2906. /**
  2907. * Gets hosting scene
  2908. * @returns the hosting scene
  2909. */
  2910. getScene(): Scene;
  2911. /**
  2912. * Does this action manager handles actions of any of the given triggers
  2913. * @param triggers defines the triggers to be tested
  2914. * @return a boolean indicating whether one (or more) of the triggers is handled
  2915. */
  2916. hasSpecificTriggers(triggers: number[]): boolean;
  2917. /**
  2918. * Does this action manager handles actions of a given trigger
  2919. * @param trigger defines the trigger to be tested
  2920. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2921. * @return whether the trigger is handled
  2922. */
  2923. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2924. /**
  2925. * Does this action manager has pointer triggers
  2926. */
  2927. readonly hasPointerTriggers: boolean;
  2928. /**
  2929. * Does this action manager has pick triggers
  2930. */
  2931. readonly hasPickTriggers: boolean;
  2932. /**
  2933. * Does exist one action manager with at least one trigger
  2934. **/
  2935. static readonly HasTriggers: boolean;
  2936. /**
  2937. * Does exist one action manager with at least one pick trigger
  2938. **/
  2939. static readonly HasPickTriggers: boolean;
  2940. /**
  2941. * Does exist one action manager that handles actions of a given trigger
  2942. * @param trigger defines the trigger to be tested
  2943. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2944. **/
  2945. static HasSpecificTrigger(trigger: number): boolean;
  2946. /**
  2947. * Registers an action to this action manager
  2948. * @param action defines the action to be registered
  2949. * @return the action amended (prepared) after registration
  2950. */
  2951. registerAction(action: Action): Nullable<Action>;
  2952. /**
  2953. * Unregisters an action to this action manager
  2954. * @param action defines the action to be unregistered
  2955. * @return a boolean indicating whether the action has been unregistered
  2956. */
  2957. unregisterAction(action: Action): Boolean;
  2958. /**
  2959. * Process a specific trigger
  2960. * @param trigger defines the trigger to process
  2961. * @param evt defines the event details to be processed
  2962. */
  2963. processTrigger(trigger: number, evt?: ActionEvent): void;
  2964. /** @hidden */
  2965. _getEffectiveTarget(target: any, propertyPath: string): any;
  2966. /** @hidden */
  2967. _getProperty(propertyPath: string): string;
  2968. /**
  2969. * Serialize this manager to a JSON object
  2970. * @param name defines the property name to store this manager
  2971. * @returns a JSON representation of this manager
  2972. */
  2973. serialize(name: string): any;
  2974. /**
  2975. * Creates a new ActionManager from a JSON data
  2976. * @param parsedActions defines the JSON data to read from
  2977. * @param object defines the hosting mesh
  2978. * @param scene defines the hosting scene
  2979. */
  2980. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2981. /**
  2982. * Get a trigger name by index
  2983. * @param trigger defines the trigger index
  2984. * @returns a trigger name
  2985. */
  2986. static GetTriggerName(trigger: number): string;
  2987. }
  2988. }
  2989. declare module BABYLON {
  2990. /**
  2991. * A Condition applied to an Action
  2992. */
  2993. class Condition {
  2994. /**
  2995. * Internal only - manager for action
  2996. * @hidden
  2997. */
  2998. _actionManager: ActionManager;
  2999. /**
  3000. * Internal only
  3001. * @hidden
  3002. */
  3003. _evaluationId: number;
  3004. /**
  3005. * Internal only
  3006. * @hidden
  3007. */
  3008. _currentResult: boolean;
  3009. /**
  3010. * Creates a new Condition
  3011. * @param actionManager the manager of the action the condition is applied to
  3012. */
  3013. constructor(actionManager: ActionManager);
  3014. /**
  3015. * Check if the current condition is valid
  3016. * @returns a boolean
  3017. */
  3018. isValid(): boolean;
  3019. /**
  3020. * Internal only
  3021. * @hidden
  3022. */
  3023. _getProperty(propertyPath: string): string;
  3024. /**
  3025. * Internal only
  3026. * @hidden
  3027. */
  3028. _getEffectiveTarget(target: any, propertyPath: string): any;
  3029. /**
  3030. * Serialize placeholder for child classes
  3031. * @returns the serialized object
  3032. */
  3033. serialize(): any;
  3034. /**
  3035. * Internal only
  3036. * @hidden
  3037. */
  3038. protected _serialize(serializedCondition: any): any;
  3039. }
  3040. /**
  3041. * Defines specific conditional operators as extensions of Condition
  3042. */
  3043. class ValueCondition extends Condition {
  3044. /** path to specify the property of the target the conditional operator uses */
  3045. propertyPath: string;
  3046. /** the value compared by the conditional operator against the current value of the property */
  3047. value: any;
  3048. /** the conditional operator, default ValueCondition.IsEqual */
  3049. operator: number;
  3050. /**
  3051. * Internal only
  3052. * @hidden
  3053. */
  3054. private static _IsEqual;
  3055. /**
  3056. * Internal only
  3057. * @hidden
  3058. */
  3059. private static _IsDifferent;
  3060. /**
  3061. * Internal only
  3062. * @hidden
  3063. */
  3064. private static _IsGreater;
  3065. /**
  3066. * Internal only
  3067. * @hidden
  3068. */
  3069. private static _IsLesser;
  3070. /**
  3071. * returns the number for IsEqual
  3072. */
  3073. static readonly IsEqual: number;
  3074. /**
  3075. * Returns the number for IsDifferent
  3076. */
  3077. static readonly IsDifferent: number;
  3078. /**
  3079. * Returns the number for IsGreater
  3080. */
  3081. static readonly IsGreater: number;
  3082. /**
  3083. * Returns the number for IsLesser
  3084. */
  3085. static readonly IsLesser: number;
  3086. /**
  3087. * Internal only The action manager for the condition
  3088. * @hidden
  3089. */
  3090. _actionManager: ActionManager;
  3091. /**
  3092. * Internal only
  3093. * @hidden
  3094. */
  3095. private _target;
  3096. /**
  3097. * Internal only
  3098. * @hidden
  3099. */
  3100. private _effectiveTarget;
  3101. /**
  3102. * Internal only
  3103. * @hidden
  3104. */
  3105. private _property;
  3106. /**
  3107. * Creates a new ValueCondition
  3108. * @param actionManager manager for the action the condition applies to
  3109. * @param target for the action
  3110. * @param propertyPath path to specify the property of the target the conditional operator uses
  3111. * @param value the value compared by the conditional operator against the current value of the property
  3112. * @param operator the conditional operator, default ValueCondition.IsEqual
  3113. */
  3114. constructor(actionManager: ActionManager, target: any,
  3115. /** path to specify the property of the target the conditional operator uses */
  3116. propertyPath: string,
  3117. /** the value compared by the conditional operator against the current value of the property */
  3118. value: any,
  3119. /** the conditional operator, default ValueCondition.IsEqual */
  3120. operator?: number);
  3121. /**
  3122. * Compares the given value with the property value for the specified conditional operator
  3123. * @returns the result of the comparison
  3124. */
  3125. isValid(): boolean;
  3126. /**
  3127. * Serialize the ValueCondition into a JSON compatible object
  3128. * @returns serialization object
  3129. */
  3130. serialize(): any;
  3131. /**
  3132. * Gets the name of the conditional operator for the ValueCondition
  3133. * @param operator the conditional operator
  3134. * @returns the name
  3135. */
  3136. static GetOperatorName(operator: number): string;
  3137. }
  3138. /**
  3139. * Defines a predicate condition as an extension of Condition
  3140. */
  3141. class PredicateCondition extends Condition {
  3142. /** defines the predicate function used to validate the condition */
  3143. predicate: () => boolean;
  3144. /**
  3145. * Internal only - manager for action
  3146. * @hidden
  3147. */
  3148. _actionManager: ActionManager;
  3149. /**
  3150. * Creates a new PredicateCondition
  3151. * @param actionManager manager for the action the condition applies to
  3152. * @param predicate defines the predicate function used to validate the condition
  3153. */
  3154. constructor(actionManager: ActionManager,
  3155. /** defines the predicate function used to validate the condition */
  3156. predicate: () => boolean);
  3157. /**
  3158. * @returns the validity of the predicate condition
  3159. */
  3160. isValid(): boolean;
  3161. }
  3162. /**
  3163. * Defines a state condition as an extension of Condition
  3164. */
  3165. class StateCondition extends Condition {
  3166. value: string;
  3167. /**
  3168. * Internal only - manager for action
  3169. * @hidden
  3170. */
  3171. _actionManager: ActionManager;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. private _target;
  3177. /**
  3178. * Creates a new StateCondition
  3179. * @param actionManager manager for the action the condition applies to
  3180. * @param target of the condition
  3181. * @param value to compare with target state
  3182. */
  3183. constructor(actionManager: ActionManager, target: any, value: string);
  3184. /**
  3185. * @returns the validity of the state
  3186. */
  3187. isValid(): boolean;
  3188. /**
  3189. * Serialize the StateCondition into a JSON compatible object
  3190. * @returns serialization object
  3191. */
  3192. serialize(): any;
  3193. }
  3194. }
  3195. declare module BABYLON {
  3196. class SwitchBooleanAction extends Action {
  3197. propertyPath: string;
  3198. private _target;
  3199. private _effectiveTarget;
  3200. private _property;
  3201. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3202. _prepare(): void;
  3203. execute(): void;
  3204. serialize(parent: any): any;
  3205. }
  3206. class SetStateAction extends Action {
  3207. value: string;
  3208. private _target;
  3209. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3210. execute(): void;
  3211. serialize(parent: any): any;
  3212. }
  3213. class SetValueAction extends Action {
  3214. propertyPath: string;
  3215. value: any;
  3216. private _target;
  3217. private _effectiveTarget;
  3218. private _property;
  3219. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3220. _prepare(): void;
  3221. execute(): void;
  3222. serialize(parent: any): any;
  3223. }
  3224. class IncrementValueAction extends Action {
  3225. propertyPath: string;
  3226. value: any;
  3227. private _target;
  3228. private _effectiveTarget;
  3229. private _property;
  3230. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3231. _prepare(): void;
  3232. execute(): void;
  3233. serialize(parent: any): any;
  3234. }
  3235. class PlayAnimationAction extends Action {
  3236. from: number;
  3237. to: number;
  3238. loop: boolean | undefined;
  3239. private _target;
  3240. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3241. _prepare(): void;
  3242. execute(): void;
  3243. serialize(parent: any): any;
  3244. }
  3245. class StopAnimationAction extends Action {
  3246. private _target;
  3247. constructor(triggerOptions: any, target: any, condition?: Condition);
  3248. _prepare(): void;
  3249. execute(): void;
  3250. serialize(parent: any): any;
  3251. }
  3252. class DoNothingAction extends Action {
  3253. constructor(triggerOptions?: any, condition?: Condition);
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class CombineAction extends Action {
  3258. children: Action[];
  3259. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3260. _prepare(): void;
  3261. execute(evt: ActionEvent): void;
  3262. serialize(parent: any): any;
  3263. }
  3264. class ExecuteCodeAction extends Action {
  3265. func: (evt: ActionEvent) => void;
  3266. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3267. execute(evt: ActionEvent): void;
  3268. }
  3269. class SetParentAction extends Action {
  3270. private _parent;
  3271. private _target;
  3272. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3273. _prepare(): void;
  3274. execute(): void;
  3275. serialize(parent: any): any;
  3276. }
  3277. class PlaySoundAction extends Action {
  3278. private _sound;
  3279. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3280. _prepare(): void;
  3281. execute(): void;
  3282. serialize(parent: any): any;
  3283. }
  3284. class StopSoundAction extends Action {
  3285. private _sound;
  3286. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3287. _prepare(): void;
  3288. execute(): void;
  3289. serialize(parent: any): any;
  3290. }
  3291. }
  3292. declare module BABYLON {
  3293. class InterpolateValueAction extends Action {
  3294. propertyPath: string;
  3295. value: any;
  3296. duration: number;
  3297. stopOtherAnimations: boolean | undefined;
  3298. onInterpolationDone: (() => void) | undefined;
  3299. private _target;
  3300. private _effectiveTarget;
  3301. private _property;
  3302. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3303. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3304. _prepare(): void;
  3305. execute(): void;
  3306. serialize(parent: any): any;
  3307. }
  3308. }
  3309. declare module BABYLON {
  3310. /**
  3311. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3313. */
  3314. class Analyser {
  3315. /**
  3316. * Gets or sets the smoothing
  3317. * @ignorenaming
  3318. */
  3319. SMOOTHING: number;
  3320. /**
  3321. * Gets or sets the FFT table size
  3322. * @ignorenaming
  3323. */
  3324. FFT_SIZE: number;
  3325. /**
  3326. * Gets or sets the bar graph amplitude
  3327. * @ignorenaming
  3328. */
  3329. BARGRAPHAMPLITUDE: number;
  3330. /**
  3331. * Gets or sets the position of the debug canvas
  3332. * @ignorenaming
  3333. */
  3334. DEBUGCANVASPOS: {
  3335. x: number;
  3336. y: number;
  3337. };
  3338. /**
  3339. * Gets or sets the debug canvas size
  3340. * @ignorenaming
  3341. */
  3342. DEBUGCANVASSIZE: {
  3343. width: number;
  3344. height: number;
  3345. };
  3346. private _byteFreqs;
  3347. private _byteTime;
  3348. private _floatFreqs;
  3349. private _webAudioAnalyser;
  3350. private _debugCanvas;
  3351. private _debugCanvasContext;
  3352. private _scene;
  3353. private _registerFunc;
  3354. private _audioEngine;
  3355. /**
  3356. * Creates a new analyser
  3357. * @param scene defines hosting scene
  3358. */
  3359. constructor(scene: Scene);
  3360. /**
  3361. * Get the number of data values you will have to play with for the visualization
  3362. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3363. * @returns a number
  3364. */
  3365. getFrequencyBinCount(): number;
  3366. /**
  3367. * Gets the current frequency data as a byte array
  3368. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3369. * @returns a Uint8Array
  3370. */
  3371. getByteFrequencyData(): Uint8Array;
  3372. /**
  3373. * Gets the current waveform as a byte array
  3374. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3375. * @returns a Uint8Array
  3376. */
  3377. getByteTimeDomainData(): Uint8Array;
  3378. /**
  3379. * Gets the current frequency data as a float array
  3380. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3381. * @returns a Float32Array
  3382. */
  3383. getFloatFrequencyData(): Float32Array;
  3384. /**
  3385. * Renders the debug canvas
  3386. */
  3387. drawDebugCanvas(): void;
  3388. /**
  3389. * Stops rendering the debug canvas and removes it
  3390. */
  3391. stopDebugCanvas(): void;
  3392. /**
  3393. * Connects two audio nodes
  3394. * @param inputAudioNode defines first node to connect
  3395. * @param outputAudioNode defines second node to connect
  3396. */
  3397. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3398. /**
  3399. * Releases all associated resources
  3400. */
  3401. dispose(): void;
  3402. }
  3403. }
  3404. declare module BABYLON {
  3405. class AudioEngine {
  3406. private _audioContext;
  3407. private _audioContextInitialized;
  3408. canUseWebAudio: boolean;
  3409. masterGain: GainNode;
  3410. private _connectedAnalyser;
  3411. WarnedWebAudioUnsupported: boolean;
  3412. unlocked: boolean;
  3413. onAudioUnlocked: () => any;
  3414. isMP3supported: boolean;
  3415. isOGGsupported: boolean;
  3416. readonly audioContext: Nullable<AudioContext>;
  3417. constructor();
  3418. private _unlockiOSaudio();
  3419. private _initializeAudioContext();
  3420. dispose(): void;
  3421. getGlobalVolume(): number;
  3422. setGlobalVolume(newVolume: number): void;
  3423. connectToAnalyser(analyser: Analyser): void;
  3424. }
  3425. }
  3426. declare module BABYLON {
  3427. class Sound {
  3428. name: string;
  3429. autoplay: boolean;
  3430. loop: boolean;
  3431. useCustomAttenuation: boolean;
  3432. soundTrackId: number;
  3433. spatialSound: boolean;
  3434. refDistance: number;
  3435. rolloffFactor: number;
  3436. maxDistance: number;
  3437. distanceModel: string;
  3438. private _panningModel;
  3439. onended: () => any;
  3440. private _playbackRate;
  3441. private _streaming;
  3442. private _startTime;
  3443. private _startOffset;
  3444. private _position;
  3445. private _localDirection;
  3446. private _volume;
  3447. private _isReadyToPlay;
  3448. isPlaying: boolean;
  3449. isPaused: boolean;
  3450. private _isDirectional;
  3451. private _readyToPlayCallback;
  3452. private _audioBuffer;
  3453. private _soundSource;
  3454. private _streamingSource;
  3455. private _soundPanner;
  3456. private _soundGain;
  3457. private _inputAudioNode;
  3458. private _ouputAudioNode;
  3459. private _coneInnerAngle;
  3460. private _coneOuterAngle;
  3461. private _coneOuterGain;
  3462. private _scene;
  3463. private _connectedMesh;
  3464. private _customAttenuationFunction;
  3465. private _registerFunc;
  3466. private _isOutputConnected;
  3467. private _htmlAudioElement;
  3468. private _urlType;
  3469. /**
  3470. * Create a sound and attach it to a scene
  3471. * @param name Name of your sound
  3472. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  3473. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3474. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3475. */
  3476. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3477. dispose(): void;
  3478. isReady(): boolean;
  3479. private _soundLoaded(audioData);
  3480. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3481. updateOptions(options: any): void;
  3482. private _createSpatialParameters();
  3483. private _updateSpatialParameters();
  3484. switchPanningModelToHRTF(): void;
  3485. switchPanningModelToEqualPower(): void;
  3486. private _switchPanningModel();
  3487. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3488. /**
  3489. * Transform this sound into a directional source
  3490. * @param coneInnerAngle Size of the inner cone in degree
  3491. * @param coneOuterAngle Size of the outer cone in degree
  3492. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3493. */
  3494. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3495. setPosition(newPosition: Vector3): void;
  3496. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3497. private _updateDirection();
  3498. updateDistanceFromListener(): void;
  3499. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3500. /**
  3501. * Play the sound
  3502. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3503. * @param offset (optional) Start the sound setting it at a specific time
  3504. */
  3505. play(time?: number, offset?: number): void;
  3506. private _onended();
  3507. /**
  3508. * Stop the sound
  3509. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3510. */
  3511. stop(time?: number): void;
  3512. pause(): void;
  3513. setVolume(newVolume: number, time?: number): void;
  3514. setPlaybackRate(newPlaybackRate: number): void;
  3515. getVolume(): number;
  3516. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3517. detachFromMesh(): void;
  3518. private _onRegisterAfterWorldMatrixUpdate(node);
  3519. clone(): Nullable<Sound>;
  3520. getAudioBuffer(): AudioBuffer | null;
  3521. serialize(): any;
  3522. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3523. }
  3524. }
  3525. declare module BABYLON {
  3526. class SoundTrack {
  3527. private _outputAudioNode;
  3528. private _scene;
  3529. id: number;
  3530. soundCollection: Array<Sound>;
  3531. private _isMainTrack;
  3532. private _connectedAnalyser;
  3533. private _options;
  3534. private _isInitialized;
  3535. constructor(scene: Scene, options?: any);
  3536. private _initializeSoundTrackAudioGraph();
  3537. dispose(): void;
  3538. AddSound(sound: Sound): void;
  3539. RemoveSound(sound: Sound): void;
  3540. setVolume(newVolume: number): void;
  3541. switchPanningModelToHRTF(): void;
  3542. switchPanningModelToEqualPower(): void;
  3543. connectToAnalyser(analyser: Analyser): void;
  3544. }
  3545. }
  3546. declare module BABYLON {
  3547. class Animatable {
  3548. target: any;
  3549. fromFrame: number;
  3550. toFrame: number;
  3551. loopAnimation: boolean;
  3552. onAnimationEnd: (() => void) | null | undefined;
  3553. private _localDelayOffset;
  3554. private _pausedDelay;
  3555. private _runtimeAnimations;
  3556. private _paused;
  3557. private _scene;
  3558. private _speedRatio;
  3559. private _weight;
  3560. private _syncRoot;
  3561. animationStarted: boolean;
  3562. /**
  3563. * Gets the root Animatable used to synchronize and normalize animations
  3564. */
  3565. readonly syncRoot: Animatable;
  3566. /**
  3567. * Gets the current frame of the first RuntimeAnimation
  3568. * Used to synchronize Animatables
  3569. */
  3570. readonly masterFrame: number;
  3571. /**
  3572. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3573. */
  3574. weight: number;
  3575. /**
  3576. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3577. */
  3578. speedRatio: number;
  3579. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3580. /**
  3581. * Synchronize and normalize current Animatable with a source Animatable
  3582. * This is useful when using animation weights and when animations are not of the same length
  3583. * @param root defines the root Animatable to synchronize with
  3584. * @returns the current Animatable
  3585. */
  3586. syncWith(root: Animatable): Animatable;
  3587. getAnimations(): RuntimeAnimation[];
  3588. appendAnimations(target: any, animations: Animation[]): void;
  3589. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3590. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3591. reset(): void;
  3592. enableBlending(blendingSpeed: number): void;
  3593. disableBlending(): void;
  3594. goToFrame(frame: number): void;
  3595. pause(): void;
  3596. restart(): void;
  3597. stop(animationName?: string): void;
  3598. _animate(delay: number): boolean;
  3599. }
  3600. }
  3601. declare module BABYLON {
  3602. /**
  3603. * Represents the range of an animation
  3604. */
  3605. class AnimationRange {
  3606. /**The name of the animation range**/
  3607. name: string;
  3608. /**The starting frame of the animation */
  3609. from: number;
  3610. /**The ending frame of the animation*/
  3611. to: number;
  3612. /**
  3613. * Initializes the range of an animation
  3614. * @param name The name of the animation range
  3615. * @param from The starting frame of the animation
  3616. * @param to The ending frame of the animation
  3617. */
  3618. constructor(
  3619. /**The name of the animation range**/
  3620. name: string,
  3621. /**The starting frame of the animation */
  3622. from: number,
  3623. /**The ending frame of the animation*/
  3624. to: number);
  3625. /**
  3626. * Makes a copy of the animation range
  3627. * @returns A copy of the animation range
  3628. */
  3629. clone(): AnimationRange;
  3630. }
  3631. /**
  3632. * Composed of a frame, and an action function
  3633. */
  3634. class AnimationEvent {
  3635. /** The frame for which the event is triggered **/
  3636. frame: number;
  3637. /** The event to perform when triggered **/
  3638. action: () => void;
  3639. /** Specifies if the event should be triggered only once**/
  3640. onlyOnce: boolean | undefined;
  3641. /**
  3642. * Specifies if the animation event is done
  3643. */
  3644. isDone: boolean;
  3645. /**
  3646. * Initializes the animation event
  3647. * @param frame The frame for which the event is triggered
  3648. * @param action The event to perform when triggered
  3649. * @param onlyOnce Specifies if the event should be triggered only once
  3650. */
  3651. constructor(
  3652. /** The frame for which the event is triggered **/
  3653. frame: number,
  3654. /** The event to perform when triggered **/
  3655. action: () => void,
  3656. /** Specifies if the event should be triggered only once**/
  3657. onlyOnce?: boolean | undefined);
  3658. }
  3659. /**
  3660. * A cursor which tracks a point on a path
  3661. */
  3662. class PathCursor {
  3663. private path;
  3664. /**
  3665. * Stores path cursor callbacks for when an onchange event is triggered
  3666. */
  3667. private _onchange;
  3668. /**
  3669. * The value of the path cursor
  3670. */
  3671. value: number;
  3672. /**
  3673. * The animation array of the path cursor
  3674. */
  3675. animations: Animation[];
  3676. /**
  3677. * Initializes the path cursor
  3678. * @param path The path to track
  3679. */
  3680. constructor(path: Path2);
  3681. /**
  3682. * Gets the cursor point on the path
  3683. * @returns A point on the path cursor at the cursor location
  3684. */
  3685. getPoint(): Vector3;
  3686. /**
  3687. * Moves the cursor ahead by the step amount
  3688. * @param step The amount to move the cursor forward
  3689. * @returns This path cursor
  3690. */
  3691. moveAhead(step?: number): PathCursor;
  3692. /**
  3693. * Moves the cursor behind by the step amount
  3694. * @param step The amount to move the cursor back
  3695. * @returns This path cursor
  3696. */
  3697. moveBack(step?: number): PathCursor;
  3698. /**
  3699. * Moves the cursor by the step amount
  3700. * If the step amount is greater than one, an exception is thrown
  3701. * @param step The amount to move the cursor
  3702. * @returns This path cursor
  3703. */
  3704. move(step: number): PathCursor;
  3705. /**
  3706. * Ensures that the value is limited between zero and one
  3707. * @returns This path cursor
  3708. */
  3709. private ensureLimits();
  3710. /**
  3711. * Runs onchange callbacks on change (used by the animation engine)
  3712. * @returns This path cursor
  3713. */
  3714. private raiseOnChange();
  3715. /**
  3716. * Executes a function on change
  3717. * @param f A path cursor onchange callback
  3718. * @returns This path cursor
  3719. */
  3720. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3721. }
  3722. /**
  3723. * Defines an interface which represents an animation key frame
  3724. */
  3725. interface IAnimationKey {
  3726. /**
  3727. * Frame of the key frame
  3728. */
  3729. frame: number;
  3730. /**
  3731. * Value at the specifies key frame
  3732. */
  3733. value: any;
  3734. /**
  3735. * The input tangent for the cubic hermite spline
  3736. */
  3737. inTangent?: any;
  3738. /**
  3739. * The output tangent for the cubic hermite spline
  3740. */
  3741. outTangent?: any;
  3742. /**
  3743. * The animation interpolation type
  3744. */
  3745. interpolation?: AnimationKeyInterpolation;
  3746. }
  3747. /**
  3748. * Enum for the animation key frame interpolation type
  3749. */
  3750. enum AnimationKeyInterpolation {
  3751. /**
  3752. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3753. */
  3754. STEP = 1,
  3755. }
  3756. /**
  3757. * Class used to store any kind of animation
  3758. */
  3759. class Animation {
  3760. /**Name of the animation */
  3761. name: string;
  3762. /**Property to animate */
  3763. targetProperty: string;
  3764. /**The frames per second of the animation */
  3765. framePerSecond: number;
  3766. /**The data type of the animation */
  3767. dataType: number;
  3768. /**The loop mode of the animation */
  3769. loopMode: number | undefined;
  3770. /**Specifies if blending should be enabled */
  3771. enableBlending: boolean | undefined;
  3772. /**
  3773. * Use matrix interpolation instead of using direct key value when animating matrices
  3774. */
  3775. static AllowMatricesInterpolation: boolean;
  3776. /**
  3777. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3778. */
  3779. static AllowMatrixDecomposeForInterpolation: boolean;
  3780. /**
  3781. * Stores the key frames of the animation
  3782. */
  3783. private _keys;
  3784. /**
  3785. * Stores the easing function of the animation
  3786. */
  3787. private _easingFunction;
  3788. /**
  3789. * @hidden Internal use only
  3790. */
  3791. _runtimeAnimations: RuntimeAnimation[];
  3792. /**
  3793. * The set of event that will be linked to this animation
  3794. */
  3795. private _events;
  3796. /**
  3797. * Stores an array of target property paths
  3798. */
  3799. targetPropertyPath: string[];
  3800. /**
  3801. * Stores the blending speed of the animation
  3802. */
  3803. blendingSpeed: number;
  3804. /**
  3805. * Stores the animation ranges for the animation
  3806. */
  3807. private _ranges;
  3808. /**
  3809. * @hidden Internal use
  3810. */
  3811. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3812. /**
  3813. * Sets up an animation
  3814. * @param property The property to animate
  3815. * @param animationType The animation type to apply
  3816. * @param framePerSecond The frames per second of the animation
  3817. * @param easingFunction The easing function used in the animation
  3818. * @returns The created animation
  3819. */
  3820. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3821. /**
  3822. * Create and start an animation on a node
  3823. * @param name defines the name of the global animation that will be run on all nodes
  3824. * @param node defines the root node where the animation will take place
  3825. * @param targetProperty defines property to animate
  3826. * @param framePerSecond defines the number of frame per second yo use
  3827. * @param totalFrame defines the number of frames in total
  3828. * @param from defines the initial value
  3829. * @param to defines the final value
  3830. * @param loopMode defines which loop mode you want to use (off by default)
  3831. * @param easingFunction defines the easing function to use (linear by default)
  3832. * @param onAnimationEnd defines the callback to call when animation end
  3833. * @returns the animatable created for this animation
  3834. */
  3835. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3836. /**
  3837. * Create and start an animation on a node and its descendants
  3838. * @param name defines the name of the global animation that will be run on all nodes
  3839. * @param node defines the root node where the animation will take place
  3840. * @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
  3841. * @param targetProperty defines property to animate
  3842. * @param framePerSecond defines the number of frame per second to use
  3843. * @param totalFrame defines the number of frames in total
  3844. * @param from defines the initial value
  3845. * @param to defines the final value
  3846. * @param loopMode defines which loop mode you want to use (off by default)
  3847. * @param easingFunction defines the easing function to use (linear by default)
  3848. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3849. * @returns the list of animatables created for all nodes
  3850. * @example https://www.babylonjs-playground.com/#MH0VLI
  3851. */
  3852. 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[]>;
  3853. /**
  3854. * Creates a new animation, merges it with the existing animations and starts it
  3855. * @param name Name of the animation
  3856. * @param node Node which contains the scene that begins the animations
  3857. * @param targetProperty Specifies which property to animate
  3858. * @param framePerSecond The frames per second of the animation
  3859. * @param totalFrame The total number of frames
  3860. * @param from The frame at the beginning of the animation
  3861. * @param to The frame at the end of the animation
  3862. * @param loopMode Specifies the loop mode of the animation
  3863. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3864. * @param onAnimationEnd Callback to run once the animation is complete
  3865. * @returns Nullable animation
  3866. */
  3867. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3868. /**
  3869. * Transition property of the Camera to the target Value
  3870. * @param property The property to transition
  3871. * @param targetValue The target Value of the property
  3872. * @param host The object where the property to animate belongs
  3873. * @param scene Scene used to run the animation
  3874. * @param frameRate Framerate (in frame/s) to use
  3875. * @param transition The transition type we want to use
  3876. * @param duration The duration of the animation, in milliseconds
  3877. * @param onAnimationEnd Callback trigger at the end of the animation
  3878. * @returns Nullable animation
  3879. */
  3880. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3881. /**
  3882. * Return the array of runtime animations currently using this animation
  3883. */
  3884. readonly runtimeAnimations: RuntimeAnimation[];
  3885. /**
  3886. * Specifies if any of the runtime animations are currently running
  3887. */
  3888. readonly hasRunningRuntimeAnimations: boolean;
  3889. /**
  3890. * Initializes the animation
  3891. * @param name Name of the animation
  3892. * @param targetProperty Property to animate
  3893. * @param framePerSecond The frames per second of the animation
  3894. * @param dataType The data type of the animation
  3895. * @param loopMode The loop mode of the animation
  3896. * @param enableBlendings Specifies if blending should be enabled
  3897. */
  3898. constructor(
  3899. /**Name of the animation */
  3900. name: string,
  3901. /**Property to animate */
  3902. targetProperty: string,
  3903. /**The frames per second of the animation */
  3904. framePerSecond: number,
  3905. /**The data type of the animation */
  3906. dataType: number,
  3907. /**The loop mode of the animation */
  3908. loopMode?: number | undefined,
  3909. /**Specifies if blending should be enabled */
  3910. enableBlending?: boolean | undefined);
  3911. /**
  3912. * Converts the animation to a string
  3913. * @param fullDetails support for multiple levels of logging within scene loading
  3914. * @returns String form of the animation
  3915. */
  3916. toString(fullDetails?: boolean): string;
  3917. /**
  3918. * Add an event to this animation
  3919. * @param event Event to add
  3920. */
  3921. addEvent(event: AnimationEvent): void;
  3922. /**
  3923. * Remove all events found at the given frame
  3924. * @param frame The frame to remove events from
  3925. */
  3926. removeEvents(frame: number): void;
  3927. /**
  3928. * Retrieves all the events from the animation
  3929. * @returns Events from the animation
  3930. */
  3931. getEvents(): AnimationEvent[];
  3932. /**
  3933. * Creates an animation range
  3934. * @param name Name of the animation range
  3935. * @param from Starting frame of the animation range
  3936. * @param to Ending frame of the animation
  3937. */
  3938. createRange(name: string, from: number, to: number): void;
  3939. /**
  3940. * Deletes an animation range by name
  3941. * @param name Name of the animation range to delete
  3942. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3943. */
  3944. deleteRange(name: string, deleteFrames?: boolean): void;
  3945. /**
  3946. * Gets the animation range by name, or null if not defined
  3947. * @param name Name of the animation range
  3948. * @returns Nullable animation range
  3949. */
  3950. getRange(name: string): Nullable<AnimationRange>;
  3951. /**
  3952. * Gets the key frames from the animation
  3953. * @returns The key frames of the animation
  3954. */
  3955. getKeys(): Array<IAnimationKey>;
  3956. /**
  3957. * Gets the highest frame rate of the animation
  3958. * @returns Highest frame rate of the animation
  3959. */
  3960. getHighestFrame(): number;
  3961. /**
  3962. * Gets the easing function of the animation
  3963. * @returns Easing function of the animation
  3964. */
  3965. getEasingFunction(): IEasingFunction;
  3966. /**
  3967. * Sets the easing function of the animation
  3968. * @param easingFunction A custom mathematical formula for animation
  3969. */
  3970. setEasingFunction(easingFunction: EasingFunction): void;
  3971. /**
  3972. * Interpolates a scalar linearly
  3973. * @param startValue Start value of the animation curve
  3974. * @param endValue End value of the animation curve
  3975. * @param gradient Scalar amount to interpolate
  3976. * @returns Interpolated scalar value
  3977. */
  3978. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3979. /**
  3980. * Interpolates a scalar cubically
  3981. * @param startValue Start value of the animation curve
  3982. * @param outTangent End tangent of the animation
  3983. * @param endValue End value of the animation curve
  3984. * @param inTangent Start tangent of the animation curve
  3985. * @param gradient Scalar amount to interpolate
  3986. * @returns Interpolated scalar value
  3987. */
  3988. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3989. /**
  3990. * Interpolates a quaternion using a spherical linear interpolation
  3991. * @param startValue Start value of the animation curve
  3992. * @param endValue End value of the animation curve
  3993. * @param gradient Scalar amount to interpolate
  3994. * @returns Interpolated quaternion value
  3995. */
  3996. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3997. /**
  3998. * Interpolates a quaternion cubically
  3999. * @param startValue Start value of the animation curve
  4000. * @param outTangent End tangent of the animation curve
  4001. * @param endValue End value of the animation curve
  4002. * @param inTangent Start tangent of the animation curve
  4003. * @param gradient Scalar amount to interpolate
  4004. * @returns Interpolated quaternion value
  4005. */
  4006. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4007. /**
  4008. * Interpolates a Vector3 linearl
  4009. * @param startValue Start value of the animation curve
  4010. * @param endValue End value of the animation curve
  4011. * @param gradient Scalar amount to interpolate
  4012. * @returns Interpolated scalar value
  4013. */
  4014. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4015. /**
  4016. * Interpolates a Vector3 cubically
  4017. * @param startValue Start value of the animation curve
  4018. * @param outTangent End tangent of the animation
  4019. * @param endValue End value of the animation curve
  4020. * @param inTangent Start tangent of the animation curve
  4021. * @param gradient Scalar amount to interpolate
  4022. * @returns InterpolatedVector3 value
  4023. */
  4024. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4025. /**
  4026. * Interpolates a Vector2 linearly
  4027. * @param startValue Start value of the animation curve
  4028. * @param endValue End value of the animation curve
  4029. * @param gradient Scalar amount to interpolate
  4030. * @returns Interpolated Vector2 value
  4031. */
  4032. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4033. /**
  4034. * Interpolates a Vector2 cubically
  4035. * @param startValue Start value of the animation curve
  4036. * @param outTangent End tangent of the animation
  4037. * @param endValue End value of the animation curve
  4038. * @param inTangent Start tangent of the animation curve
  4039. * @param gradient Scalar amount to interpolate
  4040. * @returns Interpolated Vector2 value
  4041. */
  4042. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4043. /**
  4044. * Interpolates a size linearly
  4045. * @param startValue Start value of the animation curve
  4046. * @param endValue End value of the animation curve
  4047. * @param gradient Scalar amount to interpolate
  4048. * @returns Interpolated Size value
  4049. */
  4050. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4051. /**
  4052. * Interpolates a Color3 linearly
  4053. * @param startValue Start value of the animation curve
  4054. * @param endValue End value of the animation curve
  4055. * @param gradient Scalar amount to interpolate
  4056. * @returns Interpolated Color3 value
  4057. */
  4058. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4059. /**
  4060. * @hidden Internal use only
  4061. */
  4062. _getKeyValue(value: any): any;
  4063. /**
  4064. * @hidden Internal use only
  4065. */
  4066. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4067. /**
  4068. * Defines the function to use to interpolate matrices
  4069. * @param startValue defines the start matrix
  4070. * @param endValue defines the end matrix
  4071. * @param gradient defines the gradient between both matrices
  4072. * @param result defines an optional target matrix where to store the interpolation
  4073. * @returns the interpolated matrix
  4074. */
  4075. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4076. /**
  4077. * Makes a copy of the animation
  4078. * @returns Cloned animation
  4079. */
  4080. clone(): Animation;
  4081. /**
  4082. * Sets the key frames of the animation
  4083. * @param values The animation key frames to set
  4084. */
  4085. setKeys(values: Array<IAnimationKey>): void;
  4086. /**
  4087. * Serializes the animation to an object
  4088. * @returns Serialized object
  4089. */
  4090. serialize(): any;
  4091. /**
  4092. * Float animation type
  4093. */
  4094. private static _ANIMATIONTYPE_FLOAT;
  4095. /**
  4096. * Vector3 animation type
  4097. */
  4098. private static _ANIMATIONTYPE_VECTOR3;
  4099. /**
  4100. * Quaternion animation type
  4101. */
  4102. private static _ANIMATIONTYPE_QUATERNION;
  4103. /**
  4104. * Matrix animation type
  4105. */
  4106. private static _ANIMATIONTYPE_MATRIX;
  4107. /**
  4108. * Color3 animation type
  4109. */
  4110. private static _ANIMATIONTYPE_COLOR3;
  4111. /**
  4112. * Vector2 animation type
  4113. */
  4114. private static _ANIMATIONTYPE_VECTOR2;
  4115. /**
  4116. * Size animation type
  4117. */
  4118. private static _ANIMATIONTYPE_SIZE;
  4119. /**
  4120. * Relative Loop Mode
  4121. */
  4122. private static _ANIMATIONLOOPMODE_RELATIVE;
  4123. /**
  4124. * Cycle Loop Mode
  4125. */
  4126. private static _ANIMATIONLOOPMODE_CYCLE;
  4127. /**
  4128. * Constant Loop Mode
  4129. */
  4130. private static _ANIMATIONLOOPMODE_CONSTANT;
  4131. /**
  4132. * Get the float animation type
  4133. */
  4134. static readonly ANIMATIONTYPE_FLOAT: number;
  4135. /**
  4136. * Get the Vector3 animation type
  4137. */
  4138. static readonly ANIMATIONTYPE_VECTOR3: number;
  4139. /**
  4140. * Get the Vectpr2 animation type
  4141. */
  4142. static readonly ANIMATIONTYPE_VECTOR2: number;
  4143. /**
  4144. * Get the Size animation type
  4145. */
  4146. static readonly ANIMATIONTYPE_SIZE: number;
  4147. /**
  4148. * Get the Quaternion animation type
  4149. */
  4150. static readonly ANIMATIONTYPE_QUATERNION: number;
  4151. /**
  4152. * Get the Matrix animation type
  4153. */
  4154. static readonly ANIMATIONTYPE_MATRIX: number;
  4155. /**
  4156. * Get the Color3 animation type
  4157. */
  4158. static readonly ANIMATIONTYPE_COLOR3: number;
  4159. /**
  4160. * Get the Relative Loop Mode
  4161. */
  4162. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4163. /**
  4164. * Get the Cycle Loop Mode
  4165. */
  4166. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4167. /**
  4168. * Get the Constant Loop Mode
  4169. */
  4170. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4171. /**
  4172. * Parses an animation object and creates an animation
  4173. * @param parsedAnimation Parsed animation object
  4174. * @returns Animation object
  4175. */
  4176. static Parse(parsedAnimation: any): Animation;
  4177. /**
  4178. * Appends the serialized animations from the source animations
  4179. * @param source Source containing the animations
  4180. * @param destination Target to store the animations
  4181. */
  4182. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4183. }
  4184. }
  4185. declare module BABYLON {
  4186. /**
  4187. * This class defines the direct association between an animation and a target
  4188. */
  4189. class TargetedAnimation {
  4190. animation: Animation;
  4191. target: any;
  4192. }
  4193. /**
  4194. * Use this class to create coordinated animations on multiple targets
  4195. */
  4196. class AnimationGroup implements IDisposable {
  4197. name: string;
  4198. private _scene;
  4199. private _targetedAnimations;
  4200. private _animatables;
  4201. private _from;
  4202. private _to;
  4203. private _isStarted;
  4204. private _speedRatio;
  4205. onAnimationEndObservable: Observable<TargetedAnimation>;
  4206. /**
  4207. * Gets the first frame
  4208. */
  4209. readonly from: number;
  4210. /**
  4211. * Gets the last frame
  4212. */
  4213. readonly to: number;
  4214. /**
  4215. * Define if the animations are started
  4216. */
  4217. readonly isStarted: boolean;
  4218. /**
  4219. * Gets or sets the speed ratio to use for all animations
  4220. */
  4221. /**
  4222. * Gets or sets the speed ratio to use for all animations
  4223. */
  4224. speedRatio: number;
  4225. /**
  4226. * Gets the targeted animations for this animation group
  4227. */
  4228. readonly targetedAnimations: Array<TargetedAnimation>;
  4229. /**
  4230. * returning the list of animatables controlled by this animation group.
  4231. */
  4232. readonly animatables: Array<Animatable>;
  4233. constructor(name: string, scene?: Nullable<Scene>);
  4234. /**
  4235. * Add an animation (with its target) in the group
  4236. * @param animation defines the animation we want to add
  4237. * @param target defines the target of the animation
  4238. * @returns the {BABYLON.TargetedAnimation} object
  4239. */
  4240. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4241. /**
  4242. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4243. * It can add constant keys at begin or end
  4244. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  4245. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  4246. */
  4247. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  4248. /**
  4249. * Start all animations on given targets
  4250. * @param loop defines if animations must loop
  4251. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4252. * @param from defines the from key (optional)
  4253. * @param to defines the to key (optional)
  4254. * @returns the current animation group
  4255. */
  4256. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4257. /**
  4258. * Pause all animations
  4259. */
  4260. pause(): AnimationGroup;
  4261. /**
  4262. * Play all animations to initial state
  4263. * This function will start() the animations if they were not started or will restart() them if they were paused
  4264. * @param loop defines if animations must loop
  4265. */
  4266. play(loop?: boolean): AnimationGroup;
  4267. /**
  4268. * Reset all animations to initial state
  4269. */
  4270. reset(): AnimationGroup;
  4271. /**
  4272. * Restart animations from key 0
  4273. */
  4274. restart(): AnimationGroup;
  4275. /**
  4276. * Stop all animations
  4277. */
  4278. stop(): AnimationGroup;
  4279. /**
  4280. * Set animation weight for all animatables
  4281. * @param weight defines the weight to use
  4282. * @return the animationGroup
  4283. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4284. */
  4285. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4286. /**
  4287. * Synchronize and normalize all animatables with a source animatable
  4288. * @param root defines the root animatable to synchronize with
  4289. * @return the animationGroup
  4290. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4291. */
  4292. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4293. /**
  4294. * Goes to a specific frame in this animation group
  4295. * @param frame the frame number to go to
  4296. * @return the animationGroup
  4297. */
  4298. goToFrame(frame: number): AnimationGroup;
  4299. /**
  4300. * Dispose all associated resources
  4301. */
  4302. dispose(): void;
  4303. }
  4304. }
  4305. declare module BABYLON {
  4306. /**
  4307. * Class used to override all child animations of a given target
  4308. */
  4309. class AnimationPropertiesOverride {
  4310. /**
  4311. * Gets or sets a value indicating if animation blending must be used
  4312. */
  4313. enableBlending: boolean;
  4314. /**
  4315. * Gets or sets the blending speed to use when enableBlending is true
  4316. */
  4317. blendingSpeed: number;
  4318. /**
  4319. * Gets or sets the default loop mode to use
  4320. */
  4321. loopMode: number;
  4322. }
  4323. }
  4324. declare module BABYLON {
  4325. interface IEasingFunction {
  4326. ease(gradient: number): number;
  4327. }
  4328. class EasingFunction implements IEasingFunction {
  4329. private static _EASINGMODE_EASEIN;
  4330. private static _EASINGMODE_EASEOUT;
  4331. private static _EASINGMODE_EASEINOUT;
  4332. static readonly EASINGMODE_EASEIN: number;
  4333. static readonly EASINGMODE_EASEOUT: number;
  4334. static readonly EASINGMODE_EASEINOUT: number;
  4335. private _easingMode;
  4336. setEasingMode(easingMode: number): void;
  4337. getEasingMode(): number;
  4338. easeInCore(gradient: number): number;
  4339. ease(gradient: number): number;
  4340. }
  4341. class CircleEase extends EasingFunction implements IEasingFunction {
  4342. easeInCore(gradient: number): number;
  4343. }
  4344. class BackEase extends EasingFunction implements IEasingFunction {
  4345. amplitude: number;
  4346. constructor(amplitude?: number);
  4347. easeInCore(gradient: number): number;
  4348. }
  4349. class BounceEase extends EasingFunction implements IEasingFunction {
  4350. bounces: number;
  4351. bounciness: number;
  4352. constructor(bounces?: number, bounciness?: number);
  4353. easeInCore(gradient: number): number;
  4354. }
  4355. class CubicEase extends EasingFunction implements IEasingFunction {
  4356. easeInCore(gradient: number): number;
  4357. }
  4358. class ElasticEase extends EasingFunction implements IEasingFunction {
  4359. oscillations: number;
  4360. springiness: number;
  4361. constructor(oscillations?: number, springiness?: number);
  4362. easeInCore(gradient: number): number;
  4363. }
  4364. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4365. exponent: number;
  4366. constructor(exponent?: number);
  4367. easeInCore(gradient: number): number;
  4368. }
  4369. class PowerEase extends EasingFunction implements IEasingFunction {
  4370. power: number;
  4371. constructor(power?: number);
  4372. easeInCore(gradient: number): number;
  4373. }
  4374. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4375. easeInCore(gradient: number): number;
  4376. }
  4377. class QuarticEase extends EasingFunction implements IEasingFunction {
  4378. easeInCore(gradient: number): number;
  4379. }
  4380. class QuinticEase extends EasingFunction implements IEasingFunction {
  4381. easeInCore(gradient: number): number;
  4382. }
  4383. class SineEase extends EasingFunction implements IEasingFunction {
  4384. easeInCore(gradient: number): number;
  4385. }
  4386. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4387. x1: number;
  4388. y1: number;
  4389. x2: number;
  4390. y2: number;
  4391. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4392. easeInCore(gradient: number): number;
  4393. }
  4394. }
  4395. declare module BABYLON {
  4396. /**
  4397. * Defines a runtime animation
  4398. */
  4399. class RuntimeAnimation {
  4400. /**
  4401. * The current frame of the runtime animation
  4402. */
  4403. private _currentFrame;
  4404. /**
  4405. * The animation used by the runtime animation
  4406. */
  4407. private _animation;
  4408. /**
  4409. * The target of the runtime animation
  4410. */
  4411. private _target;
  4412. /**
  4413. * The initiating animatable
  4414. */
  4415. private _host;
  4416. /**
  4417. * The original value of the runtime animation
  4418. */
  4419. private _originalValue;
  4420. /**
  4421. * The original blend value of the runtime animation
  4422. */
  4423. private _originalBlendValue;
  4424. /**
  4425. * The offsets cache of the runtime animation
  4426. */
  4427. private _offsetsCache;
  4428. /**
  4429. * The high limits cache of the runtime animation
  4430. */
  4431. private _highLimitsCache;
  4432. /**
  4433. * Specifies if the runtime animation has been stopped
  4434. */
  4435. private _stopped;
  4436. /**
  4437. * The blending factor of the runtime animation
  4438. */
  4439. private _blendingFactor;
  4440. /**
  4441. * The BabylonJS scene
  4442. */
  4443. private _scene;
  4444. /**
  4445. * The current value of the runtime animation
  4446. */
  4447. private _currentValue;
  4448. /** @hidden */
  4449. _workValue: any;
  4450. /**
  4451. * The active target of the runtime animation
  4452. */
  4453. private _activeTarget;
  4454. /**
  4455. * The target path of the runtime animation
  4456. */
  4457. private _targetPath;
  4458. /**
  4459. * The weight of the runtime animation
  4460. */
  4461. private _weight;
  4462. /**
  4463. * The ratio offset of the runtime animation
  4464. */
  4465. private _ratioOffset;
  4466. /**
  4467. * The previous delay of the runtime animation
  4468. */
  4469. private _previousDelay;
  4470. /**
  4471. * The previous ratio of the runtime animation
  4472. */
  4473. private _previousRatio;
  4474. /**
  4475. * Gets the current frame of the runtime animation
  4476. */
  4477. readonly currentFrame: number;
  4478. /**
  4479. * Gets the weight of the runtime animation
  4480. */
  4481. readonly weight: number;
  4482. /**
  4483. * Gets the original value of the runtime animation
  4484. */
  4485. readonly originalValue: any;
  4486. /**
  4487. * Gets the current value of the runtime animation
  4488. */
  4489. readonly currentValue: any;
  4490. /**
  4491. * Gets the target path of the runtime animation
  4492. */
  4493. readonly targetPath: string;
  4494. /**
  4495. * Gets the actual target of the runtime animation
  4496. */
  4497. readonly target: any;
  4498. /**
  4499. * Create a new RuntimeAnimation object
  4500. * @param target defines the target of the animation
  4501. * @param animation defines the source animation object
  4502. * @param scene defines the hosting scene
  4503. * @param host defines the initiating Animatable
  4504. */
  4505. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4506. /**
  4507. * Gets the animation from the runtime animation
  4508. */
  4509. readonly animation: Animation;
  4510. /**
  4511. * Resets the runtime animation to the beginning
  4512. */
  4513. reset(): void;
  4514. /**
  4515. * Specifies if the runtime animation is stopped
  4516. * @returns Boolean specifying if the runtime animation is stopped
  4517. */
  4518. isStopped(): boolean;
  4519. /**
  4520. * Disposes of the runtime animation
  4521. */
  4522. dispose(): void;
  4523. /**
  4524. * Interpolates the animation from the current frame
  4525. * @param currentFrame The frame to interpolate the animation to
  4526. * @param repeatCount The number of times that the animation should loop
  4527. * @param loopMode The type of looping mode to use
  4528. * @param offsetValue Animation offset value
  4529. * @param highLimitValue The high limit value
  4530. * @returns The interpolated value
  4531. */
  4532. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4533. /**
  4534. * Affect the interpolated value to the target
  4535. * @param currentValue defines the value computed by the animation
  4536. * @param weight defines the weight to apply to this value
  4537. */
  4538. setValue(currentValue: any, weight?: number): void;
  4539. /**
  4540. * Sets the value of the runtime animation
  4541. * @param target The target property of the runtime animation
  4542. * @param currentValue The current value to use for the runtime animation
  4543. * @param weight The weight to use for the runtime animation (Defaults to 1.0)
  4544. */
  4545. private _setValue(target, currentValue, weight?);
  4546. /**
  4547. * Gets the loop pmode of the runtime animation
  4548. * @returns Loop Mode
  4549. */
  4550. private _getCorrectLoopMode();
  4551. /**
  4552. * Move the current animation to a given frame
  4553. * @param frame defines the frame to move to
  4554. */
  4555. goToFrame(frame: number): void;
  4556. /**
  4557. * @hidden Internal use only
  4558. */
  4559. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4560. /**
  4561. * Execute the current animation
  4562. * @param delay defines the delay to add to the current frame
  4563. * @param from defines the lower bound of the animation range
  4564. * @param to defines the upper bound of the animation range
  4565. * @param loop defines if the current animation must loop
  4566. * @param speedRatio defines the current speed ratio
  4567. * @param weight defines the weight of the animation (default is -1 so no weight)
  4568. * @returns a boolean indicating if the animation has ended
  4569. */
  4570. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4571. }
  4572. }
  4573. declare module BABYLON {
  4574. interface Behavior<T extends Node> {
  4575. name: string;
  4576. init(): void;
  4577. attach(node: T): void;
  4578. detach(): void;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /**
  4583. * Class used to store bone information
  4584. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4585. */
  4586. class Bone extends Node {
  4587. /**
  4588. * defines the bone name
  4589. */
  4590. name: string;
  4591. private static _tmpVecs;
  4592. private static _tmpQuat;
  4593. private static _tmpMats;
  4594. /**
  4595. * Gets the list of child bones
  4596. */
  4597. children: Bone[];
  4598. /** Gets the animations associated with this bone */
  4599. animations: Animation[];
  4600. /**
  4601. * Gets or sets bone length
  4602. */
  4603. length: number;
  4604. /**
  4605. * @hidden Internal only
  4606. * Set this value to map this bone to a different index in the transform matrices
  4607. * Set this value to -1 to exclude the bone from the transform matrices
  4608. */
  4609. _index: Nullable<number>;
  4610. private _skeleton;
  4611. private _localMatrix;
  4612. private _restPose;
  4613. private _baseMatrix;
  4614. private _absoluteTransform;
  4615. private _invertedAbsoluteTransform;
  4616. private _parent;
  4617. private _scalingDeterminant;
  4618. private _worldTransform;
  4619. private _localScaling;
  4620. private _localRotation;
  4621. private _localPosition;
  4622. private _needToDecompose;
  4623. private _needToCompose;
  4624. /** @hidden */
  4625. /** @hidden */
  4626. _matrix: Matrix;
  4627. /**
  4628. * Create a new bone
  4629. * @param name defines the bone name
  4630. * @param skeleton defines the parent skeleton
  4631. * @param parentBone defines the parent (can be null if the bone is the root)
  4632. * @param localMatrix defines the local matrix
  4633. * @param restPose defines the rest pose matrix
  4634. * @param baseMatrix defines the base matrix
  4635. * @param index defines index of the bone in the hiearchy
  4636. */
  4637. constructor(
  4638. /**
  4639. * defines the bone name
  4640. */
  4641. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4642. /**
  4643. * Gets the parent skeleton
  4644. * @returns a skeleton
  4645. */
  4646. getSkeleton(): Skeleton;
  4647. /**
  4648. * Gets parent bone
  4649. * @returns a bone or null if the bone is the root of the bone hierarchy
  4650. */
  4651. getParent(): Nullable<Bone>;
  4652. /**
  4653. * Sets the parent bone
  4654. * @param parent defines the parent (can be null if the bone is the root)
  4655. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4656. */
  4657. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4658. /**
  4659. * Gets the local matrix
  4660. * @returns a matrix
  4661. */
  4662. getLocalMatrix(): Matrix;
  4663. /**
  4664. * Gets the base matrix (initial matrix which remains unchanged)
  4665. * @returns a matrix
  4666. */
  4667. getBaseMatrix(): Matrix;
  4668. /**
  4669. * Gets the rest pose matrix
  4670. * @returns a matrix
  4671. */
  4672. getRestPose(): Matrix;
  4673. /**
  4674. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4675. */
  4676. getWorldMatrix(): Matrix;
  4677. /**
  4678. * Sets the local matrix to rest pose matrix
  4679. */
  4680. returnToRest(): void;
  4681. /**
  4682. * Gets the inverse of the absolute transform matrix.
  4683. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4684. * @returns a matrix
  4685. */
  4686. getInvertedAbsoluteTransform(): Matrix;
  4687. /**
  4688. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4689. * @returns a matrix
  4690. */
  4691. getAbsoluteTransform(): Matrix;
  4692. /** Gets or sets current position (in local space) */
  4693. position: Vector3;
  4694. /** Gets or sets current rotation (in local space) */
  4695. rotation: Vector3;
  4696. /** Gets or sets current rotation quaternion (in local space) */
  4697. rotationQuaternion: Quaternion;
  4698. /** Gets or sets current scaling (in local space) */
  4699. scaling: Vector3;
  4700. /**
  4701. * Gets the animation properties override
  4702. */
  4703. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4704. private _decompose();
  4705. private _compose();
  4706. /**
  4707. * Update the base and local matrices
  4708. * @param matrix defines the new base or local matrix
  4709. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4710. * @param updateLocalMatrix defines if the local matrix should be updated
  4711. */
  4712. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4713. /** @hidden */
  4714. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4715. /**
  4716. * Flag the bone as dirty (Forcing it to update everything)
  4717. */
  4718. markAsDirty(): void;
  4719. private _markAsDirtyAndCompose();
  4720. private _markAsDirtyAndDecompose();
  4721. /**
  4722. * Copy an animation range from another bone
  4723. * @param source defines the source bone
  4724. * @param rangeName defines the range name to copy
  4725. * @param frameOffset defines the frame offset
  4726. * @param rescaleAsRequired defines if rescaling must be applied if required
  4727. * @param skelDimensionsRatio defines the scaling ratio
  4728. * @returns true if operation was successful
  4729. */
  4730. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4731. /**
  4732. * Translate the bone in local or world space
  4733. * @param vec The amount to translate the bone
  4734. * @param space The space that the translation is in
  4735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4736. */
  4737. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4738. /**
  4739. * Set the postion of the bone in local or world space
  4740. * @param position The position to set the bone
  4741. * @param space The space that the position is in
  4742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4743. */
  4744. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4745. /**
  4746. * Set the absolute position of the bone (world space)
  4747. * @param position The position to set the bone
  4748. * @param mesh The mesh that this bone is attached to
  4749. */
  4750. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4751. /**
  4752. * Scale the bone on the x, y and z axes (in local space)
  4753. * @param x The amount to scale the bone on the x axis
  4754. * @param y The amount to scale the bone on the y axis
  4755. * @param z The amount to scale the bone on the z axis
  4756. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4757. */
  4758. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4759. /**
  4760. * Set the bone scaling in local space
  4761. * @param scale defines the scaling vector
  4762. */
  4763. setScale(scale: Vector3): void;
  4764. /**
  4765. * Gets the current scaling in local space
  4766. * @returns the current scaling vector
  4767. */
  4768. getScale(): Vector3;
  4769. /**
  4770. * Gets the current scaling in local space and stores it in a target vector
  4771. * @param result defines the target vector
  4772. */
  4773. getScaleToRef(result: Vector3): void;
  4774. /**
  4775. * Set the yaw, pitch, and roll of the bone in local or world space
  4776. * @param yaw The rotation of the bone on the y axis
  4777. * @param pitch The rotation of the bone on the x axis
  4778. * @param roll The rotation of the bone on the z axis
  4779. * @param space The space that the axes of rotation are in
  4780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4781. */
  4782. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4783. /**
  4784. * Add a rotation to the bone on an axis in local or world space
  4785. * @param axis The axis to rotate the bone on
  4786. * @param amount The amount to rotate the bone
  4787. * @param space The space that the axis is in
  4788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4789. */
  4790. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4791. /**
  4792. * Set the rotation of the bone to a particular axis angle in local or world space
  4793. * @param axis The axis to rotate the bone on
  4794. * @param angle The angle that the bone should be rotated to
  4795. * @param space The space that the axis is in
  4796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4797. */
  4798. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4799. /**
  4800. * Set the euler rotation of the bone in local of world space
  4801. * @param rotation The euler rotation that the bone should be set to
  4802. * @param space The space that the rotation is in
  4803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4804. */
  4805. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4806. /**
  4807. * Set the quaternion rotation of the bone in local of world space
  4808. * @param quat The quaternion rotation that the bone should be set to
  4809. * @param space The space that the rotation is in
  4810. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4811. */
  4812. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4813. /**
  4814. * Set the rotation matrix of the bone in local of world space
  4815. * @param rotMat The rotation matrix that the bone should be set to
  4816. * @param space The space that the rotation is in
  4817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4818. */
  4819. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4820. private _rotateWithMatrix(rmat, space?, mesh?);
  4821. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4822. /**
  4823. * Get the position of the bone in local or world space
  4824. * @param space The space that the returned position is in
  4825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4826. * @returns The position of the bone
  4827. */
  4828. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4829. /**
  4830. * Copy the position of the bone to a vector3 in local or world space
  4831. * @param space The space that the returned position is in
  4832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4833. * @param result The vector3 to copy the position to
  4834. */
  4835. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4836. /**
  4837. * Get the absolute position of the bone (world space)
  4838. * @param mesh The mesh that this bone is attached to
  4839. * @returns The absolute position of the bone
  4840. */
  4841. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4842. /**
  4843. * Copy the absolute position of the bone (world space) to the result param
  4844. * @param mesh The mesh that this bone is attached to
  4845. * @param result The vector3 to copy the absolute position to
  4846. */
  4847. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4848. /**
  4849. * Compute the absolute transforms of this bone and its children
  4850. */
  4851. computeAbsoluteTransforms(): void;
  4852. /**
  4853. * Get the world direction from an axis that is in the local space of the bone
  4854. * @param localAxis The local direction that is used to compute the world direction
  4855. * @param mesh The mesh that this bone is attached to
  4856. * @returns The world direction
  4857. */
  4858. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4859. /**
  4860. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4861. * @param localAxis The local direction that is used to compute the world direction
  4862. * @param mesh The mesh that this bone is attached to
  4863. * @param result The vector3 that the world direction will be copied to
  4864. */
  4865. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4866. /**
  4867. * Get the euler rotation of the bone in local or world space
  4868. * @param space The space that the rotation should be in
  4869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4870. * @returns The euler rotation
  4871. */
  4872. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4873. /**
  4874. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4875. * @param space The space that the rotation should be in
  4876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4877. * @param result The vector3 that the rotation should be copied to
  4878. */
  4879. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4880. /**
  4881. * Get the quaternion rotation of the bone in either local or world space
  4882. * @param space The space that the rotation should be in
  4883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4884. * @returns The quaternion rotation
  4885. */
  4886. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4887. /**
  4888. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4889. * @param space The space that the rotation should be in
  4890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4891. * @param result The quaternion that the rotation should be copied to
  4892. */
  4893. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4894. /**
  4895. * Get the rotation matrix of the bone in local or world space
  4896. * @param space The space that the rotation should be in
  4897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4898. * @returns The rotation matrix
  4899. */
  4900. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4901. /**
  4902. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4903. * @param space The space that the rotation should be in
  4904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4905. * @param result The quaternion that the rotation should be copied to
  4906. */
  4907. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4908. /**
  4909. * Get the world position of a point that is in the local space of the bone
  4910. * @param position The local position
  4911. * @param mesh The mesh that this bone is attached to
  4912. * @returns The world position
  4913. */
  4914. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4915. /**
  4916. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4917. * @param position The local position
  4918. * @param mesh The mesh that this bone is attached to
  4919. * @param result The vector3 that the world position should be copied to
  4920. */
  4921. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4922. /**
  4923. * Get the local position of a point that is in world space
  4924. * @param position The world position
  4925. * @param mesh The mesh that this bone is attached to
  4926. * @returns The local position
  4927. */
  4928. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4929. /**
  4930. * Get the local position of a point that is in world space and copy it to the result param
  4931. * @param position The world position
  4932. * @param mesh The mesh that this bone is attached to
  4933. * @param result The vector3 that the local position should be copied to
  4934. */
  4935. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4936. }
  4937. }
  4938. declare module BABYLON {
  4939. /**
  4940. * Class used to apply inverse kinematics to bones
  4941. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4942. */
  4943. class BoneIKController {
  4944. private static _tmpVecs;
  4945. private static _tmpQuat;
  4946. private static _tmpMats;
  4947. /**
  4948. * Gets or sets the target mesh
  4949. */
  4950. targetMesh: AbstractMesh;
  4951. /** Gets or sets the mesh used as pole */
  4952. poleTargetMesh: AbstractMesh;
  4953. /**
  4954. * Gets or sets the bone used as pole
  4955. */
  4956. poleTargetBone: Nullable<Bone>;
  4957. /**
  4958. * Gets or sets the target position
  4959. */
  4960. targetPosition: Vector3;
  4961. /**
  4962. * Gets or sets the pole target position
  4963. */
  4964. poleTargetPosition: Vector3;
  4965. /**
  4966. * Gets or sets the pole target local offset
  4967. */
  4968. poleTargetLocalOffset: Vector3;
  4969. /**
  4970. * Gets or sets the pole angle
  4971. */
  4972. poleAngle: number;
  4973. /**
  4974. * Gets or sets the mesh associated with the controller
  4975. */
  4976. mesh: AbstractMesh;
  4977. /**
  4978. * 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)
  4979. */
  4980. slerpAmount: number;
  4981. private _bone1Quat;
  4982. private _bone1Mat;
  4983. private _bone2Ang;
  4984. private _bone1;
  4985. private _bone2;
  4986. private _bone1Length;
  4987. private _bone2Length;
  4988. private _maxAngle;
  4989. private _maxReach;
  4990. private _rightHandedSystem;
  4991. private _bendAxis;
  4992. private _slerping;
  4993. private _adjustRoll;
  4994. /**
  4995. * Gets or sets maximum allowed angle
  4996. */
  4997. maxAngle: number;
  4998. /**
  4999. * Creates a new BoneIKController
  5000. * @param mesh defines the mesh to control
  5001. * @param bone defines the bone to control
  5002. * @param options defines options to set up the controller
  5003. */
  5004. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5005. targetMesh?: AbstractMesh;
  5006. poleTargetMesh?: AbstractMesh;
  5007. poleTargetBone?: Bone;
  5008. poleTargetLocalOffset?: Vector3;
  5009. poleAngle?: number;
  5010. bendAxis?: Vector3;
  5011. maxAngle?: number;
  5012. slerpAmount?: number;
  5013. });
  5014. private _setMaxAngle(ang);
  5015. /**
  5016. * Force the controller to update the bones
  5017. */
  5018. update(): void;
  5019. }
  5020. }
  5021. declare module BABYLON {
  5022. /**
  5023. * Class used to make a bone look toward a point in space
  5024. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5025. */
  5026. class BoneLookController {
  5027. private static _tmpVecs;
  5028. private static _tmpQuat;
  5029. private static _tmpMats;
  5030. /**
  5031. * The target Vector3 that the bone will look at
  5032. */
  5033. target: Vector3;
  5034. /**
  5035. * The mesh that the bone is attached to
  5036. */
  5037. mesh: AbstractMesh;
  5038. /**
  5039. * The bone that will be looking to the target
  5040. */
  5041. bone: Bone;
  5042. /**
  5043. * The up axis of the coordinate system that is used when the bone is rotated
  5044. */
  5045. upAxis: Vector3;
  5046. /**
  5047. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5048. */
  5049. upAxisSpace: Space;
  5050. /**
  5051. * Used to make an adjustment to the yaw of the bone
  5052. */
  5053. adjustYaw: number;
  5054. /**
  5055. * Used to make an adjustment to the pitch of the bone
  5056. */
  5057. adjustPitch: number;
  5058. /**
  5059. * Used to make an adjustment to the roll of the bone
  5060. */
  5061. adjustRoll: number;
  5062. /**
  5063. * 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)
  5064. */
  5065. slerpAmount: number;
  5066. private _minYaw;
  5067. private _maxYaw;
  5068. private _minPitch;
  5069. private _maxPitch;
  5070. private _minYawSin;
  5071. private _minYawCos;
  5072. private _maxYawSin;
  5073. private _maxYawCos;
  5074. private _midYawConstraint;
  5075. private _minPitchTan;
  5076. private _maxPitchTan;
  5077. private _boneQuat;
  5078. private _slerping;
  5079. private _transformYawPitch;
  5080. private _transformYawPitchInv;
  5081. private _firstFrameSkipped;
  5082. private _yawRange;
  5083. private _fowardAxis;
  5084. /**
  5085. * Gets or sets the minimum yaw angle that the bone can look to
  5086. */
  5087. minYaw: number;
  5088. /**
  5089. * Gets or sets the maximum yaw angle that the bone can look to
  5090. */
  5091. maxYaw: number;
  5092. /**
  5093. * Gets or sets the minimum pitch angle that the bone can look to
  5094. */
  5095. minPitch: number;
  5096. /**
  5097. * Gets or sets the maximum pitch angle that the bone can look to
  5098. */
  5099. maxPitch: number;
  5100. /**
  5101. * Create a BoneLookController
  5102. * @param mesh the mesh that the bone belongs to
  5103. * @param bone the bone that will be looking to the target
  5104. * @param target the target Vector3 to look at
  5105. * @param settings optional settings:
  5106. * * maxYaw: the maximum angle the bone will yaw to
  5107. * * minYaw: the minimum angle the bone will yaw to
  5108. * * maxPitch: the maximum angle the bone will pitch to
  5109. * * minPitch: the minimum angle the bone will yaw to
  5110. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5111. * * upAxis: the up axis of the coordinate system
  5112. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5113. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5114. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5115. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5116. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5117. * * adjustRoll: used to make an adjustment to the roll of the bone
  5118. **/
  5119. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5120. maxYaw?: number;
  5121. minYaw?: number;
  5122. maxPitch?: number;
  5123. minPitch?: number;
  5124. slerpAmount?: number;
  5125. upAxis?: Vector3;
  5126. upAxisSpace?: Space;
  5127. yawAxis?: Vector3;
  5128. pitchAxis?: Vector3;
  5129. adjustYaw?: number;
  5130. adjustPitch?: number;
  5131. adjustRoll?: number;
  5132. });
  5133. /**
  5134. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5135. */
  5136. update(): void;
  5137. private _getAngleDiff(ang1, ang2);
  5138. private _getAngleBetween(ang1, ang2);
  5139. private _isAngleBetween(ang, ang1, ang2);
  5140. }
  5141. }
  5142. declare module BABYLON {
  5143. /**
  5144. * Class used to handle skinning animations
  5145. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5146. */
  5147. class Skeleton implements IAnimatable {
  5148. /** defines the skeleton name */
  5149. name: string;
  5150. /** defines the skeleton Id */
  5151. id: string;
  5152. /**
  5153. * Gets the list of child bones
  5154. */
  5155. bones: Bone[];
  5156. /**
  5157. * Gets an estimate of the dimension of the skeleton at rest
  5158. */
  5159. dimensionsAtRest: Vector3;
  5160. /**
  5161. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5162. */
  5163. needInitialSkinMatrix: boolean;
  5164. /**
  5165. * Gets the list of animations attached to this skeleton
  5166. */
  5167. animations: Array<Animation>;
  5168. private _scene;
  5169. private _isDirty;
  5170. private _transformMatrices;
  5171. private _meshesWithPoseMatrix;
  5172. private _animatables;
  5173. private _identity;
  5174. private _synchronizedWithMesh;
  5175. private _ranges;
  5176. private _lastAbsoluteTransformsUpdateId;
  5177. /**
  5178. * Specifies if the skeleton should be serialized
  5179. */
  5180. doNotSerialize: boolean;
  5181. private _animationPropertiesOverride;
  5182. /**
  5183. * Gets or sets the animation properties override
  5184. */
  5185. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5186. /**
  5187. * An observable triggered before computing the skeleton's matrices
  5188. */
  5189. onBeforeComputeObservable: Observable<Skeleton>;
  5190. /**
  5191. * Creates a new skeleton
  5192. * @param name defines the skeleton name
  5193. * @param id defines the skeleton Id
  5194. * @param scene defines the hosting scene
  5195. */
  5196. constructor(
  5197. /** defines the skeleton name */
  5198. name: string,
  5199. /** defines the skeleton Id */
  5200. id: string, scene: Scene);
  5201. /**
  5202. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5203. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5204. * @returns a Float32Array containing matrices data
  5205. */
  5206. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5207. /**
  5208. * Gets the current hosting scene
  5209. * @returns a scene object
  5210. */
  5211. getScene(): Scene;
  5212. /**
  5213. * Gets a string representing the current skeleton data
  5214. * @param fullDetails defines a boolean indicating if we want a verbose version
  5215. * @returns a string representing the current skeleton data
  5216. */
  5217. toString(fullDetails?: boolean): string;
  5218. /**
  5219. * Get bone's index searching by name
  5220. * @param name defines bone's name to search for
  5221. * @return the indice of the bone. Returns -1 if not found
  5222. */
  5223. getBoneIndexByName(name: string): number;
  5224. /**
  5225. * Creater a new animation range
  5226. * @param name defines the name of the range
  5227. * @param from defines the start key
  5228. * @param to defines the end key
  5229. */
  5230. createAnimationRange(name: string, from: number, to: number): void;
  5231. /**
  5232. * Delete a specific animation range
  5233. * @param name defines the name of the range
  5234. * @param deleteFrames defines if frames must be removed as well
  5235. */
  5236. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5237. /**
  5238. * Gets a specific animation range
  5239. * @param name defines the name of the range to look for
  5240. * @returns the requested animation range or null if not found
  5241. */
  5242. getAnimationRange(name: string): Nullable<AnimationRange>;
  5243. /**
  5244. * Gets the list of all animation ranges defined on this skeleton
  5245. * @returns an array
  5246. */
  5247. getAnimationRanges(): Nullable<AnimationRange>[];
  5248. /**
  5249. * Copy animation range from a source skeleton.
  5250. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5251. * @param source defines the source skeleton
  5252. * @param name defines the name of the range to copy
  5253. * @param rescaleAsRequired defines if rescaling must be applied if required
  5254. * @returns true if operation was successful
  5255. */
  5256. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5257. /**
  5258. * Forces the skeleton to go to rest pose
  5259. */
  5260. returnToRest(): void;
  5261. private _getHighestAnimationFrame();
  5262. /**
  5263. * Begin a specific animation range
  5264. * @param name defines the name of the range to start
  5265. * @param loop defines if looping must be turned on (false by default)
  5266. * @param speedRatio defines the speed ratio to apply (1 by default)
  5267. * @param onAnimationEnd defines a callback which will be called when animation will end
  5268. * @returns a new animatable
  5269. */
  5270. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5271. /** @hidden */
  5272. _markAsDirty(): void;
  5273. /** @hidden */
  5274. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5275. /** @hidden */
  5276. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5277. /** @hidden */
  5278. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5279. /**
  5280. * Build all resources required to render a skeleton
  5281. */
  5282. prepare(): void;
  5283. /**
  5284. * Gets the list of animatables currently running for this skeleton
  5285. * @returns an array of animatables
  5286. */
  5287. getAnimatables(): IAnimatable[];
  5288. /**
  5289. * Clone the current skeleton
  5290. * @param name defines the name of the new skeleton
  5291. * @param id defines the id of the enw skeleton
  5292. * @returns the new skeleton
  5293. */
  5294. clone(name: string, id: string): Skeleton;
  5295. /**
  5296. * Enable animation blending for this skeleton
  5297. * @param blendingSpeed defines the blending speed to apply
  5298. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5299. */
  5300. enableBlending(blendingSpeed?: number): void;
  5301. /**
  5302. * Releases all resources associated with the current skeleton
  5303. */
  5304. dispose(): void;
  5305. /**
  5306. * Serialize the skeleton in a JSON object
  5307. * @returns a JSON object
  5308. */
  5309. serialize(): any;
  5310. /**
  5311. * Creates a new skeleton from serialized data
  5312. * @param parsedSkeleton defines the serialized data
  5313. * @param scene defines the hosting scene
  5314. * @returns a new skeleton
  5315. */
  5316. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5317. /**
  5318. * Compute all node absolute transforms
  5319. * @param forceUpdate defines if computation must be done even if cache is up to date
  5320. */
  5321. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5322. /**
  5323. * Gets the root pose matrix
  5324. * @returns a matrix
  5325. */
  5326. getPoseMatrix(): Nullable<Matrix>;
  5327. /**
  5328. * Sorts bones per internal index
  5329. */
  5330. sortBones(): void;
  5331. private _sortBones(index, bones, visited);
  5332. }
  5333. }
  5334. /**
  5335. * Module Debug contains the (visual) components to debug a scene correctly
  5336. */
  5337. declare module BABYLON.Debug {
  5338. /**
  5339. * The Axes viewer will show 3 axes in a specific point in space
  5340. */
  5341. class AxesViewer {
  5342. private _xline;
  5343. private _yline;
  5344. private _zline;
  5345. private _xmesh;
  5346. private _ymesh;
  5347. private _zmesh;
  5348. scene: Nullable<Scene>;
  5349. scaleLines: number;
  5350. constructor(scene: Scene, scaleLines?: number);
  5351. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5352. dispose(): void;
  5353. }
  5354. }
  5355. declare module BABYLON.Debug {
  5356. /**
  5357. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  5358. */
  5359. class BoneAxesViewer extends AxesViewer {
  5360. mesh: Nullable<Mesh>;
  5361. bone: Nullable<Bone>;
  5362. pos: Vector3;
  5363. xaxis: Vector3;
  5364. yaxis: Vector3;
  5365. zaxis: Vector3;
  5366. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  5367. update(): void;
  5368. dispose(): void;
  5369. }
  5370. }
  5371. declare module BABYLON {
  5372. class DebugLayer {
  5373. private _scene;
  5374. static InspectorURL: string;
  5375. private _inspector;
  5376. private BJSINSPECTOR;
  5377. constructor(scene: Scene);
  5378. /** Creates the inspector window. */
  5379. private _createInspector(config?);
  5380. isVisible(): boolean;
  5381. hide(): void;
  5382. show(config?: {
  5383. popup?: boolean;
  5384. initialTab?: number;
  5385. parentElement?: HTMLElement;
  5386. newColors?: {
  5387. backgroundColor?: string;
  5388. backgroundColorLighter?: string;
  5389. backgroundColorLighter2?: string;
  5390. backgroundColorLighter3?: string;
  5391. color?: string;
  5392. colorTop?: string;
  5393. colorBot?: string;
  5394. };
  5395. }): void;
  5396. }
  5397. }
  5398. declare module BABYLON.Debug {
  5399. /**
  5400. * Used to show the physics impostor around the specific mesh.
  5401. */
  5402. class PhysicsViewer {
  5403. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  5404. protected _meshes: Array<Nullable<AbstractMesh>>;
  5405. protected _scene: Nullable<Scene>;
  5406. protected _numMeshes: number;
  5407. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5408. private _renderFunction;
  5409. private _debugBoxMesh;
  5410. private _debugSphereMesh;
  5411. private _debugMaterial;
  5412. constructor(scene: Scene);
  5413. protected _updateDebugMeshes(): void;
  5414. showImpostor(impostor: PhysicsImpostor): void;
  5415. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5416. private _getDebugMaterial(scene);
  5417. private _getDebugBoxMesh(scene);
  5418. private _getDebugSphereMesh(scene);
  5419. private _getDebugMesh(impostor, scene);
  5420. dispose(): void;
  5421. }
  5422. }
  5423. declare module BABYLON {
  5424. class RayHelper {
  5425. ray: Nullable<Ray>;
  5426. private _renderPoints;
  5427. private _renderLine;
  5428. private _renderFunction;
  5429. private _scene;
  5430. private _updateToMeshFunction;
  5431. private _attachedToMesh;
  5432. private _meshSpaceDirection;
  5433. private _meshSpaceOrigin;
  5434. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5435. constructor(ray: Ray);
  5436. show(scene: Scene, color: Color3): void;
  5437. hide(): void;
  5438. private _render();
  5439. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5440. detachFromMesh(): void;
  5441. private _updateToMesh();
  5442. dispose(): void;
  5443. }
  5444. }
  5445. declare module BABYLON.Debug {
  5446. /**
  5447. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  5448. */
  5449. class SkeletonViewer {
  5450. skeleton: Skeleton;
  5451. mesh: AbstractMesh;
  5452. autoUpdateBonesMatrices: boolean;
  5453. renderingGroupId: number;
  5454. color: Color3;
  5455. private _scene;
  5456. private _debugLines;
  5457. private _debugMesh;
  5458. private _isEnabled;
  5459. private _renderFunction;
  5460. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  5461. isEnabled: boolean;
  5462. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5463. private _getLinesForBonesWithLength(bones, meshMat);
  5464. private _getLinesForBonesNoLength(bones, meshMat);
  5465. update(): void;
  5466. dispose(): void;
  5467. }
  5468. }
  5469. declare module BABYLON {
  5470. class Collider {
  5471. /** Define if a collision was found */
  5472. collisionFound: boolean;
  5473. /**
  5474. * Define last intersection point in local space
  5475. */
  5476. intersectionPoint: Vector3;
  5477. /**
  5478. * Define last collided mesh
  5479. */
  5480. collidedMesh: Nullable<AbstractMesh>;
  5481. private _collisionPoint;
  5482. private _planeIntersectionPoint;
  5483. private _tempVector;
  5484. private _tempVector2;
  5485. private _tempVector3;
  5486. private _tempVector4;
  5487. private _edge;
  5488. private _baseToVertex;
  5489. private _destinationPoint;
  5490. private _slidePlaneNormal;
  5491. private _displacementVector;
  5492. _radius: Vector3;
  5493. _retry: number;
  5494. private _velocity;
  5495. private _basePoint;
  5496. private _epsilon;
  5497. _velocityWorldLength: number;
  5498. _basePointWorld: Vector3;
  5499. private _velocityWorld;
  5500. private _normalizedVelocity;
  5501. _initialVelocity: Vector3;
  5502. _initialPosition: Vector3;
  5503. private _nearestDistance;
  5504. private _collisionMask;
  5505. collisionMask: number;
  5506. /**
  5507. * Gets the plane normal used to compute the sliding response (in local space)
  5508. */
  5509. readonly slidePlaneNormal: Vector3;
  5510. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5511. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5512. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5513. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5514. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5515. _getResponse(pos: Vector3, vel: Vector3): void;
  5516. }
  5517. }
  5518. declare module BABYLON {
  5519. var CollisionWorker: string;
  5520. interface ICollisionCoordinator {
  5521. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5522. init(scene: Scene): void;
  5523. destroy(): void;
  5524. onMeshAdded(mesh: AbstractMesh): void;
  5525. onMeshUpdated(mesh: AbstractMesh): void;
  5526. onMeshRemoved(mesh: AbstractMesh): void;
  5527. onGeometryAdded(geometry: Geometry): void;
  5528. onGeometryUpdated(geometry: Geometry): void;
  5529. onGeometryDeleted(geometry: Geometry): void;
  5530. }
  5531. interface SerializedMesh {
  5532. id: string;
  5533. name: string;
  5534. uniqueId: number;
  5535. geometryId: Nullable<string>;
  5536. sphereCenter: Array<number>;
  5537. sphereRadius: number;
  5538. boxMinimum: Array<number>;
  5539. boxMaximum: Array<number>;
  5540. worldMatrixFromCache: any;
  5541. subMeshes: Array<SerializedSubMesh>;
  5542. checkCollisions: boolean;
  5543. }
  5544. interface SerializedSubMesh {
  5545. position: number;
  5546. verticesStart: number;
  5547. verticesCount: number;
  5548. indexStart: number;
  5549. indexCount: number;
  5550. hasMaterial: boolean;
  5551. sphereCenter: Array<number>;
  5552. sphereRadius: number;
  5553. boxMinimum: Array<number>;
  5554. boxMaximum: Array<number>;
  5555. }
  5556. /**
  5557. * Interface describing the value associated with a geometry
  5558. */
  5559. interface SerializedGeometry {
  5560. /**
  5561. * Defines the unique ID of the geometry
  5562. */
  5563. id: string;
  5564. /**
  5565. * Defines the array containing the positions
  5566. */
  5567. positions: Float32Array;
  5568. /**
  5569. * Defines the array containing the indices
  5570. */
  5571. indices: Uint32Array;
  5572. /**
  5573. * Defines the array containing the normals
  5574. */
  5575. normals: Float32Array;
  5576. }
  5577. interface BabylonMessage {
  5578. taskType: WorkerTaskType;
  5579. payload: InitPayload | CollidePayload | UpdatePayload;
  5580. }
  5581. interface SerializedColliderToWorker {
  5582. position: Array<number>;
  5583. velocity: Array<number>;
  5584. radius: Array<number>;
  5585. }
  5586. /** Defines supported task for worker process */
  5587. enum WorkerTaskType {
  5588. /** Initialization */
  5589. INIT = 0,
  5590. /** Update of geometry */
  5591. UPDATE = 1,
  5592. /** Evaluate collision */
  5593. COLLIDE = 2,
  5594. }
  5595. interface WorkerReply {
  5596. error: WorkerReplyType;
  5597. taskType: WorkerTaskType;
  5598. payload?: any;
  5599. }
  5600. interface CollisionReplyPayload {
  5601. newPosition: Array<number>;
  5602. collisionId: number;
  5603. collidedMeshUniqueId: number;
  5604. }
  5605. interface InitPayload {
  5606. }
  5607. interface CollidePayload {
  5608. collisionId: number;
  5609. collider: SerializedColliderToWorker;
  5610. maximumRetry: number;
  5611. excludedMeshUniqueId: Nullable<number>;
  5612. }
  5613. interface UpdatePayload {
  5614. updatedMeshes: {
  5615. [n: number]: SerializedMesh;
  5616. };
  5617. updatedGeometries: {
  5618. [s: string]: SerializedGeometry;
  5619. };
  5620. removedMeshes: Array<number>;
  5621. removedGeometries: Array<string>;
  5622. }
  5623. /** Defines kind of replies returned by worker */
  5624. enum WorkerReplyType {
  5625. /** Success */
  5626. SUCCESS = 0,
  5627. /** Unkown error */
  5628. UNKNOWN_ERROR = 1,
  5629. }
  5630. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5631. private _scene;
  5632. private _scaledPosition;
  5633. private _scaledVelocity;
  5634. private _collisionsCallbackArray;
  5635. private _init;
  5636. private _runningUpdated;
  5637. private _worker;
  5638. private _addUpdateMeshesList;
  5639. private _addUpdateGeometriesList;
  5640. private _toRemoveMeshesArray;
  5641. private _toRemoveGeometryArray;
  5642. constructor();
  5643. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5644. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5645. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5646. init(scene: Scene): void;
  5647. destroy(): void;
  5648. onMeshAdded(mesh: AbstractMesh): void;
  5649. onMeshUpdated: (transformNode: TransformNode) => void;
  5650. onMeshRemoved(mesh: AbstractMesh): void;
  5651. onGeometryAdded(geometry: Geometry): void;
  5652. onGeometryUpdated: (geometry: Geometry) => void;
  5653. onGeometryDeleted(geometry: Geometry): void;
  5654. private _afterRender;
  5655. private _onMessageFromWorker;
  5656. }
  5657. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5658. private _scene;
  5659. private _scaledPosition;
  5660. private _scaledVelocity;
  5661. private _finalPosition;
  5662. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5663. init(scene: Scene): void;
  5664. destroy(): void;
  5665. onMeshAdded(mesh: AbstractMesh): void;
  5666. onMeshUpdated(mesh: AbstractMesh): void;
  5667. onMeshRemoved(mesh: AbstractMesh): void;
  5668. onGeometryAdded(geometry: Geometry): void;
  5669. onGeometryUpdated(geometry: Geometry): void;
  5670. onGeometryDeleted(geometry: Geometry): void;
  5671. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5672. }
  5673. }
  5674. declare function importScripts(...urls: string[]): void;
  5675. declare const safePostMessage: any;
  5676. declare module BABYLON {
  5677. var WorkerIncluded: boolean;
  5678. class CollisionCache {
  5679. private _meshes;
  5680. private _geometries;
  5681. getMeshes(): {
  5682. [n: number]: SerializedMesh;
  5683. };
  5684. getGeometries(): {
  5685. [s: number]: SerializedGeometry;
  5686. };
  5687. getMesh(id: any): SerializedMesh;
  5688. addMesh(mesh: SerializedMesh): void;
  5689. removeMesh(uniqueId: number): void;
  5690. getGeometry(id: string): SerializedGeometry;
  5691. addGeometry(geometry: SerializedGeometry): void;
  5692. removeGeometry(id: string): void;
  5693. }
  5694. class CollideWorker {
  5695. collider: Collider;
  5696. private _collisionCache;
  5697. private finalPosition;
  5698. private collisionsScalingMatrix;
  5699. private collisionTranformationMatrix;
  5700. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5701. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5702. private checkCollision(mesh);
  5703. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5704. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5705. private checkSubmeshCollision(subMesh);
  5706. }
  5707. interface ICollisionDetector {
  5708. onInit(payload: InitPayload): void;
  5709. onUpdate(payload: UpdatePayload): void;
  5710. onCollision(payload: CollidePayload): void;
  5711. }
  5712. class CollisionDetectorTransferable implements ICollisionDetector {
  5713. private _collisionCache;
  5714. onInit(payload: InitPayload): void;
  5715. onUpdate(payload: UpdatePayload): void;
  5716. onCollision(payload: CollidePayload): void;
  5717. }
  5718. }
  5719. declare module BABYLON {
  5720. class IntersectionInfo {
  5721. bu: Nullable<number>;
  5722. bv: Nullable<number>;
  5723. distance: number;
  5724. faceId: number;
  5725. subMeshId: number;
  5726. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5727. }
  5728. class PickingInfo {
  5729. hit: boolean;
  5730. distance: number;
  5731. pickedPoint: Nullable<Vector3>;
  5732. pickedMesh: Nullable<AbstractMesh>;
  5733. bu: number;
  5734. bv: number;
  5735. faceId: number;
  5736. subMeshId: number;
  5737. pickedSprite: Nullable<Sprite>;
  5738. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5739. getTextureCoordinates(): Nullable<Vector2>;
  5740. }
  5741. }
  5742. declare module BABYLON {
  5743. /**
  5744. * Interface for attribute information associated with buffer instanciation
  5745. */
  5746. class InstancingAttributeInfo {
  5747. /**
  5748. * Index/offset of the attribute in the vertex shader
  5749. */
  5750. index: number;
  5751. /**
  5752. * size of the attribute, 1, 2, 3 or 4
  5753. */
  5754. attributeSize: number;
  5755. /**
  5756. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  5757. * default is FLOAT
  5758. */
  5759. attribyteType: number;
  5760. /**
  5761. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  5762. */
  5763. normalized: boolean;
  5764. /**
  5765. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  5766. */
  5767. offset: number;
  5768. /**
  5769. * Name of the GLSL attribute, for debugging purpose only
  5770. */
  5771. attributeName: string;
  5772. }
  5773. /**
  5774. * Define options used to create a render target texture
  5775. */
  5776. class RenderTargetCreationOptions {
  5777. /**
  5778. * Specifies is mipmaps must be generated
  5779. */
  5780. generateMipMaps?: boolean;
  5781. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5782. generateDepthBuffer?: boolean;
  5783. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5784. generateStencilBuffer?: boolean;
  5785. /** Defines texture type (int by default) */
  5786. type?: number;
  5787. /** Defines sampling mode (trilinear by default) */
  5788. samplingMode?: number;
  5789. /** Defines format (RGBA by default) */
  5790. format?: number;
  5791. }
  5792. /**
  5793. * Define options used to create a depth texture
  5794. */
  5795. class DepthTextureCreationOptions {
  5796. /** Specifies whether or not a stencil should be allocated in the texture */
  5797. generateStencil?: boolean;
  5798. /** Specifies whether or not bilinear filtering is enable on the texture */
  5799. bilinearFiltering?: boolean;
  5800. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  5801. comparisonFunction?: number;
  5802. /** Specifies if the created texture is a cube texture */
  5803. isCube?: boolean;
  5804. }
  5805. /**
  5806. * Class used to describe the capabilities of the engine relatively to the current browser
  5807. */
  5808. class EngineCapabilities {
  5809. /** Maximum textures units per fragment shader */
  5810. maxTexturesImageUnits: number;
  5811. /** Maximum texture units per vertex shader */
  5812. maxVertexTextureImageUnits: number;
  5813. /** Maximum textures units in the entire pipeline */
  5814. maxCombinedTexturesImageUnits: number;
  5815. /** Maximum texture size */
  5816. maxTextureSize: number;
  5817. /** Maximum cube texture size */
  5818. maxCubemapTextureSize: number;
  5819. /** Maximum render texture size */
  5820. maxRenderTextureSize: number;
  5821. /** Maximum number of vertex attributes */
  5822. maxVertexAttribs: number;
  5823. /** Maximum number of varyings */
  5824. maxVaryingVectors: number;
  5825. /** Maximum number of uniforms per vertex shader */
  5826. maxVertexUniformVectors: number;
  5827. /** Maximum number of uniforms per fragment shader */
  5828. maxFragmentUniformVectors: number;
  5829. /** Defines if standard derivates (dx/dy) are supported */
  5830. standardDerivatives: boolean;
  5831. /** Defines if s3tc texture compression is supported */
  5832. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  5833. /** Defines if pvrtc texture compression is supported */
  5834. pvrtc: any;
  5835. /** Defines if etc1 texture compression is supported */
  5836. etc1: any;
  5837. /** Defines if etc2 texture compression is supported */
  5838. etc2: any;
  5839. /** Defines if astc texture compression is supported */
  5840. astc: any;
  5841. /** Defines if float textures are supported */
  5842. textureFloat: boolean;
  5843. /** Defines if vertex array objects are supported */
  5844. vertexArrayObject: boolean;
  5845. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  5846. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  5847. /** Gets the maximum level of anisotropy supported */
  5848. maxAnisotropy: number;
  5849. /** Defines if instancing is supported */
  5850. instancedArrays: boolean;
  5851. /** Defines if 32 bits indices are supported */
  5852. uintIndices: boolean;
  5853. /** Defines if high precision shaders are supported */
  5854. highPrecisionShaderSupported: boolean;
  5855. /** Defines if depth reading in the fragment shader is supported */
  5856. fragmentDepthSupported: boolean;
  5857. /** Defines if float texture linear filtering is supported*/
  5858. textureFloatLinearFiltering: boolean;
  5859. /** Defines if rendering to float textures is supported */
  5860. textureFloatRender: boolean;
  5861. /** Defines if half float textures are supported*/
  5862. textureHalfFloat: boolean;
  5863. /** Defines if half float texture linear filtering is supported*/
  5864. textureHalfFloatLinearFiltering: boolean;
  5865. /** Defines if rendering to half float textures is supported */
  5866. textureHalfFloatRender: boolean;
  5867. /** Defines if textureLOD shader command is supported */
  5868. textureLOD: boolean;
  5869. /** Defines if draw buffers extension is supported */
  5870. drawBuffersExtension: boolean;
  5871. /** Defines if depth textures are supported */
  5872. depthTextureExtension: boolean;
  5873. /** Defines if float color buffer are supported */
  5874. colorBufferFloat: boolean;
  5875. /** Gets disjoint timer query extension (null if not supported) */
  5876. timerQuery: EXT_disjoint_timer_query;
  5877. /** Defines if timestamp can be used with timer query */
  5878. canUseTimestampForTimerQuery: boolean;
  5879. }
  5880. /** Interface defining initialization parameters for Engine class */
  5881. interface EngineOptions extends WebGLContextAttributes {
  5882. /**
  5883. * Defines if the engine should no exceed a specified device ratio
  5884. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  5885. */
  5886. limitDeviceRatio?: number;
  5887. /**
  5888. * Defines if webvr should be enabled automatically
  5889. * @see http://doc.babylonjs.com/how_to/webvr_camera
  5890. */
  5891. autoEnableWebVR?: boolean;
  5892. /**
  5893. * Defines if webgl2 should be turned off even if supported
  5894. * @see http://doc.babylonjs.com/features/webgl2
  5895. */
  5896. disableWebGL2Support?: boolean;
  5897. /**
  5898. * Defines if webaudio should be initialized as well
  5899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5900. */
  5901. audioEngine?: boolean;
  5902. /**
  5903. * Defines if animations should run using a deterministic lock step
  5904. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  5905. */
  5906. deterministicLockstep?: boolean;
  5907. /** Defines the maximum steps to use with deterministic lock step mode */
  5908. lockstepMaxSteps?: number;
  5909. /**
  5910. * Defines that engine should ignore context lost events
  5911. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  5912. */
  5913. doNotHandleContextLost?: boolean;
  5914. }
  5915. /**
  5916. * Defines the interface used by display changed events
  5917. */
  5918. interface IDisplayChangedEventArgs {
  5919. /** Gets the vrDisplay object (if any) */
  5920. vrDisplay: Nullable<any>;
  5921. /** Gets a boolean indicating if webVR is supported */
  5922. vrSupported: boolean;
  5923. }
  5924. /**
  5925. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  5926. */
  5927. class Engine {
  5928. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  5929. static ExceptionList: ({
  5930. key: string;
  5931. capture: string;
  5932. captureConstraint: number;
  5933. targets: string[];
  5934. } | {
  5935. key: string;
  5936. capture: null;
  5937. captureConstraint: null;
  5938. targets: string[];
  5939. })[];
  5940. /** Gets the list of created engines */
  5941. static Instances: Engine[];
  5942. /**
  5943. * Gets the latest created engine
  5944. */
  5945. static readonly LastCreatedEngine: Nullable<Engine>;
  5946. /**
  5947. * Gets the latest created scene
  5948. */
  5949. static readonly LastCreatedScene: Nullable<Scene>;
  5950. /**
  5951. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  5952. * @param flag defines which part of the materials must be marked as dirty
  5953. * @param predicate defines a predicate used to filter which materials should be affected
  5954. */
  5955. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  5956. private static _ALPHA_DISABLE;
  5957. private static _ALPHA_ADD;
  5958. private static _ALPHA_COMBINE;
  5959. private static _ALPHA_SUBTRACT;
  5960. private static _ALPHA_MULTIPLY;
  5961. private static _ALPHA_MAXIMIZED;
  5962. private static _ALPHA_ONEONE;
  5963. private static _ALPHA_PREMULTIPLIED;
  5964. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  5965. private static _ALPHA_INTERPOLATE;
  5966. private static _ALPHA_SCREENMODE;
  5967. private static _DELAYLOADSTATE_NONE;
  5968. private static _DELAYLOADSTATE_LOADED;
  5969. private static _DELAYLOADSTATE_LOADING;
  5970. private static _DELAYLOADSTATE_NOTLOADED;
  5971. private static _TEXTUREFORMAT_ALPHA;
  5972. private static _TEXTUREFORMAT_LUMINANCE;
  5973. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  5974. private static _TEXTUREFORMAT_RGB;
  5975. private static _TEXTUREFORMAT_RGBA;
  5976. private static _TEXTUREFORMAT_R32F;
  5977. private static _TEXTUREFORMAT_RG32F;
  5978. private static _TEXTUREFORMAT_RGB32F;
  5979. private static _TEXTUREFORMAT_RGBA32F;
  5980. private static _TEXTURETYPE_UNSIGNED_INT;
  5981. private static _TEXTURETYPE_FLOAT;
  5982. private static _TEXTURETYPE_HALF_FLOAT;
  5983. private static _NEVER;
  5984. private static _ALWAYS;
  5985. private static _LESS;
  5986. private static _EQUAL;
  5987. private static _LEQUAL;
  5988. private static _GREATER;
  5989. private static _GEQUAL;
  5990. private static _NOTEQUAL;
  5991. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  5992. static readonly NEVER: number;
  5993. /** 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 */
  5994. static readonly ALWAYS: number;
  5995. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  5996. static readonly LESS: number;
  5997. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  5998. static readonly EQUAL: number;
  5999. /** 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 */
  6000. static readonly LEQUAL: number;
  6001. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6002. static readonly GREATER: number;
  6003. /** 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 */
  6004. static readonly GEQUAL: number;
  6005. /** 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 */
  6006. static readonly NOTEQUAL: number;
  6007. private static _KEEP;
  6008. private static _REPLACE;
  6009. private static _INCR;
  6010. private static _DECR;
  6011. private static _INVERT;
  6012. private static _INCR_WRAP;
  6013. private static _DECR_WRAP;
  6014. /** Passed to stencilOperation to specify that stencil value must be kept */
  6015. static readonly KEEP: number;
  6016. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6017. static readonly REPLACE: number;
  6018. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6019. static readonly INCR: number;
  6020. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6021. static readonly DECR: number;
  6022. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6023. static readonly INVERT: number;
  6024. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6025. static readonly INCR_WRAP: number;
  6026. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6027. static readonly DECR_WRAP: number;
  6028. /** Defines that alpha blending is disabled */
  6029. static readonly ALPHA_DISABLE: number;
  6030. /** Defines that alpha blending to SRC + DEST */
  6031. static readonly ALPHA_ONEONE: number;
  6032. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6033. static readonly ALPHA_ADD: number;
  6034. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6035. static readonly ALPHA_COMBINE: number;
  6036. /** Defines that alpha blending to DEST - SRC * DEST */
  6037. static readonly ALPHA_SUBTRACT: number;
  6038. /** Defines that alpha blending to SRC * DEST */
  6039. static readonly ALPHA_MULTIPLY: number;
  6040. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6041. static readonly ALPHA_MAXIMIZED: number;
  6042. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6043. static readonly ALPHA_PREMULTIPLIED: number;
  6044. /**
  6045. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6046. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6047. */
  6048. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6049. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6050. static readonly ALPHA_INTERPOLATE: number;
  6051. /**
  6052. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6053. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6054. */
  6055. static readonly ALPHA_SCREENMODE: number;
  6056. /** Defines that the ressource is not delayed*/
  6057. static readonly DELAYLOADSTATE_NONE: number;
  6058. /** Defines that the ressource was successfully delay loaded */
  6059. static readonly DELAYLOADSTATE_LOADED: number;
  6060. /** Defines that the ressource is currently delay loading */
  6061. static readonly DELAYLOADSTATE_LOADING: number;
  6062. /** Defines that the ressource is delayed and has not started loading */
  6063. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6064. /** ALPHA */
  6065. static readonly TEXTUREFORMAT_ALPHA: number;
  6066. /** LUMINANCE */
  6067. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6068. /**
  6069. * R32F
  6070. */
  6071. static readonly TEXTUREFORMAT_R32F: number;
  6072. /**
  6073. * RG32F
  6074. */
  6075. static readonly TEXTUREFORMAT_RG32F: number;
  6076. /**
  6077. * RGB32F
  6078. */
  6079. static readonly TEXTUREFORMAT_RGB32F: number;
  6080. /**
  6081. * RGBA32F
  6082. */
  6083. static readonly TEXTUREFORMAT_RGBA32F: number;
  6084. /** LUMINANCE_ALPHA */
  6085. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6086. /** RGB */
  6087. static readonly TEXTUREFORMAT_RGB: number;
  6088. /** RGBA */
  6089. static readonly TEXTUREFORMAT_RGBA: number;
  6090. /** UNSIGNED_INT */
  6091. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6092. /** FLOAT */
  6093. static readonly TEXTURETYPE_FLOAT: number;
  6094. /** HALF_FLOAT */
  6095. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6096. private static _SCALEMODE_FLOOR;
  6097. private static _SCALEMODE_NEAREST;
  6098. private static _SCALEMODE_CEILING;
  6099. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6100. static readonly SCALEMODE_FLOOR: number;
  6101. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6102. static readonly SCALEMODE_NEAREST: number;
  6103. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6104. static readonly SCALEMODE_CEILING: number;
  6105. /**
  6106. * Returns the current version of the framework
  6107. */
  6108. static readonly Version: string;
  6109. /**
  6110. * Gets or sets the epsilon value used by collision engine
  6111. */
  6112. static CollisionsEpsilon: number;
  6113. /**
  6114. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6115. */
  6116. static CodeRepository: string;
  6117. /**
  6118. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6119. */
  6120. static ShadersRepository: string;
  6121. /**
  6122. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6123. */
  6124. forcePOTTextures: boolean;
  6125. /**
  6126. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6127. */
  6128. isFullscreen: boolean;
  6129. /**
  6130. * Gets a boolean indicating if the pointer is currently locked
  6131. */
  6132. isPointerLock: boolean;
  6133. /**
  6134. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6135. */
  6136. cullBackFaces: boolean;
  6137. /**
  6138. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6139. */
  6140. renderEvenInBackground: boolean;
  6141. /**
  6142. * Gets or sets a boolean indicating that cache can be kept between frames
  6143. */
  6144. preventCacheWipeBetweenFrames: boolean;
  6145. /**
  6146. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6147. **/
  6148. enableOfflineSupport: boolean;
  6149. /**
  6150. * 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)
  6151. **/
  6152. disableManifestCheck: boolean;
  6153. /**
  6154. * Gets the list of created scenes
  6155. */
  6156. scenes: Scene[];
  6157. /**
  6158. * Gets the list of created postprocesses
  6159. */
  6160. postProcesses: PostProcess[];
  6161. /**
  6162. * Observable event triggered each time the rendering canvas is resized
  6163. */
  6164. onResizeObservable: Observable<Engine>;
  6165. /**
  6166. * Observable event triggered each time the canvas loses focus
  6167. */
  6168. onCanvasBlurObservable: Observable<Engine>;
  6169. /**
  6170. * Observable event triggered each time the canvas gains focus
  6171. */
  6172. onCanvasFocusObservable: Observable<Engine>;
  6173. /**
  6174. * Observable event triggered each time the canvas receives pointerout event
  6175. */
  6176. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6177. /**
  6178. * Observable event triggered before each texture is initialized
  6179. */
  6180. onBeforeTextureInitObservable: Observable<Texture>;
  6181. private _vrDisplay;
  6182. private _vrSupported;
  6183. private _oldSize;
  6184. private _oldHardwareScaleFactor;
  6185. private _vrExclusivePointerMode;
  6186. private _webVRInitPromise;
  6187. /**
  6188. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6189. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6190. */
  6191. readonly isInVRExclusivePointerMode: boolean;
  6192. /**
  6193. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6194. */
  6195. disableUniformBuffers: boolean;
  6196. /** @hidden */
  6197. _uniformBuffers: UniformBuffer[];
  6198. /**
  6199. * Gets a boolean indicating that the engine supports uniform buffers
  6200. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6201. */
  6202. readonly supportsUniformBuffers: boolean;
  6203. /**
  6204. * Observable raised when the engine begins a new frame
  6205. */
  6206. onBeginFrameObservable: Observable<Engine>;
  6207. /**
  6208. * Observable raised when the engine ends the current frame
  6209. */
  6210. onEndFrameObservable: Observable<Engine>;
  6211. /**
  6212. * Observable raised when the engine is about to compile a shader
  6213. */
  6214. onBeforeShaderCompilationObservable: Observable<Engine>;
  6215. /**
  6216. * Observable raised when the engine has jsut compiled a shader
  6217. */
  6218. onAfterShaderCompilationObservable: Observable<Engine>;
  6219. private _gl;
  6220. private _renderingCanvas;
  6221. private _windowIsBackground;
  6222. private _webGLVersion;
  6223. /**
  6224. * Gets a boolean indicating that only power of 2 textures are supported
  6225. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6226. */
  6227. readonly needPOTTextures: boolean;
  6228. /** @hidden */
  6229. _badOS: boolean;
  6230. /** @hidden */
  6231. _badDesktopOS: boolean;
  6232. /**
  6233. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6234. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6235. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6236. */
  6237. disableTextureBindingOptimization: boolean;
  6238. /**
  6239. * Gets the audio engine
  6240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6241. * @ignorenaming
  6242. */
  6243. static audioEngine: AudioEngine;
  6244. private _onFocus;
  6245. private _onBlur;
  6246. private _onCanvasPointerOut;
  6247. private _onCanvasBlur;
  6248. private _onCanvasFocus;
  6249. private _onFullscreenChange;
  6250. private _onPointerLockChange;
  6251. private _onVRDisplayPointerRestricted;
  6252. private _onVRDisplayPointerUnrestricted;
  6253. private _onVrDisplayConnect;
  6254. private _onVrDisplayDisconnect;
  6255. private _onVrDisplayPresentChange;
  6256. /**
  6257. * Observable signaled when VR display mode changes
  6258. */
  6259. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6260. /**
  6261. * Observable signaled when VR request present is complete
  6262. */
  6263. onVRRequestPresentComplete: Observable<boolean>;
  6264. /**
  6265. * Observable signaled when VR request present starts
  6266. */
  6267. onVRRequestPresentStart: Observable<Engine>;
  6268. private _hardwareScalingLevel;
  6269. /** @hidden */
  6270. protected _caps: EngineCapabilities;
  6271. private _pointerLockRequested;
  6272. private _isStencilEnable;
  6273. private _colorWrite;
  6274. private _loadingScreen;
  6275. /** @hidden */
  6276. _drawCalls: PerfCounter;
  6277. /** @hidden */
  6278. _textureCollisions: PerfCounter;
  6279. private _glVersion;
  6280. private _glRenderer;
  6281. private _glVendor;
  6282. private _videoTextureSupported;
  6283. private _renderingQueueLaunched;
  6284. private _activeRenderLoops;
  6285. private _deterministicLockstep;
  6286. private _lockstepMaxSteps;
  6287. /**
  6288. * Observable signaled when a context lost event is raised
  6289. */
  6290. onContextLostObservable: Observable<Engine>;
  6291. /**
  6292. * Observable signaled when a context restored event is raised
  6293. */
  6294. onContextRestoredObservable: Observable<Engine>;
  6295. private _onContextLost;
  6296. private _onContextRestored;
  6297. private _contextWasLost;
  6298. private _doNotHandleContextLost;
  6299. private _performanceMonitor;
  6300. private _fps;
  6301. private _deltaTime;
  6302. /**
  6303. * Turn this value on if you want to pause FPS computation when in background
  6304. */
  6305. disablePerformanceMonitorInBackground: boolean;
  6306. /**
  6307. * Gets the performance monitor attached to this engine
  6308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  6309. */
  6310. readonly performanceMonitor: PerformanceMonitor;
  6311. /** @hidden */
  6312. protected _depthCullingState: _DepthCullingState;
  6313. /** @hidden */
  6314. protected _stencilState: _StencilState;
  6315. /** @hidden */
  6316. protected _alphaState: _AlphaState;
  6317. /** @hidden */
  6318. protected _alphaMode: number;
  6319. private _internalTexturesCache;
  6320. /** @hidden */
  6321. protected _activeChannel: number;
  6322. private _currentTextureChannel;
  6323. /** @hidden */
  6324. protected _boundTexturesCache: {
  6325. [key: string]: Nullable<InternalTexture>;
  6326. };
  6327. /** @hidden */
  6328. protected _currentEffect: Nullable<Effect>;
  6329. /** @hidden */
  6330. protected _currentProgram: Nullable<WebGLProgram>;
  6331. private _compiledEffects;
  6332. private _vertexAttribArraysEnabled;
  6333. /** @hidden */
  6334. protected _cachedViewport: Nullable<Viewport>;
  6335. private _cachedVertexArrayObject;
  6336. /** @hidden */
  6337. protected _cachedVertexBuffers: any;
  6338. /** @hidden */
  6339. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6340. /** @hidden */
  6341. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6342. /** @hidden */
  6343. protected _currentRenderTarget: Nullable<InternalTexture>;
  6344. private _uintIndicesCurrentlySet;
  6345. private _currentBoundBuffer;
  6346. /** @hidden */
  6347. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6348. private _currentBufferPointers;
  6349. private _currentInstanceLocations;
  6350. private _currentInstanceBuffers;
  6351. private _textureUnits;
  6352. private _firstBoundInternalTextureTracker;
  6353. private _lastBoundInternalTextureTracker;
  6354. private _workingCanvas;
  6355. private _workingContext;
  6356. private _rescalePostProcess;
  6357. private _dummyFramebuffer;
  6358. private _externalData;
  6359. private _bindedRenderFunction;
  6360. private _vaoRecordInProgress;
  6361. private _mustWipeVertexAttributes;
  6362. private _emptyTexture;
  6363. private _emptyCubeTexture;
  6364. private _emptyTexture3D;
  6365. private _frameHandler;
  6366. private _nextFreeTextureSlots;
  6367. private _maxSimultaneousTextures;
  6368. private _activeRequests;
  6369. private _texturesSupported;
  6370. private _textureFormatInUse;
  6371. /**
  6372. * Gets the list of texture formats supported
  6373. */
  6374. readonly texturesSupported: Array<string>;
  6375. /**
  6376. * Gets the list of texture formats in use
  6377. */
  6378. readonly textureFormatInUse: Nullable<string>;
  6379. /**
  6380. * Gets the current viewport
  6381. */
  6382. readonly currentViewport: Nullable<Viewport>;
  6383. /**
  6384. * Gets the default empty texture
  6385. */
  6386. readonly emptyTexture: InternalTexture;
  6387. /**
  6388. * Gets the default empty 3D texture
  6389. */
  6390. readonly emptyTexture3D: InternalTexture;
  6391. /**
  6392. * Gets the default empty cube texture
  6393. */
  6394. readonly emptyCubeTexture: InternalTexture;
  6395. /**
  6396. * Creates a new engine
  6397. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6398. * @param antialias defines enable antialiasing (default: false)
  6399. * @param options defines further options to be sent to the getContext() function
  6400. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6401. */
  6402. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6403. private _rebuildInternalTextures();
  6404. private _rebuildEffects();
  6405. private _rebuildBuffers();
  6406. private _initGLContext();
  6407. /**
  6408. * Gets version of the current webGL context
  6409. */
  6410. readonly webGLVersion: number;
  6411. /**
  6412. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6413. */
  6414. readonly isStencilEnable: boolean;
  6415. private _prepareWorkingCanvas();
  6416. /**
  6417. * Reset the texture cache to empty state
  6418. */
  6419. resetTextureCache(): void;
  6420. /**
  6421. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  6422. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6423. * @returns true if engine is in deterministic lock step mode
  6424. */
  6425. isDeterministicLockStep(): boolean;
  6426. /**
  6427. * Gets the max steps when engine is running in deterministic lock step
  6428. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6429. * @returns the max steps
  6430. */
  6431. getLockstepMaxSteps(): number;
  6432. /**
  6433. * Gets an object containing information about the current webGL context
  6434. * @returns an object containing the vender, the renderer and the version of the current webGL context
  6435. */
  6436. getGlInfo(): {
  6437. vendor: string;
  6438. renderer: string;
  6439. version: string;
  6440. };
  6441. /**
  6442. * Gets current aspect ratio
  6443. * @param camera defines the camera to use to get the aspect ratio
  6444. * @param useScreen defines if screen size must be used (or the current render target if any)
  6445. * @returns a number defining the aspect ratio
  6446. */
  6447. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6448. /**
  6449. * Gets the current render width
  6450. * @param useScreen defines if screen size must be used (or the current render target if any)
  6451. * @returns a number defining the current render width
  6452. */
  6453. getRenderWidth(useScreen?: boolean): number;
  6454. /**
  6455. * Gets the current render height
  6456. * @param useScreen defines if screen size must be used (or the current render target if any)
  6457. * @returns a number defining the current render height
  6458. */
  6459. getRenderHeight(useScreen?: boolean): number;
  6460. /**
  6461. * Gets the HTML canvas attached with the current webGL context
  6462. * @returns a HTML canvas
  6463. */
  6464. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6465. /**
  6466. * Gets the client rect of the HTML canvas attached with the current webGL context
  6467. * @returns a client rectanglee
  6468. */
  6469. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6470. /**
  6471. * Defines the hardware scaling level.
  6472. * By default the hardware scaling level is computed from the window device ratio.
  6473. * 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.
  6474. * @param level defines the level to use
  6475. */
  6476. setHardwareScalingLevel(level: number): void;
  6477. /**
  6478. * Gets the current hardware scaling level.
  6479. * By default the hardware scaling level is computed from the window device ratio.
  6480. * 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.
  6481. * @returns a number indicating the current hardware scaling level
  6482. */
  6483. getHardwareScalingLevel(): number;
  6484. /**
  6485. * Gets the list of loaded textures
  6486. * @returns an array containing all loaded textures
  6487. */
  6488. getLoadedTexturesCache(): InternalTexture[];
  6489. /**
  6490. * Gets the object containing all engine capabilities
  6491. * @returns the EngineCapabilities object
  6492. */
  6493. getCaps(): EngineCapabilities;
  6494. /** @hidden */
  6495. readonly drawCalls: number;
  6496. /** @hidden */
  6497. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6498. /**
  6499. * Gets the current depth function
  6500. * @returns a number defining the depth function
  6501. */
  6502. getDepthFunction(): Nullable<number>;
  6503. /**
  6504. * Sets the current depth function
  6505. * @param depthFunc defines the function to use
  6506. */
  6507. setDepthFunction(depthFunc: number): void;
  6508. /**
  6509. * Sets the current depth function to GREATER
  6510. */
  6511. setDepthFunctionToGreater(): void;
  6512. /**
  6513. * Sets the current depth function to GEQUAL
  6514. */
  6515. setDepthFunctionToGreaterOrEqual(): void;
  6516. /**
  6517. * Sets the current depth function to LESS
  6518. */
  6519. setDepthFunctionToLess(): void;
  6520. /**
  6521. * Sets the current depth function to LEQUAL
  6522. */
  6523. setDepthFunctionToLessOrEqual(): void;
  6524. /**
  6525. * Gets a boolean indicating if stencil buffer is enabled
  6526. * @returns the current stencil buffer state
  6527. */
  6528. getStencilBuffer(): boolean;
  6529. /**
  6530. * Enable or disable the stencil buffer
  6531. * @param enable defines if the stencil buffer must be enabled or disabled
  6532. */
  6533. setStencilBuffer(enable: boolean): void;
  6534. /**
  6535. * Gets the current stencil mask
  6536. * @returns a number defining the new stencil mask to use
  6537. */
  6538. getStencilMask(): number;
  6539. /**
  6540. * Sets the current stencil mask
  6541. * @param mask defines the new stencil mask to use
  6542. */
  6543. setStencilMask(mask: number): void;
  6544. /**
  6545. * Gets the current stencil function
  6546. * @returns a number defining the stencil function to use
  6547. */
  6548. getStencilFunction(): number;
  6549. /**
  6550. * Gets the current stencil reference value
  6551. * @returns a number defining the stencil reference value to use
  6552. */
  6553. getStencilFunctionReference(): number;
  6554. /**
  6555. * Gets the current stencil mask
  6556. * @returns a number defining the stencil mask to use
  6557. */
  6558. getStencilFunctionMask(): number;
  6559. /**
  6560. * Sets the current stencil function
  6561. * @param stencilFunc defines the new stencil function to use
  6562. */
  6563. setStencilFunction(stencilFunc: number): void;
  6564. /**
  6565. * Sets the current stencil reference
  6566. * @param reference defines the new stencil reference to use
  6567. */
  6568. setStencilFunctionReference(reference: number): void;
  6569. /**
  6570. * Sets the current stencil mask
  6571. * @param mask defines the new stencil mask to use
  6572. */
  6573. setStencilFunctionMask(mask: number): void;
  6574. /**
  6575. * Gets the current stencil operation when stencil fails
  6576. * @returns a number defining stencil operation to use when stencil fails
  6577. */
  6578. getStencilOperationFail(): number;
  6579. /**
  6580. * Gets the current stencil operation when depth fails
  6581. * @returns a number defining stencil operation to use when depth fails
  6582. */
  6583. getStencilOperationDepthFail(): number;
  6584. /**
  6585. * Gets the current stencil operation when stencil passes
  6586. * @returns a number defining stencil operation to use when stencil passes
  6587. */
  6588. getStencilOperationPass(): number;
  6589. /**
  6590. * Sets the stencil operation to use when stencil fails
  6591. * @param operation defines the stencil operation to use when stencil fails
  6592. */
  6593. setStencilOperationFail(operation: number): void;
  6594. /**
  6595. * Sets the stencil operation to use when depth fails
  6596. * @param operation defines the stencil operation to use when depth fails
  6597. */
  6598. setStencilOperationDepthFail(operation: number): void;
  6599. /**
  6600. * Sets the stencil operation to use when stencil passes
  6601. * @param operation defines the stencil operation to use when stencil passes
  6602. */
  6603. setStencilOperationPass(operation: number): void;
  6604. /**
  6605. * Sets a boolean indicating if the dithering state is enabled or disabled
  6606. * @param value defines the dithering state
  6607. */
  6608. setDitheringState(value: boolean): void;
  6609. /**
  6610. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  6611. * @param value defines the rasterizer state
  6612. */
  6613. setRasterizerState(value: boolean): void;
  6614. /**
  6615. * stop executing a render loop function and remove it from the execution array
  6616. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  6617. */
  6618. stopRenderLoop(renderFunction?: () => void): void;
  6619. /** @hidden */
  6620. _renderLoop(): void;
  6621. /**
  6622. * Register and execute a render loop. The engine can have more than one render function
  6623. * @param renderFunction defines the function to continuously execute
  6624. */
  6625. runRenderLoop(renderFunction: () => void): void;
  6626. /**
  6627. * Toggle full screen mode
  6628. * @param requestPointerLock defines if a pointer lock should be requested from the user
  6629. * @param options defines an option object to be sent to the requestFullscreen function
  6630. */
  6631. switchFullscreen(requestPointerLock: boolean): void;
  6632. /**
  6633. * Clear the current render buffer or the current render target (if any is set up)
  6634. * @param color defines the color to use
  6635. * @param backBuffer defines if the back buffer must be cleared
  6636. * @param depth defines if the depth buffer must be cleared
  6637. * @param stencil defines if the stencil buffer must be cleared
  6638. */
  6639. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6640. /**
  6641. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  6642. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  6643. * @param y defines the y-coordinate of the corner of the clear rectangle
  6644. * @param width defines the width of the clear rectangle
  6645. * @param height defines the height of the clear rectangle
  6646. * @param clearColor defines the clear color
  6647. */
  6648. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6649. /**
  6650. * Set the WebGL's viewport
  6651. * @param viewport defines the viewport element to be used
  6652. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  6653. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  6654. */
  6655. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6656. /**
  6657. * Directly set the WebGL Viewport
  6658. * @param x defines the x coordinate of the viewport (in screen space)
  6659. * @param y defines the y coordinate of the viewport (in screen space)
  6660. * @param width defines the width of the viewport (in screen space)
  6661. * @param height defines the height of the viewport (in screen space)
  6662. * @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
  6663. */
  6664. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6665. /**
  6666. * Begin a new frame
  6667. */
  6668. beginFrame(): void;
  6669. /**
  6670. * Enf the current frame
  6671. */
  6672. endFrame(): void;
  6673. /**
  6674. * Resize the view according to the canvas' size
  6675. */
  6676. resize(): void;
  6677. /**
  6678. * Force a specific size of the canvas
  6679. * @param width defines the new canvas' width
  6680. * @param height defines the new canvas' height
  6681. */
  6682. setSize(width: number, height: number): void;
  6683. /**
  6684. * Gets a boolean indicating if a webVR device was detected
  6685. * @returns true if a webVR device was detected
  6686. */
  6687. isVRDevicePresent(): boolean;
  6688. /**
  6689. * Gets the current webVR device
  6690. * @returns the current webVR device (or null)
  6691. */
  6692. getVRDevice(): any;
  6693. /**
  6694. * Initializes a webVR display and starts listening to display change events
  6695. * The onVRDisplayChangedObservable will be notified upon these changes
  6696. * @returns The onVRDisplayChangedObservable
  6697. */
  6698. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6699. /**
  6700. * Initializes a webVR display and starts listening to display change events
  6701. * The onVRDisplayChangedObservable will be notified upon these changes
  6702. * @returns A promise containing a VRDisplay and if vr is supported
  6703. */
  6704. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6705. /**
  6706. * Call this function to switch to webVR mode
  6707. * Will do nothing if webVR is not supported or if there is no webVR device
  6708. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6709. */
  6710. enableVR(): void;
  6711. /**
  6712. * Call this function to leave webVR mode
  6713. * Will do nothing if webVR is not supported or if there is no webVR device
  6714. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6715. */
  6716. disableVR(): void;
  6717. private _onVRFullScreenTriggered;
  6718. private _getVRDisplaysAsync();
  6719. /**
  6720. * Binds the frame buffer to the specified texture.
  6721. * @param texture The texture to render to or null for the default canvas
  6722. * @param faceIndex The face of the texture to render to in case of cube texture
  6723. * @param requiredWidth The width of the target to render to
  6724. * @param requiredHeight The height of the target to render to
  6725. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6726. * @param depthStencilTexture The depth stencil texture to use to render
  6727. */
  6728. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  6729. private bindUnboundFramebuffer(framebuffer);
  6730. /**
  6731. * Unbind the current render target texture from the webGL context
  6732. * @param texture defines the render target texture to unbind
  6733. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6734. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6735. */
  6736. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6737. /**
  6738. * Unbind a list of render target textures from the webGL context
  6739. * This is used only when drawBuffer extension or webGL2 are active
  6740. * @param textures defines the render target textures to unbind
  6741. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6742. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6743. */
  6744. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6745. /**
  6746. * Force the mipmap generation for the given render target texture
  6747. * @param texture defines the render target texture to use
  6748. */
  6749. generateMipMapsForCubemap(texture: InternalTexture): void;
  6750. /**
  6751. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  6752. */
  6753. flushFramebuffer(): void;
  6754. /**
  6755. * Unbind the current render target and bind the default framebuffer
  6756. */
  6757. restoreDefaultFramebuffer(): void;
  6758. /**
  6759. * Create an uniform buffer
  6760. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6761. * @param elements defines the content of the uniform buffer
  6762. * @returns the webGL uniform buffer
  6763. */
  6764. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  6765. /**
  6766. * Create a dynamic uniform buffer
  6767. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6768. * @param elements defines the content of the uniform buffer
  6769. * @returns the webGL uniform buffer
  6770. */
  6771. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  6772. /**
  6773. * Update an existing uniform buffer
  6774. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6775. * @param uniformBuffer defines the target uniform buffer
  6776. * @param elements defines the content to update
  6777. * @param offset defines the offset in the uniform buffer where update should start
  6778. * @param count defines the size of the data to update
  6779. */
  6780. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6781. private _resetVertexBufferBinding();
  6782. /**
  6783. * Creates a vertex buffer
  6784. * @param data the data for the vertex buffer
  6785. * @returns the new WebGL static buffer
  6786. */
  6787. createVertexBuffer(data: DataArray): WebGLBuffer;
  6788. /**
  6789. * Creates a dynamic vertex buffer
  6790. * @param data the data for the dynamic vertex buffer
  6791. * @returns the new WebGL dynamic buffer
  6792. */
  6793. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  6794. /**
  6795. * Update a dynamic index buffer
  6796. * @param indexBuffer defines the target index buffer
  6797. * @param indices defines the data to update
  6798. * @param offset defines the offset in the target index buffer where update should start
  6799. */
  6800. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  6801. /**
  6802. * Updates a dynamic vertex buffer.
  6803. * @param vertexBuffer the vertex buffer to update
  6804. * @param data the data used to update the vertex buffer
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteLength the byte length of the data
  6807. */
  6808. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  6809. private _resetIndexBufferBinding();
  6810. /**
  6811. * Creates a new index buffer
  6812. * @param indices defines the content of the index buffer
  6813. * @param updatable defines if the index buffer must be updatable
  6814. * @returns a new webGL buffer
  6815. */
  6816. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  6817. /**
  6818. * Bind a webGL buffer to the webGL context
  6819. * @param buffer defines the buffer to bind
  6820. */
  6821. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  6822. /**
  6823. * Bind an uniform buffer to the current webGL context
  6824. * @param buffer defines the buffer to bind
  6825. */
  6826. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  6827. /**
  6828. * Bind a buffer to the current webGL context at a given location
  6829. * @param buffer defines the buffer to bind
  6830. * @param location defines the index where to bind the buffer
  6831. */
  6832. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  6833. /**
  6834. * Bind a specific block at a given index in a specific shader program
  6835. * @param shaderProgram defines the shader program
  6836. * @param blockName defines the block name
  6837. * @param index defines the index where to bind the block
  6838. */
  6839. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  6840. private bindIndexBuffer(buffer);
  6841. private bindBuffer(buffer, target);
  6842. /**
  6843. * update the bound buffer with the given data
  6844. * @param data defines the data to update
  6845. */
  6846. updateArrayBuffer(data: Float32Array): void;
  6847. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  6848. private _bindIndexBufferWithCache(indexBuffer);
  6849. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  6850. /**
  6851. * Records a vertex array object
  6852. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  6853. * @param vertexBuffers defines the list of vertex buffers to store
  6854. * @param indexBuffer defines the index buffer to store
  6855. * @param effect defines the effect to store
  6856. * @returns the new vertex array object
  6857. */
  6858. recordVertexArrayObject(vertexBuffers: {
  6859. [key: string]: VertexBuffer;
  6860. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  6861. /**
  6862. * Bind a specific vertex array object
  6863. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  6864. * @param vertexArrayObject defines the vertex array object to bind
  6865. * @param indexBuffer defines the index buffer to bind
  6866. */
  6867. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  6868. /**
  6869. * Bind webGl buffers directly to the webGL context
  6870. * @param vertexBuffer defines the vertex buffer to bind
  6871. * @param indexBuffer defines the index buffer to bind
  6872. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  6873. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  6874. * @param effect defines the effect associated with the vertex buffer
  6875. */
  6876. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  6877. private _unbindVertexArrayObject();
  6878. /**
  6879. * Bind a list of vertex buffers to the webGL context
  6880. * @param vertexBuffers defines the list of vertex buffers to bind
  6881. * @param indexBuffer defines the index buffer to bind
  6882. * @param effect defines the effect associated with the vertex buffers
  6883. */
  6884. bindBuffers(vertexBuffers: {
  6885. [key: string]: Nullable<VertexBuffer>;
  6886. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  6887. /**
  6888. * Unbind all instance attributes
  6889. */
  6890. unbindInstanceAttributes(): void;
  6891. /**
  6892. * Release and free the memory of a vertex array object
  6893. * @param vao defines the vertex array object to delete
  6894. */
  6895. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  6896. /** @hidden */
  6897. _releaseBuffer(buffer: WebGLBuffer): boolean;
  6898. /**
  6899. * Creates a webGL buffer to use with instanciation
  6900. * @param capacity defines the size of the buffer
  6901. * @returns the webGL buffer
  6902. */
  6903. createInstancesBuffer(capacity: number): WebGLBuffer;
  6904. /**
  6905. * Delete a webGL buffer used with instanciation
  6906. * @param buffer defines the webGL buffer to delete
  6907. */
  6908. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  6909. /**
  6910. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  6911. * @param instancesBuffer defines the webGL buffer to update and bind
  6912. * @param data defines the data to store in the buffer
  6913. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  6914. */
  6915. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  6916. /**
  6917. * Apply all cached states (depth, culling, stencil and alpha)
  6918. */
  6919. applyStates(): void;
  6920. /**
  6921. * Send a draw order
  6922. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  6923. * @param indexStart defines the starting index
  6924. * @param indexCount defines the number of index to draw
  6925. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6926. */
  6927. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  6928. /**
  6929. * Draw a list of points
  6930. * @param verticesStart defines the index of first vertex to draw
  6931. * @param verticesCount defines the count of vertices to draw
  6932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6933. */
  6934. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6935. /**
  6936. * Draw a list of unindexed primitives
  6937. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  6938. * @param verticesStart defines the index of first vertex to draw
  6939. * @param verticesCount defines the count of vertices to draw
  6940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6941. */
  6942. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6943. /**
  6944. * Draw a list of indexed primitives
  6945. * @param fillMode defines the primitive to use
  6946. * @param indexStart defines the starting index
  6947. * @param indexCount defines the number of index to draw
  6948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6949. */
  6950. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  6951. /**
  6952. * Draw a list of unindexed primitives
  6953. * @param fillMode defines the primitive to use
  6954. * @param verticesStart defines the index of first vertex to draw
  6955. * @param verticesCount defines the count of vertices to draw
  6956. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6957. */
  6958. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6959. private _drawMode(fillMode);
  6960. /** @hidden */
  6961. _releaseEffect(effect: Effect): void;
  6962. /** @hidden */
  6963. _deleteProgram(program: WebGLProgram): void;
  6964. /**
  6965. * Create a new effect (used to store vertex/fragment shaders)
  6966. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  6967. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  6968. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  6969. * @param samplers defines an array of string used to represent textures
  6970. * @param defines defines the string containing the defines to use to compile the shaders
  6971. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  6972. * @param onCompiled defines a function to call when the effect creation is successful
  6973. * @param onError defines a function to call when the effect creation has failed
  6974. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  6975. * @returns the new Effect
  6976. */
  6977. 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;
  6978. /**
  6979. * Create an effect to use with particle systems
  6980. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  6981. * @param uniformsNames defines a list of attribute names
  6982. * @param samplers defines an array of string used to represent textures
  6983. * @param defines defines the string containing the defines to use to compile the shaders
  6984. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  6985. * @param onCompiled defines a function to call when the effect creation is successful
  6986. * @param onError defines a function to call when the effect creation has failed
  6987. * @returns the new Effect
  6988. */
  6989. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  6990. /**
  6991. * Directly creates a webGL program
  6992. * @param vertexCode defines the vertex shader code to use
  6993. * @param fragmentCode defines the fragment shader code to use
  6994. * @param context defines the webGL context to use (if not set, the current one will be used)
  6995. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  6996. * @returns the new webGL program
  6997. */
  6998. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  6999. /**
  7000. * Creates a webGL program
  7001. * @param vertexCode defines the vertex shader code to use
  7002. * @param fragmentCode defines the fragment shader code to use
  7003. * @param defines defines the string containing the defines to use to compile the shaders
  7004. * @param context defines the webGL context to use (if not set, the current one will be used)
  7005. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7006. * @returns the new webGL program
  7007. */
  7008. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7009. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7010. /**
  7011. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7012. * @param shaderProgram defines the webGL program to use
  7013. * @param uniformsNames defines the list of uniform names
  7014. * @returns an array of webGL uniform locations
  7015. */
  7016. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7017. /**
  7018. * Gets the lsit of active attributes for a given webGL program
  7019. * @param shaderProgram defines the webGL program to use
  7020. * @param attributesNames defines the list of attribute names to get
  7021. * @returns an array of indices indicating the offset of each attribute
  7022. */
  7023. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7024. /**
  7025. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7026. * @param effect defines the effect to activate
  7027. */
  7028. enableEffect(effect: Nullable<Effect>): void;
  7029. /**
  7030. * Set the value of an uniform to an array of int32
  7031. * @param uniform defines the webGL uniform location where to store the value
  7032. * @param array defines the array of int32 to store
  7033. */
  7034. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7035. /**
  7036. * Set the value of an uniform to an array of int32 (stored as vec2)
  7037. * @param uniform defines the webGL uniform location where to store the value
  7038. * @param array defines the array of int32 to store
  7039. */
  7040. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7041. /**
  7042. * Set the value of an uniform to an array of int32 (stored as vec3)
  7043. * @param uniform defines the webGL uniform location where to store the value
  7044. * @param array defines the array of int32 to store
  7045. */
  7046. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7047. /**
  7048. * Set the value of an uniform to an array of int32 (stored as vec4)
  7049. * @param uniform defines the webGL uniform location where to store the value
  7050. * @param array defines the array of int32 to store
  7051. */
  7052. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7053. /**
  7054. * Set the value of an uniform to an array of float32
  7055. * @param uniform defines the webGL uniform location where to store the value
  7056. * @param array defines the array of float32 to store
  7057. */
  7058. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7059. /**
  7060. * Set the value of an uniform to an array of float32 (stored as vec2)
  7061. * @param uniform defines the webGL uniform location where to store the value
  7062. * @param array defines the array of float32 to store
  7063. */
  7064. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7065. /**
  7066. * Set the value of an uniform to an array of float32 (stored as vec3)
  7067. * @param uniform defines the webGL uniform location where to store the value
  7068. * @param array defines the array of float32 to store
  7069. */
  7070. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7071. /**
  7072. * Set the value of an uniform to an array of float32 (stored as vec4)
  7073. * @param uniform defines the webGL uniform location where to store the value
  7074. * @param array defines the array of float32 to store
  7075. */
  7076. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7077. /**
  7078. * Set the value of an uniform to an array of number
  7079. * @param uniform defines the webGL uniform location where to store the value
  7080. * @param array defines the array of number to store
  7081. */
  7082. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7083. /**
  7084. * Set the value of an uniform to an array of number (stored as vec2)
  7085. * @param uniform defines the webGL uniform location where to store the value
  7086. * @param array defines the array of number to store
  7087. */
  7088. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7089. /**
  7090. * Set the value of an uniform to an array of number (stored as vec3)
  7091. * @param uniform defines the webGL uniform location where to store the value
  7092. * @param array defines the array of number to store
  7093. */
  7094. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7095. /**
  7096. * Set the value of an uniform to an array of number (stored as vec4)
  7097. * @param uniform defines the webGL uniform location where to store the value
  7098. * @param array defines the array of number to store
  7099. */
  7100. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7101. /**
  7102. * Set the value of an uniform to an array of float32 (stored as matrices)
  7103. * @param uniform defines the webGL uniform location where to store the value
  7104. * @param matrices defines the array of float32 to store
  7105. */
  7106. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7107. /**
  7108. * Set the value of an uniform to a matrix
  7109. * @param uniform defines the webGL uniform location where to store the value
  7110. * @param matrix defines the matrix to store
  7111. */
  7112. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7113. /**
  7114. * Set the value of an uniform to a matrix (3x3)
  7115. * @param uniform defines the webGL uniform location where to store the value
  7116. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7117. */
  7118. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7119. /**
  7120. * Set the value of an uniform to a matrix (2x2)
  7121. * @param uniform defines the webGL uniform location where to store the value
  7122. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7123. */
  7124. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7125. /**
  7126. * Set the value of an uniform to a number (int)
  7127. * @param uniform defines the webGL uniform location where to store the value
  7128. * @param value defines the int number to store
  7129. */
  7130. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7131. /**
  7132. * Set the value of an uniform to a number (float)
  7133. * @param uniform defines the webGL uniform location where to store the value
  7134. * @param value defines the float number to store
  7135. */
  7136. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7137. /**
  7138. * Set the value of an uniform to a vec2
  7139. * @param uniform defines the webGL uniform location where to store the value
  7140. * @param x defines the 1st component of the value
  7141. * @param y defines the 2nd component of the value
  7142. */
  7143. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7144. /**
  7145. * Set the value of an uniform to a vec3
  7146. * @param uniform defines the webGL uniform location where to store the value
  7147. * @param x defines the 1st component of the value
  7148. * @param y defines the 2nd component of the value
  7149. * @param z defines the 3rd component of the value
  7150. */
  7151. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7152. /**
  7153. * Set the value of an uniform to a boolean
  7154. * @param uniform defines the webGL uniform location where to store the value
  7155. * @param bool defines the boolean to store
  7156. */
  7157. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7158. /**
  7159. * Set the value of an uniform to a vec4
  7160. * @param uniform defines the webGL uniform location where to store the value
  7161. * @param x defines the 1st component of the value
  7162. * @param y defines the 2nd component of the value
  7163. * @param z defines the 3rd component of the value
  7164. * @param w defines the 4th component of the value
  7165. */
  7166. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7167. /**
  7168. * Set the value of an uniform to a Color3
  7169. * @param uniform defines the webGL uniform location where to store the value
  7170. * @param color3 defines the color to store
  7171. */
  7172. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7173. /**
  7174. * Set the value of an uniform to a Color3 and an alpha value
  7175. * @param uniform defines the webGL uniform location where to store the value
  7176. * @param color3 defines the color to store
  7177. * @param alpha defines the alpha component to store
  7178. */
  7179. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7180. /**
  7181. * Sets a Color4 on a uniform variable
  7182. * @param uniform defines the uniform location
  7183. * @param color4 defines the value to be set
  7184. */
  7185. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7186. /**
  7187. * Set various states to the webGL context
  7188. * @param culling defines backface culling state
  7189. * @param zOffset defines the value to apply to zOffset (0 by default)
  7190. * @param force defines if states must be applied even if cache is up to date
  7191. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7192. */
  7193. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7194. /**
  7195. * Set the z offset to apply to current rendering
  7196. * @param value defines the offset to apply
  7197. */
  7198. setZOffset(value: number): void;
  7199. /**
  7200. * Gets the current value of the zOffset
  7201. * @returns the current zOffset state
  7202. */
  7203. getZOffset(): number;
  7204. /**
  7205. * Enable or disable depth buffering
  7206. * @param enable defines the state to set
  7207. */
  7208. setDepthBuffer(enable: boolean): void;
  7209. /**
  7210. * Gets a boolean indicating if depth writing is enabled
  7211. * @returns the current depth writing state
  7212. */
  7213. getDepthWrite(): boolean;
  7214. /**
  7215. * Enable or disable depth writing
  7216. * @param enable defines the state to set
  7217. */
  7218. setDepthWrite(enable: boolean): void;
  7219. /**
  7220. * Enable or disable color writing
  7221. * @param enable defines the state to set
  7222. */
  7223. setColorWrite(enable: boolean): void;
  7224. /**
  7225. * Gets a boolean indicating if color writing is enabled
  7226. * @returns the current color writing state
  7227. */
  7228. getColorWrite(): boolean;
  7229. /**
  7230. * Sets alpha constants used by some alpha blending modes
  7231. * @param r defines the red component
  7232. * @param g defines the green component
  7233. * @param b defines the blue component
  7234. * @param a defines the alpha component
  7235. */
  7236. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7237. /**
  7238. * Sets the current alpha mode
  7239. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7240. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7241. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7242. */
  7243. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7244. /**
  7245. * Gets the current alpha mode
  7246. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7247. * @returns the current alpha mode
  7248. */
  7249. getAlphaMode(): number;
  7250. /**
  7251. * Force the entire cache to be cleared
  7252. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7253. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7254. */
  7255. wipeCaches(bruteForce?: boolean): void;
  7256. /**
  7257. * Set the compressed texture format to use, based on the formats you have, and the formats
  7258. * supported by the hardware / browser.
  7259. *
  7260. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7261. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7262. * to API arguments needed to compressed textures. This puts the burden on the container
  7263. * generator to house the arcane code for determining these for current & future formats.
  7264. *
  7265. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  7266. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  7267. *
  7268. * Note: The result of this call is not taken into account when a texture is base64.
  7269. *
  7270. * @param formatsAvailable defines the list of those format families you have created
  7271. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  7272. *
  7273. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  7274. * @returns The extension selected.
  7275. */
  7276. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  7277. /** @hidden */
  7278. _createTexture(): WebGLTexture;
  7279. /**
  7280. * Usually called from BABYLON.Texture.ts.
  7281. * Passed information to create a WebGLTexture
  7282. * @param urlArg defines a value which contains one of the following:
  7283. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  7284. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  7285. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  7286. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  7287. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  7288. * @param scene needed for loading to the correct scene
  7289. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  7290. * @param onLoad optional callback to be called upon successful completion
  7291. * @param onError optional callback to be called upon failure
  7292. * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  7293. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  7294. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  7295. * @returns a InternalTexture for assignment back into BABYLON.Texture
  7296. */
  7297. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  7298. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  7299. /**
  7300. * Update a raw texture
  7301. * @param texture defines the texture to update
  7302. * @param data defines the data to store in the texture
  7303. * @param format defines the format of the data
  7304. * @param invertY defines if data must be stored with Y axis inverted
  7305. * @param compression defines the compression used (null by default)
  7306. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7307. */
  7308. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  7309. /**
  7310. * Creates a raw texture
  7311. * @param data defines the data to store in the texture
  7312. * @param width defines the width of the texture
  7313. * @param height defines the height of the texture
  7314. * @param format defines the format of the data
  7315. * @param generateMipMaps defines if the engine should generate the mip levels
  7316. * @param invertY defines if data must be stored with Y axis inverted
  7317. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7318. * @param compression defines the compression used (null by default)
  7319. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7320. * @returns the raw texture inside an InternalTexture
  7321. */
  7322. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  7323. /**
  7324. * Creates a dynamic texture
  7325. * @param width defines the width of the texture
  7326. * @param height defines the height of the texture
  7327. * @param generateMipMaps defines if the engine should generate the mip levels
  7328. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7329. * @returns the dynamic texture inside an InternalTexture
  7330. */
  7331. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  7332. /**
  7333. * Update the sampling mode of a given texture
  7334. * @param samplingMode defines the required sampling mode
  7335. * @param texture defines the texture to update
  7336. */
  7337. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7338. /**
  7339. * Update the content of a dynamic texture
  7340. * @param texture defines the texture to update
  7341. * @param canvas defines the canvas containing the source
  7342. * @param invertY defines if data must be stored with Y axis inverted
  7343. * @param premulAlpha defines if alpha is stored as premultiplied
  7344. * @param format defines the format of the data
  7345. */
  7346. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  7347. /**
  7348. * Update a video texture
  7349. * @param texture defines the texture to update
  7350. * @param video defines the video element to use
  7351. * @param invertY defines if data must be stored with Y axis inverted
  7352. */
  7353. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  7354. /**
  7355. * Updates a depth texture Comparison Mode and Function.
  7356. * If the comparison Function is equal to 0, the mode will be set to none.
  7357. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  7358. * @param texture The texture to set the comparison function for
  7359. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  7360. */
  7361. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  7362. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  7363. /**
  7364. * Creates a depth stencil texture.
  7365. * This is only available in WebGL 2 or with the depth texture extension available.
  7366. * @param size The size of face edge in the texture.
  7367. * @param options The options defining the texture.
  7368. * @returns The texture
  7369. */
  7370. createDepthStencilTexture(size: number | {
  7371. width: number;
  7372. height: number;
  7373. }, options: DepthTextureCreationOptions): InternalTexture;
  7374. /**
  7375. * Creates a depth stencil texture.
  7376. * This is only available in WebGL 2 or with the depth texture extension available.
  7377. * @param size The size of face edge in the texture.
  7378. * @param options The options defining the texture.
  7379. * @returns The texture
  7380. */
  7381. private _createDepthStencilTexture(size, options);
  7382. /**
  7383. * Creates a depth stencil cube texture.
  7384. * This is only available in WebGL 2.
  7385. * @param size The size of face edge in the cube texture.
  7386. * @param options The options defining the cube texture.
  7387. * @returns The cube texture
  7388. */
  7389. private _createDepthStencilCubeTexture(size, options);
  7390. /**
  7391. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  7392. * @param renderTarget The render target to set the frame buffer for
  7393. */
  7394. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  7395. /**
  7396. * Creates a new render target texture
  7397. * @param size defines the size of the texture
  7398. * @param options defines the options used to create the texture
  7399. * @returns a new render target texture stored in an InternalTexture
  7400. */
  7401. createRenderTargetTexture(size: number | {
  7402. width: number;
  7403. height: number;
  7404. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7405. /**
  7406. * Create a multi render target texture
  7407. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  7408. * @param size defines the size of the texture
  7409. * @param options defines the creation options
  7410. * @returns the cube texture as an InternalTexture
  7411. */
  7412. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  7413. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  7414. /**
  7415. * Updates the sample count of a render target texture
  7416. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7417. * @param texture defines the texture to update
  7418. * @param samples defines the sample count to set
  7419. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7420. */
  7421. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  7422. /**
  7423. * Update the sample count for a given multiple render target texture
  7424. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7425. * @param textures defines the textures to update
  7426. * @param samples defines the sample count to set
  7427. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7428. */
  7429. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  7430. /** @hidden */
  7431. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  7432. /** @hidden */
  7433. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  7434. /**
  7435. * Creates a new render target cube texture
  7436. * @param size defines the size of the texture
  7437. * @param options defines the options used to create the texture
  7438. * @returns a new render target cube texture stored in an InternalTexture
  7439. */
  7440. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  7441. /**
  7442. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  7443. * @param rootUrl defines the url where the file to load is located
  7444. * @param scene defines the current scene
  7445. * @param scale defines scale to apply to the mip map selection
  7446. * @param offset defines offset to apply to the mip map selection
  7447. * @param onLoad defines an optional callback raised when the texture is loaded
  7448. * @param onError defines an optional callback raised if there is an issue to load the texture
  7449. * @param format defines the format of the data
  7450. * @param forcedExtension defines the extension to use to pick the right loader
  7451. * @returns the cube texture as an InternalTexture
  7452. */
  7453. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  7454. /**
  7455. * Creates a cube texture
  7456. * @param rootUrl defines the url where the files to load is located
  7457. * @param scene defines the current scene
  7458. * @param files defines the list of files to load (1 per face)
  7459. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7460. * @param onLoad defines an optional callback raised when the texture is loaded
  7461. * @param onError defines an optional callback raised if there is an issue to load the texture
  7462. * @param format defines the format of the data
  7463. * @param forcedExtension defines the extension to use to pick the right loader
  7464. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7465. * @returns the cube texture as an InternalTexture
  7466. */
  7467. 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): InternalTexture;
  7468. private setCubeMapTextureParams(gl, loadMipmap);
  7469. /**
  7470. * Update a raw cube texture
  7471. * @param texture defines the texture to udpdate
  7472. * @param data defines the data to store
  7473. * @param format defines the data format
  7474. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7475. * @param invertY defines if data must be stored with Y axis inverted
  7476. * @param compression defines the compression used (null by default)
  7477. * @param level defines which level of the texture to update
  7478. */
  7479. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  7480. /**
  7481. * Creates a new raw cube texture
  7482. * @param data defines the array of data to use to create each face
  7483. * @param size defines the size of the textures
  7484. * @param format defines the format of the data
  7485. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7486. * @param generateMipMaps defines if the engine should generate the mip levels
  7487. * @param invertY defines if data must be stored with Y axis inverted
  7488. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7489. * @param compression defines the compression used (null by default)
  7490. * @returns the cube texture as an InternalTexture
  7491. */
  7492. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7493. /**
  7494. * Creates a new raw cube texture from a specified url
  7495. * @param url defines the url where the data is located
  7496. * @param scene defines the current scene
  7497. * @param size defines the size of the textures
  7498. * @param format defines the format of the data
  7499. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7500. * @param noMipmap defines if the engine should avoid generating the mip levels
  7501. * @param callback defines a callback used to extract texture data from loaded data
  7502. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  7503. * @param onLoad defines a callback called when texture is loaded
  7504. * @param onError defines a callback called if there is an error
  7505. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7506. * @param invertY defines if data must be stored with Y axis inverted
  7507. * @returns the cube texture as an InternalTexture
  7508. */
  7509. 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;
  7510. /**
  7511. * Update a raw 3D texture
  7512. * @param texture defines the texture to update
  7513. * @param data defines the data to store
  7514. * @param format defines the data format
  7515. * @param invertY defines if data must be stored with Y axis inverted
  7516. * @param compression defines the used compression (can be null)
  7517. */
  7518. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  7519. /**
  7520. * Creates a new raw 3D texture
  7521. * @param data defines the data used to create the texture
  7522. * @param width defines the width of the texture
  7523. * @param height defines the height of the texture
  7524. * @param depth defines the depth of the texture
  7525. * @param format defines the format of the texture
  7526. * @param generateMipMaps defines if the engine must generate mip levels
  7527. * @param invertY defines if data must be stored with Y axis inverted
  7528. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7529. * @param compression defines the compressed used (can be null)
  7530. * @returns a new raw 3D texture (stored in an InternalTexture)
  7531. */
  7532. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7533. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  7534. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  7535. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  7536. /** @hidden */
  7537. _releaseFramebufferObjects(texture: InternalTexture): void;
  7538. /** @hidden */
  7539. _releaseTexture(texture: InternalTexture): void;
  7540. private setProgram(program);
  7541. private _boundUniforms;
  7542. /**
  7543. * Binds an effect to the webGL context
  7544. * @param effect defines the effect to bind
  7545. */
  7546. bindSamplers(effect: Effect): void;
  7547. private _moveBoundTextureOnTop(internalTexture);
  7548. private _getCorrectTextureChannel(channel, internalTexture);
  7549. private _linkTrackers(previous, next);
  7550. private _removeDesignatedSlot(internalTexture);
  7551. private _activateCurrentTexture();
  7552. /** @hidden */
  7553. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  7554. /** @hidden */
  7555. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  7556. /**
  7557. * Sets a texture to the webGL context from a postprocess
  7558. * @param channel defines the channel to use
  7559. * @param postProcess defines the source postprocess
  7560. */
  7561. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  7562. /**
  7563. * Binds the output of the passed in post process to the texture channel specified
  7564. * @param channel The channel the texture should be bound to
  7565. * @param postProcess The post process which's output should be bound
  7566. */
  7567. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  7568. /**
  7569. * Unbind all textures from the webGL context
  7570. */
  7571. unbindAllTextures(): void;
  7572. /**
  7573. * Sets a texture to the according uniform.
  7574. * @param channel The texture channel
  7575. * @param uniform The uniform to set
  7576. * @param texture The texture to apply
  7577. */
  7578. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  7579. /**
  7580. * Sets a depth stencil texture from a render target to the according uniform.
  7581. * @param channel The texture channel
  7582. * @param uniform The uniform to set
  7583. * @param texture The render target texture containing the depth stencil texture to apply
  7584. */
  7585. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  7586. private _bindSamplerUniformToChannel(sourceSlot, destination);
  7587. private _getTextureWrapMode(mode);
  7588. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  7589. /**
  7590. * Sets an array of texture to the webGL context
  7591. * @param channel defines the channel where the texture array must be set
  7592. * @param uniform defines the associated uniform location
  7593. * @param textures defines the array of textures to bind
  7594. */
  7595. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  7596. /** @hidden */
  7597. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  7598. private _setTextureParameterFloat(target, parameter, value, texture);
  7599. private _setTextureParameterInteger(target, parameter, value, texture?);
  7600. /**
  7601. * Reads pixels from the current frame buffer. Please note that this function can be slow
  7602. * @param x defines the x coordinate of the rectangle where pixels must be read
  7603. * @param y defines the y coordinate of the rectangle where pixels must be read
  7604. * @param width defines the width of the rectangle where pixels must be read
  7605. * @param height defines the height of the rectangle where pixels must be read
  7606. * @returns a Uint8Array containing RGBA colors
  7607. */
  7608. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  7609. /**
  7610. * Add an externaly attached data from its key.
  7611. * This method call will fail and return false, if such key already exists.
  7612. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  7613. * @param key the unique key that identifies the data
  7614. * @param data the data object to associate to the key for this Engine instance
  7615. * @return true if no such key were already present and the data was added successfully, false otherwise
  7616. */
  7617. addExternalData<T>(key: string, data: T): boolean;
  7618. /**
  7619. * Get an externaly attached data from its key
  7620. * @param key the unique key that identifies the data
  7621. * @return the associated data, if present (can be null), or undefined if not present
  7622. */
  7623. getExternalData<T>(key: string): T;
  7624. /**
  7625. * Get an externaly attached data from its key, create it using a factory if it's not already present
  7626. * @param key the unique key that identifies the data
  7627. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  7628. * @return the associated data, can be null if the factory returned null.
  7629. */
  7630. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  7631. /**
  7632. * Remove an externaly attached data from the Engine instance
  7633. * @param key the unique key that identifies the data
  7634. * @return true if the data was successfully removed, false if it doesn't exist
  7635. */
  7636. removeExternalData(key: string): boolean;
  7637. /**
  7638. * Unbind all vertex attributes from the webGL context
  7639. */
  7640. unbindAllAttributes(): void;
  7641. /**
  7642. * 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
  7643. */
  7644. releaseEffects(): void;
  7645. /**
  7646. * Dispose and release all associated resources
  7647. */
  7648. dispose(): void;
  7649. /**
  7650. * Display the loading screen
  7651. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7652. */
  7653. displayLoadingUI(): void;
  7654. /**
  7655. * Hide the loading screen
  7656. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7657. */
  7658. hideLoadingUI(): void;
  7659. /**
  7660. * Gets the current loading screen object
  7661. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7662. */
  7663. /**
  7664. * Sets the current loading screen object
  7665. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7666. */
  7667. loadingScreen: ILoadingScreen;
  7668. /**
  7669. * Sets the current loading screen text
  7670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7671. */
  7672. loadingUIText: string;
  7673. /**
  7674. * Sets the current loading screen background color
  7675. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7676. */
  7677. loadingUIBackgroundColor: string;
  7678. /**
  7679. * Attach a new callback raised when context lost event is fired
  7680. * @param callback defines the callback to call
  7681. */
  7682. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7683. /**
  7684. * Attach a new callback raised when context restored event is fired
  7685. * @param callback defines the callback to call
  7686. */
  7687. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7688. /**
  7689. * Gets the source code of the vertex shader associated with a specific webGL program
  7690. * @param program defines the program to use
  7691. * @returns a string containing the source code of the vertex shader associated with the program
  7692. */
  7693. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  7694. /**
  7695. * Gets the source code of the fragment shader associated with a specific webGL program
  7696. * @param program defines the program to use
  7697. * @returns a string containing the source code of the fragment shader associated with the program
  7698. */
  7699. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  7700. /**
  7701. * Get the current error code of the webGL context
  7702. * @returns the error code
  7703. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  7704. */
  7705. getError(): number;
  7706. /**
  7707. * Gets the current framerate
  7708. * @returns a number representing the framerate
  7709. */
  7710. getFps(): number;
  7711. /**
  7712. * Gets the time spent between current and previous frame
  7713. * @returns a number representing the delta time in ms
  7714. */
  7715. getDeltaTime(): number;
  7716. private _measureFps();
  7717. /** @hidden */
  7718. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  7719. private _canRenderToFloatFramebuffer();
  7720. private _canRenderToHalfFloatFramebuffer();
  7721. private _canRenderToFramebuffer(type);
  7722. /** @hidden */
  7723. _getWebGLTextureType(type: number): number;
  7724. private _getInternalFormat(format);
  7725. /** @hidden */
  7726. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  7727. /** @hidden */
  7728. _getRGBAMultiSampleBufferFormat(type: number): number;
  7729. /**
  7730. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  7731. * @return the new query
  7732. */
  7733. createQuery(): WebGLQuery;
  7734. /**
  7735. * Delete and release a webGL query
  7736. * @param query defines the query to delete
  7737. * @return the current engine
  7738. */
  7739. deleteQuery(query: WebGLQuery): Engine;
  7740. /**
  7741. * Check if a given query has resolved and got its value
  7742. * @param query defines the query to check
  7743. * @returns true if the query got its value
  7744. */
  7745. isQueryResultAvailable(query: WebGLQuery): boolean;
  7746. /**
  7747. * Gets the value of a given query
  7748. * @param query defines the query to check
  7749. * @returns the value of the query
  7750. */
  7751. getQueryResult(query: WebGLQuery): number;
  7752. /**
  7753. * Initiates an occlusion query
  7754. * @param algorithmType defines the algorithm to use
  7755. * @param query defines the query to use
  7756. * @returns the current engine
  7757. * @see http://doc.babylonjs.com/features/occlusionquery
  7758. */
  7759. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  7760. /**
  7761. * Ends an occlusion query
  7762. * @see http://doc.babylonjs.com/features/occlusionquery
  7763. * @param algorithmType defines the algorithm to use
  7764. * @returns the current engine
  7765. */
  7766. endOcclusionQuery(algorithmType: number): Engine;
  7767. private _createTimeQuery();
  7768. private _deleteTimeQuery(query);
  7769. private _getTimeQueryResult(query);
  7770. private _getTimeQueryAvailability(query);
  7771. private _currentNonTimestampToken;
  7772. /**
  7773. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  7774. * Please note that only one query can be issued at a time
  7775. * @returns a time token used to track the time span
  7776. */
  7777. startTimeQuery(): Nullable<_TimeToken>;
  7778. /**
  7779. * Ends a time query
  7780. * @param token defines the token used to measure the time span
  7781. * @returns the time spent (in ns)
  7782. */
  7783. endTimeQuery(token: _TimeToken): int;
  7784. private getGlAlgorithmType(algorithmType);
  7785. /**
  7786. * Creates a webGL transform feedback object
  7787. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  7788. * @returns the webGL transform feedback object
  7789. */
  7790. createTransformFeedback(): WebGLTransformFeedback;
  7791. /**
  7792. * Delete a webGL transform feedback object
  7793. * @param value defines the webGL transform feedback object to delete
  7794. */
  7795. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  7796. /**
  7797. * Bind a webGL transform feedback object to the webgl context
  7798. * @param value defines the webGL transform feedback object to bind
  7799. */
  7800. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  7801. /**
  7802. * Begins a transform feedback operation
  7803. * @param usePoints defines if points or triangles must be used
  7804. */
  7805. beginTransformFeedback(usePoints?: boolean): void;
  7806. /**
  7807. * Ends a transform feedback operation
  7808. */
  7809. endTransformFeedback(): void;
  7810. /**
  7811. * Specify the varyings to use with transform feedback
  7812. * @param program defines the associated webGL program
  7813. * @param value defines the list of strings representing the varying names
  7814. */
  7815. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  7816. /**
  7817. * Bind a webGL buffer for a transform feedback operation
  7818. * @param value defines the webGL buffer to bind
  7819. */
  7820. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  7821. /** @hidden */
  7822. _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;
  7823. /** @hidden */
  7824. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  7825. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  7826. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  7827. /**
  7828. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  7829. * @returns true if the engine can be created
  7830. * @ignorenaming
  7831. */
  7832. static isSupported(): boolean;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. class NullEngineOptions {
  7837. renderWidth: number;
  7838. renderHeight: number;
  7839. textureSize: number;
  7840. deterministicLockstep: boolean;
  7841. lockstepMaxSteps: number;
  7842. }
  7843. /**
  7844. * The null engine class provides support for headless version of babylon.js.
  7845. * This can be used in server side scenario or for testing purposes
  7846. */
  7847. class NullEngine extends Engine {
  7848. private _options;
  7849. isDeterministicLockStep(): boolean;
  7850. getLockstepMaxSteps(): number;
  7851. getHardwareScalingLevel(): number;
  7852. constructor(options?: NullEngineOptions);
  7853. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  7854. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  7855. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7856. getRenderWidth(useScreen?: boolean): number;
  7857. getRenderHeight(useScreen?: boolean): number;
  7858. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7859. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  7860. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  7861. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7862. bindSamplers(effect: Effect): void;
  7863. enableEffect(effect: Effect): void;
  7864. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7865. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  7866. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  7867. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  7868. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  7869. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  7870. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  7871. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  7872. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  7873. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  7874. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  7875. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  7876. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  7877. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  7878. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  7879. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  7880. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  7881. setFloat(uniform: WebGLUniformLocation, value: number): void;
  7882. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  7883. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  7884. setBool(uniform: WebGLUniformLocation, bool: number): void;
  7885. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  7886. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  7887. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  7888. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7889. bindBuffers(vertexBuffers: {
  7890. [key: string]: VertexBuffer;
  7891. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  7892. wipeCaches(bruteForce?: boolean): void;
  7893. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7894. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7895. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7896. _createTexture(): WebGLTexture;
  7897. _releaseTexture(texture: InternalTexture): void;
  7898. 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;
  7899. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7900. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7901. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  7902. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7903. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  7904. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7905. /**
  7906. * Updates a dynamic vertex buffer.
  7907. * @param vertexBuffer the vertex buffer to update
  7908. * @param data the data used to update the vertex buffer
  7909. * @param byteOffset the byte offset of the data (optional)
  7910. * @param byteLength the byte length of the data (optional)
  7911. */
  7912. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  7913. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  7914. _bindTexture(channel: number, texture: InternalTexture): void;
  7915. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7916. }
  7917. }
  7918. interface WebGLRenderingContext {
  7919. readonly RASTERIZER_DISCARD: number;
  7920. readonly DEPTH_COMPONENT24: number;
  7921. readonly TEXTURE_3D: number;
  7922. readonly TEXTURE_2D_ARRAY: number;
  7923. readonly TEXTURE_COMPARE_FUNC: number;
  7924. readonly TEXTURE_COMPARE_MODE: number;
  7925. readonly COMPARE_REF_TO_TEXTURE: number;
  7926. readonly TEXTURE_WRAP_R: number;
  7927. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  7928. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  7929. 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;
  7930. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  7931. readonly TRANSFORM_FEEDBACK: number;
  7932. readonly INTERLEAVED_ATTRIBS: number;
  7933. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  7934. createTransformFeedback(): WebGLTransformFeedback;
  7935. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  7936. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  7937. beginTransformFeedback(primitiveMode: number): void;
  7938. endTransformFeedback(): void;
  7939. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  7940. }
  7941. interface ImageBitmap {
  7942. readonly width: number;
  7943. readonly height: number;
  7944. close(): void;
  7945. }
  7946. interface WebGLQuery extends WebGLObject {
  7947. }
  7948. declare var WebGLQuery: {
  7949. prototype: WebGLQuery;
  7950. new (): WebGLQuery;
  7951. };
  7952. interface WebGLSampler extends WebGLObject {
  7953. }
  7954. declare var WebGLSampler: {
  7955. prototype: WebGLSampler;
  7956. new (): WebGLSampler;
  7957. };
  7958. interface WebGLSync extends WebGLObject {
  7959. }
  7960. declare var WebGLSync: {
  7961. prototype: WebGLSync;
  7962. new (): WebGLSync;
  7963. };
  7964. interface WebGLTransformFeedback extends WebGLObject {
  7965. }
  7966. declare var WebGLTransformFeedback: {
  7967. prototype: WebGLTransformFeedback;
  7968. new (): WebGLTransformFeedback;
  7969. };
  7970. interface WebGLVertexArrayObject extends WebGLObject {
  7971. }
  7972. declare var WebGLVertexArrayObject: {
  7973. prototype: WebGLVertexArrayObject;
  7974. new (): WebGLVertexArrayObject;
  7975. };
  7976. declare module BABYLON {
  7977. class ArcRotateCamera extends TargetCamera {
  7978. alpha: number;
  7979. beta: number;
  7980. radius: number;
  7981. protected _target: Vector3;
  7982. protected _targetHost: Nullable<AbstractMesh>;
  7983. target: Vector3;
  7984. inertialAlphaOffset: number;
  7985. inertialBetaOffset: number;
  7986. inertialRadiusOffset: number;
  7987. lowerAlphaLimit: Nullable<number>;
  7988. upperAlphaLimit: Nullable<number>;
  7989. lowerBetaLimit: number;
  7990. upperBetaLimit: number;
  7991. lowerRadiusLimit: Nullable<number>;
  7992. upperRadiusLimit: Nullable<number>;
  7993. inertialPanningX: number;
  7994. inertialPanningY: number;
  7995. pinchToPanMaxDistance: number;
  7996. panningDistanceLimit: Nullable<number>;
  7997. panningOriginTarget: Vector3;
  7998. panningInertia: number;
  7999. angularSensibilityX: number;
  8000. angularSensibilityY: number;
  8001. pinchPrecision: number;
  8002. pinchDeltaPercentage: number;
  8003. panningSensibility: number;
  8004. keysUp: number[];
  8005. keysDown: number[];
  8006. keysLeft: number[];
  8007. keysRight: number[];
  8008. wheelPrecision: number;
  8009. wheelDeltaPercentage: number;
  8010. zoomOnFactor: number;
  8011. targetScreenOffset: Vector2;
  8012. allowUpsideDown: boolean;
  8013. _viewMatrix: Matrix;
  8014. _useCtrlForPanning: boolean;
  8015. _panningMouseButton: number;
  8016. inputs: ArcRotateCameraInputsManager;
  8017. _reset: () => void;
  8018. panningAxis: Vector3;
  8019. protected _localDirection: Vector3;
  8020. protected _transformedDirection: Vector3;
  8021. private _bouncingBehavior;
  8022. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  8023. useBouncingBehavior: boolean;
  8024. private _framingBehavior;
  8025. readonly framingBehavior: Nullable<FramingBehavior>;
  8026. useFramingBehavior: boolean;
  8027. private _autoRotationBehavior;
  8028. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  8029. useAutoRotationBehavior: boolean;
  8030. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  8031. onCollide: (collidedMesh: AbstractMesh) => void;
  8032. checkCollisions: boolean;
  8033. collisionRadius: Vector3;
  8034. protected _collider: Collider;
  8035. protected _previousPosition: Vector3;
  8036. protected _collisionVelocity: Vector3;
  8037. protected _newPosition: Vector3;
  8038. protected _previousAlpha: number;
  8039. protected _previousBeta: number;
  8040. protected _previousRadius: number;
  8041. protected _collisionTriggered: boolean;
  8042. protected _targetBoundingCenter: Nullable<Vector3>;
  8043. private _computationVector;
  8044. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8045. _initCache(): void;
  8046. _updateCache(ignoreParentClass?: boolean): void;
  8047. protected _getTargetPosition(): Vector3;
  8048. /**
  8049. * Store current camera state (fov, position, etc..)
  8050. */
  8051. private _storedAlpha;
  8052. private _storedBeta;
  8053. private _storedRadius;
  8054. private _storedTarget;
  8055. storeState(): Camera;
  8056. /**
  8057. * Restored camera state. You must call storeState() first
  8058. */
  8059. _restoreStateValues(): boolean;
  8060. _isSynchronizedViewMatrix(): boolean;
  8061. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  8062. detachControl(element: HTMLElement): void;
  8063. _checkInputs(): void;
  8064. protected _checkLimits(): void;
  8065. rebuildAnglesAndRadius(): void;
  8066. setPosition(position: Vector3): void;
  8067. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  8068. _getViewMatrix(): Matrix;
  8069. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  8070. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  8071. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  8072. min: Vector3;
  8073. max: Vector3;
  8074. distance: number;
  8075. }, doNotUpdateMaxZ?: boolean): void;
  8076. /**
  8077. * @override
  8078. * Override Camera.createRigCamera
  8079. */
  8080. createRigCamera(name: string, cameraIndex: number): Camera;
  8081. /**
  8082. * @override
  8083. * Override Camera._updateRigCameras
  8084. */
  8085. _updateRigCameras(): void;
  8086. dispose(): void;
  8087. getClassName(): string;
  8088. }
  8089. }
  8090. declare module BABYLON {
  8091. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  8092. constructor(camera: ArcRotateCamera);
  8093. addMouseWheel(): ArcRotateCameraInputsManager;
  8094. addPointers(): ArcRotateCameraInputsManager;
  8095. addKeyboard(): ArcRotateCameraInputsManager;
  8096. addGamepad(): ArcRotateCameraInputsManager;
  8097. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  8098. }
  8099. }
  8100. declare module BABYLON {
  8101. class Camera extends Node {
  8102. inputs: CameraInputsManager<Camera>;
  8103. private static _PERSPECTIVE_CAMERA;
  8104. private static _ORTHOGRAPHIC_CAMERA;
  8105. private static _FOVMODE_VERTICAL_FIXED;
  8106. private static _FOVMODE_HORIZONTAL_FIXED;
  8107. private static _RIG_MODE_NONE;
  8108. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  8109. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  8110. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  8111. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  8112. private static _RIG_MODE_VR;
  8113. private static _RIG_MODE_WEBVR;
  8114. static readonly PERSPECTIVE_CAMERA: number;
  8115. static readonly ORTHOGRAPHIC_CAMERA: number;
  8116. /**
  8117. * This is the default FOV mode for perspective cameras.
  8118. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8119. *
  8120. */
  8121. static readonly FOVMODE_VERTICAL_FIXED: number;
  8122. /**
  8123. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8124. *
  8125. */
  8126. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8127. static readonly RIG_MODE_NONE: number;
  8128. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8129. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8130. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8131. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8132. static readonly RIG_MODE_VR: number;
  8133. static readonly RIG_MODE_WEBVR: number;
  8134. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8135. static UseAlternateWebVRRendering: boolean;
  8136. position: Vector3;
  8137. /**
  8138. * The vector the camera should consider as up.
  8139. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8140. */
  8141. upVector: Vector3;
  8142. orthoLeft: Nullable<number>;
  8143. orthoRight: Nullable<number>;
  8144. orthoBottom: Nullable<number>;
  8145. orthoTop: Nullable<number>;
  8146. /**
  8147. * FOV is set in Radians. (default is 0.8)
  8148. */
  8149. fov: number;
  8150. minZ: number;
  8151. maxZ: number;
  8152. inertia: number;
  8153. mode: number;
  8154. isIntermediate: boolean;
  8155. viewport: Viewport;
  8156. /**
  8157. * Restricts the camera to viewing objects with the same layerMask.
  8158. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8159. */
  8160. layerMask: number;
  8161. /**
  8162. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8163. */
  8164. fovMode: number;
  8165. cameraRigMode: number;
  8166. interaxialDistance: number;
  8167. isStereoscopicSideBySide: boolean;
  8168. _cameraRigParams: any;
  8169. _rigCameras: Camera[];
  8170. _rigPostProcess: Nullable<PostProcess>;
  8171. protected _webvrViewMatrix: Matrix;
  8172. _skipRendering: boolean;
  8173. _alternateCamera: Camera;
  8174. customRenderTargets: RenderTargetTexture[];
  8175. onViewMatrixChangedObservable: Observable<Camera>;
  8176. onProjectionMatrixChangedObservable: Observable<Camera>;
  8177. onAfterCheckInputsObservable: Observable<Camera>;
  8178. onRestoreStateObservable: Observable<Camera>;
  8179. private _computedViewMatrix;
  8180. _projectionMatrix: Matrix;
  8181. private _doNotComputeProjectionMatrix;
  8182. private _worldMatrix;
  8183. _postProcesses: Nullable<PostProcess>[];
  8184. private _transformMatrix;
  8185. _activeMeshes: SmartArray<AbstractMesh>;
  8186. protected _globalPosition: Vector3;
  8187. private _frustumPlanes;
  8188. private _refreshFrustumPlanes;
  8189. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8190. private _storedFov;
  8191. private _stateStored;
  8192. /**
  8193. * Store current camera state (fov, position, etc..)
  8194. */
  8195. storeState(): Camera;
  8196. /**
  8197. * Restores the camera state values if it has been stored. You must call storeState() first
  8198. */
  8199. protected _restoreStateValues(): boolean;
  8200. /**
  8201. * Restored camera state. You must call storeState() first
  8202. */
  8203. restoreState(): boolean;
  8204. getClassName(): string;
  8205. /**
  8206. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8207. */
  8208. toString(fullDetails?: boolean): string;
  8209. readonly globalPosition: Vector3;
  8210. getActiveMeshes(): SmartArray<AbstractMesh>;
  8211. isActiveMesh(mesh: Mesh): boolean;
  8212. /**
  8213. * Is this camera ready to be used/rendered
  8214. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8215. * @return true if the camera is ready
  8216. */
  8217. isReady(completeCheck?: boolean): boolean;
  8218. _initCache(): void;
  8219. _updateCache(ignoreParentClass?: boolean): void;
  8220. _isSynchronized(): boolean;
  8221. _isSynchronizedViewMatrix(): boolean;
  8222. _isSynchronizedProjectionMatrix(): boolean;
  8223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8224. detachControl(element: HTMLElement): void;
  8225. update(): void;
  8226. _checkInputs(): void;
  8227. readonly rigCameras: Camera[];
  8228. readonly rigPostProcess: Nullable<PostProcess>;
  8229. /**
  8230. * Internal, gets the first post proces.
  8231. * @returns the first post process to be run on this camera.
  8232. */
  8233. _getFirstPostProcess(): Nullable<PostProcess>;
  8234. private _cascadePostProcessesToRigCams();
  8235. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8236. detachPostProcess(postProcess: PostProcess): void;
  8237. getWorldMatrix(): Matrix;
  8238. _getViewMatrix(): Matrix;
  8239. getViewMatrix(force?: boolean): Matrix;
  8240. freezeProjectionMatrix(projection?: Matrix): void;
  8241. unfreezeProjectionMatrix(): void;
  8242. getProjectionMatrix(force?: boolean): Matrix;
  8243. getTranformationMatrix(): Matrix;
  8244. private updateFrustumPlanes();
  8245. isInFrustum(target: ICullable): boolean;
  8246. isCompletelyInFrustum(target: ICullable): boolean;
  8247. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8248. /**
  8249. * Releases resources associated with this node.
  8250. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8251. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8252. */
  8253. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8254. readonly leftCamera: Nullable<FreeCamera>;
  8255. readonly rightCamera: Nullable<FreeCamera>;
  8256. getLeftTarget(): Nullable<Vector3>;
  8257. getRightTarget(): Nullable<Vector3>;
  8258. setCameraRigMode(mode: number, rigParams: any): void;
  8259. private _getVRProjectionMatrix();
  8260. protected _updateCameraRotationMatrix(): void;
  8261. protected _updateWebVRCameraRotationMatrix(): void;
  8262. /**
  8263. * This function MUST be overwritten by the different WebVR cameras available.
  8264. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8265. */
  8266. protected _getWebVRProjectionMatrix(): Matrix;
  8267. /**
  8268. * This function MUST be overwritten by the different WebVR cameras available.
  8269. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8270. */
  8271. protected _getWebVRViewMatrix(): Matrix;
  8272. setCameraRigParameter(name: string, value: any): void;
  8273. /**
  8274. * needs to be overridden by children so sub has required properties to be copied
  8275. */
  8276. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8277. /**
  8278. * May need to be overridden by children
  8279. */
  8280. _updateRigCameras(): void;
  8281. _setupInputs(): void;
  8282. serialize(): any;
  8283. clone(name: string): Camera;
  8284. getDirection(localAxis: Vector3): Vector3;
  8285. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8286. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8287. computeWorldMatrix(): Matrix;
  8288. static Parse(parsedCamera: any, scene: Scene): Camera;
  8289. }
  8290. }
  8291. declare module BABYLON {
  8292. var CameraInputTypes: {};
  8293. interface ICameraInput<TCamera extends Camera> {
  8294. camera: Nullable<TCamera>;
  8295. getClassName(): string;
  8296. getSimpleName(): string;
  8297. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  8298. detachControl: (element: Nullable<HTMLElement>) => void;
  8299. checkInputs?: () => void;
  8300. }
  8301. interface CameraInputsMap<TCamera extends Camera> {
  8302. [name: string]: ICameraInput<TCamera>;
  8303. [idx: number]: ICameraInput<TCamera>;
  8304. }
  8305. class CameraInputsManager<TCamera extends Camera> {
  8306. attached: CameraInputsMap<TCamera>;
  8307. attachedElement: Nullable<HTMLElement>;
  8308. noPreventDefault: boolean;
  8309. camera: TCamera;
  8310. checkInputs: () => void;
  8311. constructor(camera: TCamera);
  8312. /**
  8313. * Add an input method to a camera.
  8314. * builtin inputs example: camera.inputs.addGamepad();
  8315. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  8316. * @param input camera input method
  8317. */
  8318. add(input: ICameraInput<TCamera>): void;
  8319. /**
  8320. * Remove a specific input method from a camera
  8321. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8322. * @param inputToRemove camera input method
  8323. */
  8324. remove(inputToRemove: ICameraInput<TCamera>): void;
  8325. removeByType(inputType: string): void;
  8326. private _addCheckInputs(fn);
  8327. attachInput(input: ICameraInput<TCamera>): void;
  8328. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8329. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8330. rebuildInputCheck(): void;
  8331. /**
  8332. * Remove all attached input methods from a camera
  8333. */
  8334. clear(): void;
  8335. serialize(serializedCamera: any): void;
  8336. parse(parsedCamera: any): void;
  8337. }
  8338. }
  8339. declare module BABYLON {
  8340. /**
  8341. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8342. * being tilted forward or back and left or right.
  8343. */
  8344. class DeviceOrientationCamera extends FreeCamera {
  8345. private _initialQuaternion;
  8346. private _quaternionCache;
  8347. /**
  8348. * Creates a new device orientation camera
  8349. * @param name The name of the camera
  8350. * @param position The start position camera
  8351. * @param scene The scene the camera belongs to
  8352. */
  8353. constructor(name: string, position: Vector3, scene: Scene);
  8354. /**
  8355. * Gets the current instance class name ("DeviceOrientationCamera").
  8356. * This helps avoiding instanceof at run time.
  8357. * @returns the class name
  8358. */
  8359. getClassName(): string;
  8360. /**
  8361. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8362. */
  8363. _checkInputs(): void;
  8364. /**
  8365. * Reset the camera to its default orientation on the specified axis only.
  8366. * @param axis The axis to reset
  8367. */
  8368. resetToCurrentRotation(axis?: Axis): void;
  8369. }
  8370. }
  8371. declare module BABYLON {
  8372. class FollowCamera extends TargetCamera {
  8373. radius: number;
  8374. rotationOffset: number;
  8375. heightOffset: number;
  8376. cameraAcceleration: number;
  8377. maxCameraSpeed: number;
  8378. lockedTarget: Nullable<AbstractMesh>;
  8379. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8380. private getRadians(degrees);
  8381. private follow(cameraTarget);
  8382. _checkInputs(): void;
  8383. getClassName(): string;
  8384. }
  8385. class ArcFollowCamera extends TargetCamera {
  8386. alpha: number;
  8387. beta: number;
  8388. radius: number;
  8389. target: Nullable<AbstractMesh>;
  8390. private _cartesianCoordinates;
  8391. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  8392. private follow();
  8393. _checkInputs(): void;
  8394. getClassName(): string;
  8395. }
  8396. }
  8397. declare module BABYLON {
  8398. class FreeCamera extends TargetCamera {
  8399. ellipsoid: Vector3;
  8400. ellipsoidOffset: Vector3;
  8401. checkCollisions: boolean;
  8402. applyGravity: boolean;
  8403. inputs: FreeCameraInputsManager;
  8404. /**
  8405. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8406. * Higher values reduce sensitivity.
  8407. */
  8408. /**
  8409. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8410. * Higher values reduce sensitivity.
  8411. */
  8412. angularSensibility: number;
  8413. keysUp: number[];
  8414. keysDown: number[];
  8415. keysLeft: number[];
  8416. keysRight: number[];
  8417. onCollide: (collidedMesh: AbstractMesh) => void;
  8418. private _collider;
  8419. private _needMoveForGravity;
  8420. private _oldPosition;
  8421. private _diffPosition;
  8422. private _newPosition;
  8423. _localDirection: Vector3;
  8424. _transformedDirection: Vector3;
  8425. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8427. detachControl(element: HTMLElement): void;
  8428. private _collisionMask;
  8429. collisionMask: number;
  8430. _collideWithWorld(displacement: Vector3): void;
  8431. private _onCollisionPositionChange;
  8432. _checkInputs(): void;
  8433. _decideIfNeedsToMove(): boolean;
  8434. _updatePosition(): void;
  8435. dispose(): void;
  8436. getClassName(): string;
  8437. }
  8438. }
  8439. declare module BABYLON {
  8440. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8441. constructor(camera: FreeCamera);
  8442. addKeyboard(): FreeCameraInputsManager;
  8443. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8444. addGamepad(): FreeCameraInputsManager;
  8445. addDeviceOrientation(): FreeCameraInputsManager;
  8446. addTouch(): FreeCameraInputsManager;
  8447. addVirtualJoystick(): FreeCameraInputsManager;
  8448. }
  8449. }
  8450. declare module BABYLON {
  8451. class GamepadCamera extends UniversalCamera {
  8452. gamepadAngularSensibility: number;
  8453. gamepadMoveSensibility: number;
  8454. constructor(name: string, position: Vector3, scene: Scene);
  8455. getClassName(): string;
  8456. }
  8457. }
  8458. declare module BABYLON {
  8459. /**
  8460. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  8461. */
  8462. class AnaglyphFreeCamera extends FreeCamera {
  8463. /**
  8464. * Creates a new AnaglyphFreeCamera
  8465. * @param name defines camera name
  8466. * @param position defines initial position
  8467. * @param interaxialDistance defines distance between each color axis
  8468. * @param scene defines the hosting scene
  8469. */
  8470. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8471. /**
  8472. * Gets camera class name
  8473. * @returns AnaglyphFreeCamera
  8474. */
  8475. getClassName(): string;
  8476. }
  8477. /**
  8478. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  8479. */
  8480. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  8481. /**
  8482. * Creates a new AnaglyphArcRotateCamera
  8483. * @param name defines camera name
  8484. * @param alpha defines alpha angle (in radians)
  8485. * @param beta defines beta angle (in radians)
  8486. * @param radius defines radius
  8487. * @param target defines camera target
  8488. * @param interaxialDistance defines distance between each color axis
  8489. * @param scene defines the hosting scene
  8490. */
  8491. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  8492. /**
  8493. * Gets camera class name
  8494. * @returns AnaglyphArcRotateCamera
  8495. */
  8496. getClassName(): string;
  8497. }
  8498. /**
  8499. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  8500. */
  8501. class AnaglyphGamepadCamera extends GamepadCamera {
  8502. /**
  8503. * Creates a new AnaglyphGamepadCamera
  8504. * @param name defines camera name
  8505. * @param position defines initial position
  8506. * @param interaxialDistance defines distance between each color axis
  8507. * @param scene defines the hosting scene
  8508. */
  8509. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8510. /**
  8511. * Gets camera class name
  8512. * @returns AnaglyphGamepadCamera
  8513. */
  8514. getClassName(): string;
  8515. }
  8516. /**
  8517. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  8518. */
  8519. class AnaglyphUniversalCamera extends UniversalCamera {
  8520. /**
  8521. * Creates a new AnaglyphUniversalCamera
  8522. * @param name defines camera name
  8523. * @param position defines initial position
  8524. * @param interaxialDistance defines distance between each color axis
  8525. * @param scene defines the hosting scene
  8526. */
  8527. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8528. /**
  8529. * Gets camera class name
  8530. * @returns AnaglyphUniversalCamera
  8531. */
  8532. getClassName(): string;
  8533. }
  8534. /**
  8535. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  8536. */
  8537. class StereoscopicFreeCamera extends FreeCamera {
  8538. /**
  8539. * Creates a new StereoscopicFreeCamera
  8540. * @param name defines camera name
  8541. * @param position defines initial position
  8542. * @param interaxialDistance defines distance between each color axis
  8543. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8544. * @param scene defines the hosting scene
  8545. */
  8546. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8547. /**
  8548. * Gets camera class name
  8549. * @returns StereoscopicFreeCamera
  8550. */
  8551. getClassName(): string;
  8552. }
  8553. /**
  8554. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  8555. */
  8556. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  8557. /**
  8558. * Creates a new StereoscopicArcRotateCamera
  8559. * @param name defines camera name
  8560. * @param alpha defines alpha angle (in radians)
  8561. * @param beta defines beta angle (in radians)
  8562. * @param radius defines radius
  8563. * @param target defines camera target
  8564. * @param interaxialDistance defines distance between each color axis
  8565. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8566. * @param scene defines the hosting scene
  8567. */
  8568. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8569. /**
  8570. * Gets camera class name
  8571. * @returns StereoscopicArcRotateCamera
  8572. */
  8573. getClassName(): string;
  8574. }
  8575. /**
  8576. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  8577. */
  8578. class StereoscopicGamepadCamera extends GamepadCamera {
  8579. /**
  8580. * Creates a new StereoscopicGamepadCamera
  8581. * @param name defines camera name
  8582. * @param position defines initial position
  8583. * @param interaxialDistance defines distance between each color axis
  8584. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8585. * @param scene defines the hosting scene
  8586. */
  8587. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8588. /**
  8589. * Gets camera class name
  8590. * @returns StereoscopicGamepadCamera
  8591. */
  8592. getClassName(): string;
  8593. }
  8594. /**
  8595. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  8596. */
  8597. class StereoscopicUniversalCamera extends UniversalCamera {
  8598. /**
  8599. * Creates a new StereoscopicUniversalCamera
  8600. * @param name defines camera name
  8601. * @param position defines initial position
  8602. * @param interaxialDistance defines distance between each color axis
  8603. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8604. * @param scene defines the hosting scene
  8605. */
  8606. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8607. /**
  8608. * Gets camera class name
  8609. * @returns StereoscopicUniversalCamera
  8610. */
  8611. getClassName(): string;
  8612. }
  8613. }
  8614. declare module BABYLON {
  8615. class TargetCamera extends Camera {
  8616. cameraDirection: Vector3;
  8617. cameraRotation: Vector2;
  8618. rotation: Vector3;
  8619. rotationQuaternion: Quaternion;
  8620. speed: number;
  8621. noRotationConstraint: boolean;
  8622. lockedTarget: any;
  8623. _currentTarget: Vector3;
  8624. _viewMatrix: Matrix;
  8625. _camMatrix: Matrix;
  8626. _cameraTransformMatrix: Matrix;
  8627. _cameraRotationMatrix: Matrix;
  8628. private _rigCamTransformMatrix;
  8629. _referencePoint: Vector3;
  8630. private _currentUpVector;
  8631. _transformedReferencePoint: Vector3;
  8632. protected _globalCurrentTarget: Vector3;
  8633. protected _globalCurrentUpVector: Vector3;
  8634. _reset: () => void;
  8635. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8636. getFrontPosition(distance: number): Vector3;
  8637. _getLockedTargetPosition(): Nullable<Vector3>;
  8638. /**
  8639. * Store current camera state (fov, position, etc..)
  8640. */
  8641. private _storedPosition;
  8642. private _storedRotation;
  8643. private _storedRotationQuaternion;
  8644. storeState(): Camera;
  8645. /**
  8646. * Restored camera state. You must call storeState() first
  8647. */
  8648. _restoreStateValues(): boolean;
  8649. _initCache(): void;
  8650. _updateCache(ignoreParentClass?: boolean): void;
  8651. _isSynchronizedViewMatrix(): boolean;
  8652. _computeLocalCameraSpeed(): number;
  8653. setTarget(target: Vector3): void;
  8654. /**
  8655. * Return the current target position of the camera. This value is expressed in local space.
  8656. */
  8657. getTarget(): Vector3;
  8658. _decideIfNeedsToMove(): boolean;
  8659. _updatePosition(): void;
  8660. _checkInputs(): void;
  8661. protected _updateCameraRotationMatrix(): void;
  8662. _getViewMatrix(): Matrix;
  8663. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8664. /**
  8665. * @override
  8666. * Override Camera.createRigCamera
  8667. */
  8668. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8669. /**
  8670. * @override
  8671. * Override Camera._updateRigCameras
  8672. */
  8673. _updateRigCameras(): void;
  8674. private _getRigCamPosition(halfSpace, result);
  8675. getClassName(): string;
  8676. }
  8677. }
  8678. declare module BABYLON {
  8679. class TouchCamera extends FreeCamera {
  8680. touchAngularSensibility: number;
  8681. touchMoveSensibility: number;
  8682. constructor(name: string, position: Vector3, scene: Scene);
  8683. getClassName(): string;
  8684. _setupInputs(): void;
  8685. }
  8686. }
  8687. declare module BABYLON {
  8688. class UniversalCamera extends TouchCamera {
  8689. gamepadAngularSensibility: number;
  8690. gamepadMoveSensibility: number;
  8691. constructor(name: string, position: Vector3, scene: Scene);
  8692. getClassName(): string;
  8693. }
  8694. }
  8695. declare module BABYLON {
  8696. class VirtualJoysticksCamera extends FreeCamera {
  8697. constructor(name: string, position: Vector3, scene: Scene);
  8698. getClassName(): string;
  8699. }
  8700. }
  8701. interface VRDisplay extends EventTarget {
  8702. /**
  8703. * Dictionary of capabilities describing the VRDisplay.
  8704. */
  8705. readonly capabilities: VRDisplayCapabilities;
  8706. /**
  8707. * z-depth defining the far plane of the eye view frustum
  8708. * enables mapping of values in the render target depth
  8709. * attachment to scene coordinates. Initially set to 10000.0.
  8710. */
  8711. depthFar: number;
  8712. /**
  8713. * z-depth defining the near plane of the eye view frustum
  8714. * enables mapping of values in the render target depth
  8715. * attachment to scene coordinates. Initially set to 0.01.
  8716. */
  8717. depthNear: number;
  8718. /**
  8719. * An identifier for this distinct VRDisplay. Used as an
  8720. * association point in the Gamepad API.
  8721. */
  8722. readonly displayId: number;
  8723. /**
  8724. * A display name, a user-readable name identifying it.
  8725. */
  8726. readonly displayName: string;
  8727. readonly isConnected: boolean;
  8728. readonly isPresenting: boolean;
  8729. /**
  8730. * If this VRDisplay supports room-scale experiences, the optional
  8731. * stage attribute contains details on the room-scale parameters.
  8732. */
  8733. readonly stageParameters: VRStageParameters | null;
  8734. /**
  8735. * Passing the value returned by `requestAnimationFrame` to
  8736. * `cancelAnimationFrame` will unregister the callback.
  8737. */
  8738. cancelAnimationFrame(handle: number): void;
  8739. /**
  8740. * Stops presenting to the VRDisplay.
  8741. */
  8742. exitPresent(): Promise<void>;
  8743. getEyeParameters(whichEye: string): VREyeParameters;
  8744. /**
  8745. * Populates the passed VRFrameData with the information required to render
  8746. * the current frame.
  8747. */
  8748. getFrameData(frameData: VRFrameData): boolean;
  8749. /**
  8750. * Get the layers currently being presented.
  8751. */
  8752. getLayers(): VRLayer[];
  8753. /**
  8754. * Return a VRPose containing the future predicted pose of the VRDisplay
  8755. * when the current frame will be presented. The value returned will not
  8756. * change until JavaScript has returned control to the browser.
  8757. *
  8758. * The VRPose will contain the position, orientation, velocity,
  8759. * and acceleration of each of these properties.
  8760. */
  8761. getPose(): VRPose;
  8762. /**
  8763. * Return the current instantaneous pose of the VRDisplay, with no
  8764. * prediction applied.
  8765. */
  8766. getImmediatePose(): VRPose;
  8767. /**
  8768. * The callback passed to `requestAnimationFrame` will be called
  8769. * any time a new frame should be rendered. When the VRDisplay is
  8770. * presenting the callback will be called at the native refresh
  8771. * rate of the HMD. When not presenting this function acts
  8772. * identically to how window.requestAnimationFrame acts. Content should
  8773. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8774. * asynchronously from other displays and at differing refresh rates.
  8775. */
  8776. requestAnimationFrame(callback: FrameRequestCallback): number;
  8777. /**
  8778. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8779. * Repeat calls while already presenting will update the VRLayers being displayed.
  8780. */
  8781. requestPresent(layers: VRLayer[]): Promise<void>;
  8782. /**
  8783. * Reset the pose for this display, treating its current position and
  8784. * orientation as the "origin/zero" values. VRPose.position,
  8785. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8786. * updated when calling resetPose(). This should be called in only
  8787. * sitting-space experiences.
  8788. */
  8789. resetPose(): void;
  8790. /**
  8791. * The VRLayer provided to the VRDisplay will be captured and presented
  8792. * in the HMD. Calling this function has the same effect on the source
  8793. * canvas as any other operation that uses its source image, and canvases
  8794. * created without preserveDrawingBuffer set to true will be cleared.
  8795. */
  8796. submitFrame(pose?: VRPose): void;
  8797. }
  8798. declare var VRDisplay: {
  8799. prototype: VRDisplay;
  8800. new (): VRDisplay;
  8801. };
  8802. interface VRLayer {
  8803. leftBounds?: number[] | null;
  8804. rightBounds?: number[] | null;
  8805. source?: HTMLCanvasElement | null;
  8806. }
  8807. interface VRDisplayCapabilities {
  8808. readonly canPresent: boolean;
  8809. readonly hasExternalDisplay: boolean;
  8810. readonly hasOrientation: boolean;
  8811. readonly hasPosition: boolean;
  8812. readonly maxLayers: number;
  8813. }
  8814. interface VREyeParameters {
  8815. /** @deprecated */
  8816. readonly fieldOfView: VRFieldOfView;
  8817. readonly offset: Float32Array;
  8818. readonly renderHeight: number;
  8819. readonly renderWidth: number;
  8820. }
  8821. interface VRFieldOfView {
  8822. readonly downDegrees: number;
  8823. readonly leftDegrees: number;
  8824. readonly rightDegrees: number;
  8825. readonly upDegrees: number;
  8826. }
  8827. interface VRFrameData {
  8828. readonly leftProjectionMatrix: Float32Array;
  8829. readonly leftViewMatrix: Float32Array;
  8830. readonly pose: VRPose;
  8831. readonly rightProjectionMatrix: Float32Array;
  8832. readonly rightViewMatrix: Float32Array;
  8833. readonly timestamp: number;
  8834. }
  8835. interface VRPose {
  8836. readonly angularAcceleration: Float32Array | null;
  8837. readonly angularVelocity: Float32Array | null;
  8838. readonly linearAcceleration: Float32Array | null;
  8839. readonly linearVelocity: Float32Array | null;
  8840. readonly orientation: Float32Array | null;
  8841. readonly position: Float32Array | null;
  8842. readonly timestamp: number;
  8843. }
  8844. interface VRStageParameters {
  8845. sittingToStandingTransform?: Float32Array;
  8846. sizeX?: number;
  8847. sizeY?: number;
  8848. }
  8849. interface Navigator {
  8850. getVRDisplays(): Promise<VRDisplay[]>;
  8851. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8852. }
  8853. interface Window {
  8854. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8855. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8856. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8857. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8858. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8859. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8860. }
  8861. interface Gamepad {
  8862. readonly displayId: number;
  8863. }
  8864. declare module BABYLON {
  8865. class BoundingBox implements ICullable {
  8866. vectors: Vector3[];
  8867. center: Vector3;
  8868. centerWorld: Vector3;
  8869. extendSize: Vector3;
  8870. extendSizeWorld: Vector3;
  8871. directions: Vector3[];
  8872. vectorsWorld: Vector3[];
  8873. minimumWorld: Vector3;
  8874. maximumWorld: Vector3;
  8875. minimum: Vector3;
  8876. maximum: Vector3;
  8877. private _worldMatrix;
  8878. /**
  8879. * Creates a new bounding box
  8880. * @param min defines the minimum vector (in local space)
  8881. * @param max defines the maximum vector (in local space)
  8882. */
  8883. constructor(min: Vector3, max: Vector3);
  8884. /**
  8885. * Recreates the entire bounding box from scratch
  8886. * @param min defines the new minimum vector (in local space)
  8887. * @param max defines the new maximum vector (in local space)
  8888. */
  8889. reConstruct(min: Vector3, max: Vector3): void;
  8890. getWorldMatrix(): Matrix;
  8891. setWorldMatrix(matrix: Matrix): BoundingBox;
  8892. _update(world: Matrix): void;
  8893. isInFrustum(frustumPlanes: Plane[]): boolean;
  8894. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8895. intersectsPoint(point: Vector3): boolean;
  8896. intersectsSphere(sphere: BoundingSphere): boolean;
  8897. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  8898. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  8899. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  8900. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8901. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8902. }
  8903. }
  8904. declare module BABYLON {
  8905. interface ICullable {
  8906. isInFrustum(frustumPlanes: Plane[]): boolean;
  8907. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8908. }
  8909. class BoundingInfo implements ICullable {
  8910. minimum: Vector3;
  8911. maximum: Vector3;
  8912. boundingBox: BoundingBox;
  8913. boundingSphere: BoundingSphere;
  8914. private _isLocked;
  8915. constructor(minimum: Vector3, maximum: Vector3);
  8916. isLocked: boolean;
  8917. update(world: Matrix): void;
  8918. /**
  8919. * Recreate the bounding info to be centered around a specific point given a specific extend.
  8920. * @param center New center of the bounding info
  8921. * @param extend New extend of the bounding info
  8922. */
  8923. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  8924. isInFrustum(frustumPlanes: Plane[]): boolean;
  8925. /**
  8926. * Gets the world distance between the min and max points of the bounding box
  8927. */
  8928. readonly diagonalLength: number;
  8929. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8930. _checkCollision(collider: Collider): boolean;
  8931. intersectsPoint(point: Vector3): boolean;
  8932. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  8933. }
  8934. }
  8935. declare module BABYLON {
  8936. class BoundingSphere {
  8937. center: Vector3;
  8938. radius: number;
  8939. centerWorld: Vector3;
  8940. radiusWorld: number;
  8941. minimum: Vector3;
  8942. maximum: Vector3;
  8943. private _tempRadiusVector;
  8944. /**
  8945. * Creates a new bounding sphere
  8946. * @param min defines the minimum vector (in local space)
  8947. * @param max defines the maximum vector (in local space)
  8948. */
  8949. constructor(min: Vector3, max: Vector3);
  8950. /**
  8951. * Recreates the entire bounding sphere from scratch
  8952. * @param min defines the new minimum vector (in local space)
  8953. * @param max defines the new maximum vector (in local space)
  8954. */
  8955. reConstruct(min: Vector3, max: Vector3): void;
  8956. _update(world: Matrix): void;
  8957. isInFrustum(frustumPlanes: Plane[]): boolean;
  8958. intersectsPoint(point: Vector3): boolean;
  8959. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  8960. }
  8961. }
  8962. declare module BABYLON {
  8963. class Ray {
  8964. origin: Vector3;
  8965. direction: Vector3;
  8966. length: number;
  8967. private _edge1;
  8968. private _edge2;
  8969. private _pvec;
  8970. private _tvec;
  8971. private _qvec;
  8972. private _tmpRay;
  8973. constructor(origin: Vector3, direction: Vector3, length?: number);
  8974. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  8975. intersectsBox(box: BoundingBox): boolean;
  8976. intersectsSphere(sphere: BoundingSphere): boolean;
  8977. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  8978. intersectsPlane(plane: Plane): Nullable<number>;
  8979. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  8980. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  8981. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  8982. private static smallnum;
  8983. private static rayl;
  8984. /**
  8985. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  8986. * @param sega the first point of the segment to test the intersection against
  8987. * @param segb the second point of the segment to test the intersection against
  8988. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  8989. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  8990. */
  8991. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  8992. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  8993. static Zero(): Ray;
  8994. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  8995. /**
  8996. * 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
  8997. * transformed to the given world matrix.
  8998. * @param origin The origin point
  8999. * @param end The end point
  9000. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9001. */
  9002. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  9003. static Transform(ray: Ray, matrix: Matrix): Ray;
  9004. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  9005. }
  9006. }
  9007. declare module BABYLON {
  9008. class KeyboardEventTypes {
  9009. static _KEYDOWN: number;
  9010. static _KEYUP: number;
  9011. static readonly KEYDOWN: number;
  9012. static readonly KEYUP: number;
  9013. }
  9014. class KeyboardInfo {
  9015. type: number;
  9016. event: KeyboardEvent;
  9017. constructor(type: number, event: KeyboardEvent);
  9018. }
  9019. /**
  9020. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9021. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9022. */
  9023. class KeyboardInfoPre extends KeyboardInfo {
  9024. constructor(type: number, event: KeyboardEvent);
  9025. skipOnPointerObservable: boolean;
  9026. }
  9027. }
  9028. declare module BABYLON {
  9029. class PointerEventTypes {
  9030. static _POINTERDOWN: number;
  9031. static _POINTERUP: number;
  9032. static _POINTERMOVE: number;
  9033. static _POINTERWHEEL: number;
  9034. static _POINTERPICK: number;
  9035. static _POINTERTAP: number;
  9036. static _POINTERDOUBLETAP: number;
  9037. static readonly POINTERDOWN: number;
  9038. static readonly POINTERUP: number;
  9039. static readonly POINTERMOVE: number;
  9040. static readonly POINTERWHEEL: number;
  9041. static readonly POINTERPICK: number;
  9042. static readonly POINTERTAP: number;
  9043. static readonly POINTERDOUBLETAP: number;
  9044. }
  9045. class PointerInfoBase {
  9046. type: number;
  9047. event: PointerEvent | MouseWheelEvent;
  9048. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9049. }
  9050. /**
  9051. * This class is used to store pointer related info for the onPrePointerObservable event.
  9052. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9053. */
  9054. class PointerInfoPre extends PointerInfoBase {
  9055. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9056. localPosition: Vector2;
  9057. skipOnPointerObservable: boolean;
  9058. }
  9059. /**
  9060. * This type contains all the data related to a pointer event in Babylon.js.
  9061. * 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.
  9062. */
  9063. class PointerInfo extends PointerInfoBase {
  9064. pickInfo: Nullable<PickingInfo>;
  9065. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9066. }
  9067. }
  9068. declare module BABYLON {
  9069. /**
  9070. * Represents the different options available during the creation of
  9071. * a Environment helper.
  9072. *
  9073. * This can control the default ground, skybox and image processing setup of your scene.
  9074. */
  9075. interface IEnvironmentHelperOptions {
  9076. /**
  9077. * Specifies wether or not to create a ground.
  9078. * True by default.
  9079. */
  9080. createGround: boolean;
  9081. /**
  9082. * Specifies the ground size.
  9083. * 15 by default.
  9084. */
  9085. groundSize: number;
  9086. /**
  9087. * The texture used on the ground for the main color.
  9088. * Comes from the BabylonJS CDN by default.
  9089. *
  9090. * Remarks: Can be either a texture or a url.
  9091. */
  9092. groundTexture: string | BaseTexture;
  9093. /**
  9094. * The color mixed in the ground texture by default.
  9095. * BabylonJS clearColor by default.
  9096. */
  9097. groundColor: Color3;
  9098. /**
  9099. * Specifies the ground opacity.
  9100. * 1 by default.
  9101. */
  9102. groundOpacity: number;
  9103. /**
  9104. * Enables the ground to receive shadows.
  9105. * True by default.
  9106. */
  9107. enableGroundShadow: boolean;
  9108. /**
  9109. * Helps preventing the shadow to be fully black on the ground.
  9110. * 0.5 by default.
  9111. */
  9112. groundShadowLevel: number;
  9113. /**
  9114. * Creates a mirror texture attach to the ground.
  9115. * false by default.
  9116. */
  9117. enableGroundMirror: boolean;
  9118. /**
  9119. * Specifies the ground mirror size ratio.
  9120. * 0.3 by default as the default kernel is 64.
  9121. */
  9122. groundMirrorSizeRatio: number;
  9123. /**
  9124. * Specifies the ground mirror blur kernel size.
  9125. * 64 by default.
  9126. */
  9127. groundMirrorBlurKernel: number;
  9128. /**
  9129. * Specifies the ground mirror visibility amount.
  9130. * 1 by default
  9131. */
  9132. groundMirrorAmount: number;
  9133. /**
  9134. * Specifies the ground mirror reflectance weight.
  9135. * This uses the standard weight of the background material to setup the fresnel effect
  9136. * of the mirror.
  9137. * 1 by default.
  9138. */
  9139. groundMirrorFresnelWeight: number;
  9140. /**
  9141. * Specifies the ground mirror Falloff distance.
  9142. * This can helps reducing the size of the reflection.
  9143. * 0 by Default.
  9144. */
  9145. groundMirrorFallOffDistance: number;
  9146. /**
  9147. * Specifies the ground mirror texture type.
  9148. * Unsigned Int by Default.
  9149. */
  9150. groundMirrorTextureType: number;
  9151. /**
  9152. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9153. * the shown objects.
  9154. */
  9155. groundYBias: number;
  9156. /**
  9157. * Specifies wether or not to create a skybox.
  9158. * True by default.
  9159. */
  9160. createSkybox: boolean;
  9161. /**
  9162. * Specifies the skybox size.
  9163. * 20 by default.
  9164. */
  9165. skyboxSize: number;
  9166. /**
  9167. * The texture used on the skybox for the main color.
  9168. * Comes from the BabylonJS CDN by default.
  9169. *
  9170. * Remarks: Can be either a texture or a url.
  9171. */
  9172. skyboxTexture: string | BaseTexture;
  9173. /**
  9174. * The color mixed in the skybox texture by default.
  9175. * BabylonJS clearColor by default.
  9176. */
  9177. skyboxColor: Color3;
  9178. /**
  9179. * The background rotation around the Y axis of the scene.
  9180. * This helps aligning the key lights of your scene with the background.
  9181. * 0 by default.
  9182. */
  9183. backgroundYRotation: number;
  9184. /**
  9185. * Compute automatically the size of the elements to best fit with the scene.
  9186. */
  9187. sizeAuto: boolean;
  9188. /**
  9189. * Default position of the rootMesh if autoSize is not true.
  9190. */
  9191. rootPosition: Vector3;
  9192. /**
  9193. * Sets up the image processing in the scene.
  9194. * true by default.
  9195. */
  9196. setupImageProcessing: boolean;
  9197. /**
  9198. * The texture used as your environment texture in the scene.
  9199. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9200. *
  9201. * Remarks: Can be either a texture or a url.
  9202. */
  9203. environmentTexture: string | BaseTexture;
  9204. /**
  9205. * The value of the exposure to apply to the scene.
  9206. * 0.6 by default if setupImageProcessing is true.
  9207. */
  9208. cameraExposure: number;
  9209. /**
  9210. * The value of the contrast to apply to the scene.
  9211. * 1.6 by default if setupImageProcessing is true.
  9212. */
  9213. cameraContrast: number;
  9214. /**
  9215. * Specifies wether or not tonemapping should be enabled in the scene.
  9216. * true by default if setupImageProcessing is true.
  9217. */
  9218. toneMappingEnabled: boolean;
  9219. }
  9220. /**
  9221. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9222. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9223. * It also helps with the default setup of your imageProcessing configuration.
  9224. */
  9225. class EnvironmentHelper {
  9226. /**
  9227. * Default ground texture URL.
  9228. */
  9229. private static _groundTextureCDNUrl;
  9230. /**
  9231. * Default skybox texture URL.
  9232. */
  9233. private static _skyboxTextureCDNUrl;
  9234. /**
  9235. * Default environment texture URL.
  9236. */
  9237. private static _environmentTextureCDNUrl;
  9238. /**
  9239. * Creates the default options for the helper.
  9240. */
  9241. private static _getDefaultOptions();
  9242. private _rootMesh;
  9243. /**
  9244. * Gets the root mesh created by the helper.
  9245. */
  9246. readonly rootMesh: Mesh;
  9247. private _skybox;
  9248. /**
  9249. * Gets the skybox created by the helper.
  9250. */
  9251. readonly skybox: Nullable<Mesh>;
  9252. private _skyboxTexture;
  9253. /**
  9254. * Gets the skybox texture created by the helper.
  9255. */
  9256. readonly skyboxTexture: Nullable<BaseTexture>;
  9257. private _skyboxMaterial;
  9258. /**
  9259. * Gets the skybox material created by the helper.
  9260. */
  9261. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9262. private _ground;
  9263. /**
  9264. * Gets the ground mesh created by the helper.
  9265. */
  9266. readonly ground: Nullable<Mesh>;
  9267. private _groundTexture;
  9268. /**
  9269. * Gets the ground texture created by the helper.
  9270. */
  9271. readonly groundTexture: Nullable<BaseTexture>;
  9272. private _groundMirror;
  9273. /**
  9274. * Gets the ground mirror created by the helper.
  9275. */
  9276. readonly groundMirror: Nullable<MirrorTexture>;
  9277. /**
  9278. * Gets the ground mirror render list to helps pushing the meshes
  9279. * you wish in the ground reflection.
  9280. */
  9281. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9282. private _groundMaterial;
  9283. /**
  9284. * Gets the ground material created by the helper.
  9285. */
  9286. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9287. /**
  9288. * Stores the creation options.
  9289. */
  9290. private readonly _scene;
  9291. private _options;
  9292. /**
  9293. * This observable will be notified with any error during the creation of the environment,
  9294. * mainly texture creation errors.
  9295. */
  9296. onErrorObservable: Observable<{
  9297. message?: string;
  9298. exception?: any;
  9299. }>;
  9300. /**
  9301. * constructor
  9302. * @param options
  9303. * @param scene The scene to add the material to
  9304. */
  9305. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9306. /**
  9307. * Updates the background according to the new options
  9308. * @param options
  9309. */
  9310. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9311. /**
  9312. * Sets the primary color of all the available elements.
  9313. * @param color the main color to affect to the ground and the background
  9314. */
  9315. setMainColor(color: Color3): void;
  9316. /**
  9317. * Setup the image processing according to the specified options.
  9318. */
  9319. private _setupImageProcessing();
  9320. /**
  9321. * Setup the environment texture according to the specified options.
  9322. */
  9323. private _setupEnvironmentTexture();
  9324. /**
  9325. * Setup the background according to the specified options.
  9326. */
  9327. private _setupBackground();
  9328. /**
  9329. * Get the scene sizes according to the setup.
  9330. */
  9331. private _getSceneSize();
  9332. /**
  9333. * Setup the ground according to the specified options.
  9334. */
  9335. private _setupGround(sceneSize);
  9336. /**
  9337. * Setup the ground material according to the specified options.
  9338. */
  9339. private _setupGroundMaterial();
  9340. /**
  9341. * Setup the ground diffuse texture according to the specified options.
  9342. */
  9343. private _setupGroundDiffuseTexture();
  9344. /**
  9345. * Setup the ground mirror texture according to the specified options.
  9346. */
  9347. private _setupGroundMirrorTexture(sceneSize);
  9348. /**
  9349. * Setup the ground to receive the mirror texture.
  9350. */
  9351. private _setupMirrorInGroundMaterial();
  9352. /**
  9353. * Setup the skybox according to the specified options.
  9354. */
  9355. private _setupSkybox(sceneSize);
  9356. /**
  9357. * Setup the skybox material according to the specified options.
  9358. */
  9359. private _setupSkyboxMaterial();
  9360. /**
  9361. * Setup the skybox reflection texture according to the specified options.
  9362. */
  9363. private _setupSkyboxReflectionTexture();
  9364. private _errorHandler;
  9365. /**
  9366. * Dispose all the elements created by the Helper.
  9367. */
  9368. dispose(): void;
  9369. }
  9370. }
  9371. declare module BABYLON {
  9372. /**
  9373. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9374. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9375. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9376. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9377. */
  9378. class VideoDome extends Node {
  9379. /**
  9380. * The video texture being displayed on the sphere
  9381. */
  9382. protected _videoTexture: VideoTexture;
  9383. /**
  9384. * The skybox material
  9385. */
  9386. protected _material: BackgroundMaterial;
  9387. /**
  9388. * The surface used for the skybox
  9389. */
  9390. protected _mesh: Mesh;
  9391. /**
  9392. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9393. * Also see the options.resolution property.
  9394. */
  9395. fovMultiplier: number;
  9396. /**
  9397. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9398. * @param name Element's name, child elements will append suffixes for their own names.
  9399. * @param urlsOrVideo
  9400. * @param options An object containing optional or exposed sub element properties:
  9401. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9402. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  9403. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  9404. * @param options **loop=true** Automatically loop video on end.
  9405. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  9406. */
  9407. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  9408. resolution?: number;
  9409. clickToPlay?: boolean;
  9410. autoPlay?: boolean;
  9411. loop?: boolean;
  9412. size?: number;
  9413. }, scene: Scene);
  9414. /**
  9415. * Releases resources associated with this node.
  9416. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9417. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9418. */
  9419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9420. }
  9421. }
  9422. declare module BABYLON {
  9423. class StickValues {
  9424. x: number;
  9425. y: number;
  9426. constructor(x: number, y: number);
  9427. }
  9428. interface GamepadButtonChanges {
  9429. changed: boolean;
  9430. pressChanged: boolean;
  9431. touchChanged: boolean;
  9432. valueChanged: boolean;
  9433. }
  9434. class Gamepad {
  9435. id: string;
  9436. index: number;
  9437. browserGamepad: any;
  9438. type: number;
  9439. private _leftStick;
  9440. private _rightStick;
  9441. _isConnected: boolean;
  9442. private _leftStickAxisX;
  9443. private _leftStickAxisY;
  9444. private _rightStickAxisX;
  9445. private _rightStickAxisY;
  9446. private _onleftstickchanged;
  9447. private _onrightstickchanged;
  9448. static GAMEPAD: number;
  9449. static GENERIC: number;
  9450. static XBOX: number;
  9451. static POSE_ENABLED: number;
  9452. protected _invertLeftStickY: boolean;
  9453. readonly isConnected: boolean;
  9454. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9455. onleftstickchanged(callback: (values: StickValues) => void): void;
  9456. onrightstickchanged(callback: (values: StickValues) => void): void;
  9457. leftStick: StickValues;
  9458. rightStick: StickValues;
  9459. update(): void;
  9460. dispose(): void;
  9461. }
  9462. class GenericPad extends Gamepad {
  9463. private _buttons;
  9464. private _onbuttondown;
  9465. private _onbuttonup;
  9466. onButtonDownObservable: Observable<number>;
  9467. onButtonUpObservable: Observable<number>;
  9468. onbuttondown(callback: (buttonPressed: number) => void): void;
  9469. onbuttonup(callback: (buttonReleased: number) => void): void;
  9470. constructor(id: string, index: number, browserGamepad: any);
  9471. private _setButtonValue(newValue, currentValue, buttonIndex);
  9472. update(): void;
  9473. dispose(): void;
  9474. }
  9475. }
  9476. declare module BABYLON {
  9477. class GamepadManager {
  9478. private _scene;
  9479. private _babylonGamepads;
  9480. private _oneGamepadConnected;
  9481. _isMonitoring: boolean;
  9482. private _gamepadEventSupported;
  9483. private _gamepadSupport;
  9484. onGamepadConnectedObservable: Observable<Gamepad>;
  9485. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9486. private _onGamepadConnectedEvent;
  9487. private _onGamepadDisconnectedEvent;
  9488. constructor(_scene?: Scene | undefined);
  9489. readonly gamepads: Gamepad[];
  9490. getGamepadByType(type?: number): Nullable<Gamepad>;
  9491. dispose(): void;
  9492. private _addNewGamepad(gamepad);
  9493. private _startMonitoringGamepads();
  9494. private _stopMonitoringGamepads();
  9495. _checkGamepadsStatus(): void;
  9496. private _updateGamepadObjects();
  9497. }
  9498. }
  9499. declare module BABYLON {
  9500. /**
  9501. * Defines supported buttons for XBox360 compatible gamepads
  9502. */
  9503. enum Xbox360Button {
  9504. /** A */
  9505. A = 0,
  9506. /** B */
  9507. B = 1,
  9508. /** X */
  9509. X = 2,
  9510. /** Y */
  9511. Y = 3,
  9512. /** Start */
  9513. Start = 4,
  9514. /** Back */
  9515. Back = 5,
  9516. /** Left button */
  9517. LB = 6,
  9518. /** Right button */
  9519. RB = 7,
  9520. /** Left stick */
  9521. LeftStick = 8,
  9522. /** Right stick */
  9523. RightStick = 9,
  9524. }
  9525. /** Defines values for XBox360 DPad */
  9526. enum Xbox360Dpad {
  9527. /** Up */
  9528. Up = 0,
  9529. /** Down */
  9530. Down = 1,
  9531. /** Left */
  9532. Left = 2,
  9533. /** Right */
  9534. Right = 3,
  9535. }
  9536. /**
  9537. * Defines a XBox360 gamepad
  9538. */
  9539. class Xbox360Pad extends Gamepad {
  9540. private _leftTrigger;
  9541. private _rightTrigger;
  9542. private _onlefttriggerchanged;
  9543. private _onrighttriggerchanged;
  9544. private _onbuttondown;
  9545. private _onbuttonup;
  9546. private _ondpaddown;
  9547. private _ondpadup;
  9548. /** Observable raised when a button is pressed */
  9549. onButtonDownObservable: Observable<Xbox360Button>;
  9550. /** Observable raised when a button is released */
  9551. onButtonUpObservable: Observable<Xbox360Button>;
  9552. /** Observable raised when a pad is pressed */
  9553. onPadDownObservable: Observable<Xbox360Dpad>;
  9554. /** Observable raised when a pad is released */
  9555. onPadUpObservable: Observable<Xbox360Dpad>;
  9556. private _buttonA;
  9557. private _buttonB;
  9558. private _buttonX;
  9559. private _buttonY;
  9560. private _buttonBack;
  9561. private _buttonStart;
  9562. private _buttonLB;
  9563. private _buttonRB;
  9564. private _buttonLeftStick;
  9565. private _buttonRightStick;
  9566. private _dPadUp;
  9567. private _dPadDown;
  9568. private _dPadLeft;
  9569. private _dPadRight;
  9570. private _isXboxOnePad;
  9571. /**
  9572. * Creates a new XBox360 gamepad object
  9573. * @param id defines the id of this gamepad
  9574. * @param index defines its index
  9575. * @param gamepad defines the internal HTML gamepad object
  9576. * @param xboxOne defines if it is a XBox One gamepad
  9577. */
  9578. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9579. /**
  9580. * Defines the callback to call when left trigger is pressed
  9581. * @param callback defines the callback to use
  9582. */
  9583. onlefttriggerchanged(callback: (value: number) => void): void;
  9584. /**
  9585. * Defines the callback to call when right trigger is pressed
  9586. * @param callback defines the callback to use
  9587. */
  9588. onrighttriggerchanged(callback: (value: number) => void): void;
  9589. /**
  9590. * Gets or sets left trigger value
  9591. */
  9592. leftTrigger: number;
  9593. /**
  9594. * Gets or sets right trigger value
  9595. */
  9596. rightTrigger: number;
  9597. /**
  9598. * Defines the callback to call when a button is pressed
  9599. * @param callback defines the callback to use
  9600. */
  9601. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9602. /**
  9603. * Defines the callback to call when a button is released
  9604. * @param callback defines the callback to use
  9605. */
  9606. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9607. /**
  9608. * Defines the callback to call when a pad is pressed
  9609. * @param callback defines the callback to use
  9610. */
  9611. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9612. /**
  9613. * Defines the callback to call when a pad is released
  9614. * @param callback defines the callback to use
  9615. */
  9616. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9617. private _setButtonValue(newValue, currentValue, buttonType);
  9618. private _setDPadValue(newValue, currentValue, buttonType);
  9619. /** Gets or sets value of A button */
  9620. buttonA: number;
  9621. /** Gets or sets value of B button */
  9622. buttonB: number;
  9623. /** Gets or sets value of X button */
  9624. buttonX: number;
  9625. /** Gets or sets value of Y button */
  9626. buttonY: number;
  9627. /** Gets or sets value of Start button */
  9628. buttonStart: number;
  9629. /** Gets or sets value of Back button */
  9630. buttonBack: number;
  9631. /** Gets or sets value of Left button */
  9632. buttonLB: number;
  9633. /** Gets or sets value of Right button */
  9634. buttonRB: number;
  9635. /** Gets or sets value of left stick */
  9636. buttonLeftStick: number;
  9637. /** Gets or sets value of right stick */
  9638. buttonRightStick: number;
  9639. /** Gets or sets value of DPad up */
  9640. dPadUp: number;
  9641. /** Gets or sets value of DPad down */
  9642. dPadDown: number;
  9643. /** Gets or sets value of DPad left */
  9644. dPadLeft: number;
  9645. /** Gets or sets value of DPad right */
  9646. dPadRight: number;
  9647. /**
  9648. * Force the gamepad to synchronize with device values
  9649. */
  9650. update(): void;
  9651. dispose(): void;
  9652. }
  9653. }
  9654. declare module BABYLON {
  9655. /**
  9656. * This class can be used to get instrumentation data from a Babylon engine
  9657. */
  9658. class EngineInstrumentation implements IDisposable {
  9659. engine: Engine;
  9660. private _captureGPUFrameTime;
  9661. private _gpuFrameTimeToken;
  9662. private _gpuFrameTime;
  9663. private _captureShaderCompilationTime;
  9664. private _shaderCompilationTime;
  9665. private _onBeginFrameObserver;
  9666. private _onEndFrameObserver;
  9667. private _onBeforeShaderCompilationObserver;
  9668. private _onAfterShaderCompilationObserver;
  9669. /**
  9670. * Gets the perf counter used for GPU frame time
  9671. */
  9672. readonly gpuFrameTimeCounter: PerfCounter;
  9673. /**
  9674. * Gets the GPU frame time capture status
  9675. */
  9676. /**
  9677. * Enable or disable the GPU frame time capture
  9678. */
  9679. captureGPUFrameTime: boolean;
  9680. /**
  9681. * Gets the perf counter used for shader compilation time
  9682. */
  9683. readonly shaderCompilationTimeCounter: PerfCounter;
  9684. /**
  9685. * Gets the shader compilation time capture status
  9686. */
  9687. /**
  9688. * Enable or disable the shader compilation time capture
  9689. */
  9690. captureShaderCompilationTime: boolean;
  9691. constructor(engine: Engine);
  9692. dispose(): void;
  9693. }
  9694. }
  9695. declare module BABYLON {
  9696. /**
  9697. * This class can be used to get instrumentation data from a Babylon engine
  9698. */
  9699. class SceneInstrumentation implements IDisposable {
  9700. scene: Scene;
  9701. private _captureActiveMeshesEvaluationTime;
  9702. private _activeMeshesEvaluationTime;
  9703. private _captureRenderTargetsRenderTime;
  9704. private _renderTargetsRenderTime;
  9705. private _captureFrameTime;
  9706. private _frameTime;
  9707. private _captureRenderTime;
  9708. private _renderTime;
  9709. private _captureInterFrameTime;
  9710. private _interFrameTime;
  9711. private _captureParticlesRenderTime;
  9712. private _particlesRenderTime;
  9713. private _captureSpritesRenderTime;
  9714. private _spritesRenderTime;
  9715. private _capturePhysicsTime;
  9716. private _physicsTime;
  9717. private _captureAnimationsTime;
  9718. private _animationsTime;
  9719. private _onBeforeActiveMeshesEvaluationObserver;
  9720. private _onAfterActiveMeshesEvaluationObserver;
  9721. private _onBeforeRenderTargetsRenderObserver;
  9722. private _onAfterRenderTargetsRenderObserver;
  9723. private _onAfterRenderObserver;
  9724. private _onBeforeDrawPhaseObserver;
  9725. private _onAfterDrawPhaseObserver;
  9726. private _onBeforeAnimationsObserver;
  9727. private _onBeforeParticlesRenderingObserver;
  9728. private _onAfterParticlesRenderingObserver;
  9729. private _onBeforeSpritesRenderingObserver;
  9730. private _onAfterSpritesRenderingObserver;
  9731. private _onBeforePhysicsObserver;
  9732. private _onAfterPhysicsObserver;
  9733. private _onAfterAnimationsObserver;
  9734. /**
  9735. * Gets the perf counter used for active meshes evaluation time
  9736. */
  9737. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9738. /**
  9739. * Gets the active meshes evaluation time capture status
  9740. */
  9741. /**
  9742. * Enable or disable the active meshes evaluation time capture
  9743. */
  9744. captureActiveMeshesEvaluationTime: boolean;
  9745. /**
  9746. * Gets the perf counter used for render targets render time
  9747. */
  9748. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9749. /**
  9750. * Gets the render targets render time capture status
  9751. */
  9752. /**
  9753. * Enable or disable the render targets render time capture
  9754. */
  9755. captureRenderTargetsRenderTime: boolean;
  9756. /**
  9757. * Gets the perf counter used for particles render time
  9758. */
  9759. readonly particlesRenderTimeCounter: PerfCounter;
  9760. /**
  9761. * Gets the particles render time capture status
  9762. */
  9763. /**
  9764. * Enable or disable the particles render time capture
  9765. */
  9766. captureParticlesRenderTime: boolean;
  9767. /**
  9768. * Gets the perf counter used for sprites render time
  9769. */
  9770. readonly spritesRenderTimeCounter: PerfCounter;
  9771. /**
  9772. * Gets the sprites render time capture status
  9773. */
  9774. /**
  9775. * Enable or disable the sprites render time capture
  9776. */
  9777. captureSpritesRenderTime: boolean;
  9778. /**
  9779. * Gets the perf counter used for physics time
  9780. */
  9781. readonly physicsTimeCounter: PerfCounter;
  9782. /**
  9783. * Gets the physics time capture status
  9784. */
  9785. /**
  9786. * Enable or disable the physics time capture
  9787. */
  9788. capturePhysicsTime: boolean;
  9789. /**
  9790. * Gets the perf counter used for animations time
  9791. */
  9792. readonly animationsTimeCounter: PerfCounter;
  9793. /**
  9794. * Gets the animations time capture status
  9795. */
  9796. /**
  9797. * Enable or disable the animations time capture
  9798. */
  9799. captureAnimationsTime: boolean;
  9800. /**
  9801. * Gets the perf counter used for frame time capture
  9802. */
  9803. readonly frameTimeCounter: PerfCounter;
  9804. /**
  9805. * Gets the frame time capture status
  9806. */
  9807. /**
  9808. * Enable or disable the frame time capture
  9809. */
  9810. captureFrameTime: boolean;
  9811. /**
  9812. * Gets the perf counter used for inter-frames time capture
  9813. */
  9814. readonly interFrameTimeCounter: PerfCounter;
  9815. /**
  9816. * Gets the inter-frames time capture status
  9817. */
  9818. /**
  9819. * Enable or disable the inter-frames time capture
  9820. */
  9821. captureInterFrameTime: boolean;
  9822. /**
  9823. * Gets the perf counter used for render time capture
  9824. */
  9825. readonly renderTimeCounter: PerfCounter;
  9826. /**
  9827. * Gets the render time capture status
  9828. */
  9829. /**
  9830. * Enable or disable the render time capture
  9831. */
  9832. captureRenderTime: boolean;
  9833. /**
  9834. * Gets the perf counter used for draw calls
  9835. */
  9836. readonly drawCallsCounter: PerfCounter;
  9837. /**
  9838. * Gets the perf counter used for texture collisions
  9839. */
  9840. readonly textureCollisionsCounter: PerfCounter;
  9841. constructor(scene: Scene);
  9842. dispose(): void;
  9843. }
  9844. }
  9845. declare module BABYLON {
  9846. /**
  9847. * @hidden
  9848. **/
  9849. class _TimeToken {
  9850. _startTimeQuery: Nullable<WebGLQuery>;
  9851. _endTimeQuery: Nullable<WebGLQuery>;
  9852. _timeElapsedQuery: Nullable<WebGLQuery>;
  9853. _timeElapsedQueryEnded: boolean;
  9854. }
  9855. }
  9856. declare module BABYLON {
  9857. /**
  9858. * Effect layer options. This helps customizing the behaviour
  9859. * of the effect layer.
  9860. */
  9861. interface IEffectLayerOptions {
  9862. /**
  9863. * Multiplication factor apply to the canvas size to compute the render target size
  9864. * used to generated the objects (the smaller the faster).
  9865. */
  9866. mainTextureRatio: number;
  9867. /**
  9868. * Enforces a fixed size texture to ensure effect stability across devices.
  9869. */
  9870. mainTextureFixedSize?: number;
  9871. /**
  9872. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  9873. */
  9874. alphaBlendingMode: number;
  9875. /**
  9876. * The camera attached to the layer.
  9877. */
  9878. camera: Nullable<Camera>;
  9879. }
  9880. /**
  9881. * The effect layer Helps adding post process effect blended with the main pass.
  9882. *
  9883. * This can be for instance use to generate glow or higlight effects on the scene.
  9884. *
  9885. * The effect layer class can not be used directly and is intented to inherited from to be
  9886. * customized per effects.
  9887. */
  9888. abstract class EffectLayer {
  9889. private _vertexBuffers;
  9890. private _indexBuffer;
  9891. private _cachedDefines;
  9892. private _effectLayerMapGenerationEffect;
  9893. private _effectLayerOptions;
  9894. private _mergeEffect;
  9895. protected _scene: Scene;
  9896. protected _engine: Engine;
  9897. protected _maxSize: number;
  9898. protected _mainTextureDesiredSize: ISize;
  9899. protected _mainTexture: RenderTargetTexture;
  9900. protected _shouldRender: boolean;
  9901. protected _postProcesses: PostProcess[];
  9902. protected _textures: BaseTexture[];
  9903. protected _emissiveTextureAndColor: {
  9904. texture: Nullable<BaseTexture>;
  9905. color: Color4;
  9906. };
  9907. /**
  9908. * The name of the layer
  9909. */
  9910. name: string;
  9911. /**
  9912. * The clear color of the texture used to generate the glow map.
  9913. */
  9914. neutralColor: Color4;
  9915. /**
  9916. * Specifies wether the highlight layer is enabled or not.
  9917. */
  9918. isEnabled: boolean;
  9919. /**
  9920. * Gets the camera attached to the layer.
  9921. */
  9922. readonly camera: Nullable<Camera>;
  9923. /**
  9924. * An event triggered when the effect layer has been disposed.
  9925. */
  9926. onDisposeObservable: Observable<EffectLayer>;
  9927. /**
  9928. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  9929. */
  9930. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  9931. /**
  9932. * An event triggered when the generated texture is being merged in the scene.
  9933. */
  9934. onBeforeComposeObservable: Observable<EffectLayer>;
  9935. /**
  9936. * An event triggered when the generated texture has been merged in the scene.
  9937. */
  9938. onAfterComposeObservable: Observable<EffectLayer>;
  9939. /**
  9940. * An event triggered when the efffect layer changes its size.
  9941. */
  9942. onSizeChangedObservable: Observable<EffectLayer>;
  9943. /**
  9944. * Instantiates a new effect Layer and references it in the scene.
  9945. * @param name The name of the layer
  9946. * @param scene The scene to use the layer in
  9947. */
  9948. constructor(
  9949. /** The Friendly of the effect in the scene */
  9950. name: string, scene: Scene);
  9951. /**
  9952. * Get the effect name of the layer.
  9953. * @return The effect name
  9954. */
  9955. abstract getEffectName(): string;
  9956. /**
  9957. * Checks for the readiness of the element composing the layer.
  9958. * @param subMesh the mesh to check for
  9959. * @param useInstances specify wether or not to use instances to render the mesh
  9960. * @return true if ready otherwise, false
  9961. */
  9962. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9963. /**
  9964. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9965. * @returns true if the effect requires stencil during the main canvas render pass.
  9966. */
  9967. abstract needStencil(): boolean;
  9968. /**
  9969. * Create the merge effect. This is the shader use to blit the information back
  9970. * to the main canvas at the end of the scene rendering.
  9971. * @returns The effect containing the shader used to merge the effect on the main canvas
  9972. */
  9973. protected abstract _createMergeEffect(): Effect;
  9974. /**
  9975. * Creates the render target textures and post processes used in the effect layer.
  9976. */
  9977. protected abstract _createTextureAndPostProcesses(): void;
  9978. /**
  9979. * Implementation specific of rendering the generating effect on the main canvas.
  9980. * @param effect The effect used to render through
  9981. */
  9982. protected abstract _internalRender(effect: Effect): void;
  9983. /**
  9984. * Sets the required values for both the emissive texture and and the main color.
  9985. */
  9986. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9987. /**
  9988. * Free any resources and references associated to a mesh.
  9989. * Internal use
  9990. * @param mesh The mesh to free.
  9991. */
  9992. abstract _disposeMesh(mesh: Mesh): void;
  9993. /**
  9994. * Serializes this layer (Glow or Highlight for example)
  9995. * @returns a serialized layer object
  9996. */
  9997. abstract serialize?(): any;
  9998. /**
  9999. * Initializes the effect layer with the required options.
  10000. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10001. */
  10002. protected _init(options: Partial<IEffectLayerOptions>): void;
  10003. /**
  10004. * Generates the index buffer of the full screen quad blending to the main canvas.
  10005. */
  10006. private _generateIndexBuffer();
  10007. /**
  10008. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10009. */
  10010. private _genrateVertexBuffer();
  10011. /**
  10012. * Sets the main texture desired size which is the closest power of two
  10013. * of the engine canvas size.
  10014. */
  10015. private _setMainTextureSize();
  10016. /**
  10017. * Creates the main texture for the effect layer.
  10018. */
  10019. protected _createMainTexture(): void;
  10020. /**
  10021. * Checks for the readiness of the element composing the layer.
  10022. * @param subMesh the mesh to check for
  10023. * @param useInstances specify wether or not to use instances to render the mesh
  10024. * @param emissiveTexture the associated emissive texture used to generate the glow
  10025. * @return true if ready otherwise, false
  10026. */
  10027. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10028. /**
  10029. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10030. */
  10031. render(): void;
  10032. /**
  10033. * Determine if a given mesh will be used in the current effect.
  10034. * @param mesh mesh to test
  10035. * @returns true if the mesh will be used
  10036. */
  10037. hasMesh(mesh: AbstractMesh): boolean;
  10038. /**
  10039. * Returns true if the layer contains information to display, otherwise false.
  10040. * @returns true if the glow layer should be rendered
  10041. */
  10042. shouldRender(): boolean;
  10043. /**
  10044. * Returns true if the mesh should render, otherwise false.
  10045. * @param mesh The mesh to render
  10046. * @returns true if it should render otherwise false
  10047. */
  10048. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10049. /**
  10050. * Returns true if the mesh should render, otherwise false.
  10051. * @param mesh The mesh to render
  10052. * @returns true if it should render otherwise false
  10053. */
  10054. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10055. /**
  10056. * Renders the submesh passed in parameter to the generation map.
  10057. */
  10058. protected _renderSubMesh(subMesh: SubMesh): void;
  10059. /**
  10060. * Rebuild the required buffers.
  10061. * @hidden Internal use only.
  10062. */
  10063. _rebuild(): void;
  10064. /**
  10065. * Dispose only the render target textures and post process.
  10066. */
  10067. private _disposeTextureAndPostProcesses();
  10068. /**
  10069. * Dispose the highlight layer and free resources.
  10070. */
  10071. dispose(): void;
  10072. /**
  10073. * Gets the class name of the effect layer
  10074. * @returns the string with the class name of the effect layer
  10075. */
  10076. getClassName(): string;
  10077. /**
  10078. * Creates an effect layer from parsed effect layer data
  10079. * @param parsedEffectLayer defines effect layer data
  10080. * @param scene defines the current scene
  10081. * @param rootUrl defines the root URL containing the effect layer information
  10082. * @returns a parsed effect Layer
  10083. */
  10084. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10085. }
  10086. }
  10087. declare module BABYLON {
  10088. /**
  10089. * Glow layer options. This helps customizing the behaviour
  10090. * of the glow layer.
  10091. */
  10092. interface IGlowLayerOptions {
  10093. /**
  10094. * Multiplication factor apply to the canvas size to compute the render target size
  10095. * used to generated the glowing objects (the smaller the faster).
  10096. */
  10097. mainTextureRatio: number;
  10098. /**
  10099. * Enforces a fixed size texture to ensure resize independant blur.
  10100. */
  10101. mainTextureFixedSize?: number;
  10102. /**
  10103. * How big is the kernel of the blur texture.
  10104. */
  10105. blurKernelSize: number;
  10106. /**
  10107. * The camera attached to the layer.
  10108. */
  10109. camera: Nullable<Camera>;
  10110. /**
  10111. * Enable MSAA by chosing the number of samples.
  10112. */
  10113. mainTextureSamples?: number;
  10114. }
  10115. /**
  10116. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10117. *
  10118. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10119. * glowy meshes to your scene.
  10120. *
  10121. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10122. */
  10123. class GlowLayer extends EffectLayer {
  10124. /**
  10125. * Effect Name of the layer.
  10126. */
  10127. static readonly EffectName: string;
  10128. /**
  10129. * The default blur kernel size used for the glow.
  10130. */
  10131. static DefaultBlurKernelSize: number;
  10132. /**
  10133. * The default texture size ratio used for the glow.
  10134. */
  10135. static DefaultTextureRatio: number;
  10136. /**
  10137. * Gets the kernel size of the blur.
  10138. */
  10139. /**
  10140. * Sets the kernel size of the blur.
  10141. */
  10142. blurKernelSize: number;
  10143. /**
  10144. * Gets the glow intensity.
  10145. */
  10146. /**
  10147. * Sets the glow intensity.
  10148. */
  10149. intensity: number;
  10150. private _options;
  10151. private _intensity;
  10152. private _horizontalBlurPostprocess1;
  10153. private _verticalBlurPostprocess1;
  10154. private _horizontalBlurPostprocess2;
  10155. private _verticalBlurPostprocess2;
  10156. private _blurTexture1;
  10157. private _blurTexture2;
  10158. private _postProcesses1;
  10159. private _postProcesses2;
  10160. private _includedOnlyMeshes;
  10161. private _excludedMeshes;
  10162. /**
  10163. * Callback used to let the user override the color selection on a per mesh basis
  10164. */
  10165. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10166. /**
  10167. * Callback used to let the user override the texture selection on a per mesh basis
  10168. */
  10169. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10170. /**
  10171. * Instantiates a new glow Layer and references it to the scene.
  10172. * @param name The name of the layer
  10173. * @param scene The scene to use the layer in
  10174. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10175. */
  10176. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10177. /**
  10178. * Get the effect name of the layer.
  10179. * @return The effect name
  10180. */
  10181. getEffectName(): string;
  10182. /**
  10183. * Create the merge effect. This is the shader use to blit the information back
  10184. * to the main canvas at the end of the scene rendering.
  10185. */
  10186. protected _createMergeEffect(): Effect;
  10187. /**
  10188. * Creates the render target textures and post processes used in the glow layer.
  10189. */
  10190. protected _createTextureAndPostProcesses(): void;
  10191. /**
  10192. * Checks for the readiness of the element composing the layer.
  10193. * @param subMesh the mesh to check for
  10194. * @param useInstances specify wether or not to use instances to render the mesh
  10195. * @param emissiveTexture the associated emissive texture used to generate the glow
  10196. * @return true if ready otherwise, false
  10197. */
  10198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10199. /**
  10200. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10201. */
  10202. needStencil(): boolean;
  10203. /**
  10204. * Implementation specific of rendering the generating effect on the main canvas.
  10205. * @param effect The effect used to render through
  10206. */
  10207. protected _internalRender(effect: Effect): void;
  10208. /**
  10209. * Sets the required values for both the emissive texture and and the main color.
  10210. */
  10211. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10212. /**
  10213. * Returns true if the mesh should render, otherwise false.
  10214. * @param mesh The mesh to render
  10215. * @returns true if it should render otherwise false
  10216. */
  10217. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10218. /**
  10219. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10220. * @param mesh The mesh to exclude from the glow layer
  10221. */
  10222. addExcludedMesh(mesh: Mesh): void;
  10223. /**
  10224. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10225. * @param mesh The mesh to remove
  10226. */
  10227. removeExcludedMesh(mesh: Mesh): void;
  10228. /**
  10229. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10230. * @param mesh The mesh to include in the glow layer
  10231. */
  10232. addIncludedOnlyMesh(mesh: Mesh): void;
  10233. /**
  10234. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10235. * @param mesh The mesh to remove
  10236. */
  10237. removeIncludedOnlyMesh(mesh: Mesh): void;
  10238. /**
  10239. * Determine if a given mesh will be used in the glow layer
  10240. * @param mesh The mesh to test
  10241. * @returns true if the mesh will be highlighted by the current glow layer
  10242. */
  10243. hasMesh(mesh: AbstractMesh): boolean;
  10244. /**
  10245. * Free any resources and references associated to a mesh.
  10246. * Internal use
  10247. * @param mesh The mesh to free.
  10248. */
  10249. _disposeMesh(mesh: Mesh): void;
  10250. /**
  10251. * Gets the class name of the effect layer
  10252. * @returns the string with the class name of the effect layer
  10253. */
  10254. getClassName(): string;
  10255. /**
  10256. * Serializes this glow layer
  10257. * @returns a serialized glow layer object
  10258. */
  10259. serialize(): any;
  10260. /**
  10261. * Creates a Glow Layer from parsed glow layer data
  10262. * @param parsedGlowLayer defines glow layer data
  10263. * @param scene defines the current scene
  10264. * @param rootUrl defines the root URL containing the glow layer information
  10265. * @returns a parsed Glow Layer
  10266. */
  10267. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10268. }
  10269. }
  10270. declare module BABYLON {
  10271. /**
  10272. * Highlight layer options. This helps customizing the behaviour
  10273. * of the highlight layer.
  10274. */
  10275. interface IHighlightLayerOptions {
  10276. /**
  10277. * Multiplication factor apply to the canvas size to compute the render target size
  10278. * used to generated the glowing objects (the smaller the faster).
  10279. */
  10280. mainTextureRatio: number;
  10281. /**
  10282. * Enforces a fixed size texture to ensure resize independant blur.
  10283. */
  10284. mainTextureFixedSize?: number;
  10285. /**
  10286. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10287. * of the picture to blur (the smaller the faster).
  10288. */
  10289. blurTextureSizeRatio: number;
  10290. /**
  10291. * How big in texel of the blur texture is the vertical blur.
  10292. */
  10293. blurVerticalSize: number;
  10294. /**
  10295. * How big in texel of the blur texture is the horizontal blur.
  10296. */
  10297. blurHorizontalSize: number;
  10298. /**
  10299. * Alpha blending mode used to apply the blur. Default is combine.
  10300. */
  10301. alphaBlendingMode: number;
  10302. /**
  10303. * The camera attached to the layer.
  10304. */
  10305. camera: Nullable<Camera>;
  10306. /**
  10307. * Should we display highlight as a solid stroke?
  10308. */
  10309. isStroke?: boolean;
  10310. }
  10311. /**
  10312. * The highlight layer Helps adding a glow effect around a mesh.
  10313. *
  10314. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10315. * glowy meshes to your scene.
  10316. *
  10317. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10318. */
  10319. class HighlightLayer extends EffectLayer {
  10320. name: string;
  10321. /**
  10322. * Effect Name of the highlight layer.
  10323. */
  10324. static readonly EffectName: string;
  10325. /**
  10326. * The neutral color used during the preparation of the glow effect.
  10327. * This is black by default as the blend operation is a blend operation.
  10328. */
  10329. static NeutralColor: Color4;
  10330. /**
  10331. * Stencil value used for glowing meshes.
  10332. */
  10333. static GlowingMeshStencilReference: number;
  10334. /**
  10335. * Stencil value used for the other meshes in the scene.
  10336. */
  10337. static NormalMeshStencilReference: number;
  10338. /**
  10339. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10340. */
  10341. innerGlow: boolean;
  10342. /**
  10343. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10344. */
  10345. outerGlow: boolean;
  10346. /**
  10347. * Gets the horizontal size of the blur.
  10348. */
  10349. /**
  10350. * Specifies the horizontal size of the blur.
  10351. */
  10352. blurHorizontalSize: number;
  10353. /**
  10354. * Gets the vertical size of the blur.
  10355. */
  10356. /**
  10357. * Specifies the vertical size of the blur.
  10358. */
  10359. blurVerticalSize: number;
  10360. /**
  10361. * An event triggered when the highlight layer is being blurred.
  10362. */
  10363. onBeforeBlurObservable: Observable<HighlightLayer>;
  10364. /**
  10365. * An event triggered when the highlight layer has been blurred.
  10366. */
  10367. onAfterBlurObservable: Observable<HighlightLayer>;
  10368. private _instanceGlowingMeshStencilReference;
  10369. private _options;
  10370. private _downSamplePostprocess;
  10371. private _horizontalBlurPostprocess;
  10372. private _verticalBlurPostprocess;
  10373. private _blurTexture;
  10374. private _meshes;
  10375. private _excludedMeshes;
  10376. /**
  10377. * Instantiates a new highlight Layer and references it to the scene..
  10378. * @param name The name of the layer
  10379. * @param scene The scene to use the layer in
  10380. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10381. */
  10382. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10383. /**
  10384. * Get the effect name of the layer.
  10385. * @return The effect name
  10386. */
  10387. getEffectName(): string;
  10388. /**
  10389. * Create the merge effect. This is the shader use to blit the information back
  10390. * to the main canvas at the end of the scene rendering.
  10391. */
  10392. protected _createMergeEffect(): Effect;
  10393. /**
  10394. * Creates the render target textures and post processes used in the highlight layer.
  10395. */
  10396. protected _createTextureAndPostProcesses(): void;
  10397. /**
  10398. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10399. */
  10400. needStencil(): boolean;
  10401. /**
  10402. * Checks for the readiness of the element composing the layer.
  10403. * @param subMesh the mesh to check for
  10404. * @param useInstances specify wether or not to use instances to render the mesh
  10405. * @param emissiveTexture the associated emissive texture used to generate the glow
  10406. * @return true if ready otherwise, false
  10407. */
  10408. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10409. /**
  10410. * Implementation specific of rendering the generating effect on the main canvas.
  10411. * @param effect The effect used to render through
  10412. */
  10413. protected _internalRender(effect: Effect): void;
  10414. /**
  10415. * Returns true if the layer contains information to display, otherwise false.
  10416. */
  10417. shouldRender(): boolean;
  10418. /**
  10419. * Returns true if the mesh should render, otherwise false.
  10420. * @param mesh The mesh to render
  10421. * @returns true if it should render otherwise false
  10422. */
  10423. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10424. /**
  10425. * Sets the required values for both the emissive texture and and the main color.
  10426. */
  10427. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10428. /**
  10429. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10430. * @param mesh The mesh to exclude from the highlight layer
  10431. */
  10432. addExcludedMesh(mesh: Mesh): void;
  10433. /**
  10434. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10435. * @param mesh The mesh to highlight
  10436. */
  10437. removeExcludedMesh(mesh: Mesh): void;
  10438. /**
  10439. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10440. * @param mesh mesh to test
  10441. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10442. */
  10443. hasMesh(mesh: AbstractMesh): boolean;
  10444. /**
  10445. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10446. * @param mesh The mesh to highlight
  10447. * @param color The color of the highlight
  10448. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10449. */
  10450. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10451. /**
  10452. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10453. * @param mesh The mesh to highlight
  10454. */
  10455. removeMesh(mesh: Mesh): void;
  10456. /**
  10457. * Force the stencil to the normal expected value for none glowing parts
  10458. */
  10459. private _defaultStencilReference(mesh);
  10460. /**
  10461. * Free any resources and references associated to a mesh.
  10462. * Internal use
  10463. * @param mesh The mesh to free.
  10464. */
  10465. _disposeMesh(mesh: Mesh): void;
  10466. /**
  10467. * Dispose the highlight layer and free resources.
  10468. */
  10469. dispose(): void;
  10470. /**
  10471. * Gets the class name of the effect layer
  10472. * @returns the string with the class name of the effect layer
  10473. */
  10474. getClassName(): string;
  10475. /**
  10476. * Serializes this Highlight layer
  10477. * @returns a serialized Highlight layer object
  10478. */
  10479. serialize(): any;
  10480. /**
  10481. * Creates a Highlight layer from parsed Highlight layer data
  10482. * @param parsedHightlightLayer defines the Highlight layer data
  10483. * @param scene defines the current scene
  10484. * @param rootUrl defines the root URL containing the Highlight layer information
  10485. * @returns a parsed Highlight layer
  10486. */
  10487. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10488. }
  10489. }
  10490. declare module BABYLON {
  10491. class Layer {
  10492. name: string;
  10493. texture: Nullable<Texture>;
  10494. isBackground: boolean;
  10495. color: Color4;
  10496. scale: Vector2;
  10497. offset: Vector2;
  10498. alphaBlendingMode: number;
  10499. alphaTest: boolean;
  10500. layerMask: number;
  10501. private _scene;
  10502. private _vertexBuffers;
  10503. private _indexBuffer;
  10504. private _effect;
  10505. private _alphaTestEffect;
  10506. /**
  10507. * An event triggered when the layer is disposed.
  10508. */
  10509. onDisposeObservable: Observable<Layer>;
  10510. private _onDisposeObserver;
  10511. onDispose: () => void;
  10512. /**
  10513. * An event triggered before rendering the scene
  10514. */
  10515. onBeforeRenderObservable: Observable<Layer>;
  10516. private _onBeforeRenderObserver;
  10517. onBeforeRender: () => void;
  10518. /**
  10519. * An event triggered after rendering the scene
  10520. */
  10521. onAfterRenderObservable: Observable<Layer>;
  10522. private _onAfterRenderObserver;
  10523. onAfterRender: () => void;
  10524. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10525. private _createIndexBuffer();
  10526. _rebuild(): void;
  10527. render(): void;
  10528. dispose(): void;
  10529. }
  10530. }
  10531. declare module BABYLON {
  10532. class LensFlare {
  10533. size: number;
  10534. position: number;
  10535. color: Color3;
  10536. texture: Nullable<Texture>;
  10537. alphaMode: number;
  10538. private _system;
  10539. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10540. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10541. dispose(): void;
  10542. }
  10543. }
  10544. declare module BABYLON {
  10545. class LensFlareSystem {
  10546. name: string;
  10547. lensFlares: LensFlare[];
  10548. borderLimit: number;
  10549. viewportBorder: number;
  10550. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10551. layerMask: number;
  10552. id: string;
  10553. private _scene;
  10554. private _emitter;
  10555. private _vertexBuffers;
  10556. private _indexBuffer;
  10557. private _effect;
  10558. private _positionX;
  10559. private _positionY;
  10560. private _isEnabled;
  10561. constructor(name: string, emitter: any, scene: Scene);
  10562. isEnabled: boolean;
  10563. getScene(): Scene;
  10564. getEmitter(): any;
  10565. setEmitter(newEmitter: any): void;
  10566. getEmitterPosition(): Vector3;
  10567. computeEffectivePosition(globalViewport: Viewport): boolean;
  10568. _isVisible(): boolean;
  10569. render(): boolean;
  10570. dispose(): void;
  10571. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10572. serialize(): any;
  10573. }
  10574. }
  10575. declare module BABYLON {
  10576. /**
  10577. * A directional light is defined by a direction (what a surprise!).
  10578. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10579. * 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.
  10580. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10581. */
  10582. class DirectionalLight extends ShadowLight {
  10583. private _shadowFrustumSize;
  10584. /**
  10585. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10586. */
  10587. /**
  10588. * Specifies a fix frustum size for the shadow generation.
  10589. */
  10590. shadowFrustumSize: number;
  10591. private _shadowOrthoScale;
  10592. /**
  10593. * Gets the shadow projection scale against the optimal computed one.
  10594. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10595. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10596. */
  10597. /**
  10598. * Sets the shadow projection scale against the optimal computed one.
  10599. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10600. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10601. */
  10602. shadowOrthoScale: number;
  10603. /**
  10604. * Automatically compute the projection matrix to best fit (including all the casters)
  10605. * on each frame.
  10606. */
  10607. autoUpdateExtends: boolean;
  10608. private _orthoLeft;
  10609. private _orthoRight;
  10610. private _orthoTop;
  10611. private _orthoBottom;
  10612. /**
  10613. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10614. * The directional light is emitted from everywhere in the given direction.
  10615. * It can cast shawdows.
  10616. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10617. * @param name The friendly name of the light
  10618. * @param direction The direction of the light
  10619. * @param scene The scene the light belongs to
  10620. */
  10621. constructor(name: string, direction: Vector3, scene: Scene);
  10622. /**
  10623. * Returns the string "DirectionalLight".
  10624. * @return The class name
  10625. */
  10626. getClassName(): string;
  10627. /**
  10628. * Returns the integer 1.
  10629. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10630. */
  10631. getTypeID(): number;
  10632. /**
  10633. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10634. * Returns the DirectionalLight Shadow projection matrix.
  10635. */
  10636. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10637. /**
  10638. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10639. * Returns the DirectionalLight Shadow projection matrix.
  10640. */
  10641. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10642. /**
  10643. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10644. * Returns the DirectionalLight Shadow projection matrix.
  10645. */
  10646. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10647. protected _buildUniformLayout(): void;
  10648. /**
  10649. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10650. * @param effect The effect to update
  10651. * @param lightIndex The index of the light in the effect to update
  10652. * @returns The directional light
  10653. */
  10654. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10655. /**
  10656. * Gets the minZ used for shadow according to both the scene and the light.
  10657. *
  10658. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10659. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10660. * @param activeCamera The camera we are returning the min for
  10661. * @returns the depth min z
  10662. */
  10663. getDepthMinZ(activeCamera: Camera): number;
  10664. /**
  10665. * Gets the maxZ used for shadow according to both the scene and the light.
  10666. *
  10667. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10668. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10669. * @param activeCamera The camera we are returning the max for
  10670. * @returns the depth max z
  10671. */
  10672. getDepthMaxZ(activeCamera: Camera): number;
  10673. }
  10674. }
  10675. declare module BABYLON {
  10676. /**
  10677. * The HemisphericLight simulates the ambient environment light,
  10678. * so the passed direction is the light reflection direction, not the incoming direction.
  10679. */
  10680. class HemisphericLight extends Light {
  10681. /**
  10682. * The groundColor is the light in the opposite direction to the one specified during creation.
  10683. * 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.
  10684. */
  10685. groundColor: Color3;
  10686. /**
  10687. * The light reflection direction, not the incoming direction.
  10688. */
  10689. direction: Vector3;
  10690. private _worldMatrix;
  10691. /**
  10692. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10693. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10694. * The HemisphericLight can't cast shadows.
  10695. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10696. * @param name The friendly name of the light
  10697. * @param direction The direction of the light reflection
  10698. * @param scene The scene the light belongs to
  10699. */
  10700. constructor(name: string, direction: Vector3, scene: Scene);
  10701. protected _buildUniformLayout(): void;
  10702. /**
  10703. * Returns the string "HemisphericLight".
  10704. * @return The class name
  10705. */
  10706. getClassName(): string;
  10707. /**
  10708. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10709. * Returns the updated direction.
  10710. * @param target The target the direction should point to
  10711. * @return The computed direction
  10712. */
  10713. setDirectionToTarget(target: Vector3): Vector3;
  10714. /**
  10715. * Returns the shadow generator associated to the light.
  10716. * @returns Always null for hemispheric lights because it does not support shadows.
  10717. */
  10718. getShadowGenerator(): Nullable<ShadowGenerator>;
  10719. /**
  10720. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10721. * @param effect The effect to update
  10722. * @param lightIndex The index of the light in the effect to update
  10723. * @returns The hemispheric light
  10724. */
  10725. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10726. /**
  10727. * @hidden internal use only.
  10728. */
  10729. _getWorldMatrix(): Matrix;
  10730. /**
  10731. * Returns the integer 3.
  10732. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10733. */
  10734. getTypeID(): number;
  10735. }
  10736. }
  10737. declare module BABYLON {
  10738. /**
  10739. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10740. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10741. * 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.
  10742. */
  10743. abstract class Light extends Node {
  10744. private static _LIGHTMAP_DEFAULT;
  10745. private static _LIGHTMAP_SPECULAR;
  10746. private static _LIGHTMAP_SHADOWSONLY;
  10747. /**
  10748. * If every light affecting the material is in this lightmapMode,
  10749. * material.lightmapTexture adds or multiplies
  10750. * (depends on material.useLightmapAsShadowmap)
  10751. * after every other light calculations.
  10752. */
  10753. static readonly LIGHTMAP_DEFAULT: number;
  10754. /**
  10755. * material.lightmapTexture as only diffuse lighting from this light
  10756. * adds only specular lighting from this light
  10757. * adds dynamic shadows
  10758. */
  10759. static readonly LIGHTMAP_SPECULAR: number;
  10760. /**
  10761. * material.lightmapTexture as only lighting
  10762. * no light calculation from this light
  10763. * only adds dynamic shadows from this light
  10764. */
  10765. static readonly LIGHTMAP_SHADOWSONLY: number;
  10766. private static _INTENSITYMODE_AUTOMATIC;
  10767. private static _INTENSITYMODE_LUMINOUSPOWER;
  10768. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  10769. private static _INTENSITYMODE_ILLUMINANCE;
  10770. private static _INTENSITYMODE_LUMINANCE;
  10771. /**
  10772. * Each light type uses the default quantity according to its type:
  10773. * point/spot lights use luminous intensity
  10774. * directional lights use illuminance
  10775. */
  10776. static readonly INTENSITYMODE_AUTOMATIC: number;
  10777. /**
  10778. * lumen (lm)
  10779. */
  10780. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10781. /**
  10782. * candela (lm/sr)
  10783. */
  10784. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10785. /**
  10786. * lux (lm/m^2)
  10787. */
  10788. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10789. /**
  10790. * nit (cd/m^2)
  10791. */
  10792. static readonly INTENSITYMODE_LUMINANCE: number;
  10793. private static _LIGHTTYPEID_POINTLIGHT;
  10794. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  10795. private static _LIGHTTYPEID_SPOTLIGHT;
  10796. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  10797. /**
  10798. * Light type const id of the point light.
  10799. */
  10800. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10801. /**
  10802. * Light type const id of the directional light.
  10803. */
  10804. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10805. /**
  10806. * Light type const id of the spot light.
  10807. */
  10808. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10809. /**
  10810. * Light type const id of the hemispheric light.
  10811. */
  10812. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10813. /**
  10814. * Diffuse gives the basic color to an object.
  10815. */
  10816. diffuse: Color3;
  10817. /**
  10818. * Specular produces a highlight color on an object.
  10819. * Note: This is note affecting PBR materials.
  10820. */
  10821. specular: Color3;
  10822. /**
  10823. * Strength of the light.
  10824. * Note: By default it is define in the framework own unit.
  10825. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10826. */
  10827. intensity: number;
  10828. /**
  10829. * Defines how far from the source the light is impacting in scene units.
  10830. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10831. */
  10832. range: number;
  10833. /**
  10834. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10835. * of light.
  10836. */
  10837. private _photometricScale;
  10838. private _intensityMode;
  10839. /**
  10840. * Gets the photometric scale used to interpret the intensity.
  10841. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10842. */
  10843. /**
  10844. * Sets the photometric scale used to interpret the intensity.
  10845. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10846. */
  10847. intensityMode: number;
  10848. private _radius;
  10849. /**
  10850. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10851. */
  10852. /**
  10853. * sets the light radius used by PBR Materials to simulate soft area lights.
  10854. */
  10855. radius: number;
  10856. private _renderPriority;
  10857. /**
  10858. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10859. * exceeding the number allowed of the materials.
  10860. */
  10861. renderPriority: number;
  10862. /**
  10863. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10864. * the current shadow generator.
  10865. */
  10866. shadowEnabled: boolean;
  10867. private _includedOnlyMeshes;
  10868. /**
  10869. * Gets the only meshes impacted by this light.
  10870. */
  10871. /**
  10872. * Sets the only meshes impacted by this light.
  10873. */
  10874. includedOnlyMeshes: AbstractMesh[];
  10875. private _excludedMeshes;
  10876. /**
  10877. * Gets the meshes not impacted by this light.
  10878. */
  10879. /**
  10880. * Sets the meshes not impacted by this light.
  10881. */
  10882. excludedMeshes: AbstractMesh[];
  10883. private _excludeWithLayerMask;
  10884. /**
  10885. * Gets the layer id use to find what meshes are not impacted by the light.
  10886. * Inactive if 0
  10887. */
  10888. /**
  10889. * Sets the layer id use to find what meshes are not impacted by the light.
  10890. * Inactive if 0
  10891. */
  10892. excludeWithLayerMask: number;
  10893. private _includeOnlyWithLayerMask;
  10894. /**
  10895. * Gets the layer id use to find what meshes are impacted by the light.
  10896. * Inactive if 0
  10897. */
  10898. /**
  10899. * Sets the layer id use to find what meshes are impacted by the light.
  10900. * Inactive if 0
  10901. */
  10902. includeOnlyWithLayerMask: number;
  10903. private _lightmapMode;
  10904. /**
  10905. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10906. */
  10907. /**
  10908. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10909. */
  10910. lightmapMode: number;
  10911. private _parentedWorldMatrix;
  10912. /**
  10913. * Shadow generator associted to the light.
  10914. * Internal use only.
  10915. */
  10916. _shadowGenerator: Nullable<IShadowGenerator>;
  10917. /**
  10918. * @hidden Internal use only.
  10919. */
  10920. _excludedMeshesIds: string[];
  10921. /**
  10922. * @hidden Internal use only.
  10923. */
  10924. _includedOnlyMeshesIds: string[];
  10925. /**
  10926. * The current light unifom buffer.
  10927. * @hidden Internal use only.
  10928. */
  10929. _uniformBuffer: UniformBuffer;
  10930. /**
  10931. * Creates a Light object in the scene.
  10932. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10933. * @param name The firendly name of the light
  10934. * @param scene The scene the light belongs too
  10935. */
  10936. constructor(name: string, scene: Scene);
  10937. protected abstract _buildUniformLayout(): void;
  10938. /**
  10939. * Sets the passed Effect "effect" with the Light information.
  10940. * @param effect The effect to update
  10941. * @param lightIndex The index of the light in the effect to update
  10942. * @returns The light
  10943. */
  10944. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10945. /**
  10946. * @hidden internal use only.
  10947. */
  10948. abstract _getWorldMatrix(): Matrix;
  10949. /**
  10950. * Returns the string "Light".
  10951. * @returns the class name
  10952. */
  10953. getClassName(): string;
  10954. /**
  10955. * Converts the light information to a readable string for debug purpose.
  10956. * @param fullDetails Supports for multiple levels of logging within scene loading
  10957. * @returns the human readable light info
  10958. */
  10959. toString(fullDetails?: boolean): string;
  10960. /**
  10961. * Set the enabled state of this node.
  10962. * @param value - the new enabled state
  10963. */
  10964. setEnabled(value: boolean): void;
  10965. /**
  10966. * Returns the Light associated shadow generator if any.
  10967. * @return the associated shadow generator.
  10968. */
  10969. getShadowGenerator(): Nullable<IShadowGenerator>;
  10970. /**
  10971. * Returns a Vector3, the absolute light position in the World.
  10972. * @returns the world space position of the light
  10973. */
  10974. getAbsolutePosition(): Vector3;
  10975. /**
  10976. * Specifies if the light will affect the passed mesh.
  10977. * @param mesh The mesh to test against the light
  10978. * @return true the mesh is affected otherwise, false.
  10979. */
  10980. canAffectMesh(mesh: AbstractMesh): boolean;
  10981. /**
  10982. * Computes and Returns the light World matrix.
  10983. * @returns the world matrix
  10984. */
  10985. getWorldMatrix(): Matrix;
  10986. /**
  10987. * Sort function to order lights for rendering.
  10988. * @param a First Light object to compare to second.
  10989. * @param b Second Light object to compare first.
  10990. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10991. */
  10992. static CompareLightsPriority(a: Light, b: Light): number;
  10993. /**
  10994. * Releases resources associated with this node.
  10995. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10996. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10997. */
  10998. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10999. /**
  11000. * Returns the light type ID (integer).
  11001. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11002. */
  11003. getTypeID(): number;
  11004. /**
  11005. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11006. * @returns the scaled intensity in intensity mode unit
  11007. */
  11008. getScaledIntensity(): number;
  11009. /**
  11010. * Returns a new Light object, named "name", from the current one.
  11011. * @param name The name of the cloned light
  11012. * @returns the new created light
  11013. */
  11014. clone(name: string): Nullable<Light>;
  11015. /**
  11016. * Serializes the current light into a Serialization object.
  11017. * @returns the serialized object.
  11018. */
  11019. serialize(): any;
  11020. /**
  11021. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11022. * This new light is named "name" and added to the passed scene.
  11023. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11024. * @param name The friendly name of the light
  11025. * @param scene The scene the new light will belong to
  11026. * @returns the constructor function
  11027. */
  11028. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11029. /**
  11030. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11031. * @param parsedLight The JSON representation of the light
  11032. * @param scene The scene to create the parsed light in
  11033. * @returns the created light after parsing
  11034. */
  11035. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11036. private _hookArrayForExcluded(array);
  11037. private _hookArrayForIncludedOnly(array);
  11038. private _resyncMeshes();
  11039. /**
  11040. * Forces the meshes to update their light related information in their rendering used effects
  11041. * @hidden Internal Use Only
  11042. */
  11043. _markMeshesAsLightDirty(): void;
  11044. /**
  11045. * Recomputes the cached photometric scale if needed.
  11046. */
  11047. private _computePhotometricScale();
  11048. /**
  11049. * Returns the Photometric Scale according to the light type and intensity mode.
  11050. */
  11051. private _getPhotometricScale();
  11052. /**
  11053. * Reorder the light in the scene according to their defined priority.
  11054. * @hidden Internal Use Only
  11055. */
  11056. _reorderLightsInScene(): void;
  11057. }
  11058. }
  11059. declare module BABYLON {
  11060. /**
  11061. * A point light is a light defined by an unique point in world space.
  11062. * The light is emitted in every direction from this point.
  11063. * A good example of a point light is a standard light bulb.
  11064. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11065. */
  11066. class PointLight extends ShadowLight {
  11067. private _shadowAngle;
  11068. /**
  11069. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11070. * This specifies what angle the shadow will use to be created.
  11071. *
  11072. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11073. */
  11074. /**
  11075. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11076. * This specifies what angle the shadow will use to be created.
  11077. *
  11078. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11079. */
  11080. shadowAngle: number;
  11081. /**
  11082. * Gets the direction if it has been set.
  11083. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11084. */
  11085. /**
  11086. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11087. */
  11088. direction: Vector3;
  11089. /**
  11090. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11091. * A PointLight emits the light in every direction.
  11092. * It can cast shadows.
  11093. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11094. * ```javascript
  11095. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11096. * ```
  11097. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11098. * @param name The light friendly name
  11099. * @param position The position of the point light in the scene
  11100. * @param scene The scene the lights belongs to
  11101. */
  11102. constructor(name: string, position: Vector3, scene: Scene);
  11103. /**
  11104. * Returns the string "PointLight"
  11105. * @returns the class name
  11106. */
  11107. getClassName(): string;
  11108. /**
  11109. * Returns the integer 0.
  11110. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11111. */
  11112. getTypeID(): number;
  11113. /**
  11114. * Specifies wether or not the shadowmap should be a cube texture.
  11115. * @returns true if the shadowmap needs to be a cube texture.
  11116. */
  11117. needCube(): boolean;
  11118. /**
  11119. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11120. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11121. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11122. */
  11123. getShadowDirection(faceIndex?: number): Vector3;
  11124. /**
  11125. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11126. * - fov = PI / 2
  11127. * - aspect ratio : 1.0
  11128. * - z-near and far equal to the active camera minZ and maxZ.
  11129. * Returns the PointLight.
  11130. */
  11131. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11132. protected _buildUniformLayout(): void;
  11133. /**
  11134. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11135. * @param effect The effect to update
  11136. * @param lightIndex The index of the light in the effect to update
  11137. * @returns The point light
  11138. */
  11139. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11140. }
  11141. }
  11142. declare module BABYLON {
  11143. /**
  11144. * Interface describing all the common properties and methods a shadow light needs to implement.
  11145. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11146. * as well as binding the different shadow properties to the effects.
  11147. */
  11148. interface IShadowLight extends Light {
  11149. /**
  11150. * The light id in the scene (used in scene.findLighById for instance)
  11151. */
  11152. id: string;
  11153. /**
  11154. * The position the shdow will be casted from.
  11155. */
  11156. position: Vector3;
  11157. /**
  11158. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11159. */
  11160. direction: Vector3;
  11161. /**
  11162. * The transformed position. Position of the light in world space taking parenting in account.
  11163. */
  11164. transformedPosition: Vector3;
  11165. /**
  11166. * The transformed direction. Direction of the light in world space taking parenting in account.
  11167. */
  11168. transformedDirection: Vector3;
  11169. /**
  11170. * The friendly name of the light in the scene.
  11171. */
  11172. name: string;
  11173. /**
  11174. * Defines the shadow projection clipping minimum z value.
  11175. */
  11176. shadowMinZ: number;
  11177. /**
  11178. * Defines the shadow projection clipping maximum z value.
  11179. */
  11180. shadowMaxZ: number;
  11181. /**
  11182. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11183. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11184. */
  11185. computeTransformedInformation(): boolean;
  11186. /**
  11187. * Gets the scene the light belongs to.
  11188. * @returns The scene
  11189. */
  11190. getScene(): Scene;
  11191. /**
  11192. * Callback defining a custom Projection Matrix Builder.
  11193. * This can be used to override the default projection matrix computation.
  11194. */
  11195. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11196. /**
  11197. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11198. * @param matrix The materix to updated with the projection information
  11199. * @param viewMatrix The transform matrix of the light
  11200. * @param renderList The list of mesh to render in the map
  11201. * @returns The current light
  11202. */
  11203. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11204. /**
  11205. * Gets the current depth scale used in ESM.
  11206. * @returns The scale
  11207. */
  11208. getDepthScale(): number;
  11209. /**
  11210. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11211. * @returns true if a cube texture needs to be use
  11212. */
  11213. needCube(): boolean;
  11214. /**
  11215. * Detects if the projection matrix requires to be recomputed this frame.
  11216. * @returns true if it requires to be recomputed otherwise, false.
  11217. */
  11218. needProjectionMatrixCompute(): boolean;
  11219. /**
  11220. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11221. */
  11222. forceProjectionMatrixCompute(): void;
  11223. /**
  11224. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11225. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11226. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11227. */
  11228. getShadowDirection(faceIndex?: number): Vector3;
  11229. /**
  11230. * Gets the minZ used for shadow according to both the scene and the light.
  11231. * @param activeCamera The camera we are returning the min for
  11232. * @returns the depth min z
  11233. */
  11234. getDepthMinZ(activeCamera: Camera): number;
  11235. /**
  11236. * Gets the maxZ used for shadow according to both the scene and the light.
  11237. * @param activeCamera The camera we are returning the max for
  11238. * @returns the depth max z
  11239. */
  11240. getDepthMaxZ(activeCamera: Camera): number;
  11241. }
  11242. /**
  11243. * Base implementation IShadowLight
  11244. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11245. */
  11246. abstract class ShadowLight extends Light implements IShadowLight {
  11247. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11248. protected _position: Vector3;
  11249. protected _setPosition(value: Vector3): void;
  11250. /**
  11251. * Sets the position the shadow will be casted from. Also use as the light position for both
  11252. * point and spot lights.
  11253. */
  11254. /**
  11255. * Sets the position the shadow will be casted from. Also use as the light position for both
  11256. * point and spot lights.
  11257. */
  11258. position: Vector3;
  11259. protected _direction: Vector3;
  11260. protected _setDirection(value: Vector3): void;
  11261. /**
  11262. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11263. * Also use as the light direction on spot and directional lights.
  11264. */
  11265. /**
  11266. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11267. * Also use as the light direction on spot and directional lights.
  11268. */
  11269. direction: Vector3;
  11270. private _shadowMinZ;
  11271. /**
  11272. * Gets the shadow projection clipping minimum z value.
  11273. */
  11274. /**
  11275. * Sets the shadow projection clipping minimum z value.
  11276. */
  11277. shadowMinZ: number;
  11278. private _shadowMaxZ;
  11279. /**
  11280. * Sets the shadow projection clipping maximum z value.
  11281. */
  11282. /**
  11283. * Gets the shadow projection clipping maximum z value.
  11284. */
  11285. shadowMaxZ: number;
  11286. /**
  11287. * Callback defining a custom Projection Matrix Builder.
  11288. * This can be used to override the default projection matrix computation.
  11289. */
  11290. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11291. /**
  11292. * The transformed position. Position of the light in world space taking parenting in account.
  11293. */
  11294. transformedPosition: Vector3;
  11295. /**
  11296. * The transformed direction. Direction of the light in world space taking parenting in account.
  11297. */
  11298. transformedDirection: Vector3;
  11299. private _worldMatrix;
  11300. private _needProjectionMatrixCompute;
  11301. /**
  11302. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11303. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11304. */
  11305. computeTransformedInformation(): boolean;
  11306. /**
  11307. * Return the depth scale used for the shadow map.
  11308. * @returns the depth scale.
  11309. */
  11310. getDepthScale(): number;
  11311. /**
  11312. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11313. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11314. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11315. */
  11316. getShadowDirection(faceIndex?: number): Vector3;
  11317. /**
  11318. * Returns the ShadowLight absolute position in the World.
  11319. * @returns the position vector in world space
  11320. */
  11321. getAbsolutePosition(): Vector3;
  11322. /**
  11323. * Sets the ShadowLight direction toward the passed target.
  11324. * @param target The point tot target in local space
  11325. * @returns the updated ShadowLight direction
  11326. */
  11327. setDirectionToTarget(target: Vector3): Vector3;
  11328. /**
  11329. * Returns the light rotation in euler definition.
  11330. * @returns the x y z rotation in local space.
  11331. */
  11332. getRotation(): Vector3;
  11333. /**
  11334. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11335. * @returns true if a cube texture needs to be use
  11336. */
  11337. needCube(): boolean;
  11338. /**
  11339. * Detects if the projection matrix requires to be recomputed this frame.
  11340. * @returns true if it requires to be recomputed otherwise, false.
  11341. */
  11342. needProjectionMatrixCompute(): boolean;
  11343. /**
  11344. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11345. */
  11346. forceProjectionMatrixCompute(): void;
  11347. /**
  11348. * Get the world matrix of the sahdow lights.
  11349. * @hidden Internal Use Only
  11350. */
  11351. _getWorldMatrix(): Matrix;
  11352. /**
  11353. * Gets the minZ used for shadow according to both the scene and the light.
  11354. * @param activeCamera The camera we are returning the min for
  11355. * @returns the depth min z
  11356. */
  11357. getDepthMinZ(activeCamera: Camera): number;
  11358. /**
  11359. * Gets the maxZ used for shadow according to both the scene and the light.
  11360. * @param activeCamera The camera we are returning the max for
  11361. * @returns the depth max z
  11362. */
  11363. getDepthMaxZ(activeCamera: Camera): number;
  11364. /**
  11365. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11366. * @param matrix The materix to updated with the projection information
  11367. * @param viewMatrix The transform matrix of the light
  11368. * @param renderList The list of mesh to render in the map
  11369. * @returns The current light
  11370. */
  11371. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11372. }
  11373. }
  11374. declare module BABYLON {
  11375. /**
  11376. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11377. * These values define a cone of light starting from the position, emitting toward the direction.
  11378. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11379. * and the exponent defines the speed of the decay of the light with distance (reach).
  11380. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11381. */
  11382. class SpotLight extends ShadowLight {
  11383. private _angle;
  11384. /**
  11385. * Gets the cone angle of the spot light in Radians.
  11386. */
  11387. /**
  11388. * Sets the cone angle of the spot light in Radians.
  11389. */
  11390. angle: number;
  11391. private _shadowAngleScale;
  11392. /**
  11393. * Allows scaling the angle of the light for shadow generation only.
  11394. */
  11395. /**
  11396. * Allows scaling the angle of the light for shadow generation only.
  11397. */
  11398. shadowAngleScale: number;
  11399. /**
  11400. * The light decay speed with the distance from the emission spot.
  11401. */
  11402. exponent: number;
  11403. private _projectionTextureMatrix;
  11404. /**
  11405. * Allows reading the projecton texture
  11406. */
  11407. readonly projectionTextureMatrix: Matrix;
  11408. protected _projectionTextureLightNear: number;
  11409. /**
  11410. * Gets the near clip of the Spotlight for texture projection.
  11411. */
  11412. /**
  11413. * Sets the near clip of the Spotlight for texture projection.
  11414. */
  11415. projectionTextureLightNear: number;
  11416. protected _projectionTextureLightFar: number;
  11417. /**
  11418. * Gets the far clip of the Spotlight for texture projection.
  11419. */
  11420. /**
  11421. * Sets the far clip of the Spotlight for texture projection.
  11422. */
  11423. projectionTextureLightFar: number;
  11424. protected _projectionTextureUpDirection: Vector3;
  11425. /**
  11426. * Gets the Up vector of the Spotlight for texture projection.
  11427. */
  11428. /**
  11429. * Sets the Up vector of the Spotlight for texture projection.
  11430. */
  11431. projectionTextureUpDirection: Vector3;
  11432. private _projectionTexture;
  11433. /**
  11434. * Gets the projection texture of the light.
  11435. */
  11436. /**
  11437. * Sets the projection texture of the light.
  11438. */
  11439. projectionTexture: Nullable<BaseTexture>;
  11440. private _projectionTextureViewLightDirty;
  11441. private _projectionTextureProjectionLightDirty;
  11442. private _projectionTextureDirty;
  11443. private _projectionTextureViewTargetVector;
  11444. private _projectionTextureViewLightMatrix;
  11445. private _projectionTextureProjectionLightMatrix;
  11446. private _projectionTextureScalingMatrix;
  11447. /**
  11448. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11449. * It can cast shadows.
  11450. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11451. * @param name The light friendly name
  11452. * @param position The position of the spot light in the scene
  11453. * @param direction The direction of the light in the scene
  11454. * @param angle The cone angle of the light in Radians
  11455. * @param exponent The light decay speed with the distance from the emission spot
  11456. * @param scene The scene the lights belongs to
  11457. */
  11458. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11459. /**
  11460. * Returns the string "SpotLight".
  11461. * @returns the class name
  11462. */
  11463. getClassName(): string;
  11464. /**
  11465. * Returns the integer 2.
  11466. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11467. */
  11468. getTypeID(): number;
  11469. /**
  11470. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11471. */
  11472. protected _setDirection(value: Vector3): void;
  11473. /**
  11474. * Overrides the position setter to recompute the projection texture view light Matrix.
  11475. */
  11476. protected _setPosition(value: Vector3): void;
  11477. /**
  11478. * 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.
  11479. * Returns the SpotLight.
  11480. */
  11481. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11482. protected _computeProjectionTextureViewLightMatrix(): void;
  11483. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11484. /**
  11485. * Main function for light texture projection matrix computing.
  11486. */
  11487. protected _computeProjectionTextureMatrix(): void;
  11488. protected _buildUniformLayout(): void;
  11489. /**
  11490. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11491. * @param effect The effect to update
  11492. * @param lightIndex The index of the light in the effect to update
  11493. * @returns The spot light
  11494. */
  11495. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11496. /**
  11497. * Disposes the light and the associated resources.
  11498. */
  11499. dispose(): void;
  11500. }
  11501. }
  11502. declare module BABYLON {
  11503. interface ILoadingScreen {
  11504. displayLoadingUI: () => void;
  11505. hideLoadingUI: () => void;
  11506. loadingUIBackgroundColor: string;
  11507. loadingUIText: string;
  11508. }
  11509. class DefaultLoadingScreen implements ILoadingScreen {
  11510. private _renderingCanvas;
  11511. private _loadingText;
  11512. private _loadingDivBackgroundColor;
  11513. private _loadingDiv;
  11514. private _loadingTextDiv;
  11515. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11516. displayLoadingUI(): void;
  11517. hideLoadingUI(): void;
  11518. loadingUIText: string;
  11519. loadingUIBackgroundColor: string;
  11520. private _resizeLoadingUI;
  11521. }
  11522. }
  11523. declare module BABYLON {
  11524. class SceneLoaderProgressEvent {
  11525. readonly lengthComputable: boolean;
  11526. readonly loaded: number;
  11527. readonly total: number;
  11528. constructor(lengthComputable: boolean, loaded: number, total: number);
  11529. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11530. }
  11531. interface ISceneLoaderPluginExtensions {
  11532. [extension: string]: {
  11533. isBinary: boolean;
  11534. };
  11535. }
  11536. interface ISceneLoaderPluginFactory {
  11537. name: string;
  11538. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11539. canDirectLoad?: (data: string) => boolean;
  11540. }
  11541. interface ISceneLoaderPlugin {
  11542. /**
  11543. * The friendly name of this plugin.
  11544. */
  11545. name: string;
  11546. /**
  11547. * The file extensions supported by this plugin.
  11548. */
  11549. extensions: string | ISceneLoaderPluginExtensions;
  11550. /**
  11551. * Import meshes into a scene.
  11552. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11553. * @param scene The scene to import into
  11554. * @param data The data to import
  11555. * @param rootUrl The root url for scene and resources
  11556. * @param meshes The meshes array to import into
  11557. * @param particleSystems The particle systems array to import into
  11558. * @param skeletons The skeletons array to import into
  11559. * @param onError The callback when import fails
  11560. * @returns True if successful or false otherwise
  11561. */
  11562. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11563. /**
  11564. * Load into a scene.
  11565. * @param scene The scene to load into
  11566. * @param data The data to import
  11567. * @param rootUrl The root url for scene and resources
  11568. * @param onError The callback when import fails
  11569. * @returns true if successful or false otherwise
  11570. */
  11571. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11572. /**
  11573. * The callback that returns true if the data can be directly loaded.
  11574. */
  11575. canDirectLoad?: (data: string) => boolean;
  11576. /**
  11577. * The callback that allows custom handling of the root url based on the response url.
  11578. */
  11579. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11580. /**
  11581. * Load into an asset container.
  11582. * @param scene The scene to load into
  11583. * @param data The data to import
  11584. * @param rootUrl The root url for scene and resources
  11585. * @param onError The callback when import fails
  11586. * @returns The loaded asset container
  11587. */
  11588. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11589. }
  11590. interface ISceneLoaderPluginAsync {
  11591. /**
  11592. * The friendly name of this plugin.
  11593. */
  11594. name: string;
  11595. /**
  11596. * The file extensions supported by this plugin.
  11597. */
  11598. extensions: string | ISceneLoaderPluginExtensions;
  11599. /**
  11600. * Import meshes into a scene.
  11601. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11602. * @param scene The scene to import into
  11603. * @param data The data to import
  11604. * @param rootUrl The root url for scene and resources
  11605. * @param onProgress The callback when the load progresses
  11606. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11607. */
  11608. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11609. meshes: AbstractMesh[];
  11610. particleSystems: ParticleSystem[];
  11611. skeletons: Skeleton[];
  11612. animationGroups: AnimationGroup[];
  11613. }>;
  11614. /**
  11615. * Load into a scene.
  11616. * @param scene The scene to load into
  11617. * @param data The data to import
  11618. * @param rootUrl The root url for scene and resources
  11619. * @param onProgress The callback when the load progresses
  11620. * @returns Nothing
  11621. */
  11622. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11623. /**
  11624. * The callback that returns true if the data can be directly loaded.
  11625. */
  11626. canDirectLoad?: (data: string) => boolean;
  11627. /**
  11628. * The callback that allows custom handling of the root url based on the response url.
  11629. */
  11630. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11631. /**
  11632. * Load into an asset container.
  11633. * @param scene The scene to load into
  11634. * @param data The data to import
  11635. * @param rootUrl The root url for scene and resources
  11636. * @param onProgress The callback when the load progresses
  11637. * @returns The loaded asset container
  11638. */
  11639. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11640. }
  11641. class SceneLoader {
  11642. private static _ForceFullSceneLoadingForIncremental;
  11643. private static _ShowLoadingScreen;
  11644. private static _CleanBoneMatrixWeights;
  11645. static readonly NO_LOGGING: number;
  11646. static readonly MINIMAL_LOGGING: number;
  11647. static readonly SUMMARY_LOGGING: number;
  11648. static readonly DETAILED_LOGGING: number;
  11649. private static _loggingLevel;
  11650. static ForceFullSceneLoadingForIncremental: boolean;
  11651. static ShowLoadingScreen: boolean;
  11652. static loggingLevel: number;
  11653. static CleanBoneMatrixWeights: boolean;
  11654. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11655. private static _registeredPlugins;
  11656. private static _getDefaultPlugin();
  11657. private static _getPluginForExtension(extension);
  11658. private static _getPluginForDirectLoad(data);
  11659. private static _getPluginForFilename(sceneFilename);
  11660. private static _getDirectLoad(sceneFilename);
  11661. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  11662. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  11663. static IsPluginForExtensionAvailable(extension: string): boolean;
  11664. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  11665. /**
  11666. * Import meshes into a scene
  11667. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11668. * @param rootUrl a string that defines the root url for scene and resources
  11669. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11670. * @param scene the instance of BABYLON.Scene to append to
  11671. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  11672. * @param onProgress a callback with a progress event for each file being loaded
  11673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11674. * @param pluginExtension the extension used to determine the plugin
  11675. * @returns The loaded plugin
  11676. */
  11677. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11678. /**
  11679. * Import meshes into a scene
  11680. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11681. * @param rootUrl a string that defines the root url for scene and resources
  11682. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11683. * @param scene the instance of BABYLON.Scene to append to
  11684. * @param onProgress a callback with a progress event for each file being loaded
  11685. * @param pluginExtension the extension used to determine the plugin
  11686. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  11687. */
  11688. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  11689. meshes: AbstractMesh[];
  11690. particleSystems: ParticleSystem[];
  11691. skeletons: Skeleton[];
  11692. animationGroups: AnimationGroup[];
  11693. }>;
  11694. /**
  11695. * Load a scene
  11696. * @param rootUrl a string that defines the root url for scene and resources
  11697. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11698. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11699. * @param onSuccess a callback with the scene when import succeeds
  11700. * @param onProgress a callback with a progress event for each file being loaded
  11701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11702. * @param pluginExtension the extension used to determine the plugin
  11703. * @returns The loaded plugin
  11704. */
  11705. 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>;
  11706. /**
  11707. * Load a scene
  11708. * @param rootUrl a string that defines the root url for scene and resources
  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
  11710. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11711. * @param onProgress a callback with a progress event for each file being loaded
  11712. * @param pluginExtension the extension used to determine the plugin
  11713. * @returns The loaded scene
  11714. */
  11715. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11716. /**
  11717. * Append a scene
  11718. * @param rootUrl a string that defines the root url for scene and resources
  11719. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11720. * @param scene is the instance of BABYLON.Scene to append to
  11721. * @param onSuccess a callback with the scene when import succeeds
  11722. * @param onProgress a callback with a progress event for each file being loaded
  11723. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11724. * @param pluginExtension the extension used to determine the plugin
  11725. * @returns The loaded plugin
  11726. */
  11727. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11728. /**
  11729. * Append a scene
  11730. * @param rootUrl a string that defines the root url for scene and resources
  11731. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11732. * @param scene is the instance of BABYLON.Scene to append to
  11733. * @param onProgress a callback with a progress event for each file being loaded
  11734. * @param pluginExtension the extension used to determine the plugin
  11735. * @returns The given scene
  11736. */
  11737. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11738. /**
  11739. * Load a scene into an asset container
  11740. * @param rootUrl a string that defines the root url for scene and resources
  11741. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11742. * @param scene is the instance of BABYLON.Scene to append to
  11743. * @param onSuccess a callback with the scene when import succeeds
  11744. * @param onProgress a callback with a progress event for each file being loaded
  11745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11746. * @param pluginExtension the extension used to determine the plugin
  11747. * @returns The loaded plugin
  11748. */
  11749. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11750. /**
  11751. * Load a scene into an asset container
  11752. * @param rootUrl a string that defines the root url for scene and resources
  11753. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11754. * @param scene is the instance of BABYLON.Scene to append to
  11755. * @param onProgress a callback with a progress event for each file being loaded
  11756. * @param pluginExtension the extension used to determine the plugin
  11757. * @returns The loaded asset container
  11758. */
  11759. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11760. }
  11761. }
  11762. declare module BABYLON {
  11763. class Scalar {
  11764. /**
  11765. * Two pi constants convenient for computation.
  11766. */
  11767. static TwoPi: number;
  11768. /**
  11769. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  11770. */
  11771. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  11772. /**
  11773. * Returns a string : the upper case translation of the number i to hexadecimal.
  11774. */
  11775. static ToHex(i: number): string;
  11776. /**
  11777. * Returns -1 if value is negative and +1 is value is positive.
  11778. * Returns the value itself if it's equal to zero.
  11779. */
  11780. static Sign(value: number): number;
  11781. /**
  11782. * Returns the value itself if it's between min and max.
  11783. * Returns min if the value is lower than min.
  11784. * Returns max if the value is greater than max.
  11785. */
  11786. static Clamp(value: number, min?: number, max?: number): number;
  11787. /**
  11788. * Returns the log2 of value.
  11789. */
  11790. static Log2(value: number): number;
  11791. /**
  11792. * Loops the value, so that it is never larger than length and never smaller than 0.
  11793. *
  11794. * This is similar to the modulo operator but it works with floating point numbers.
  11795. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  11796. * With t = 5 and length = 2.5, the result would be 0.0.
  11797. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  11798. */
  11799. static Repeat(value: number, length: number): number;
  11800. /**
  11801. * Normalize the value between 0.0 and 1.0 using min and max values
  11802. */
  11803. static Normalize(value: number, min: number, max: number): number;
  11804. /**
  11805. * Denormalize the value from 0.0 and 1.0 using min and max values
  11806. */
  11807. static Denormalize(normalized: number, min: number, max: number): number;
  11808. /**
  11809. * Calculates the shortest difference between two given angles given in degrees.
  11810. */
  11811. static DeltaAngle(current: number, target: number): number;
  11812. /**
  11813. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  11814. *
  11815. * The returned value will move back and forth between 0 and length
  11816. */
  11817. static PingPong(tx: number, length: number): number;
  11818. /**
  11819. * Interpolates between min and max with smoothing at the limits.
  11820. *
  11821. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  11822. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  11823. */
  11824. static SmoothStep(from: number, to: number, tx: number): number;
  11825. /**
  11826. * Moves a value current towards target.
  11827. *
  11828. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  11829. * Negative values of maxDelta pushes the value away from target.
  11830. */
  11831. static MoveTowards(current: number, target: number, maxDelta: number): number;
  11832. /**
  11833. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11834. *
  11835. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  11836. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  11837. */
  11838. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  11839. /**
  11840. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  11841. */
  11842. static Lerp(start: number, end: number, amount: number): number;
  11843. /**
  11844. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11845. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  11846. */
  11847. static LerpAngle(start: number, end: number, amount: number): number;
  11848. /**
  11849. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  11850. */
  11851. static InverseLerp(a: number, b: number, value: number): number;
  11852. /**
  11853. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  11854. */
  11855. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  11856. /**
  11857. * Returns a random float number between and min and max values
  11858. */
  11859. static RandomRange(min: number, max: number): number;
  11860. /**
  11861. * This function returns percentage of a number in a given range.
  11862. *
  11863. * RangeToPercent(40,20,60) will return 0.5 (50%)
  11864. * RangeToPercent(34,0,100) will return 0.34 (34%)
  11865. */
  11866. static RangeToPercent(number: number, min: number, max: number): number;
  11867. /**
  11868. * This function returns number that corresponds to the percentage in a given range.
  11869. *
  11870. * PercentToRange(0.34,0,100) will return 34.
  11871. */
  11872. static PercentToRange(percent: number, min: number, max: number): number;
  11873. /**
  11874. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  11875. * @param angle The angle to normalize in radian.
  11876. * @return The converted angle.
  11877. */
  11878. static NormalizeRadians(angle: number): number;
  11879. }
  11880. }
  11881. declare module BABYLON {
  11882. const ToGammaSpace: number;
  11883. const ToLinearSpace = 2.2;
  11884. const Epsilon = 0.001;
  11885. /**
  11886. * Class used to hold a RBG color
  11887. */
  11888. class Color3 {
  11889. /**
  11890. * Defines the red component (between 0 and 1, default is 0)
  11891. */
  11892. r: number;
  11893. /**
  11894. * Defines the green component (between 0 and 1, default is 0)
  11895. */
  11896. g: number;
  11897. /**
  11898. * Defines the blue component (between 0 and 1, default is 0)
  11899. */
  11900. b: number;
  11901. /**
  11902. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  11903. * @param r defines the red component (between 0 and 1, default is 0)
  11904. * @param g defines the green component (between 0 and 1, default is 0)
  11905. * @param b defines the blue component (between 0 and 1, default is 0)
  11906. */
  11907. constructor(
  11908. /**
  11909. * Defines the red component (between 0 and 1, default is 0)
  11910. */
  11911. r?: number,
  11912. /**
  11913. * Defines the green component (between 0 and 1, default is 0)
  11914. */
  11915. g?: number,
  11916. /**
  11917. * Defines the blue component (between 0 and 1, default is 0)
  11918. */
  11919. b?: number);
  11920. /**
  11921. * Creates a string with the Color3 current values
  11922. * @returns the string representation of the Color3 object
  11923. */
  11924. toString(): string;
  11925. /**
  11926. * Returns the string "Color3"
  11927. * @returns "Color3"
  11928. */
  11929. getClassName(): string;
  11930. /**
  11931. * Compute the Color3 hash code
  11932. * @returns an unique number that can be used to hash Color3 objects
  11933. */
  11934. getHashCode(): number;
  11935. /**
  11936. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  11937. * @param array defines the array where to store the r,g,b components
  11938. * @param index defines an optional index in the target array to define where to start storing values
  11939. * @returns the current Color3 object
  11940. */
  11941. toArray(array: FloatArray, index?: number): Color3;
  11942. /**
  11943. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  11944. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  11945. * @returns a new {BABYLON.Color4} object
  11946. */
  11947. toColor4(alpha?: number): Color4;
  11948. /**
  11949. * Returns a new array populated with 3 numeric elements : red, green and blue values
  11950. * @returns the new array
  11951. */
  11952. asArray(): number[];
  11953. /**
  11954. * Returns the luminance value
  11955. * @returns a float value
  11956. */
  11957. toLuminance(): number;
  11958. /**
  11959. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  11960. * @param otherColor defines the second operand
  11961. * @returns the new Color3 object
  11962. */
  11963. multiply(otherColor: Color3): Color3;
  11964. /**
  11965. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  11966. * @param otherColor defines the second operand
  11967. * @param result defines the Color3 object where to store the result
  11968. * @returns the current Color3
  11969. */
  11970. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  11971. /**
  11972. * Determines equality between Color3 objects
  11973. * @param otherColor defines the second operand
  11974. * @returns true if the rgb values are equal to the given ones
  11975. */
  11976. equals(otherColor: Color3): boolean;
  11977. /**
  11978. * Determines equality between the current Color3 object and a set of r,b,g values
  11979. * @param r defines the red component to check
  11980. * @param g defines the green component to check
  11981. * @param b defines the blue component to check
  11982. * @returns true if the rgb values are equal to the given ones
  11983. */
  11984. equalsFloats(r: number, g: number, b: number): boolean;
  11985. /**
  11986. * Multiplies in place each rgb value by scale
  11987. * @param scale defines the scaling factor
  11988. * @returns the updated Color3
  11989. */
  11990. scale(scale: number): Color3;
  11991. /**
  11992. * Multiplies the rgb values by scale and stores the result into "result"
  11993. * @param scale defines the scaling factor
  11994. * @param result defines the Color3 object where to store the result
  11995. * @returns the unmodified current Color3
  11996. */
  11997. scaleToRef(scale: number, result: Color3): Color3;
  11998. /**
  11999. * Scale the current Color3 values by a factor and add the result to a given Color3
  12000. * @param scale defines the scale factor
  12001. * @param result defines color to store the result into
  12002. * @returns the unmodified current Color3
  12003. */
  12004. scaleAndAddToRef(scale: number, result: Color3): Color3;
  12005. /**
  12006. * Clamps the rgb values by the min and max values and stores the result into "result"
  12007. * @param min defines minimum clamping value (default is 0)
  12008. * @param max defines maximum clamping value (default is 1)
  12009. * @param result defines color to store the result into
  12010. * @returns the original Color3
  12011. */
  12012. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  12013. /**
  12014. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  12015. * @param otherColor defines the second operand
  12016. * @returns the new Color3
  12017. */
  12018. add(otherColor: Color3): Color3;
  12019. /**
  12020. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  12021. * @param otherColor defines the second operand
  12022. * @param result defines Color3 object to store the result into
  12023. * @returns the unmodified current Color3
  12024. */
  12025. addToRef(otherColor: Color3, result: Color3): Color3;
  12026. /**
  12027. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  12028. * @param otherColor defines the second operand
  12029. * @returns the new Color3
  12030. */
  12031. subtract(otherColor: Color3): Color3;
  12032. /**
  12033. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  12034. * @param otherColor defines the second operand
  12035. * @param result defines Color3 object to store the result into
  12036. * @returns the unmodified current Color3
  12037. */
  12038. subtractToRef(otherColor: Color3, result: Color3): Color3;
  12039. /**
  12040. * Copy the current object
  12041. * @returns a new Color3 copied the current one
  12042. */
  12043. clone(): Color3;
  12044. /**
  12045. * Copies the rgb values from the source in the current Color3
  12046. * @param source defines the source Color3 object
  12047. * @returns the updated Color3 object
  12048. */
  12049. copyFrom(source: Color3): Color3;
  12050. /**
  12051. * Updates the Color3 rgb values from the given floats
  12052. * @param r defines the red component to read from
  12053. * @param g defines the green component to read from
  12054. * @param b defines the blue component to read from
  12055. * @returns the current Color3 object
  12056. */
  12057. copyFromFloats(r: number, g: number, b: number): Color3;
  12058. /**
  12059. * Updates the Color3 rgb values from the given floats
  12060. * @param r defines the red component to read from
  12061. * @param g defines the green component to read from
  12062. * @param b defines the blue component to read from
  12063. * @returns the current Color3 object
  12064. */
  12065. set(r: number, g: number, b: number): Color3;
  12066. /**
  12067. * Compute the Color3 hexadecimal code as a string
  12068. * @returns a string containing the hexadecimal representation of the Color3 object
  12069. */
  12070. toHexString(): string;
  12071. /**
  12072. * Computes a new Color3 converted from the current one to linear space
  12073. * @returns a new Color3 object
  12074. */
  12075. toLinearSpace(): Color3;
  12076. /**
  12077. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  12078. * @param convertedColor defines the Color3 object where to store the linear space version
  12079. * @returns the unmodified Color3
  12080. */
  12081. toLinearSpaceToRef(convertedColor: Color3): Color3;
  12082. /**
  12083. * Computes a new Color3 converted from the current one to gamma space
  12084. * @returns a new Color3 object
  12085. */
  12086. toGammaSpace(): Color3;
  12087. /**
  12088. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  12089. * @param convertedColor defines the Color3 object where to store the gamma space version
  12090. * @returns the unmodified Color3
  12091. */
  12092. toGammaSpaceToRef(convertedColor: Color3): Color3;
  12093. /**
  12094. * Creates a new Color3 from the string containing valid hexadecimal values
  12095. * @param hex defines a string containing valid hexadecimal values
  12096. * @returns a new Color3 object
  12097. */
  12098. static FromHexString(hex: string): Color3;
  12099. /**
  12100. * Creates a new Vector3 from the starting index of the given array
  12101. * @param array defines the source array
  12102. * @param offset defines an offset in the source array
  12103. * @returns a new Color3 object
  12104. */
  12105. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  12106. /**
  12107. * Creates a new Color3 from integer values (< 256)
  12108. * @param r defines the red component to read from (value between 0 and 255)
  12109. * @param g defines the green component to read from (value between 0 and 255)
  12110. * @param b defines the blue component to read from (value between 0 and 255)
  12111. * @returns a new Color3 object
  12112. */
  12113. static FromInts(r: number, g: number, b: number): Color3;
  12114. /**
  12115. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  12116. * @param start defines the start Color3 value
  12117. * @param end defines the end Color3 value
  12118. * @param amount defines the gradient value between start and end
  12119. * @returns a new Color3 object
  12120. */
  12121. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  12122. /**
  12123. * Returns a Color3 value containing a red color
  12124. * @returns a new Color3 object
  12125. */
  12126. static Red(): Color3;
  12127. /**
  12128. * Returns a Color3 value containing a green color
  12129. * @returns a new Color3 object
  12130. */
  12131. static Green(): Color3;
  12132. /**
  12133. * Returns a Color3 value containing a blue color
  12134. * @returns a new Color3 object
  12135. */
  12136. static Blue(): Color3;
  12137. /**
  12138. * Returns a Color3 value containing a black color
  12139. * @returns a new Color3 object
  12140. */
  12141. static Black(): Color3;
  12142. /**
  12143. * Returns a Color3 value containing a white color
  12144. * @returns a new Color3 object
  12145. */
  12146. static White(): Color3;
  12147. /**
  12148. * Returns a Color3 value containing a purple color
  12149. * @returns a new Color3 object
  12150. */
  12151. static Purple(): Color3;
  12152. /**
  12153. * Returns a Color3 value containing a magenta color
  12154. * @returns a new Color3 object
  12155. */
  12156. static Magenta(): Color3;
  12157. /**
  12158. * Returns a Color3 value containing a yellow color
  12159. * @returns a new Color3 object
  12160. */
  12161. static Yellow(): Color3;
  12162. /**
  12163. * Returns a Color3 value containing a gray color
  12164. * @returns a new Color3 object
  12165. */
  12166. static Gray(): Color3;
  12167. /**
  12168. * Returns a Color3 value containing a teal color
  12169. * @returns a new Color3 object
  12170. */
  12171. static Teal(): Color3;
  12172. /**
  12173. * Returns a Color3 value containing a random color
  12174. * @returns a new Color3 object
  12175. */
  12176. static Random(): Color3;
  12177. }
  12178. /**
  12179. * Class used to hold a RBGA color
  12180. */
  12181. class Color4 {
  12182. /**
  12183. * Defines the red component (between 0 and 1, default is 0)
  12184. */
  12185. r: number;
  12186. /**
  12187. * Defines the green component (between 0 and 1, default is 0)
  12188. */
  12189. g: number;
  12190. /**
  12191. * Defines the blue component (between 0 and 1, default is 0)
  12192. */
  12193. b: number;
  12194. /**
  12195. * Defines the alpha component (between 0 and 1, default is 1)
  12196. */
  12197. a: number;
  12198. /**
  12199. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  12200. * @param r defines the red component (between 0 and 1, default is 0)
  12201. * @param g defines the green component (between 0 and 1, default is 0)
  12202. * @param b defines the blue component (between 0 and 1, default is 0)
  12203. * @param a defines the alpha component (between 0 and 1, default is 1)
  12204. */
  12205. constructor(
  12206. /**
  12207. * Defines the red component (between 0 and 1, default is 0)
  12208. */
  12209. r?: number,
  12210. /**
  12211. * Defines the green component (between 0 and 1, default is 0)
  12212. */
  12213. g?: number,
  12214. /**
  12215. * Defines the blue component (between 0 and 1, default is 0)
  12216. */
  12217. b?: number,
  12218. /**
  12219. * Defines the alpha component (between 0 and 1, default is 1)
  12220. */
  12221. a?: number);
  12222. /**
  12223. * Adds in place the given Color4 values to the current Color4 object
  12224. * @param right defines the second operand
  12225. * @returns the current updated Color4 object
  12226. */
  12227. addInPlace(right: Color4): Color4;
  12228. /**
  12229. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  12230. * @returns the new array
  12231. */
  12232. asArray(): number[];
  12233. /**
  12234. * Stores from the starting index in the given array the Color4 successive values
  12235. * @param array defines the array where to store the r,g,b components
  12236. * @param index defines an optional index in the target array to define where to start storing values
  12237. * @returns the current Color4 object
  12238. */
  12239. toArray(array: number[], index?: number): Color4;
  12240. /**
  12241. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  12242. * @param right defines the second operand
  12243. * @returns a new Color4 object
  12244. */
  12245. add(right: Color4): Color4;
  12246. /**
  12247. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  12248. * @param right defines the second operand
  12249. * @returns a new Color4 object
  12250. */
  12251. subtract(right: Color4): Color4;
  12252. /**
  12253. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  12254. * @param right defines the second operand
  12255. * @param result defines the Color4 object where to store the result
  12256. * @returns the current Color4 object
  12257. */
  12258. subtractToRef(right: Color4, result: Color4): Color4;
  12259. /**
  12260. * Creates a new Color4 with the current Color4 values multiplied by scale
  12261. * @param scale defines the scaling factor to apply
  12262. * @returns a new Color4 object
  12263. */
  12264. scale(scale: number): Color4;
  12265. /**
  12266. * Multiplies the current Color4 values by scale and stores the result in "result"
  12267. * @param scale defines the scaling factor to apply
  12268. * @param result defines the Color4 object where to store the result
  12269. * @returns the current unmodified Color4
  12270. */
  12271. scaleToRef(scale: number, result: Color4): Color4;
  12272. /**
  12273. * Scale the current Color4 values by a factor and add the result to a given Color4
  12274. * @param scale defines the scale factor
  12275. * @param result defines the Color4 object where to store the result
  12276. * @returns the unmodified current Color4
  12277. */
  12278. scaleAndAddToRef(scale: number, result: Color4): Color4;
  12279. /**
  12280. * Clamps the rgb values by the min and max values and stores the result into "result"
  12281. * @param min defines minimum clamping value (default is 0)
  12282. * @param max defines maximum clamping value (default is 1)
  12283. * @param result defines color to store the result into.
  12284. * @returns the cuurent Color4
  12285. */
  12286. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  12287. /**
  12288. * Multipy an Color4 value by another and return a new Color4 object
  12289. * @param color defines the Color4 value to multiply by
  12290. * @returns a new Color4 object
  12291. */
  12292. multiply(color: Color4): Color4;
  12293. /**
  12294. * Multipy a Color4 value by another and push the result in a reference value
  12295. * @param color defines the Color4 value to multiply by
  12296. * @param result defines the Color4 to fill the result in
  12297. * @returns the result Color4
  12298. */
  12299. multiplyToRef(color: Color4, result: Color4): Color4;
  12300. /**
  12301. * Creates a string with the Color4 current values
  12302. * @returns the string representation of the Color4 object
  12303. */
  12304. toString(): string;
  12305. /**
  12306. * Returns the string "Color4"
  12307. * @returns "Color4"
  12308. */
  12309. getClassName(): string;
  12310. /**
  12311. * Compute the Color4 hash code
  12312. * @returns an unique number that can be used to hash Color4 objects
  12313. */
  12314. getHashCode(): number;
  12315. /**
  12316. * Creates a new Color4 copied from the current one
  12317. * @returns a new Color4 object
  12318. */
  12319. clone(): Color4;
  12320. /**
  12321. * Copies the given Color4 values into the current one
  12322. * @param source defines the source Color4 object
  12323. * @returns the current updated Color4 object
  12324. */
  12325. copyFrom(source: Color4): Color4;
  12326. /**
  12327. * Copies the given float values into the current one
  12328. * @param r defines the red component to read from
  12329. * @param g defines the green component to read from
  12330. * @param b defines the blue component to read from
  12331. * @param a defines the alpha component to read from
  12332. * @returns the current updated Color4 object
  12333. */
  12334. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  12335. /**
  12336. * Copies the given float values into the current one
  12337. * @param r defines the red component to read from
  12338. * @param g defines the green component to read from
  12339. * @param b defines the blue component to read from
  12340. * @param a defines the alpha component to read from
  12341. * @returns the current updated Color4 object
  12342. */
  12343. set(r: number, g: number, b: number, a: number): Color4;
  12344. /**
  12345. * Compute the Color4 hexadecimal code as a string
  12346. * @returns a string containing the hexadecimal representation of the Color4 object
  12347. */
  12348. toHexString(): string;
  12349. /**
  12350. * Computes a new Color4 converted from the current one to linear space
  12351. * @returns a new Color4 object
  12352. */
  12353. toLinearSpace(): Color4;
  12354. /**
  12355. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  12356. * @param convertedColor defines the Color4 object where to store the linear space version
  12357. * @returns the unmodified Color4
  12358. */
  12359. toLinearSpaceToRef(convertedColor: Color4): Color4;
  12360. /**
  12361. * Computes a new Color4 converted from the current one to gamma space
  12362. * @returns a new Color4 object
  12363. */
  12364. toGammaSpace(): Color4;
  12365. /**
  12366. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  12367. * @param convertedColor defines the Color4 object where to store the gamma space version
  12368. * @returns the unmodified Color4
  12369. */
  12370. toGammaSpaceToRef(convertedColor: Color4): Color4;
  12371. /**
  12372. * Creates a new Color4 from the string containing valid hexadecimal values
  12373. * @param hex defines a string containing valid hexadecimal values
  12374. * @returns a new Color4 object
  12375. */
  12376. static FromHexString(hex: string): Color4;
  12377. /**
  12378. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12379. * @param left defines the start value
  12380. * @param right defines the end value
  12381. * @param amount defines the gradient factor
  12382. * @returns a new Color4 object
  12383. */
  12384. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  12385. /**
  12386. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12387. * @param left defines the start value
  12388. * @param right defines the end value
  12389. * @param amount defines the gradient factor
  12390. * @param result defines the Color4 object where to store data
  12391. */
  12392. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  12393. /**
  12394. * Creates a new Color4 from the starting index element of the given array
  12395. * @param array defines the source array to read from
  12396. * @param offset defines the offset in the source array
  12397. * @returns a new Color4 object
  12398. */
  12399. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  12400. /**
  12401. * Creates a new Color3 from integer values (< 256)
  12402. * @param r defines the red component to read from (value between 0 and 255)
  12403. * @param g defines the green component to read from (value between 0 and 255)
  12404. * @param b defines the blue component to read from (value between 0 and 255)
  12405. * @param a defines the alpha component to read from (value between 0 and 255)
  12406. * @returns a new Color3 object
  12407. */
  12408. static FromInts(r: number, g: number, b: number, a: number): Color4;
  12409. /**
  12410. * Check the content of a given array and convert it to an array containing RGBA data
  12411. * If the original array was already containing count * 4 values then it is returned directly
  12412. * @param colors defines the array to check
  12413. * @param count defines the number of RGBA data to expect
  12414. * @returns an array containing count * 4 values (RGBA)
  12415. */
  12416. static CheckColors4(colors: number[], count: number): number[];
  12417. }
  12418. /**
  12419. * Class representing a vector containing 2 coordinates
  12420. */
  12421. class Vector2 {
  12422. /** defines the first coordinate */
  12423. x: number;
  12424. /** defines the second coordinate */
  12425. y: number;
  12426. /**
  12427. * Creates a new Vector2 from the given x and y coordinates
  12428. * @param x defines the first coordinate
  12429. * @param y defines the second coordinate
  12430. */
  12431. constructor(
  12432. /** defines the first coordinate */
  12433. x: number,
  12434. /** defines the second coordinate */
  12435. y: number);
  12436. /**
  12437. * Gets a string with the Vector2 coordinates
  12438. * @returns a string with the Vector2 coordinates
  12439. */
  12440. toString(): string;
  12441. /**
  12442. * Gets class name
  12443. * @returns the string "Vector2"
  12444. */
  12445. getClassName(): string;
  12446. /**
  12447. * Gets current vector hash code
  12448. * @returns the Vector2 hash code as a number
  12449. */
  12450. getHashCode(): number;
  12451. /**
  12452. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  12453. * @param array defines the source array
  12454. * @param index defines the offset in source array
  12455. * @returns the current Vector2
  12456. */
  12457. toArray(array: FloatArray, index?: number): Vector2;
  12458. /**
  12459. * Copy the current vector to an array
  12460. * @returns a new array with 2 elements: the Vector2 coordinates.
  12461. */
  12462. asArray(): number[];
  12463. /**
  12464. * Sets the Vector2 coordinates with the given Vector2 coordinates
  12465. * @param source defines the source Vector2
  12466. * @returns the current updated Vector2
  12467. */
  12468. copyFrom(source: Vector2): Vector2;
  12469. /**
  12470. * Sets the Vector2 coordinates with the given floats
  12471. * @param x defines the first coordinate
  12472. * @param y defines the second coordinate
  12473. * @returns the current updated Vector2
  12474. */
  12475. copyFromFloats(x: number, y: number): Vector2;
  12476. /**
  12477. * Sets the Vector2 coordinates with the given floats
  12478. * @param x defines the first coordinate
  12479. * @param y defines the second coordinate
  12480. * @returns the current updated Vector2
  12481. */
  12482. set(x: number, y: number): Vector2;
  12483. /**
  12484. * Add another vector with the current one
  12485. * @param otherVector defines the other vector
  12486. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  12487. */
  12488. add(otherVector: Vector2): Vector2;
  12489. /**
  12490. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  12491. * @param otherVector defines the other vector
  12492. * @param result defines the target vector
  12493. * @returns the unmodified current Vector2
  12494. */
  12495. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  12496. /**
  12497. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  12498. * @param otherVector defines the other vector
  12499. * @returns the current updated Vector2
  12500. */
  12501. addInPlace(otherVector: Vector2): Vector2;
  12502. /**
  12503. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  12504. * @param otherVector defines the other vector
  12505. * @returns a new Vector2
  12506. */
  12507. addVector3(otherVector: Vector3): Vector2;
  12508. /**
  12509. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  12510. * @param otherVector defines the other vector
  12511. * @returns a new Vector2
  12512. */
  12513. subtract(otherVector: Vector2): Vector2;
  12514. /**
  12515. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  12516. * @param otherVector defines the other vector
  12517. * @param result defines the target vector
  12518. * @returns the unmodified current Vector2
  12519. */
  12520. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  12521. /**
  12522. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  12523. * @param otherVector defines the other vector
  12524. * @returns the current updated Vector2
  12525. */
  12526. subtractInPlace(otherVector: Vector2): Vector2;
  12527. /**
  12528. * Multiplies in place the current Vector2 coordinates by the given ones
  12529. * @param otherVector defines the other vector
  12530. * @returns the current updated Vector2
  12531. */
  12532. multiplyInPlace(otherVector: Vector2): Vector2;
  12533. /**
  12534. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  12535. * @param otherVector defines the other vector
  12536. * @returns a new Vector2
  12537. */
  12538. multiply(otherVector: Vector2): Vector2;
  12539. /**
  12540. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  12541. * @param otherVector defines the other vector
  12542. * @param result defines the target vector
  12543. * @returns the unmodified current Vector2
  12544. */
  12545. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  12546. /**
  12547. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  12548. * @param x defines the first coordinate
  12549. * @param y defines the second coordinate
  12550. * @returns a new Vector2
  12551. */
  12552. multiplyByFloats(x: number, y: number): Vector2;
  12553. /**
  12554. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  12555. * @param otherVector defines the other vector
  12556. * @returns a new Vector2
  12557. */
  12558. divide(otherVector: Vector2): Vector2;
  12559. /**
  12560. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  12561. * @param otherVector defines the other vector
  12562. * @param result defines the target vector
  12563. * @returns the unmodified current Vector2
  12564. */
  12565. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  12566. /**
  12567. * Divides the current Vector3 coordinates by the given ones
  12568. * @param otherVector defines the other vector
  12569. * @returns the current updated Vector2
  12570. */
  12571. divideInPlace(otherVector: Vector2): Vector2;
  12572. /**
  12573. * Gets a new Vector2 with current Vector2 negated coordinates
  12574. * @returns a new Vector2
  12575. */
  12576. negate(): Vector2;
  12577. /**
  12578. * Multiply the Vector2 coordinates by scale
  12579. * @param scale defines the scaling factor
  12580. * @returns the current updated Vector2
  12581. */
  12582. scaleInPlace(scale: number): Vector2;
  12583. /**
  12584. * Returns a new Vector2 scaled by "scale" from the current Vector2
  12585. * @param scale defines the scaling factor
  12586. * @returns a new Vector2
  12587. */
  12588. scale(scale: number): Vector2;
  12589. /**
  12590. * Scale the current Vector2 values by a factor to a given Vector2
  12591. * @param scale defines the scale factor
  12592. * @param result defines the Vector2 object where to store the result
  12593. * @returns the unmodified current Vector2
  12594. */
  12595. scaleToRef(scale: number, result: Vector2): Vector2;
  12596. /**
  12597. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  12598. * @param scale defines the scale factor
  12599. * @param result defines the Vector2 object where to store the result
  12600. * @returns the unmodified current Vector2
  12601. */
  12602. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  12603. /**
  12604. * Gets a boolean if two vectors are equals
  12605. * @param otherVector defines the other vector
  12606. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  12607. */
  12608. equals(otherVector: Vector2): boolean;
  12609. /**
  12610. * Gets a boolean if two vectors are equals (using an epsilon value)
  12611. * @param otherVector defines the other vector
  12612. * @param epsilon defines the minimal distance to consider equality
  12613. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  12614. */
  12615. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  12616. /**
  12617. * Gets the length of the vector
  12618. * @returns the vector length (float)
  12619. */
  12620. length(): number;
  12621. /**
  12622. * Gets the vector squared length
  12623. * @returns the vector squared length (float)
  12624. */
  12625. lengthSquared(): number;
  12626. /**
  12627. * Normalize the vector
  12628. * @returns the current updated Vector2
  12629. */
  12630. normalize(): Vector2;
  12631. /**
  12632. * Gets a new Vector2 copied from the Vector2
  12633. * @returns a new Vector2
  12634. */
  12635. clone(): Vector2;
  12636. /**
  12637. * Gets a new Vector2(0, 0)
  12638. * @returns a new Vector2
  12639. */
  12640. static Zero(): Vector2;
  12641. /**
  12642. * Gets a new Vector2(1, 1)
  12643. * @returns a new Vector2
  12644. */
  12645. static One(): Vector2;
  12646. /**
  12647. * Gets a new Vector2 set from the given index element of the given array
  12648. * @param array defines the data source
  12649. * @param offset defines the offset in the data source
  12650. * @returns a new Vector2
  12651. */
  12652. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  12653. /**
  12654. * Sets "result" from the given index element of the given array
  12655. * @param array defines the data source
  12656. * @param offset defines the offset in the data source
  12657. * @param result defines the target vector
  12658. */
  12659. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  12660. /**
  12661. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  12662. * @param value1 defines 1st point of control
  12663. * @param value2 defines 2nd point of control
  12664. * @param value3 defines 3rd point of control
  12665. * @param value4 defines 4th point of control
  12666. * @param amount defines the interpolation factor
  12667. * @returns a new Vector2
  12668. */
  12669. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  12670. /**
  12671. * 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".
  12672. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  12673. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  12674. * @param value defines the value to clamp
  12675. * @param min defines the lower limit
  12676. * @param max defines the upper limit
  12677. * @returns a new Vector2
  12678. */
  12679. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  12680. /**
  12681. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  12682. * @param value1 defines the 1st control point
  12683. * @param tangent1 defines the outgoing tangent
  12684. * @param value2 defines the 2nd control point
  12685. * @param tangent2 defines the incoming tangent
  12686. * @param amount defines the interpolation factor
  12687. * @returns a new Vector2
  12688. */
  12689. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  12690. /**
  12691. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  12692. * @param start defines the start vector
  12693. * @param end defines the end vector
  12694. * @param amount defines the interpolation factor
  12695. * @returns a new Vector2
  12696. */
  12697. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  12698. /**
  12699. * Gets the dot product of the vector "left" and the vector "right"
  12700. * @param left defines first vector
  12701. * @param right defines second vector
  12702. * @returns the dot product (float)
  12703. */
  12704. static Dot(left: Vector2, right: Vector2): number;
  12705. /**
  12706. * Returns a new Vector2 equal to the normalized given vector
  12707. * @param vector defines the vector to normalize
  12708. * @returns a new Vector2
  12709. */
  12710. static Normalize(vector: Vector2): Vector2;
  12711. /**
  12712. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  12713. * @param left defines 1st vector
  12714. * @param right defines 2nd vector
  12715. * @returns a new Vector2
  12716. */
  12717. static Minimize(left: Vector2, right: Vector2): Vector2;
  12718. /**
  12719. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  12720. * @param left defines 1st vector
  12721. * @param right defines 2nd vector
  12722. * @returns a new Vector2
  12723. */
  12724. static Maximize(left: Vector2, right: Vector2): Vector2;
  12725. /**
  12726. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  12727. * @param vector defines the vector to transform
  12728. * @param transformation defines the matrix to apply
  12729. * @returns a new Vector2
  12730. */
  12731. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  12732. /**
  12733. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  12734. * @param vector defines the vector to transform
  12735. * @param transformation defines the matrix to apply
  12736. * @param result defines the target vector
  12737. */
  12738. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  12739. /**
  12740. * Determines if a given vector is included in a triangle
  12741. * @param p defines the vector to test
  12742. * @param p0 defines 1st triangle point
  12743. * @param p1 defines 2nd triangle point
  12744. * @param p2 defines 3rd triangle point
  12745. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  12746. */
  12747. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  12748. /**
  12749. * Gets the distance between the vectors "value1" and "value2"
  12750. * @param value1 defines first vector
  12751. * @param value2 defines second vector
  12752. * @returns the distance between vectors
  12753. */
  12754. static Distance(value1: Vector2, value2: Vector2): number;
  12755. /**
  12756. * Returns the squared distance between the vectors "value1" and "value2"
  12757. * @param value1 defines first vector
  12758. * @param value2 defines second vector
  12759. * @returns the squared distance between vectors
  12760. */
  12761. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  12762. /**
  12763. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  12764. * @param value1 defines first vector
  12765. * @param value2 defines second vector
  12766. * @returns a new Vector2
  12767. */
  12768. static Center(value1: Vector2, value2: Vector2): Vector2;
  12769. /**
  12770. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  12771. * @param p defines the middle point
  12772. * @param segA defines one point of the segment
  12773. * @param segB defines the other point of the segment
  12774. * @returns the shortest distance
  12775. */
  12776. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  12777. }
  12778. /**
  12779. * Classed used to store (x,y,z) vector representation
  12780. * A Vector3 is the main object used in 3D geometry
  12781. * It can represent etiher the coordinates of a point the space, either a direction
  12782. * Reminder: Babylon.js uses a left handed forward facing system
  12783. */
  12784. class Vector3 {
  12785. /**
  12786. * Defines the first coordinates (on X axis)
  12787. */
  12788. x: number;
  12789. /**
  12790. * Defines the second coordinates (on Y axis)
  12791. */
  12792. y: number;
  12793. /**
  12794. * Defines the third coordinates (on Z axis)
  12795. */
  12796. z: number;
  12797. /**
  12798. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  12799. * @param x defines the first coordinates (on X axis)
  12800. * @param y defines the second coordinates (on Y axis)
  12801. * @param z defines the third coordinates (on Z axis)
  12802. */
  12803. constructor(
  12804. /**
  12805. * Defines the first coordinates (on X axis)
  12806. */
  12807. x: number,
  12808. /**
  12809. * Defines the second coordinates (on Y axis)
  12810. */
  12811. y: number,
  12812. /**
  12813. * Defines the third coordinates (on Z axis)
  12814. */
  12815. z: number);
  12816. /**
  12817. * Creates a string representation of the Vector3
  12818. * @returns a string with the Vector3 coordinates.
  12819. */
  12820. toString(): string;
  12821. /**
  12822. * Gets the class name
  12823. * @returns the string "Vector3"
  12824. */
  12825. getClassName(): string;
  12826. /**
  12827. * Creates the Vector3 hash code
  12828. * @returns a number which tends to be unique between Vector3 instances
  12829. */
  12830. getHashCode(): number;
  12831. /**
  12832. * Creates an array containing three elements : the coordinates of the Vector3
  12833. * @returns a new array of numbers
  12834. */
  12835. asArray(): number[];
  12836. /**
  12837. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  12838. * @param array defines the destination array
  12839. * @param index defines the offset in the destination array
  12840. * @returns the current Vector3
  12841. */
  12842. toArray(array: FloatArray, index?: number): Vector3;
  12843. /**
  12844. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  12845. * @returns a new Quaternion object, computed from the Vector3 coordinates
  12846. */
  12847. toQuaternion(): Quaternion;
  12848. /**
  12849. * Adds the given vector to the current Vector3
  12850. * @param otherVector defines the second operand
  12851. * @returns the current updated Vector3
  12852. */
  12853. addInPlace(otherVector: Vector3): Vector3;
  12854. /**
  12855. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  12856. * @param otherVector defines the second operand
  12857. * @returns the resulting Vector3
  12858. */
  12859. add(otherVector: Vector3): Vector3;
  12860. /**
  12861. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  12862. * @param otherVector defines the second operand
  12863. * @param result defines the Vector3 object where to store the result
  12864. * @returns the current Vector3
  12865. */
  12866. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  12867. /**
  12868. * Subtract the given vector from the current Vector3
  12869. * @param otherVector defines the second operand
  12870. * @returns the current updated Vector3
  12871. */
  12872. subtractInPlace(otherVector: Vector3): Vector3;
  12873. /**
  12874. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  12875. * @param otherVector defines the second operand
  12876. * @returns the resulting Vector3
  12877. */
  12878. subtract(otherVector: Vector3): Vector3;
  12879. /**
  12880. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  12881. * @param otherVector defines the second operand
  12882. * @param result defines the Vector3 object where to store the result
  12883. * @returns the current Vector3
  12884. */
  12885. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  12886. /**
  12887. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  12888. * @param x defines the x coordinate of the operand
  12889. * @param y defines the y coordinate of the operand
  12890. * @param z defines the z coordinate of the operand
  12891. * @returns the resulting Vector3
  12892. */
  12893. subtractFromFloats(x: number, y: number, z: number): Vector3;
  12894. /**
  12895. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  12896. * @param x defines the x coordinate of the operand
  12897. * @param y defines the y coordinate of the operand
  12898. * @param z defines the z coordinate of the operand
  12899. * @param result defines the Vector3 object where to store the result
  12900. * @returns the current Vector3
  12901. */
  12902. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  12903. /**
  12904. * Gets a new Vector3 set with the current Vector3 negated coordinates
  12905. * @returns a new Vector3
  12906. */
  12907. negate(): Vector3;
  12908. /**
  12909. * Multiplies the Vector3 coordinates by the float "scale"
  12910. * @param scale defines the multiplier factor
  12911. * @returns the current updated Vector3
  12912. */
  12913. scaleInPlace(scale: number): Vector3;
  12914. /**
  12915. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  12916. * @param scale defines the multiplier factor
  12917. * @returns a new Vector3
  12918. */
  12919. scale(scale: number): Vector3;
  12920. /**
  12921. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  12922. * @param scale defines the multiplier factor
  12923. * @param result defines the Vector3 object where to store the result
  12924. * @returns the current Vector3
  12925. */
  12926. scaleToRef(scale: number, result: Vector3): Vector3;
  12927. /**
  12928. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  12929. * @param scale defines the scale factor
  12930. * @param result defines the Vector3 object where to store the result
  12931. * @returns the unmodified current Vector3
  12932. */
  12933. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  12934. /**
  12935. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  12936. * @param otherVector defines the second operand
  12937. * @returns true if both vectors are equals
  12938. */
  12939. equals(otherVector: Vector3): boolean;
  12940. /**
  12941. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  12942. * @param otherVector defines the second operand
  12943. * @param epsilon defines the minimal distance to define values as equals
  12944. * @returns true if both vectors are distant less than epsilon
  12945. */
  12946. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  12947. /**
  12948. * Returns true if the current Vector3 coordinates equals the given floats
  12949. * @param x defines the x coordinate of the operand
  12950. * @param y defines the y coordinate of the operand
  12951. * @param z defines the z coordinate of the operand
  12952. * @returns true if both vectors are equals
  12953. */
  12954. equalsToFloats(x: number, y: number, z: number): boolean;
  12955. /**
  12956. * Multiplies the current Vector3 coordinates by the given ones
  12957. * @param otherVector defines the second operand
  12958. * @returns the current updated Vector3
  12959. */
  12960. multiplyInPlace(otherVector: Vector3): Vector3;
  12961. /**
  12962. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  12963. * @param otherVector defines the second operand
  12964. * @returns the new Vector3
  12965. */
  12966. multiply(otherVector: Vector3): Vector3;
  12967. /**
  12968. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  12969. * @param otherVector defines the second operand
  12970. * @param result defines the Vector3 object where to store the result
  12971. * @returns the current Vector3
  12972. */
  12973. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  12974. /**
  12975. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  12976. * @param x defines the x coordinate of the operand
  12977. * @param y defines the y coordinate of the operand
  12978. * @param z defines the z coordinate of the operand
  12979. * @returns the new Vector3
  12980. */
  12981. multiplyByFloats(x: number, y: number, z: number): Vector3;
  12982. /**
  12983. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  12984. * @param otherVector defines the second operand
  12985. * @returns the new Vector3
  12986. */
  12987. divide(otherVector: Vector3): Vector3;
  12988. /**
  12989. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  12990. * @param otherVector defines the second operand
  12991. * @param result defines the Vector3 object where to store the result
  12992. * @returns the current Vector3
  12993. */
  12994. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  12995. /**
  12996. * Divides the current Vector3 coordinates by the given ones.
  12997. * @param otherVector defines the second operand
  12998. * @returns the current updated Vector3
  12999. */
  13000. divideInPlace(otherVector: Vector3): Vector3;
  13001. /**
  13002. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  13003. * @param other defines the second operand
  13004. * @returns the current updated Vector3
  13005. */
  13006. minimizeInPlace(other: Vector3): Vector3;
  13007. /**
  13008. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  13009. * @param other defines the second operand
  13010. * @returns the current updated Vector3
  13011. */
  13012. maximizeInPlace(other: Vector3): Vector3;
  13013. /**
  13014. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  13015. */
  13016. readonly isNonUniform: boolean;
  13017. /**
  13018. * Gets the length of the Vector3
  13019. * @returns the length of the Vecto3
  13020. */
  13021. length(): number;
  13022. /**
  13023. * Gets the squared length of the Vector3
  13024. * @returns squared length of the Vector3
  13025. */
  13026. lengthSquared(): number;
  13027. /**
  13028. * Normalize the current Vector3.
  13029. * Please note that this is an in place operation.
  13030. * @returns the current updated Vector3
  13031. */
  13032. normalize(): Vector3;
  13033. /**
  13034. * Normalize the current Vector3 to a new vector
  13035. * @returns the new Vector3
  13036. */
  13037. normalizeToNew(): Vector3;
  13038. /**
  13039. * Normalize the current Vector3 to the reference
  13040. * @param reference define the Vector3 to update
  13041. * @returns the updated Vector3
  13042. */
  13043. normalizeToRef(reference: Vector3): Vector3;
  13044. /**
  13045. * Creates a new Vector3 copied from the current Vector3
  13046. * @returns the new Vector3
  13047. */
  13048. clone(): Vector3;
  13049. /**
  13050. * Copies the given vector coordinates to the current Vector3 ones
  13051. * @param source defines the source Vector3
  13052. * @returns the current updated Vector3
  13053. */
  13054. copyFrom(source: Vector3): Vector3;
  13055. /**
  13056. * Copies the given floats to the current Vector3 coordinates
  13057. * @param x defines the x coordinate of the operand
  13058. * @param y defines the y coordinate of the operand
  13059. * @param z defines the z coordinate of the operand
  13060. * @returns the current updated Vector3
  13061. */
  13062. copyFromFloats(x: number, y: number, z: number): Vector3;
  13063. /**
  13064. * Copies the given floats to the current Vector3 coordinates
  13065. * @param x defines the x coordinate of the operand
  13066. * @param y defines the y coordinate of the operand
  13067. * @param z defines the z coordinate of the operand
  13068. * @returns the current updated Vector3
  13069. */
  13070. set(x: number, y: number, z: number): Vector3;
  13071. /**
  13072. * Get the clip factor between two vectors
  13073. * @param vector0 defines the first operand
  13074. * @param vector1 defines the second operand
  13075. * @param axis defines the axis to use
  13076. * @param size defines the size along the axis
  13077. * @returns the clip factor
  13078. */
  13079. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  13080. /**
  13081. * Get angle between two vectors
  13082. * @param vector0 angle between vector0 and vector1
  13083. * @param vector1 angle between vector0 and vector1
  13084. * @param normal direction of the normal
  13085. * @return the angle between vector0 and vector1
  13086. */
  13087. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  13088. /**
  13089. * Returns a new Vector3 set from the index "offset" of the given array
  13090. * @param array defines the source array
  13091. * @param offset defines the offset in the source array
  13092. * @returns the new Vector3
  13093. */
  13094. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  13095. /**
  13096. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  13097. * This function is deprecated. Use FromArray instead
  13098. * @param array defines the source array
  13099. * @param offset defines the offset in the source array
  13100. * @returns the new Vector3
  13101. */
  13102. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  13103. /**
  13104. * Sets the given vector "result" with the element values from the index "offset" of the given array
  13105. * @param array defines the source array
  13106. * @param offset defines the offset in the source array
  13107. * @param result defines the Vector3 where to store the result
  13108. */
  13109. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  13110. /**
  13111. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  13112. * This function is deprecated. Use FromArrayToRef instead.
  13113. * @param array defines the source array
  13114. * @param offset defines the offset in the source array
  13115. * @param result defines the Vector3 where to store the result
  13116. */
  13117. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  13118. /**
  13119. * Sets the given vector "result" with the given floats.
  13120. * @param x defines the x coordinate of the source
  13121. * @param y defines the y coordinate of the source
  13122. * @param z defines the z coordinate of the source
  13123. * @param result defines the Vector3 where to store the result
  13124. */
  13125. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  13126. /**
  13127. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  13128. * @returns a new empty Vector3
  13129. */
  13130. static Zero(): Vector3;
  13131. /**
  13132. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  13133. * @returns a new unit Vector3
  13134. */
  13135. static One(): Vector3;
  13136. /**
  13137. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  13138. * @returns a new up Vector3
  13139. */
  13140. static Up(): Vector3;
  13141. /**
  13142. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  13143. * @returns a new forward Vector3
  13144. */
  13145. static Forward(): Vector3;
  13146. /**
  13147. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  13148. * @returns a new right Vector3
  13149. */
  13150. static Right(): Vector3;
  13151. /**
  13152. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  13153. * @returns a new left Vector3
  13154. */
  13155. static Left(): Vector3;
  13156. /**
  13157. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  13158. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13159. * @param vector defines the Vector3 to transform
  13160. * @param transformation defines the transformation matrix
  13161. * @returns the transformed Vector3
  13162. */
  13163. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  13164. /**
  13165. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  13166. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13167. * @param vector defines the Vector3 to transform
  13168. * @param transformation defines the transformation matrix
  13169. * @param result defines the Vector3 where to store the result
  13170. */
  13171. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13172. /**
  13173. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  13174. * This method computes tranformed coordinates only, not transformed direction vectors
  13175. * @param x define the x coordinate of the source vector
  13176. * @param y define the y coordinate of the source vector
  13177. * @param z define the z coordinate of the source vector
  13178. * @param transformation defines the transformation matrix
  13179. * @param result defines the Vector3 where to store the result
  13180. */
  13181. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13182. /**
  13183. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  13184. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13185. * @param vector defines the Vector3 to transform
  13186. * @param transformation defines the transformation matrix
  13187. * @returns the new Vector3
  13188. */
  13189. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  13190. /**
  13191. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  13192. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13193. * @param vector defines the Vector3 to transform
  13194. * @param transformation defines the transformation matrix
  13195. * @param result defines the Vector3 where to store the result
  13196. */
  13197. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13198. /**
  13199. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  13200. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13201. * @param x define the x coordinate of the source vector
  13202. * @param y define the y coordinate of the source vector
  13203. * @param z define the z coordinate of the source vector
  13204. * @param transformation defines the transformation matrix
  13205. * @param result defines the Vector3 where to store the result
  13206. */
  13207. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13208. /**
  13209. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  13210. * @param value1 defines the first control point
  13211. * @param value2 defines the second control point
  13212. * @param value3 defines the third control point
  13213. * @param value4 defines the fourth control point
  13214. * @param amount defines the amount on the spline to use
  13215. * @returns the new Vector3
  13216. */
  13217. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13218. /**
  13219. * 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"
  13220. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  13221. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  13222. * @param value defines the current value
  13223. * @param min defines the lower range value
  13224. * @param max defines the upper range value
  13225. * @returns the new Vector3
  13226. */
  13227. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13228. /**
  13229. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  13230. * @param value1 defines the first control point
  13231. * @param tangent1 defines the first tangent vector
  13232. * @param value2 defines the second control point
  13233. * @param tangent2 defines the second tangent vector
  13234. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  13235. * @returns the new Vector3
  13236. */
  13237. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13238. /**
  13239. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  13240. * @param start defines the start value
  13241. * @param end defines the end value
  13242. * @param amount max defines amount between both (between 0 and 1)
  13243. * @returns the new Vector3
  13244. */
  13245. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13246. /**
  13247. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  13248. * @param start defines the start value
  13249. * @param end defines the end value
  13250. * @param amount max defines amount between both (between 0 and 1)
  13251. * @param result defines the Vector3 where to store the result
  13252. */
  13253. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13254. /**
  13255. * Returns the dot product (float) between the vectors "left" and "right"
  13256. * @param left defines the left operand
  13257. * @param right defines the right operand
  13258. * @returns the dot product
  13259. */
  13260. static Dot(left: Vector3, right: Vector3): number;
  13261. /**
  13262. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  13263. * The cross product is then orthogonal to both "left" and "right"
  13264. * @param left defines the left operand
  13265. * @param right defines the right operand
  13266. * @returns the cross product
  13267. */
  13268. static Cross(left: Vector3, right: Vector3): Vector3;
  13269. /**
  13270. * Sets the given vector "result" with the cross product of "left" and "right"
  13271. * The cross product is then orthogonal to both "left" and "right"
  13272. * @param left defines the left operand
  13273. * @param right defines the right operand
  13274. * @param result defines the Vector3 where to store the result
  13275. */
  13276. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  13277. /**
  13278. * Returns a new Vector3 as the normalization of the given vector
  13279. * @param vector defines the Vector3 to normalize
  13280. * @returns the new Vector3
  13281. */
  13282. static Normalize(vector: Vector3): Vector3;
  13283. /**
  13284. * Sets the given vector "result" with the normalization of the given first vector
  13285. * @param vector defines the Vector3 to normalize
  13286. * @param result defines the Vector3 where to store the result
  13287. */
  13288. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  13289. private static _viewportMatrixCache;
  13290. /**
  13291. * Project a Vector3 onto screen space
  13292. * @param vector defines the Vector3 to project
  13293. * @param world defines the world matrix to use
  13294. * @param transform defines the transform (view x projection) matrix to use
  13295. * @param viewport defines the screen viewport to use
  13296. * @returns the new Vector3
  13297. */
  13298. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  13299. /**
  13300. * Unproject from screen space to object space
  13301. * @param source defines the screen space Vector3 to use
  13302. * @param viewportWidth defines the current width of the viewport
  13303. * @param viewportHeight defines the current height of the viewport
  13304. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13305. * @param transform defines the transform (view x projection) matrix to use
  13306. * @returns the new Vector3
  13307. */
  13308. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  13309. /**
  13310. * Unproject from screen space to object space
  13311. * @param source defines the screen space Vector3 to use
  13312. * @param viewportWidth defines the current width of the viewport
  13313. * @param viewportHeight defines the current height of the viewport
  13314. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13315. * @param view defines the view matrix to use
  13316. * @param projection defines the projection matrix to use
  13317. * @returns the new Vector3
  13318. */
  13319. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  13320. /**
  13321. * Unproject from screen space to object space
  13322. * @param source defines the screen space Vector3 to use
  13323. * @param viewportWidth defines the current width of the viewport
  13324. * @param viewportHeight defines the current height of the viewport
  13325. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13326. * @param view defines the view matrix to use
  13327. * @param projection defines the projection matrix to use
  13328. * @param result defines the Vector3 where to store the result
  13329. */
  13330. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13331. /**
  13332. * Unproject from screen space to object space
  13333. * @param sourceX defines the screen space x coordinate to use
  13334. * @param sourceY defines the screen space y coordinate to use
  13335. * @param sourceZ defines the screen space z coordinate to use
  13336. * @param viewportWidth defines the current width of the viewport
  13337. * @param viewportHeight defines the current height of the viewport
  13338. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13339. * @param view defines the view matrix to use
  13340. * @param projection defines the projection matrix to use
  13341. * @param result defines the Vector3 where to store the result
  13342. */
  13343. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13344. /**
  13345. * Gets the minimal coordinate values between two Vector3
  13346. * @param left defines the first operand
  13347. * @param right defines the second operand
  13348. * @returns the new Vector3
  13349. */
  13350. static Minimize(left: Vector3, right: Vector3): Vector3;
  13351. /**
  13352. * Gets the maximal coordinate values between two Vector3
  13353. * @param left defines the first operand
  13354. * @param right defines the second operand
  13355. * @returns the new Vector3
  13356. */
  13357. static Maximize(left: Vector3, right: Vector3): Vector3;
  13358. /**
  13359. * Returns the distance between the vectors "value1" and "value2"
  13360. * @param value1 defines the first operand
  13361. * @param value2 defines the second operand
  13362. * @returns the distance
  13363. */
  13364. static Distance(value1: Vector3, value2: Vector3): number;
  13365. /**
  13366. * Returns the squared distance between the vectors "value1" and "value2"
  13367. * @param value1 defines the first operand
  13368. * @param value2 defines the second operand
  13369. * @returns the squared distance
  13370. */
  13371. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  13372. /**
  13373. * Returns a new Vector3 located at the center between "value1" and "value2"
  13374. * @param value1 defines the first operand
  13375. * @param value2 defines the second operand
  13376. * @returns the new Vector3
  13377. */
  13378. static Center(value1: Vector3, value2: Vector3): Vector3;
  13379. /**
  13380. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  13381. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  13382. * to something in order to rotate it from its local system to the given target system
  13383. * Note: axis1, axis2 and axis3 are normalized during this operation
  13384. * @param axis1 defines the first axis
  13385. * @param axis2 defines the second axis
  13386. * @param axis3 defines the third axis
  13387. * @returns a new Vector3
  13388. */
  13389. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  13390. /**
  13391. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  13392. * @param axis1 defines the first axis
  13393. * @param axis2 defines the second axis
  13394. * @param axis3 defines the third axis
  13395. * @param ref defines the Vector3 where to store the result
  13396. */
  13397. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  13398. }
  13399. class Vector4 {
  13400. x: number;
  13401. y: number;
  13402. z: number;
  13403. w: number;
  13404. /**
  13405. * Creates a Vector4 object from the given floats.
  13406. */
  13407. constructor(x: number, y: number, z: number, w: number);
  13408. /**
  13409. * Returns the string with the Vector4 coordinates.
  13410. */
  13411. toString(): string;
  13412. /**
  13413. * Returns the string "Vector4".
  13414. */
  13415. getClassName(): string;
  13416. /**
  13417. * Returns the Vector4 hash code.
  13418. */
  13419. getHashCode(): number;
  13420. /**
  13421. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  13422. */
  13423. asArray(): number[];
  13424. /**
  13425. * Populates the given array from the given index with the Vector4 coordinates.
  13426. * Returns the Vector4.
  13427. */
  13428. toArray(array: FloatArray, index?: number): Vector4;
  13429. /**
  13430. * Adds the given vector to the current Vector4.
  13431. * Returns the updated Vector4.
  13432. */
  13433. addInPlace(otherVector: Vector4): Vector4;
  13434. /**
  13435. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  13436. */
  13437. add(otherVector: Vector4): Vector4;
  13438. /**
  13439. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  13440. * Returns the current Vector4.
  13441. */
  13442. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  13443. /**
  13444. * Subtract in place the given vector from the current Vector4.
  13445. * Returns the updated Vector4.
  13446. */
  13447. subtractInPlace(otherVector: Vector4): Vector4;
  13448. /**
  13449. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  13450. */
  13451. subtract(otherVector: Vector4): Vector4;
  13452. /**
  13453. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  13454. * Returns the current Vector4.
  13455. */
  13456. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  13457. /**
  13458. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13459. */
  13460. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13461. /**
  13462. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13463. * Returns the current Vector4.
  13464. */
  13465. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  13466. /**
  13467. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  13468. */
  13469. negate(): Vector4;
  13470. /**
  13471. * Multiplies the current Vector4 coordinates by scale (float).
  13472. * Returns the updated Vector4.
  13473. */
  13474. scaleInPlace(scale: number): Vector4;
  13475. /**
  13476. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  13477. */
  13478. scale(scale: number): Vector4;
  13479. /**
  13480. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  13481. * Returns the current Vector4.
  13482. */
  13483. scaleToRef(scale: number, result: Vector4): Vector4;
  13484. /**
  13485. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  13486. * @param scale defines the scale factor
  13487. * @param result defines the Vector4 object where to store the result
  13488. * @returns the unmodified current Vector4
  13489. */
  13490. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  13491. /**
  13492. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  13493. */
  13494. equals(otherVector: Vector4): boolean;
  13495. /**
  13496. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  13497. */
  13498. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  13499. /**
  13500. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  13501. */
  13502. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  13503. /**
  13504. * Multiplies in place the current Vector4 by the given one.
  13505. * Returns the updated Vector4.
  13506. */
  13507. multiplyInPlace(otherVector: Vector4): Vector4;
  13508. /**
  13509. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  13510. */
  13511. multiply(otherVector: Vector4): Vector4;
  13512. /**
  13513. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  13514. * Returns the current Vector4.
  13515. */
  13516. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  13517. /**
  13518. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  13519. */
  13520. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  13521. /**
  13522. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  13523. */
  13524. divide(otherVector: Vector4): Vector4;
  13525. /**
  13526. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  13527. * Returns the current Vector4.
  13528. */
  13529. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  13530. /**
  13531. * Divides the current Vector3 coordinates by the given ones.
  13532. * @returns the updated Vector3.
  13533. */
  13534. divideInPlace(otherVector: Vector4): Vector4;
  13535. /**
  13536. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  13537. * @param other defines the second operand
  13538. * @returns the current updated Vector4
  13539. */
  13540. minimizeInPlace(other: Vector4): Vector4;
  13541. /**
  13542. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  13543. * @param other defines the second operand
  13544. * @returns the current updated Vector4
  13545. */
  13546. maximizeInPlace(other: Vector4): Vector4;
  13547. /**
  13548. * Returns the Vector4 length (float).
  13549. */
  13550. length(): number;
  13551. /**
  13552. * Returns the Vector4 squared length (float).
  13553. */
  13554. lengthSquared(): number;
  13555. /**
  13556. * Normalizes in place the Vector4.
  13557. * Returns the updated Vector4.
  13558. */
  13559. normalize(): Vector4;
  13560. /**
  13561. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  13562. */
  13563. toVector3(): Vector3;
  13564. /**
  13565. * Returns a new Vector4 copied from the current one.
  13566. */
  13567. clone(): Vector4;
  13568. /**
  13569. * Updates the current Vector4 with the given one coordinates.
  13570. * Returns the updated Vector4.
  13571. */
  13572. copyFrom(source: Vector4): Vector4;
  13573. /**
  13574. * Updates the current Vector4 coordinates with the given floats.
  13575. * Returns the updated Vector4.
  13576. */
  13577. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13578. /**
  13579. * Updates the current Vector4 coordinates with the given floats.
  13580. * Returns the updated Vector4.
  13581. */
  13582. set(x: number, y: number, z: number, w: number): Vector4;
  13583. /**
  13584. * Returns a new Vector4 set from the starting index of the given array.
  13585. */
  13586. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  13587. /**
  13588. * Updates the given vector "result" from the starting index of the given array.
  13589. */
  13590. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  13591. /**
  13592. * Updates the given vector "result" from the starting index of the given Float32Array.
  13593. */
  13594. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  13595. /**
  13596. * Updates the given vector "result" coordinates from the given floats.
  13597. */
  13598. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  13599. /**
  13600. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  13601. */
  13602. static Zero(): Vector4;
  13603. /**
  13604. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  13605. */
  13606. static One(): Vector4;
  13607. /**
  13608. * Returns a new normalized Vector4 from the given one.
  13609. */
  13610. static Normalize(vector: Vector4): Vector4;
  13611. /**
  13612. * Updates the given vector "result" from the normalization of the given one.
  13613. */
  13614. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  13615. static Minimize(left: Vector4, right: Vector4): Vector4;
  13616. static Maximize(left: Vector4, right: Vector4): Vector4;
  13617. /**
  13618. * Returns the distance (float) between the vectors "value1" and "value2".
  13619. */
  13620. static Distance(value1: Vector4, value2: Vector4): number;
  13621. /**
  13622. * Returns the squared distance (float) between the vectors "value1" and "value2".
  13623. */
  13624. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  13625. /**
  13626. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  13627. */
  13628. static Center(value1: Vector4, value2: Vector4): Vector4;
  13629. /**
  13630. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  13631. * This methods computes transformed normalized direction vectors only.
  13632. */
  13633. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  13634. /**
  13635. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  13636. * This methods computes transformed normalized direction vectors only.
  13637. */
  13638. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  13639. /**
  13640. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  13641. * This methods computes transformed normalized direction vectors only.
  13642. */
  13643. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  13644. }
  13645. interface ISize {
  13646. width: number;
  13647. height: number;
  13648. }
  13649. class Size implements ISize {
  13650. width: number;
  13651. height: number;
  13652. /**
  13653. * Creates a Size object from the given width and height (floats).
  13654. */
  13655. constructor(width: number, height: number);
  13656. toString(): string;
  13657. /**
  13658. * Returns the string "Size"
  13659. */
  13660. getClassName(): string;
  13661. /**
  13662. * Returns the Size hash code.
  13663. */
  13664. getHashCode(): number;
  13665. /**
  13666. * Updates the current size from the given one.
  13667. * Returns the updated Size.
  13668. */
  13669. copyFrom(src: Size): void;
  13670. /**
  13671. * Updates in place the current Size from the given floats.
  13672. * Returns the updated Size.
  13673. */
  13674. copyFromFloats(width: number, height: number): Size;
  13675. /**
  13676. * Updates in place the current Size from the given floats.
  13677. * Returns the updated Size.
  13678. */
  13679. set(width: number, height: number): Size;
  13680. /**
  13681. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  13682. */
  13683. multiplyByFloats(w: number, h: number): Size;
  13684. /**
  13685. * Returns a new Size copied from the given one.
  13686. */
  13687. clone(): Size;
  13688. /**
  13689. * Boolean : True if the current Size and the given one width and height are strictly equal.
  13690. */
  13691. equals(other: Size): boolean;
  13692. /**
  13693. * Returns the surface of the Size : width * height (float).
  13694. */
  13695. readonly surface: number;
  13696. /**
  13697. * Returns a new Size set to (0.0, 0.0)
  13698. */
  13699. static Zero(): Size;
  13700. /**
  13701. * Returns a new Size set as the addition result of the current Size and the given one.
  13702. */
  13703. add(otherSize: Size): Size;
  13704. /**
  13705. * Returns a new Size set as the subtraction result of the given one from the current Size.
  13706. */
  13707. subtract(otherSize: Size): Size;
  13708. /**
  13709. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  13710. */
  13711. static Lerp(start: Size, end: Size, amount: number): Size;
  13712. }
  13713. /**
  13714. * Class used to store quaternion data
  13715. * @see https://en.wikipedia.org/wiki/Quaternion
  13716. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  13717. */
  13718. class Quaternion {
  13719. /** defines the first component (0 by default) */
  13720. x: number;
  13721. /** defines the second component (0 by default) */
  13722. y: number;
  13723. /** defines the third component (0 by default) */
  13724. z: number;
  13725. /** defines the fourth component (1.0 by default) */
  13726. w: number;
  13727. /**
  13728. * Creates a new Quaternion from the given floats
  13729. * @param x defines the first component (0 by default)
  13730. * @param y defines the second component (0 by default)
  13731. * @param z defines the third component (0 by default)
  13732. * @param w defines the fourth component (1.0 by default)
  13733. */
  13734. constructor(
  13735. /** defines the first component (0 by default) */
  13736. x?: number,
  13737. /** defines the second component (0 by default) */
  13738. y?: number,
  13739. /** defines the third component (0 by default) */
  13740. z?: number,
  13741. /** defines the fourth component (1.0 by default) */
  13742. w?: number);
  13743. /**
  13744. * Gets a string representation for the current quaternion
  13745. * @returns a string with the Quaternion coordinates
  13746. */
  13747. toString(): string;
  13748. /**
  13749. * Gets the class name of the quaternion
  13750. * @returns the string "Quaternion"
  13751. */
  13752. getClassName(): string;
  13753. /**
  13754. * Gets a hash code for this quaternion
  13755. * @returns the quaternion hash code
  13756. */
  13757. getHashCode(): number;
  13758. /**
  13759. * Copy the quaternion to an array
  13760. * @returns a new array populated with 4 elements from the quaternion coordinates
  13761. */
  13762. asArray(): number[];
  13763. /**
  13764. * Check if two quaternions are equals
  13765. * @param otherQuaternion defines the second operand
  13766. * @return true if the current quaternion and the given one coordinates are strictly equals
  13767. */
  13768. equals(otherQuaternion: Quaternion): boolean;
  13769. /**
  13770. * Clone the current quaternion
  13771. * @returns a new quaternion copied from the current one
  13772. */
  13773. clone(): Quaternion;
  13774. /**
  13775. * Copy a quaternion to the current one
  13776. * @param other defines the other quaternion
  13777. * @returns the updated current quaternion
  13778. */
  13779. copyFrom(other: Quaternion): Quaternion;
  13780. /**
  13781. * Updates the current quaternion with the given float coordinates
  13782. * @param x defines the x coordinate
  13783. * @param y defines the y coordinate
  13784. * @param z defines the z coordinate
  13785. * @param w defines the w coordinate
  13786. * @returns the updated current quaternion
  13787. */
  13788. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  13789. /**
  13790. * Updates the current quaternion from the given float coordinates
  13791. * @param x defines the x coordinate
  13792. * @param y defines the y coordinate
  13793. * @param z defines the z coordinate
  13794. * @param w defines the w coordinate
  13795. * @returns the updated current quaternion
  13796. */
  13797. set(x: number, y: number, z: number, w: number): Quaternion;
  13798. /**
  13799. * Adds two quaternions
  13800. * @param other defines the second operand
  13801. * @returns a new quaternion as the addition result of the given one and the current quaternion
  13802. */
  13803. add(other: Quaternion): Quaternion;
  13804. /**
  13805. * Add a quaternion to the current one
  13806. * @param other defines the quaternion to add
  13807. * @returns the current quaternion
  13808. */
  13809. addInPlace(other: Quaternion): Quaternion;
  13810. /**
  13811. * Subtract two quaternions
  13812. * @param other defines the second operand
  13813. * @returns a new quaternion as the subtraction result of the given one from the current one
  13814. */
  13815. subtract(other: Quaternion): Quaternion;
  13816. /**
  13817. * Multiplies the current quaternion by a scale factor
  13818. * @param value defines the scale factor
  13819. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  13820. */
  13821. scale(value: number): Quaternion;
  13822. /**
  13823. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  13824. * @param scale defines the scale factor
  13825. * @param result defines the Quaternion object where to store the result
  13826. * @returns the unmodified current quaternion
  13827. */
  13828. scaleToRef(scale: number, result: Quaternion): Quaternion;
  13829. /**
  13830. * Multiplies in place the current quaternion by a scale factor
  13831. * @param value defines the scale factor
  13832. * @returns the current modified quaternion
  13833. */
  13834. scaleInPlace(value: number): Quaternion;
  13835. /**
  13836. * Scale the current quaternion values by a factor and add the result to a given quaternion
  13837. * @param scale defines the scale factor
  13838. * @param result defines the Quaternion object where to store the result
  13839. * @returns the unmodified current quaternion
  13840. */
  13841. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  13842. /**
  13843. * Multiplies two quaternions
  13844. * @param q1 defines the second operand
  13845. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  13846. */
  13847. multiply(q1: Quaternion): Quaternion;
  13848. /**
  13849. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  13850. * @param q1 defines the second operand
  13851. * @param result defines the target quaternion
  13852. * @returns the current quaternion
  13853. */
  13854. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  13855. /**
  13856. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  13857. * @param q1 defines the second operand
  13858. * @returns the currentupdated quaternion
  13859. */
  13860. multiplyInPlace(q1: Quaternion): Quaternion;
  13861. /**
  13862. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  13863. * @param ref defines the target quaternion
  13864. * @returns the current quaternion
  13865. */
  13866. conjugateToRef(ref: Quaternion): Quaternion;
  13867. /**
  13868. * Conjugates in place (1-q) the current quaternion
  13869. * @returns the current updated quaternion
  13870. */
  13871. conjugateInPlace(): Quaternion;
  13872. /**
  13873. * Conjugates in place (1-q) the current quaternion
  13874. * @returns a new quaternion
  13875. */
  13876. conjugate(): Quaternion;
  13877. /**
  13878. * Gets length of current quaternion
  13879. * @returns the quaternion length (float)
  13880. */
  13881. length(): number;
  13882. /**
  13883. * Normalize in place the current quaternion
  13884. * @returns the current updated quaternion
  13885. */
  13886. normalize(): Quaternion;
  13887. /**
  13888. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  13889. * @param order is a reserved parameter and is ignore for now
  13890. * @returns a new Vector3 containing the Euler angles
  13891. */
  13892. toEulerAngles(order?: string): Vector3;
  13893. /**
  13894. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  13895. * @param result defines the vector which will be filled with the Euler angles
  13896. * @param order is a reserved parameter and is ignore for now
  13897. * @returns the current unchanged quaternion
  13898. */
  13899. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  13900. /**
  13901. * Updates the given rotation matrix with the current quaternion values
  13902. * @param result defines the target matrix
  13903. * @returns the current unchanged quaternion
  13904. */
  13905. toRotationMatrix(result: Matrix): Quaternion;
  13906. /**
  13907. * Updates the current quaternion from the given rotation matrix values
  13908. * @param matrix defines the source matrix
  13909. * @returns the current updated quaternion
  13910. */
  13911. fromRotationMatrix(matrix: Matrix): Quaternion;
  13912. /**
  13913. * Creates a new quaternion from a rotation matrix
  13914. * @param matrix defines the source matrix
  13915. * @returns a new quaternion created from the given rotation matrix values
  13916. */
  13917. static FromRotationMatrix(matrix: Matrix): Quaternion;
  13918. /**
  13919. * Updates the given quaternion with the given rotation matrix values
  13920. * @param matrix defines the source matrix
  13921. * @param result defines the target quaternion
  13922. */
  13923. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  13924. /**
  13925. * Creates an empty quaternion
  13926. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  13927. */
  13928. static Zero(): Quaternion;
  13929. /**
  13930. * Inverse a given quaternion
  13931. * @param q defines the source quaternion
  13932. * @returns a new quaternion as the inverted current quaternion
  13933. */
  13934. static Inverse(q: Quaternion): Quaternion;
  13935. /**
  13936. * Creates an identity quaternion
  13937. * @returns the identity quaternion
  13938. */
  13939. static Identity(): Quaternion;
  13940. /**
  13941. * Gets a boolean indicating if the given quaternion is identity
  13942. * @param quaternion defines the quaternion to check
  13943. * @returns true if the quaternion is identity
  13944. */
  13945. static IsIdentity(quaternion: Quaternion): boolean;
  13946. /**
  13947. * Creates a quaternion from a rotation around an axis
  13948. * @param axis defines the axis to use
  13949. * @param angle defines the angle to use
  13950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  13951. */
  13952. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  13953. /**
  13954. * Creates a rotation around an axis and stores it into the given quaternion
  13955. * @param axis defines the axis to use
  13956. * @param angle defines the angle to use
  13957. * @param result defines the target quaternion
  13958. * @returns the target quaternion
  13959. */
  13960. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  13961. /**
  13962. * Creates a new quaternion from data stored into an array
  13963. * @param array defines the data source
  13964. * @param offset defines the offset in the source array where the data starts
  13965. * @returns a new quaternion
  13966. */
  13967. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  13968. /**
  13969. * Creates a new quaternion from the given Euler float angles (y, x, z)
  13970. * @param yaw defines the rotation around Y axis
  13971. * @param pitch defines the rotation around X axis
  13972. * @param roll defines the rotation around Z axis
  13973. * @returns the new quaternion
  13974. */
  13975. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  13976. /**
  13977. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  13978. * @param yaw defines the rotation around Y axis
  13979. * @param pitch defines the rotation around X axis
  13980. * @param roll defines the rotation around Z axis
  13981. * @param result defines the target quaternion
  13982. */
  13983. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  13984. /**
  13985. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  13986. * @param alpha defines the rotation around first axis
  13987. * @param beta defines the rotation around second axis
  13988. * @param gamma defines the rotation around third axis
  13989. * @returns the new quaternion
  13990. */
  13991. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  13992. /**
  13993. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  13994. * @param alpha defines the rotation around first axis
  13995. * @param beta defines the rotation around second axis
  13996. * @param gamma defines the rotation around third axis
  13997. * @param result defines the target quaternion
  13998. */
  13999. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  14000. /**
  14001. * 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)
  14002. * @param axis1 defines the first axis
  14003. * @param axis2 defines the second axis
  14004. * @param axis3 defines the third axis
  14005. * @returns the new quaternion
  14006. */
  14007. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  14008. /**
  14009. * 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
  14010. * @param axis1 defines the first axis
  14011. * @param axis2 defines the second axis
  14012. * @param axis3 defines the third axis
  14013. * @param ref defines the target quaternion
  14014. */
  14015. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  14016. /**
  14017. * Interpolates between two quaternions
  14018. * @param left defines first quaternion
  14019. * @param right defines second quaternion
  14020. * @param amount defines the gradient to use
  14021. * @returns the new interpolated quaternion
  14022. */
  14023. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  14024. /**
  14025. * Interpolates between two quaternions and stores it into a target quaternion
  14026. * @param left defines first quaternion
  14027. * @param right defines second quaternion
  14028. * @param amount defines the gradient to use
  14029. * @param result defines the target quaternion
  14030. */
  14031. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  14032. /**
  14033. * Interpolate between two quaternions using Hermite interpolation
  14034. * @param value1 defines first quaternion
  14035. * @param tangent1 defines the incoming tangent
  14036. * @param value2 defines second quaternion
  14037. * @param tangent2 defines the outgoing tangent
  14038. * @param amount defines the target quaternion
  14039. * @returns the new interpolated quaternion
  14040. */
  14041. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  14042. }
  14043. /**
  14044. * Class used to store matrix data (4x4)
  14045. */
  14046. class Matrix {
  14047. private static _tempQuaternion;
  14048. private static _xAxis;
  14049. private static _yAxis;
  14050. private static _zAxis;
  14051. private static _updateFlagSeed;
  14052. private static _identityReadOnly;
  14053. private _isIdentity;
  14054. private _isIdentityDirty;
  14055. /**
  14056. * Gets the update flag of the matrix which is an unique number for the matrix.
  14057. * It will be incremented every time the matrix data change.
  14058. * You can use it to speed the comparison between two versions of the same matrix.
  14059. */
  14060. updateFlag: number;
  14061. /**
  14062. * Gets or sets the internal data of the matrix
  14063. */
  14064. m: Float32Array;
  14065. /** @hidden */
  14066. _markAsUpdated(): void;
  14067. /**
  14068. * Creates an empty matrix (filled with zeros)
  14069. */
  14070. constructor();
  14071. /**
  14072. * Check if the current matrix is indentity
  14073. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  14074. * @returns true is the matrix is the identity matrix
  14075. */
  14076. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  14077. /**
  14078. * Gets the determinant of the matrix
  14079. * @returns the matrix determinant
  14080. */
  14081. determinant(): number;
  14082. /**
  14083. * Returns the matrix as a Float32Array
  14084. * @returns the matrix underlying array
  14085. */
  14086. toArray(): Float32Array;
  14087. /**
  14088. * Returns the matrix as a Float32Array
  14089. * @returns the matrix underlying array.
  14090. */
  14091. asArray(): Float32Array;
  14092. /**
  14093. * Inverts the current matrix in place
  14094. * @returns the current inverted matrix
  14095. */
  14096. invert(): Matrix;
  14097. /**
  14098. * Sets all the matrix elements to zero
  14099. * @returns the current matrix
  14100. */
  14101. reset(): Matrix;
  14102. /**
  14103. * Adds the current matrix with a second one
  14104. * @param other defines the matrix to add
  14105. * @returns a new matrix as the addition of the current matrix and the given one
  14106. */
  14107. add(other: Matrix): Matrix;
  14108. /**
  14109. * Sets the given matrix "result" to the addition of the current matrix and the given one
  14110. * @param other defines the matrix to add
  14111. * @param result defines the target matrix
  14112. * @returns the current matrix
  14113. */
  14114. addToRef(other: Matrix, result: Matrix): Matrix;
  14115. /**
  14116. * Adds in place the given matrix to the current matrix
  14117. * @param other defines the second operand
  14118. * @returns the current updated matrix
  14119. */
  14120. addToSelf(other: Matrix): Matrix;
  14121. /**
  14122. * Sets the given matrix to the current inverted Matrix
  14123. * @param other defines the target matrix
  14124. * @returns the unmodified current matrix
  14125. */
  14126. invertToRef(other: Matrix): Matrix;
  14127. /**
  14128. * Inserts the translation vector (using 3 floats) in the current matrix
  14129. * @param x defines the 1st component of the translation
  14130. * @param y defines the 2nd component of the translation
  14131. * @param z defines the 3rd component of the translation
  14132. * @returns the current updated matrix
  14133. */
  14134. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  14135. /**
  14136. * Inserts the translation vector in the current matrix
  14137. * @param vector3 defines the translation to insert
  14138. * @returns the current updated matrix
  14139. */
  14140. setTranslation(vector3: Vector3): Matrix;
  14141. /**
  14142. * Gets the translation value of the current matrix
  14143. * @returns a new Vector3 as the extracted translation from the matrix
  14144. */
  14145. getTranslation(): Vector3;
  14146. /**
  14147. * Fill a Vector3 with the extracted translation from the matrix
  14148. * @param result defines the Vector3 where to store the translation
  14149. * @returns the current matrix
  14150. */
  14151. getTranslationToRef(result: Vector3): Matrix;
  14152. /**
  14153. * Remove rotation and scaling part from the matrix
  14154. * @returns the updated matrix
  14155. */
  14156. removeRotationAndScaling(): Matrix;
  14157. /**
  14158. * Multiply two matrices
  14159. * @param other defines the second operand
  14160. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  14161. */
  14162. multiply(other: Matrix): Matrix;
  14163. /**
  14164. * Copy the current matrix from the given one
  14165. * @param other defines the source matrix
  14166. * @returns the current updated matrix
  14167. */
  14168. copyFrom(other: Matrix): Matrix;
  14169. /**
  14170. * Populates the given array from the starting index with the current matrix values
  14171. * @param array defines the target array
  14172. * @param offset defines the offset in the target array where to start storing values
  14173. * @returns the current matrix
  14174. */
  14175. copyToArray(array: Float32Array, offset?: number): Matrix;
  14176. /**
  14177. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  14178. * @param other defines the second operand
  14179. * @param result defines the matrix where to store the multiplication
  14180. * @returns the current matrix
  14181. */
  14182. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  14183. /**
  14184. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  14185. * @param other defines the second operand
  14186. * @param result defines the array where to store the multiplication
  14187. * @param offset defines the offset in the target array where to start storing values
  14188. * @returns the current matrix
  14189. */
  14190. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  14191. /**
  14192. * Check equality between this matrix and a second one
  14193. * @param value defines the second matrix to compare
  14194. * @returns true is the current matrix and the given one values are strictly equal
  14195. */
  14196. equals(value: Matrix): boolean;
  14197. /**
  14198. * Clone the current matrix
  14199. * @returns a new matrix from the current matrix
  14200. */
  14201. clone(): Matrix;
  14202. /**
  14203. * Returns the name of the current matrix class
  14204. * @returns the string "Matrix"
  14205. */
  14206. getClassName(): string;
  14207. /**
  14208. * Gets the hash code of the current matrix
  14209. * @returns the hash code
  14210. */
  14211. getHashCode(): number;
  14212. /**
  14213. * Decomposes the current Matrix into a translation, rotation and scaling components
  14214. * @param scale defines the scale vector3 given as a reference to update
  14215. * @param rotation defines the rotation quaternion given as a reference to update
  14216. * @param translation defines the translation vector3 given as a reference to update
  14217. * @returns true if operation was successful
  14218. */
  14219. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  14220. /**
  14221. * Gets specific row of the matrix
  14222. * @param index defines the number of the row to get
  14223. * @returns the index-th row of the current matrix as a new Vector4
  14224. */
  14225. getRow(index: number): Nullable<Vector4>;
  14226. /**
  14227. * Sets the index-th row of the current matrix to the vector4 values
  14228. * @param index defines the number of the row to set
  14229. * @param row defines the target vector4
  14230. * @returns the updated current matrix
  14231. */
  14232. setRow(index: number, row: Vector4): Matrix;
  14233. /**
  14234. * Compute the transpose of the matrix
  14235. * @returns the new transposed matrix
  14236. */
  14237. transpose(): Matrix;
  14238. /**
  14239. * Compute the transpose of the matrix and store it in a given matrix
  14240. * @param result defines the target matrix
  14241. * @returns the current matrix
  14242. */
  14243. transposeToRef(result: Matrix): Matrix;
  14244. /**
  14245. * Sets the index-th row of the current matrix with the given 4 x float values
  14246. * @param index defines the row index
  14247. * @param x defines the x component to set
  14248. * @param y defines the y component to set
  14249. * @param z defines the z component to set
  14250. * @param w defines the w component to set
  14251. * @returns the updated current matrix
  14252. */
  14253. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  14254. /**
  14255. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  14256. * @param scale defines the scale factor
  14257. * @returns a new matrix
  14258. */
  14259. scale(scale: number): Matrix;
  14260. /**
  14261. * Scale the current matrix values by a factor to a given result matrix
  14262. * @param scale defines the scale factor
  14263. * @param result defines the matrix to store the result
  14264. * @returns the current matrix
  14265. */
  14266. scaleToRef(scale: number, result: Matrix): Matrix;
  14267. /**
  14268. * Scale the current matrix values by a factor and add the result to a given matrix
  14269. * @param scale defines the scale factor
  14270. * @param result defines the Matrix to store the result
  14271. * @returns the current matrix
  14272. */
  14273. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  14274. /**
  14275. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  14276. * @param ref matrix to store the result
  14277. */
  14278. toNormalMatrix(ref: Matrix): void;
  14279. /**
  14280. * Gets only rotation part of the current matrix
  14281. * @returns a new matrix sets to the extracted rotation matrix from the current one
  14282. */
  14283. getRotationMatrix(): Matrix;
  14284. /**
  14285. * Extracts the rotation matrix from the current one and sets it as the given "result"
  14286. * @param result defines the target matrix to store data to
  14287. * @returns the current matrix
  14288. */
  14289. getRotationMatrixToRef(result: Matrix): Matrix;
  14290. /**
  14291. * Creates a matrix from an array
  14292. * @param array defines the source array
  14293. * @param offset defines an offset in the source array
  14294. * @returns a new Matrix set from the starting index of the given array
  14295. */
  14296. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  14297. /**
  14298. * Copy the content of an array into a given matrix
  14299. * @param array defines the source array
  14300. * @param offset defines an offset in the source array
  14301. * @param result defines the target matrix
  14302. */
  14303. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  14304. /**
  14305. * Stores an array into a matrix after having multiplied each component by a given factor
  14306. * @param array defines the source array
  14307. * @param offset defines the offset in the source array
  14308. * @param scale defines the scaling factor
  14309. * @param result defines the target matrix
  14310. */
  14311. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  14312. /**
  14313. * Stores a list of values (16) inside a given matrix
  14314. * @param initialM11 defines 1st value of 1st row
  14315. * @param initialM12 defines 2nd value of 1st row
  14316. * @param initialM13 defines 3rd value of 1st row
  14317. * @param initialM14 defines 4th value of 1st row
  14318. * @param initialM21 defines 1st value of 2nd row
  14319. * @param initialM22 defines 2nd value of 2nd row
  14320. * @param initialM23 defines 3rd value of 2nd row
  14321. * @param initialM24 defines 4th value of 2nd row
  14322. * @param initialM31 defines 1st value of 3rd row
  14323. * @param initialM32 defines 2nd value of 3rd row
  14324. * @param initialM33 defines 3rd value of 3rd row
  14325. * @param initialM34 defines 4th value of 3rd row
  14326. * @param initialM41 defines 1st value of 4th row
  14327. * @param initialM42 defines 2nd value of 4th row
  14328. * @param initialM43 defines 3rd value of 4th row
  14329. * @param initialM44 defines 4th value of 4th row
  14330. * @param result defines the target matrix
  14331. */
  14332. 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;
  14333. /**
  14334. * Gets an identity matrix that must not be updated
  14335. */
  14336. static readonly IdentityReadOnly: Matrix;
  14337. /**
  14338. * Creates new matrix from a list of values (16)
  14339. * @param initialM11 defines 1st value of 1st row
  14340. * @param initialM12 defines 2nd value of 1st row
  14341. * @param initialM13 defines 3rd value of 1st row
  14342. * @param initialM14 defines 4th value of 1st row
  14343. * @param initialM21 defines 1st value of 2nd row
  14344. * @param initialM22 defines 2nd value of 2nd row
  14345. * @param initialM23 defines 3rd value of 2nd row
  14346. * @param initialM24 defines 4th value of 2nd row
  14347. * @param initialM31 defines 1st value of 3rd row
  14348. * @param initialM32 defines 2nd value of 3rd row
  14349. * @param initialM33 defines 3rd value of 3rd row
  14350. * @param initialM34 defines 4th value of 3rd row
  14351. * @param initialM41 defines 1st value of 4th row
  14352. * @param initialM42 defines 2nd value of 4th row
  14353. * @param initialM43 defines 3rd value of 4th row
  14354. * @param initialM44 defines 4th value of 4th row
  14355. * @returns the new matrix
  14356. */
  14357. 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;
  14358. /**
  14359. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14360. * @param scale defines the scale vector3
  14361. * @param rotation defines the rotation quaternion
  14362. * @param translation defines the translation vector3
  14363. * @returns a new matrix
  14364. */
  14365. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  14366. /**
  14367. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14368. * @param scale defines the scale vector3
  14369. * @param rotation defines the rotation quaternion
  14370. * @param translation defines the translation vector3
  14371. * @param result defines the target matrix
  14372. */
  14373. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  14374. /**
  14375. * Creates a new identity matrix
  14376. * @returns a new identity matrix
  14377. */
  14378. static Identity(): Matrix;
  14379. /**
  14380. * Creates a new identity matrix and stores the result in a given matrix
  14381. * @param result defines the target matrix
  14382. */
  14383. static IdentityToRef(result: Matrix): void;
  14384. /**
  14385. * Creates a new zero matrix
  14386. * @returns a new zero matrix
  14387. */
  14388. static Zero(): Matrix;
  14389. /**
  14390. * Creates a new rotation matrix for "angle" radians around the X axis
  14391. * @param angle defines the angle (in radians) to use
  14392. * @return the new matrix
  14393. */
  14394. static RotationX(angle: number): Matrix;
  14395. /**
  14396. * Creates a new matrix as the invert of a given matrix
  14397. * @param source defines the source matrix
  14398. * @returns the new matrix
  14399. */
  14400. static Invert(source: Matrix): Matrix;
  14401. /**
  14402. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  14403. * @param angle defines the angle (in radians) to use
  14404. * @param result defines the target matrix
  14405. */
  14406. static RotationXToRef(angle: number, result: Matrix): void;
  14407. /**
  14408. * Creates a new rotation matrix for "angle" radians around the Y axis
  14409. * @param angle defines the angle (in radians) to use
  14410. * @return the new matrix
  14411. */
  14412. static RotationY(angle: number): Matrix;
  14413. /**
  14414. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  14415. * @param angle defines the angle (in radians) to use
  14416. * @param result defines the target matrix
  14417. */
  14418. static RotationYToRef(angle: number, result: Matrix): void;
  14419. /**
  14420. * Creates a new rotation matrix for "angle" radians around the Z axis
  14421. * @param angle defines the angle (in radians) to use
  14422. * @return the new matrix
  14423. */
  14424. static RotationZ(angle: number): Matrix;
  14425. /**
  14426. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  14427. * @param angle defines the angle (in radians) to use
  14428. * @param result defines the target matrix
  14429. */
  14430. static RotationZToRef(angle: number, result: Matrix): void;
  14431. /**
  14432. * Creates a new rotation matrix for "angle" radians around the given axis
  14433. * @param axis defines the axis to use
  14434. * @param angle defines the angle (in radians) to use
  14435. * @return the new matrix
  14436. */
  14437. static RotationAxis(axis: Vector3, angle: number): Matrix;
  14438. /**
  14439. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  14440. * @param axis defines the axis to use
  14441. * @param angle defines the angle (in radians) to use
  14442. * @param result defines the target matrix
  14443. */
  14444. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  14445. /**
  14446. * Creates a rotation matrix
  14447. * @param yaw defines the yaw angle in radians (Y axis)
  14448. * @param pitch defines the pitch angle in radians (X axis)
  14449. * @param roll defines the roll angle in radians (X axis)
  14450. * @returns the new rotation matrix
  14451. */
  14452. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  14453. /**
  14454. * Creates a rotation matrix and stores it in a given matrix
  14455. * @param yaw defines the yaw angle in radians (Y axis)
  14456. * @param pitch defines the pitch angle in radians (X axis)
  14457. * @param roll defines the roll angle in radians (X axis)
  14458. * @param result defines the target matrix
  14459. */
  14460. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  14461. /**
  14462. * Creates a scaling matrix
  14463. * @param x defines the scale factor on X axis
  14464. * @param y defines the scale factor on Y axis
  14465. * @param z defines the scale factor on Z axis
  14466. * @returns the new matrix
  14467. */
  14468. static Scaling(x: number, y: number, z: number): Matrix;
  14469. /**
  14470. * Creates a scaling matrix and stores it in a given matrix
  14471. * @param x defines the scale factor on X axis
  14472. * @param y defines the scale factor on Y axis
  14473. * @param z defines the scale factor on Z axis
  14474. * @param result defines the target matrix
  14475. */
  14476. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  14477. /**
  14478. * Creates a translation matrix
  14479. * @param x defines the translation on X axis
  14480. * @param y defines the translation on Y axis
  14481. * @param z defines the translationon Z axis
  14482. * @returns the new matrix
  14483. */
  14484. static Translation(x: number, y: number, z: number): Matrix;
  14485. /**
  14486. * Creates a translation matrix and stores it in a given matrix
  14487. * @param x defines the translation on X axis
  14488. * @param y defines the translation on Y axis
  14489. * @param z defines the translationon Z axis
  14490. * @param result defines the target matrix
  14491. */
  14492. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  14493. /**
  14494. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14495. * @param startValue defines the start value
  14496. * @param endValue defines the end value
  14497. * @param gradient defines the gradient factor
  14498. * @returns the new matrix
  14499. */
  14500. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14501. /**
  14502. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14503. * @param startValue defines the start value
  14504. * @param endValue defines the end value
  14505. * @param gradient defines the gradient factor
  14506. * @param result defines the Matrix object where to store data
  14507. */
  14508. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14509. /**
  14510. * Builds a new matrix whose values are computed by:
  14511. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14512. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14513. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14514. * @param startValue defines the first matrix
  14515. * @param endValue defines the second matrix
  14516. * @param gradient defines the gradient between the two matrices
  14517. * @returns the new matrix
  14518. */
  14519. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14520. /**
  14521. * Update a matrix to values which are computed by:
  14522. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14523. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14524. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14525. * @param startValue defines the first matrix
  14526. * @param endValue defines the second matrix
  14527. * @param gradient defines the gradient between the two matrices
  14528. * @param result defines the target matrix
  14529. */
  14530. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14531. /**
  14532. * 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"
  14533. * This function works in left handed mode
  14534. * @param eye defines the final position of the entity
  14535. * @param target defines where the entity should look at
  14536. * @param up defines the up vector for the entity
  14537. * @returns the new matrix
  14538. */
  14539. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14540. /**
  14541. * 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".
  14542. * This function works in left handed mode
  14543. * @param eye defines the final position of the entity
  14544. * @param target defines where the entity should look at
  14545. * @param up defines the up vector for the entity
  14546. * @param result defines the target matrix
  14547. */
  14548. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14549. /**
  14550. * 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"
  14551. * This function works in right handed mode
  14552. * @param eye defines the final position of the entity
  14553. * @param target defines where the entity should look at
  14554. * @param up defines the up vector for the entity
  14555. * @returns the new matrix
  14556. */
  14557. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14558. /**
  14559. * 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".
  14560. * This function works in right handed mode
  14561. * @param eye defines the final position of the entity
  14562. * @param target defines where the entity should look at
  14563. * @param up defines the up vector for the entity
  14564. * @param result defines the target matrix
  14565. */
  14566. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14567. /**
  14568. * Create a left-handed orthographic projection matrix
  14569. * @param width defines the viewport width
  14570. * @param height defines the viewport height
  14571. * @param znear defines the near clip plane
  14572. * @param zfar defines the far clip plane
  14573. * @returns a new matrix as a left-handed orthographic projection matrix
  14574. */
  14575. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14576. /**
  14577. * Store a left-handed orthographic projection to a given matrix
  14578. * @param width defines the viewport width
  14579. * @param height defines the viewport height
  14580. * @param znear defines the near clip plane
  14581. * @param zfar defines the far clip plane
  14582. * @param result defines the target matrix
  14583. */
  14584. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  14585. /**
  14586. * Create a left-handed orthographic projection matrix
  14587. * @param left defines the viewport left coordinate
  14588. * @param right defines the viewport right coordinate
  14589. * @param bottom defines the viewport bottom coordinate
  14590. * @param top defines the viewport top coordinate
  14591. * @param znear defines the near clip plane
  14592. * @param zfar defines the far clip plane
  14593. * @returns a new matrix as a left-handed orthographic projection matrix
  14594. */
  14595. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14596. /**
  14597. * Stores a left-handed orthographic projection into a given matrix
  14598. * @param left defines the viewport left coordinate
  14599. * @param right defines the viewport right coordinate
  14600. * @param bottom defines the viewport bottom coordinate
  14601. * @param top defines the viewport top coordinate
  14602. * @param znear defines the near clip plane
  14603. * @param zfar defines the far clip plane
  14604. * @param result defines the target matrix
  14605. */
  14606. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14607. /**
  14608. * Creates a right-handed orthographic projection matrix
  14609. * @param left defines the viewport left coordinate
  14610. * @param right defines the viewport right coordinate
  14611. * @param bottom defines the viewport bottom coordinate
  14612. * @param top defines the viewport top coordinate
  14613. * @param znear defines the near clip plane
  14614. * @param zfar defines the far clip plane
  14615. * @returns a new matrix as a right-handed orthographic projection matrix
  14616. */
  14617. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14618. /**
  14619. * Stores a right-handed orthographic projection into a given matrix
  14620. * @param left defines the viewport left coordinate
  14621. * @param right defines the viewport right coordinate
  14622. * @param bottom defines the viewport bottom coordinate
  14623. * @param top defines the viewport top coordinate
  14624. * @param znear defines the near clip plane
  14625. * @param zfar defines the far clip plane
  14626. * @param result defines the target matrix
  14627. */
  14628. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14629. /**
  14630. * Creates a left-handed perspective projection matrix
  14631. * @param width defines the viewport width
  14632. * @param height defines the viewport height
  14633. * @param znear defines the near clip plane
  14634. * @param zfar defines the far clip plane
  14635. * @returns a new matrix as a left-handed perspective projection matrix
  14636. */
  14637. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14638. /**
  14639. * Creates a left-handed perspective projection matrix
  14640. * @param fov defines the horizontal field of view
  14641. * @param aspect defines the aspect ratio
  14642. * @param znear defines the near clip plane
  14643. * @param zfar defines the far clip plane
  14644. * @returns a new matrix as a left-handed perspective projection matrix
  14645. */
  14646. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14647. /**
  14648. * Stores a left-handed perspective projection into a given matrix
  14649. * @param fov defines the horizontal field of view
  14650. * @param aspect defines the aspect ratio
  14651. * @param znear defines the near clip plane
  14652. * @param zfar defines the far clip plane
  14653. * @param result defines the target matrix
  14654. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  14655. */
  14656. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14657. /**
  14658. * Creates a right-handed perspective projection matrix
  14659. * @param fov defines the horizontal field of view
  14660. * @param aspect defines the aspect ratio
  14661. * @param znear defines the near clip plane
  14662. * @param zfar defines the far clip plane
  14663. * @returns a new matrix as a right-handed perspective projection matrix
  14664. */
  14665. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14666. /**
  14667. * Stores a right-handed perspective projection into a given matrix
  14668. * @param fov defines the horizontal field of view
  14669. * @param aspect defines the aspect ratio
  14670. * @param znear defines the near clip plane
  14671. * @param zfar defines the far clip plane
  14672. * @param result defines the target matrix
  14673. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  14674. */
  14675. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14676. /**
  14677. * Stores a perspective projection for WebVR info a given matrix
  14678. * @param fov defines the field of view
  14679. * @param znear defines the near clip plane
  14680. * @param zfar defines the far clip plane
  14681. * @param result defines the target matrix
  14682. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  14683. */
  14684. static PerspectiveFovWebVRToRef(fov: {
  14685. upDegrees: number;
  14686. downDegrees: number;
  14687. leftDegrees: number;
  14688. rightDegrees: number;
  14689. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  14690. /**
  14691. * Computes a complete transformation matrix
  14692. * @param viewport defines the viewport to use
  14693. * @param world defines the world matrix
  14694. * @param view defines the view matrix
  14695. * @param projection defines the projection matrix
  14696. * @param zmin defines the near clip plane
  14697. * @param zmax defines the far clip plane
  14698. * @returns the transformation matrix
  14699. */
  14700. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  14701. /**
  14702. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  14703. * @param matrix defines the matrix to use
  14704. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  14705. */
  14706. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  14707. /**
  14708. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  14709. * @param matrix defines the matrix to use
  14710. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  14711. */
  14712. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  14713. /**
  14714. * Compute the transpose of a given matrix
  14715. * @param matrix defines the matrix to transpose
  14716. * @returns the new matrix
  14717. */
  14718. static Transpose(matrix: Matrix): Matrix;
  14719. /**
  14720. * Compute the transpose of a matrix and store it in a target matrix
  14721. * @param matrix defines the matrix to transpose
  14722. * @param result defines the target matrix
  14723. */
  14724. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  14725. /**
  14726. * Computes a reflection matrix from a plane
  14727. * @param plane defines the reflection plane
  14728. * @returns a new matrix
  14729. */
  14730. static Reflection(plane: Plane): Matrix;
  14731. /**
  14732. * Computes a reflection matrix from a plane
  14733. * @param plane defines the reflection plane
  14734. * @param result defines the target matrix
  14735. */
  14736. static ReflectionToRef(plane: Plane, result: Matrix): void;
  14737. /**
  14738. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  14739. * @param xaxis defines the value of the 1st axis
  14740. * @param yaxis defines the value of the 2nd axis
  14741. * @param zaxis defines the value of the 3rd axis
  14742. * @param result defines the target matrix
  14743. */
  14744. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  14745. /**
  14746. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  14747. * @param quat defines the quaternion to use
  14748. * @param result defines the target matrix
  14749. */
  14750. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  14751. }
  14752. class Plane {
  14753. normal: Vector3;
  14754. d: number;
  14755. /**
  14756. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  14757. */
  14758. constructor(a: number, b: number, c: number, d: number);
  14759. /**
  14760. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  14761. */
  14762. asArray(): number[];
  14763. /**
  14764. * Returns a new plane copied from the current Plane.
  14765. */
  14766. clone(): Plane;
  14767. /**
  14768. * Returns the string "Plane".
  14769. */
  14770. getClassName(): string;
  14771. /**
  14772. * Returns the Plane hash code.
  14773. */
  14774. getHashCode(): number;
  14775. /**
  14776. * Normalize the current Plane in place.
  14777. * Returns the updated Plane.
  14778. */
  14779. normalize(): Plane;
  14780. /**
  14781. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  14782. */
  14783. transform(transformation: Matrix): Plane;
  14784. /**
  14785. * Returns the dot product (float) of the point coordinates and the plane normal.
  14786. */
  14787. dotCoordinate(point: Vector3): number;
  14788. /**
  14789. * Updates the current Plane from the plane defined by the three given points.
  14790. * Returns the updated Plane.
  14791. */
  14792. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14793. /**
  14794. * Boolean : True is the vector "direction" is the same side than the plane normal.
  14795. */
  14796. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  14797. /**
  14798. * Returns the signed distance (float) from the given point to the Plane.
  14799. */
  14800. signedDistanceTo(point: Vector3): number;
  14801. /**
  14802. * Returns a new Plane from the given array.
  14803. */
  14804. static FromArray(array: ArrayLike<number>): Plane;
  14805. /**
  14806. * Returns a new Plane defined by the three given points.
  14807. */
  14808. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14809. /**
  14810. * Returns a new Plane the normal vector to this plane at the given origin point.
  14811. * Note : the vector "normal" is updated because normalized.
  14812. */
  14813. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  14814. /**
  14815. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  14816. */
  14817. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  14818. }
  14819. class Viewport {
  14820. x: number;
  14821. y: number;
  14822. width: number;
  14823. height: number;
  14824. /**
  14825. * Creates a Viewport object located at (x, y) and sized (width, height).
  14826. */
  14827. constructor(x: number, y: number, width: number, height: number);
  14828. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  14829. /**
  14830. * Returns a new Viewport copied from the current one.
  14831. */
  14832. clone(): Viewport;
  14833. }
  14834. class Frustum {
  14835. /**
  14836. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14837. */
  14838. static GetPlanes(transform: Matrix): Plane[];
  14839. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14840. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14841. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14842. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14843. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14844. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14845. /**
  14846. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14847. */
  14848. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  14849. }
  14850. /** Defines supported spaces */
  14851. enum Space {
  14852. /** Local (object) space */
  14853. LOCAL = 0,
  14854. /** World space */
  14855. WORLD = 1,
  14856. /** Bone space */
  14857. BONE = 2,
  14858. }
  14859. /** Defines the 3 main axes */
  14860. class Axis {
  14861. /** X axis */
  14862. static X: Vector3;
  14863. /** Y axis */
  14864. static Y: Vector3;
  14865. /** Z axis */
  14866. static Z: Vector3;
  14867. }
  14868. class BezierCurve {
  14869. /**
  14870. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  14871. */
  14872. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  14873. }
  14874. /**
  14875. * Defines potential orientation for back face culling
  14876. */
  14877. enum Orientation {
  14878. /**
  14879. * Clockwise
  14880. */
  14881. CW = 0,
  14882. /** Counter clockwise */
  14883. CCW = 1,
  14884. }
  14885. /**
  14886. * Defines angle representation
  14887. */
  14888. class Angle {
  14889. private _radians;
  14890. /**
  14891. * Creates an Angle object of "radians" radians (float).
  14892. */
  14893. constructor(radians: number);
  14894. /**
  14895. * Get value in degrees
  14896. * @returns the Angle value in degrees (float)
  14897. */
  14898. degrees(): number;
  14899. /**
  14900. * Get value in radians
  14901. * @returns the Angle value in radians (float)
  14902. */
  14903. radians(): number;
  14904. /**
  14905. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  14906. * @param a defines first vector
  14907. * @param b defines second vector
  14908. * @returns a new Angle
  14909. */
  14910. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  14911. /**
  14912. * Gets a new Angle object from the given float in radians
  14913. * @param radians defines the angle value in radians
  14914. * @returns a new Angle
  14915. */
  14916. static FromRadians(radians: number): Angle;
  14917. /**
  14918. * Gets a new Angle object from the given float in degrees
  14919. * @param degrees defines the angle value in degrees
  14920. * @returns a new Angle
  14921. */
  14922. static FromDegrees(degrees: number): Angle;
  14923. }
  14924. class Arc2 {
  14925. startPoint: Vector2;
  14926. midPoint: Vector2;
  14927. endPoint: Vector2;
  14928. centerPoint: Vector2;
  14929. radius: number;
  14930. angle: Angle;
  14931. startAngle: Angle;
  14932. orientation: Orientation;
  14933. /**
  14934. * Creates an Arc object from the three given points : start, middle and end.
  14935. */
  14936. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  14937. }
  14938. class Path2 {
  14939. private _points;
  14940. private _length;
  14941. closed: boolean;
  14942. /**
  14943. * Creates a Path2 object from the starting 2D coordinates x and y.
  14944. */
  14945. constructor(x: number, y: number);
  14946. /**
  14947. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  14948. * Returns the updated Path2.
  14949. */
  14950. addLineTo(x: number, y: number): Path2;
  14951. /**
  14952. * 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.
  14953. * Returns the updated Path2.
  14954. */
  14955. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  14956. /**
  14957. * Closes the Path2.
  14958. * Returns the Path2.
  14959. */
  14960. close(): Path2;
  14961. /**
  14962. * Returns the Path2 total length (float).
  14963. */
  14964. length(): number;
  14965. /**
  14966. * Returns the Path2 internal array of points.
  14967. */
  14968. getPoints(): Vector2[];
  14969. /**
  14970. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  14971. */
  14972. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  14973. /**
  14974. * Returns a new Path2 starting at the coordinates (x, y).
  14975. */
  14976. static StartingAt(x: number, y: number): Path2;
  14977. }
  14978. class Path3D {
  14979. path: Vector3[];
  14980. private _curve;
  14981. private _distances;
  14982. private _tangents;
  14983. private _normals;
  14984. private _binormals;
  14985. private _raw;
  14986. /**
  14987. * new Path3D(path, normal, raw)
  14988. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  14989. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  14990. * path : an array of Vector3, the curve axis of the Path3D
  14991. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  14992. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  14993. */
  14994. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  14995. /**
  14996. * Returns the Path3D array of successive Vector3 designing its curve.
  14997. */
  14998. getCurve(): Vector3[];
  14999. /**
  15000. * Returns an array populated with tangent vectors on each Path3D curve point.
  15001. */
  15002. getTangents(): Vector3[];
  15003. /**
  15004. * Returns an array populated with normal vectors on each Path3D curve point.
  15005. */
  15006. getNormals(): Vector3[];
  15007. /**
  15008. * Returns an array populated with binormal vectors on each Path3D curve point.
  15009. */
  15010. getBinormals(): Vector3[];
  15011. /**
  15012. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  15013. */
  15014. getDistances(): number[];
  15015. /**
  15016. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  15017. * Returns the same object updated.
  15018. */
  15019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  15020. private _compute(firstNormal);
  15021. private _getFirstNonNullVector(index);
  15022. private _getLastNonNullVector(index);
  15023. private _normalVector(v0, vt, va);
  15024. }
  15025. class Curve3 {
  15026. private _points;
  15027. private _length;
  15028. /**
  15029. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  15030. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  15031. * @param v1 (Vector3) the control point
  15032. * @param v2 (Vector3) the end point of the Quadratic Bezier
  15033. * @param nbPoints (integer) the wanted number of points in the curve
  15034. */
  15035. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  15036. /**
  15037. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  15038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  15039. * @param v1 (Vector3) the first control point
  15040. * @param v2 (Vector3) the second control point
  15041. * @param v3 (Vector3) the end point of the Cubic Bezier
  15042. * @param nbPoints (integer) the wanted number of points in the curve
  15043. */
  15044. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  15045. /**
  15046. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  15047. * @param p1 (Vector3) the origin point of the Hermite Spline
  15048. * @param t1 (Vector3) the tangent vector at the origin point
  15049. * @param p2 (Vector3) the end point of the Hermite Spline
  15050. * @param t2 (Vector3) the tangent vector at the end point
  15051. * @param nbPoints (integer) the wanted number of points in the curve
  15052. */
  15053. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  15054. /**
  15055. * Returns a Curve3 object along a CatmullRom Spline curve :
  15056. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  15057. * @param nbPoints (integer) the wanted number of points between each curve control points.
  15058. */
  15059. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  15060. /**
  15061. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  15062. * A Curve3 is designed from a series of successive Vector3.
  15063. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  15064. */
  15065. constructor(points: Vector3[]);
  15066. /**
  15067. * Returns the Curve3 stored array of successive Vector3
  15068. */
  15069. getPoints(): Vector3[];
  15070. /**
  15071. * Returns the computed length (float) of the curve.
  15072. */
  15073. length(): number;
  15074. /**
  15075. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  15076. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  15077. * curveA and curveB keep unchanged.
  15078. */
  15079. continue(curve: Curve3): Curve3;
  15080. private _computeLength(path);
  15081. }
  15082. class PositionNormalVertex {
  15083. position: Vector3;
  15084. normal: Vector3;
  15085. constructor(position?: Vector3, normal?: Vector3);
  15086. clone(): PositionNormalVertex;
  15087. }
  15088. class PositionNormalTextureVertex {
  15089. position: Vector3;
  15090. normal: Vector3;
  15091. uv: Vector2;
  15092. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  15093. clone(): PositionNormalTextureVertex;
  15094. }
  15095. class Tmp {
  15096. static Color3: Color3[];
  15097. static Vector2: Vector2[];
  15098. static Vector3: Vector3[];
  15099. static Vector4: Vector4[];
  15100. static Quaternion: Quaternion[];
  15101. static Matrix: Matrix[];
  15102. }
  15103. }
  15104. declare module BABYLON {
  15105. class SphericalPolynomial {
  15106. x: Vector3;
  15107. y: Vector3;
  15108. z: Vector3;
  15109. xx: Vector3;
  15110. yy: Vector3;
  15111. zz: Vector3;
  15112. xy: Vector3;
  15113. yz: Vector3;
  15114. zx: Vector3;
  15115. addAmbient(color: Color3): void;
  15116. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  15117. scale(scale: number): void;
  15118. }
  15119. class SphericalHarmonics {
  15120. L00: Vector3;
  15121. L1_1: Vector3;
  15122. L10: Vector3;
  15123. L11: Vector3;
  15124. L2_2: Vector3;
  15125. L2_1: Vector3;
  15126. L20: Vector3;
  15127. L21: Vector3;
  15128. L22: Vector3;
  15129. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  15130. scale(scale: number): void;
  15131. convertIncidentRadianceToIrradiance(): void;
  15132. convertIrradianceToLambertianRadiance(): void;
  15133. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  15134. }
  15135. }
  15136. declare module BABYLON {
  15137. /**
  15138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15140. * 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;
  15141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15142. */
  15143. class ColorCurves {
  15144. private _dirty;
  15145. private _tempColor;
  15146. private _globalCurve;
  15147. private _highlightsCurve;
  15148. private _midtonesCurve;
  15149. private _shadowsCurve;
  15150. private _positiveCurve;
  15151. private _negativeCurve;
  15152. private _globalHue;
  15153. private _globalDensity;
  15154. private _globalSaturation;
  15155. private _globalExposure;
  15156. /**
  15157. * Gets the global Hue value.
  15158. * 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).
  15159. */
  15160. /**
  15161. * Sets the global Hue value.
  15162. * 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).
  15163. */
  15164. globalHue: number;
  15165. /**
  15166. * Gets the global Density value.
  15167. * 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.
  15168. * Values less than zero provide a filter of opposite hue.
  15169. */
  15170. /**
  15171. * Sets the global Density value.
  15172. * 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.
  15173. * Values less than zero provide a filter of opposite hue.
  15174. */
  15175. globalDensity: number;
  15176. /**
  15177. * Gets the global Saturation value.
  15178. * 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.
  15179. */
  15180. /**
  15181. * Sets the global Saturation value.
  15182. * 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.
  15183. */
  15184. globalSaturation: number;
  15185. private _highlightsHue;
  15186. private _highlightsDensity;
  15187. private _highlightsSaturation;
  15188. private _highlightsExposure;
  15189. /**
  15190. * Gets the highlights Hue value.
  15191. * 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).
  15192. */
  15193. /**
  15194. * Sets the highlights Hue value.
  15195. * 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).
  15196. */
  15197. highlightsHue: number;
  15198. /**
  15199. * Gets the highlights Density value.
  15200. * 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.
  15201. * Values less than zero provide a filter of opposite hue.
  15202. */
  15203. /**
  15204. * Sets the highlights Density value.
  15205. * 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.
  15206. * Values less than zero provide a filter of opposite hue.
  15207. */
  15208. highlightsDensity: number;
  15209. /**
  15210. * Gets the highlights Saturation value.
  15211. * 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.
  15212. */
  15213. /**
  15214. * Sets the highlights Saturation value.
  15215. * 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.
  15216. */
  15217. highlightsSaturation: number;
  15218. /**
  15219. * Gets the highlights Exposure value.
  15220. * 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.
  15221. */
  15222. /**
  15223. * Sets the highlights Exposure value.
  15224. * 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.
  15225. */
  15226. highlightsExposure: number;
  15227. private _midtonesHue;
  15228. private _midtonesDensity;
  15229. private _midtonesSaturation;
  15230. private _midtonesExposure;
  15231. /**
  15232. * Gets the midtones Hue value.
  15233. * 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).
  15234. */
  15235. /**
  15236. * Sets the midtones Hue value.
  15237. * 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).
  15238. */
  15239. midtonesHue: number;
  15240. /**
  15241. * Gets the midtones Density value.
  15242. * 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.
  15243. * Values less than zero provide a filter of opposite hue.
  15244. */
  15245. /**
  15246. * Sets the midtones Density value.
  15247. * 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.
  15248. * Values less than zero provide a filter of opposite hue.
  15249. */
  15250. midtonesDensity: number;
  15251. /**
  15252. * Gets the midtones Saturation value.
  15253. * 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.
  15254. */
  15255. /**
  15256. * Sets the midtones Saturation value.
  15257. * 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.
  15258. */
  15259. midtonesSaturation: number;
  15260. /**
  15261. * Gets the midtones Exposure value.
  15262. * 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.
  15263. */
  15264. /**
  15265. * Sets the midtones Exposure value.
  15266. * 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.
  15267. */
  15268. midtonesExposure: number;
  15269. private _shadowsHue;
  15270. private _shadowsDensity;
  15271. private _shadowsSaturation;
  15272. private _shadowsExposure;
  15273. /**
  15274. * Gets the shadows Hue value.
  15275. * 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).
  15276. */
  15277. /**
  15278. * Sets the shadows Hue value.
  15279. * 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).
  15280. */
  15281. shadowsHue: number;
  15282. /**
  15283. * Gets the shadows Density value.
  15284. * 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.
  15285. * Values less than zero provide a filter of opposite hue.
  15286. */
  15287. /**
  15288. * Sets the shadows Density value.
  15289. * 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.
  15290. * Values less than zero provide a filter of opposite hue.
  15291. */
  15292. shadowsDensity: number;
  15293. /**
  15294. * Gets the shadows Saturation value.
  15295. * 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.
  15296. */
  15297. /**
  15298. * Sets the shadows Saturation value.
  15299. * 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.
  15300. */
  15301. shadowsSaturation: number;
  15302. /**
  15303. * Gets the shadows Exposure value.
  15304. * 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.
  15305. */
  15306. /**
  15307. * Sets the shadows Exposure value.
  15308. * 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.
  15309. */
  15310. shadowsExposure: number;
  15311. getClassName(): string;
  15312. /**
  15313. * Binds the color curves to the shader.
  15314. * @param colorCurves The color curve to bind
  15315. * @param effect The effect to bind to
  15316. */
  15317. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  15318. /**
  15319. * Prepare the list of uniforms associated with the ColorCurves effects.
  15320. * @param uniformsList The list of uniforms used in the effect
  15321. */
  15322. static PrepareUniforms(uniformsList: string[]): void;
  15323. /**
  15324. * Returns color grading data based on a hue, density, saturation and exposure value.
  15325. * @param filterHue The hue of the color filter.
  15326. * @param filterDensity The density of the color filter.
  15327. * @param saturation The saturation.
  15328. * @param exposure The exposure.
  15329. * @param result The result data container.
  15330. */
  15331. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  15332. /**
  15333. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  15334. * @param value The input slider value in range [-100,100].
  15335. * @returns Adjusted value.
  15336. */
  15337. private static applyColorGradingSliderNonlinear(value);
  15338. /**
  15339. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  15340. * @param hue The hue (H) input.
  15341. * @param saturation The saturation (S) input.
  15342. * @param brightness The brightness (B) input.
  15343. * @result An RGBA color represented as Vector4.
  15344. */
  15345. private static fromHSBToRef(hue, saturation, brightness, result);
  15346. /**
  15347. * Returns a value clamped between min and max
  15348. * @param value The value to clamp
  15349. * @param min The minimum of value
  15350. * @param max The maximum of value
  15351. * @returns The clamped value.
  15352. */
  15353. private static clamp(value, min, max);
  15354. /**
  15355. * Clones the current color curve instance.
  15356. * @return The cloned curves
  15357. */
  15358. clone(): ColorCurves;
  15359. /**
  15360. * Serializes the current color curve instance to a json representation.
  15361. * @return a JSON representation
  15362. */
  15363. serialize(): any;
  15364. /**
  15365. * Parses the color curve from a json representation.
  15366. * @param source the JSON source to parse
  15367. * @return The parsed curves
  15368. */
  15369. static Parse(source: any): ColorCurves;
  15370. }
  15371. }
  15372. declare module BABYLON {
  15373. /**
  15374. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  15375. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  15376. */
  15377. class EffectFallbacks {
  15378. private _defines;
  15379. private _currentRank;
  15380. private _maxRank;
  15381. private _mesh;
  15382. /**
  15383. * Removes the fallback from the bound mesh.
  15384. */
  15385. unBindMesh(): void;
  15386. /**
  15387. * Adds a fallback on the specified property.
  15388. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15389. * @param define The name of the define in the shader
  15390. */
  15391. addFallback(rank: number, define: string): void;
  15392. /**
  15393. * Sets the mesh to use CPU skinning when needing to fallback.
  15394. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15395. * @param mesh The mesh to use the fallbacks.
  15396. */
  15397. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  15398. /**
  15399. * Checks to see if more fallbacks are still availible.
  15400. */
  15401. readonly isMoreFallbacks: boolean;
  15402. /**
  15403. * Removes the defines that shoould be removed when falling back.
  15404. * @param currentDefines defines the current define statements for the shader.
  15405. * @param effect defines the current effect we try to compile
  15406. * @returns The resulting defines with defines of the current rank removed.
  15407. */
  15408. reduce(currentDefines: string, effect: Effect): string;
  15409. }
  15410. /**
  15411. * Options to be used when creating an effect.
  15412. */
  15413. class EffectCreationOptions {
  15414. /**
  15415. * Atrributes that will be used in the shader.
  15416. */
  15417. attributes: string[];
  15418. /**
  15419. * Uniform varible names that will be set in the shader.
  15420. */
  15421. uniformsNames: string[];
  15422. /**
  15423. * Uniform buffer varible names that will be set in the shader.
  15424. */
  15425. uniformBuffersNames: string[];
  15426. /**
  15427. * Sampler texture variable names that will be set in the shader.
  15428. */
  15429. samplers: string[];
  15430. /**
  15431. * Define statements that will be set in the shader.
  15432. */
  15433. defines: any;
  15434. /**
  15435. * Possible fallbacks for this effect to improve performance when needed.
  15436. */
  15437. fallbacks: Nullable<EffectFallbacks>;
  15438. /**
  15439. * Callback that will be called when the shader is compiled.
  15440. */
  15441. onCompiled: Nullable<(effect: Effect) => void>;
  15442. /**
  15443. * Callback that will be called if an error occurs during shader compilation.
  15444. */
  15445. onError: Nullable<(effect: Effect, errors: string) => void>;
  15446. /**
  15447. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15448. */
  15449. indexParameters: any;
  15450. /**
  15451. * Max number of lights that can be used in the shader.
  15452. */
  15453. maxSimultaneousLights: number;
  15454. /**
  15455. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  15456. */
  15457. transformFeedbackVaryings: Nullable<string[]>;
  15458. }
  15459. /**
  15460. * Effect containing vertex and fragment shader that can be executed on an object.
  15461. */
  15462. class Effect {
  15463. /**
  15464. * Name of the effect.
  15465. */
  15466. name: any;
  15467. /**
  15468. * String container all the define statements that should be set on the shader.
  15469. */
  15470. defines: string;
  15471. /**
  15472. * Callback that will be called when the shader is compiled.
  15473. */
  15474. onCompiled: Nullable<(effect: Effect) => void>;
  15475. /**
  15476. * Callback that will be called if an error occurs during shader compilation.
  15477. */
  15478. onError: Nullable<(effect: Effect, errors: string) => void>;
  15479. /**
  15480. * Callback that will be called when effect is bound.
  15481. */
  15482. onBind: Nullable<(effect: Effect) => void>;
  15483. /**
  15484. * Unique ID of the effect.
  15485. */
  15486. uniqueId: number;
  15487. /**
  15488. * Observable that will be called when the shader is compiled.
  15489. */
  15490. onCompileObservable: Observable<Effect>;
  15491. /**
  15492. * Observable that will be called if an error occurs during shader compilation.
  15493. */
  15494. onErrorObservable: Observable<Effect>;
  15495. /**
  15496. * Observable that will be called when effect is bound.
  15497. */
  15498. onBindObservable: Observable<Effect>;
  15499. private static _uniqueIdSeed;
  15500. private _engine;
  15501. private _uniformBuffersNames;
  15502. private _uniformsNames;
  15503. private _samplers;
  15504. private _isReady;
  15505. private _compilationError;
  15506. private _attributesNames;
  15507. private _attributes;
  15508. private _uniforms;
  15509. /**
  15510. * Key for the effect.
  15511. */
  15512. _key: string;
  15513. private _indexParameters;
  15514. private _fallbacks;
  15515. private _vertexSourceCode;
  15516. private _fragmentSourceCode;
  15517. private _vertexSourceCodeOverride;
  15518. private _fragmentSourceCodeOverride;
  15519. private _transformFeedbackVaryings;
  15520. /**
  15521. * Compiled shader to webGL program.
  15522. */
  15523. _program: WebGLProgram;
  15524. private _valueCache;
  15525. private static _baseCache;
  15526. /**
  15527. * Instantiates an effect.
  15528. * An effect can be used to create/manage/execute vertex and fragment shaders.
  15529. * @param baseName Name of the effect.
  15530. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  15531. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  15532. * @param samplers List of sampler variables that will be passed to the shader.
  15533. * @param engine Engine to be used to render the effect
  15534. * @param defines Define statements to be added to the shader.
  15535. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  15536. * @param onCompiled Callback that will be called when the shader is compiled.
  15537. * @param onError Callback that will be called if an error occurs during shader compilation.
  15538. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15539. */
  15540. 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);
  15541. /**
  15542. * Unique key for this effect
  15543. */
  15544. readonly key: string;
  15545. /**
  15546. * If the effect has been compiled and prepared.
  15547. * @returns if the effect is compiled and prepared.
  15548. */
  15549. isReady(): boolean;
  15550. /**
  15551. * The engine the effect was initialized with.
  15552. * @returns the engine.
  15553. */
  15554. getEngine(): Engine;
  15555. /**
  15556. * The compiled webGL program for the effect
  15557. * @returns the webGL program.
  15558. */
  15559. getProgram(): WebGLProgram;
  15560. /**
  15561. * The set of names of attribute variables for the shader.
  15562. * @returns An array of attribute names.
  15563. */
  15564. getAttributesNames(): string[];
  15565. /**
  15566. * Returns the attribute at the given index.
  15567. * @param index The index of the attribute.
  15568. * @returns The location of the attribute.
  15569. */
  15570. getAttributeLocation(index: number): number;
  15571. /**
  15572. * Returns the attribute based on the name of the variable.
  15573. * @param name of the attribute to look up.
  15574. * @returns the attribute location.
  15575. */
  15576. getAttributeLocationByName(name: string): number;
  15577. /**
  15578. * The number of attributes.
  15579. * @returns the numnber of attributes.
  15580. */
  15581. getAttributesCount(): number;
  15582. /**
  15583. * Gets the index of a uniform variable.
  15584. * @param uniformName of the uniform to look up.
  15585. * @returns the index.
  15586. */
  15587. getUniformIndex(uniformName: string): number;
  15588. /**
  15589. * Returns the attribute based on the name of the variable.
  15590. * @param uniformName of the uniform to look up.
  15591. * @returns the location of the uniform.
  15592. */
  15593. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  15594. /**
  15595. * Returns an array of sampler variable names
  15596. * @returns The array of sampler variable neames.
  15597. */
  15598. getSamplers(): string[];
  15599. /**
  15600. * The error from the last compilation.
  15601. * @returns the error string.
  15602. */
  15603. getCompilationError(): string;
  15604. /**
  15605. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  15606. * @param func The callback to be used.
  15607. */
  15608. executeWhenCompiled(func: (effect: Effect) => void): void;
  15609. /** @hidden */
  15610. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  15611. /** @hidden */
  15612. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  15613. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  15614. private _processShaderConversion(sourceCode, isFragment, callback);
  15615. private _processIncludes(sourceCode, callback);
  15616. private _processPrecision(source);
  15617. /**
  15618. * Recompiles the webGL program
  15619. * @param vertexSourceCode The source code for the vertex shader.
  15620. * @param fragmentSourceCode The source code for the fragment shader.
  15621. * @param onCompiled Callback called when completed.
  15622. * @param onError Callback called on error.
  15623. */
  15624. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  15625. /**
  15626. * Gets the uniform locations of the the specified variable names
  15627. * @param names THe names of the variables to lookup.
  15628. * @returns Array of locations in the same order as variable names.
  15629. */
  15630. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  15631. /**
  15632. * Prepares the effect
  15633. */
  15634. _prepareEffect(): void;
  15635. /**
  15636. * Checks if the effect is supported. (Must be called after compilation)
  15637. */
  15638. readonly isSupported: boolean;
  15639. /**
  15640. * Binds a texture to the engine to be used as output of the shader.
  15641. * @param channel Name of the output variable.
  15642. * @param texture Texture to bind.
  15643. */
  15644. _bindTexture(channel: string, texture: InternalTexture): void;
  15645. /**
  15646. * Sets a texture on the engine to be used in the shader.
  15647. * @param channel Name of the sampler variable.
  15648. * @param texture Texture to set.
  15649. */
  15650. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  15651. /**
  15652. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  15653. * @param channel Name of the sampler variable.
  15654. * @param texture Texture to set.
  15655. */
  15656. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  15657. /**
  15658. * Sets an array of textures on the engine to be used in the shader.
  15659. * @param channel Name of the variable.
  15660. * @param textures Textures to set.
  15661. */
  15662. setTextureArray(channel: string, textures: BaseTexture[]): void;
  15663. /**
  15664. * 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)
  15665. * @param channel Name of the sampler variable.
  15666. * @param postProcess Post process to get the input texture from.
  15667. */
  15668. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  15669. /**
  15670. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  15671. * 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)
  15672. * @param channel Name of the sampler variable.
  15673. * @param postProcess Post process to get the output texture from.
  15674. */
  15675. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  15676. /** @hidden */
  15677. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  15678. /** @hidden */
  15679. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  15680. /** @hidden */
  15681. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  15682. /** @hidden */
  15683. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  15684. /**
  15685. * Binds a buffer to a uniform.
  15686. * @param buffer Buffer to bind.
  15687. * @param name Name of the uniform variable to bind to.
  15688. */
  15689. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  15690. /**
  15691. * Binds block to a uniform.
  15692. * @param blockName Name of the block to bind.
  15693. * @param index Index to bind.
  15694. */
  15695. bindUniformBlock(blockName: string, index: number): void;
  15696. /**
  15697. * Sets an interger value on a uniform variable.
  15698. * @param uniformName Name of the variable.
  15699. * @param value Value to be set.
  15700. * @returns this effect.
  15701. */
  15702. setInt(uniformName: string, value: number): Effect;
  15703. /**
  15704. * Sets an int array on a uniform variable.
  15705. * @param uniformName Name of the variable.
  15706. * @param array array to be set.
  15707. * @returns this effect.
  15708. */
  15709. setIntArray(uniformName: string, array: Int32Array): Effect;
  15710. /**
  15711. * 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)
  15712. * @param uniformName Name of the variable.
  15713. * @param array array to be set.
  15714. * @returns this effect.
  15715. */
  15716. setIntArray2(uniformName: string, array: Int32Array): Effect;
  15717. /**
  15718. * 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)
  15719. * @param uniformName Name of the variable.
  15720. * @param array array to be set.
  15721. * @returns this effect.
  15722. */
  15723. setIntArray3(uniformName: string, array: Int32Array): Effect;
  15724. /**
  15725. * 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)
  15726. * @param uniformName Name of the variable.
  15727. * @param array array to be set.
  15728. * @returns this effect.
  15729. */
  15730. setIntArray4(uniformName: string, array: Int32Array): Effect;
  15731. /**
  15732. * Sets an float array on a uniform variable.
  15733. * @param uniformName Name of the variable.
  15734. * @param array array to be set.
  15735. * @returns this effect.
  15736. */
  15737. setFloatArray(uniformName: string, array: Float32Array): Effect;
  15738. /**
  15739. * 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)
  15740. * @param uniformName Name of the variable.
  15741. * @param array array to be set.
  15742. * @returns this effect.
  15743. */
  15744. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  15745. /**
  15746. * 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)
  15747. * @param uniformName Name of the variable.
  15748. * @param array array to be set.
  15749. * @returns this effect.
  15750. */
  15751. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  15752. /**
  15753. * 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)
  15754. * @param uniformName Name of the variable.
  15755. * @param array array to be set.
  15756. * @returns this effect.
  15757. */
  15758. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  15759. /**
  15760. * Sets an array on a uniform variable.
  15761. * @param uniformName Name of the variable.
  15762. * @param array array to be set.
  15763. * @returns this effect.
  15764. */
  15765. setArray(uniformName: string, array: number[]): Effect;
  15766. /**
  15767. * 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)
  15768. * @param uniformName Name of the variable.
  15769. * @param array array to be set.
  15770. * @returns this effect.
  15771. */
  15772. setArray2(uniformName: string, array: number[]): Effect;
  15773. /**
  15774. * 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)
  15775. * @param uniformName Name of the variable.
  15776. * @param array array to be set.
  15777. * @returns this effect.
  15778. */
  15779. setArray3(uniformName: string, array: number[]): Effect;
  15780. /**
  15781. * 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)
  15782. * @param uniformName Name of the variable.
  15783. * @param array array to be set.
  15784. * @returns this effect.
  15785. */
  15786. setArray4(uniformName: string, array: number[]): Effect;
  15787. /**
  15788. * Sets matrices on a uniform variable.
  15789. * @param uniformName Name of the variable.
  15790. * @param matrices matrices to be set.
  15791. * @returns this effect.
  15792. */
  15793. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  15794. /**
  15795. * Sets matrix on a uniform variable.
  15796. * @param uniformName Name of the variable.
  15797. * @param matrix matrix to be set.
  15798. * @returns this effect.
  15799. */
  15800. setMatrix(uniformName: string, matrix: Matrix): Effect;
  15801. /**
  15802. * 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)
  15803. * @param uniformName Name of the variable.
  15804. * @param matrix matrix to be set.
  15805. * @returns this effect.
  15806. */
  15807. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  15808. /**
  15809. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  15810. * @param uniformName Name of the variable.
  15811. * @param matrix matrix to be set.
  15812. * @returns this effect.
  15813. */
  15814. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  15815. /**
  15816. * Sets a float on a uniform variable.
  15817. * @param uniformName Name of the variable.
  15818. * @param value value to be set.
  15819. * @returns this effect.
  15820. */
  15821. setFloat(uniformName: string, value: number): Effect;
  15822. /**
  15823. * Sets a boolean on a uniform variable.
  15824. * @param uniformName Name of the variable.
  15825. * @param bool value to be set.
  15826. * @returns this effect.
  15827. */
  15828. setBool(uniformName: string, bool: boolean): Effect;
  15829. /**
  15830. * Sets a Vector2 on a uniform variable.
  15831. * @param uniformName Name of the variable.
  15832. * @param vector2 vector2 to be set.
  15833. * @returns this effect.
  15834. */
  15835. setVector2(uniformName: string, vector2: Vector2): Effect;
  15836. /**
  15837. * Sets a float2 on a uniform variable.
  15838. * @param uniformName Name of the variable.
  15839. * @param x First float in float2.
  15840. * @param y Second float in float2.
  15841. * @returns this effect.
  15842. */
  15843. setFloat2(uniformName: string, x: number, y: number): Effect;
  15844. /**
  15845. * Sets a Vector3 on a uniform variable.
  15846. * @param uniformName Name of the variable.
  15847. * @param vector3 Value to be set.
  15848. * @returns this effect.
  15849. */
  15850. setVector3(uniformName: string, vector3: Vector3): Effect;
  15851. /**
  15852. * Sets a float3 on a uniform variable.
  15853. * @param uniformName Name of the variable.
  15854. * @param x First float in float3.
  15855. * @param y Second float in float3.
  15856. * @param z Third float in float3.
  15857. * @returns this effect.
  15858. */
  15859. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  15860. /**
  15861. * Sets a Vector4 on a uniform variable.
  15862. * @param uniformName Name of the variable.
  15863. * @param vector4 Value to be set.
  15864. * @returns this effect.
  15865. */
  15866. setVector4(uniformName: string, vector4: Vector4): Effect;
  15867. /**
  15868. * Sets a float4 on a uniform variable.
  15869. * @param uniformName Name of the variable.
  15870. * @param x First float in float4.
  15871. * @param y Second float in float4.
  15872. * @param z Third float in float4.
  15873. * @param w Fourth float in float4.
  15874. * @returns this effect.
  15875. */
  15876. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  15877. /**
  15878. * Sets a Color3 on a uniform variable.
  15879. * @param uniformName Name of the variable.
  15880. * @param color3 Value to be set.
  15881. * @returns this effect.
  15882. */
  15883. setColor3(uniformName: string, color3: Color3): Effect;
  15884. /**
  15885. * Sets a Color4 on a uniform variable.
  15886. * @param uniformName Name of the variable.
  15887. * @param color3 Value to be set.
  15888. * @param alpha Alpha value to be set.
  15889. * @returns this effect.
  15890. */
  15891. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  15892. /**
  15893. * Sets a Color4 on a uniform variable
  15894. * @param uniformName defines the name of the variable
  15895. * @param color4 defines the value to be set
  15896. * @returns this effect.
  15897. */
  15898. setDirectColor4(uniformName: string, color4: Color4): Effect;
  15899. /**
  15900. * Store of each shader (The can be looked up using effect.key)
  15901. */
  15902. static ShadersStore: {
  15903. [key: string]: string;
  15904. };
  15905. /**
  15906. * Store of each included file for a shader (The can be looked up using effect.key)
  15907. */
  15908. static IncludesShadersStore: {
  15909. [key: string]: string;
  15910. };
  15911. /**
  15912. * Resets the cache of effects.
  15913. */
  15914. static ResetCache(): void;
  15915. }
  15916. }
  15917. declare module BABYLON {
  15918. class FresnelParameters {
  15919. private _isEnabled;
  15920. isEnabled: boolean;
  15921. leftColor: Color3;
  15922. rightColor: Color3;
  15923. bias: number;
  15924. power: number;
  15925. clone(): FresnelParameters;
  15926. serialize(): any;
  15927. static Parse(parsedFresnelParameters: any): FresnelParameters;
  15928. }
  15929. }
  15930. declare module BABYLON {
  15931. /**
  15932. * Interface to follow in your material defines to integrate easily the
  15933. * Image proccessing functions.
  15934. * @hidden
  15935. */
  15936. interface IImageProcessingConfigurationDefines {
  15937. IMAGEPROCESSING: boolean;
  15938. VIGNETTE: boolean;
  15939. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15940. VIGNETTEBLENDMODEOPAQUE: boolean;
  15941. TONEMAPPING: boolean;
  15942. CONTRAST: boolean;
  15943. EXPOSURE: boolean;
  15944. COLORCURVES: boolean;
  15945. COLORGRADING: boolean;
  15946. COLORGRADING3D: boolean;
  15947. SAMPLER3DGREENDEPTH: boolean;
  15948. SAMPLER3DBGRMAP: boolean;
  15949. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15950. }
  15951. /**
  15952. * This groups together the common properties used for image processing either in direct forward pass
  15953. * or through post processing effect depending on the use of the image processing pipeline in your scene
  15954. * or not.
  15955. */
  15956. class ImageProcessingConfiguration {
  15957. /**
  15958. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  15959. */
  15960. colorCurves: Nullable<ColorCurves>;
  15961. private _colorCurvesEnabled;
  15962. /**
  15963. * Gets wether the color curves effect is enabled.
  15964. */
  15965. /**
  15966. * Sets wether the color curves effect is enabled.
  15967. */
  15968. colorCurvesEnabled: boolean;
  15969. /**
  15970. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  15971. */
  15972. colorGradingTexture: Nullable<BaseTexture>;
  15973. private _colorGradingEnabled;
  15974. /**
  15975. * Gets wether the color grading effect is enabled.
  15976. */
  15977. /**
  15978. * Sets wether the color grading effect is enabled.
  15979. */
  15980. colorGradingEnabled: boolean;
  15981. private _colorGradingWithGreenDepth;
  15982. /**
  15983. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  15984. */
  15985. /**
  15986. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  15987. */
  15988. colorGradingWithGreenDepth: boolean;
  15989. private _colorGradingBGR;
  15990. /**
  15991. * Gets wether the color grading texture contains BGR values.
  15992. */
  15993. /**
  15994. * Sets wether the color grading texture contains BGR values.
  15995. */
  15996. colorGradingBGR: boolean;
  15997. _exposure: number;
  15998. /**
  15999. * Gets the Exposure used in the effect.
  16000. */
  16001. /**
  16002. * Sets the Exposure used in the effect.
  16003. */
  16004. exposure: number;
  16005. private _toneMappingEnabled;
  16006. /**
  16007. * Gets wether the tone mapping effect is enabled.
  16008. */
  16009. /**
  16010. * Sets wether the tone mapping effect is enabled.
  16011. */
  16012. toneMappingEnabled: boolean;
  16013. protected _contrast: number;
  16014. /**
  16015. * Gets the contrast used in the effect.
  16016. */
  16017. /**
  16018. * Sets the contrast used in the effect.
  16019. */
  16020. contrast: number;
  16021. /**
  16022. * Vignette stretch size.
  16023. */
  16024. vignetteStretch: number;
  16025. /**
  16026. * Vignette centre X Offset.
  16027. */
  16028. vignetteCentreX: number;
  16029. /**
  16030. * Vignette centre Y Offset.
  16031. */
  16032. vignetteCentreY: number;
  16033. /**
  16034. * Vignette weight or intensity of the vignette effect.
  16035. */
  16036. vignetteWeight: number;
  16037. /**
  16038. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16039. * if vignetteEnabled is set to true.
  16040. */
  16041. vignetteColor: Color4;
  16042. /**
  16043. * Camera field of view used by the Vignette effect.
  16044. */
  16045. vignetteCameraFov: number;
  16046. private _vignetteBlendMode;
  16047. /**
  16048. * Gets the vignette blend mode allowing different kind of effect.
  16049. */
  16050. /**
  16051. * Sets the vignette blend mode allowing different kind of effect.
  16052. */
  16053. vignetteBlendMode: number;
  16054. private _vignetteEnabled;
  16055. /**
  16056. * Gets wether the vignette effect is enabled.
  16057. */
  16058. /**
  16059. * Sets wether the vignette effect is enabled.
  16060. */
  16061. vignetteEnabled: boolean;
  16062. private _applyByPostProcess;
  16063. /**
  16064. * Gets wether the image processing is applied through a post process or not.
  16065. */
  16066. /**
  16067. * Sets wether the image processing is applied through a post process or not.
  16068. */
  16069. applyByPostProcess: boolean;
  16070. private _isEnabled;
  16071. /**
  16072. * Gets wether the image processing is enabled or not.
  16073. */
  16074. /**
  16075. * Sets wether the image processing is enabled or not.
  16076. */
  16077. isEnabled: boolean;
  16078. /**
  16079. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16080. */
  16081. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16082. /**
  16083. * Method called each time the image processing information changes requires to recompile the effect.
  16084. */
  16085. protected _updateParameters(): void;
  16086. getClassName(): string;
  16087. /**
  16088. * Prepare the list of uniforms associated with the Image Processing effects.
  16089. * @param uniformsList The list of uniforms used in the effect
  16090. * @param defines the list of defines currently in use
  16091. */
  16092. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16093. /**
  16094. * Prepare the list of samplers associated with the Image Processing effects.
  16095. * @param uniformsList The list of uniforms used in the effect
  16096. * @param defines the list of defines currently in use
  16097. */
  16098. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16099. /**
  16100. * Prepare the list of defines associated to the shader.
  16101. * @param defines the list of defines to complete
  16102. */
  16103. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16104. /**
  16105. * Returns true if all the image processing information are ready.
  16106. */
  16107. isReady(): boolean;
  16108. /**
  16109. * Binds the image processing to the shader.
  16110. * @param effect The effect to bind to
  16111. */
  16112. bind(effect: Effect, aspectRatio?: number): void;
  16113. /**
  16114. * Clones the current image processing instance.
  16115. * @return The cloned image processing
  16116. */
  16117. clone(): ImageProcessingConfiguration;
  16118. /**
  16119. * Serializes the current image processing instance to a json representation.
  16120. * @return a JSON representation
  16121. */
  16122. serialize(): any;
  16123. /**
  16124. * Parses the image processing from a json representation.
  16125. * @param source the JSON source to parse
  16126. * @return The parsed image processing
  16127. */
  16128. static Parse(source: any): ImageProcessingConfiguration;
  16129. private static _VIGNETTEMODE_MULTIPLY;
  16130. private static _VIGNETTEMODE_OPAQUE;
  16131. /**
  16132. * Used to apply the vignette as a mix with the pixel color.
  16133. */
  16134. static readonly VIGNETTEMODE_MULTIPLY: number;
  16135. /**
  16136. * Used to apply the vignette as a replacement of the pixel color.
  16137. */
  16138. static readonly VIGNETTEMODE_OPAQUE: number;
  16139. }
  16140. }
  16141. declare module BABYLON {
  16142. /**
  16143. * Manages the defines for the Material
  16144. */
  16145. class MaterialDefines {
  16146. private _keys;
  16147. private _isDirty;
  16148. /** @hidden */
  16149. _renderId: number;
  16150. /** @hidden */
  16151. _areLightsDirty: boolean;
  16152. /** @hidden */
  16153. _areAttributesDirty: boolean;
  16154. /** @hidden */
  16155. _areTexturesDirty: boolean;
  16156. /** @hidden */
  16157. _areFresnelDirty: boolean;
  16158. /** @hidden */
  16159. _areMiscDirty: boolean;
  16160. /** @hidden */
  16161. _areImageProcessingDirty: boolean;
  16162. /** @hidden */
  16163. _normals: boolean;
  16164. /** @hidden */
  16165. _uvs: boolean;
  16166. /** @hidden */
  16167. _needNormals: boolean;
  16168. /** @hidden */
  16169. _needUVs: boolean;
  16170. /**
  16171. * Specifies if the material needs to be re-calculated
  16172. */
  16173. readonly isDirty: boolean;
  16174. /**
  16175. * Marks the material to indicate that it has been re-calculated
  16176. */
  16177. markAsProcessed(): void;
  16178. /**
  16179. * Marks the material to indicate that it needs to be re-calculated
  16180. */
  16181. markAsUnprocessed(): void;
  16182. /**
  16183. * Marks the material to indicate all of its defines need to be re-calculated
  16184. */
  16185. markAllAsDirty(): void;
  16186. /**
  16187. * Marks the material to indicate that image processing needs to be re-calculated
  16188. */
  16189. markAsImageProcessingDirty(): void;
  16190. /**
  16191. * Marks the material to indicate the lights need to be re-calculated
  16192. */
  16193. markAsLightDirty(): void;
  16194. /**
  16195. * Marks the attribute state as changed
  16196. */
  16197. markAsAttributesDirty(): void;
  16198. /**
  16199. * Marks the texture state as changed
  16200. */
  16201. markAsTexturesDirty(): void;
  16202. /**
  16203. * Marks the fresnel state as changed
  16204. */
  16205. markAsFresnelDirty(): void;
  16206. /**
  16207. * Marks the misc state as changed
  16208. */
  16209. markAsMiscDirty(): void;
  16210. /**
  16211. * Rebuilds the material defines
  16212. */
  16213. rebuild(): void;
  16214. /**
  16215. * Specifies if two material defines are equal
  16216. * @param other - A material define instance to compare to
  16217. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  16218. */
  16219. isEqual(other: MaterialDefines): boolean;
  16220. /**
  16221. * Clones this instance's defines to another instance
  16222. * @param other - material defines to clone values to
  16223. */
  16224. cloneTo(other: MaterialDefines): void;
  16225. /**
  16226. * Resets the material define values
  16227. */
  16228. reset(): void;
  16229. /**
  16230. * Converts the material define values to a string
  16231. * @returns - String of material define information
  16232. */
  16233. toString(): string;
  16234. }
  16235. /**
  16236. * Base class for the main features of a material in Babylon.js
  16237. */
  16238. class Material implements IAnimatable {
  16239. private static _TriangleFillMode;
  16240. private static _WireFrameFillMode;
  16241. private static _PointFillMode;
  16242. private static _PointListDrawMode;
  16243. private static _LineListDrawMode;
  16244. private static _LineLoopDrawMode;
  16245. private static _LineStripDrawMode;
  16246. private static _TriangleStripDrawMode;
  16247. private static _TriangleFanDrawMode;
  16248. /**
  16249. * Returns the triangle fill mode
  16250. */
  16251. static readonly TriangleFillMode: number;
  16252. /**
  16253. * Returns the wireframe mode
  16254. */
  16255. static readonly WireFrameFillMode: number;
  16256. /**
  16257. * Returns the point fill mode
  16258. */
  16259. static readonly PointFillMode: number;
  16260. /**
  16261. * Returns the point list draw mode
  16262. */
  16263. static readonly PointListDrawMode: number;
  16264. /**
  16265. * Returns the line list draw mode
  16266. */
  16267. static readonly LineListDrawMode: number;
  16268. /**
  16269. * Returns the line loop draw mode
  16270. */
  16271. static readonly LineLoopDrawMode: number;
  16272. /**
  16273. * Returns the line strip draw mode
  16274. */
  16275. static readonly LineStripDrawMode: number;
  16276. /**
  16277. * Returns the triangle strip draw mode
  16278. */
  16279. static readonly TriangleStripDrawMode: number;
  16280. /**
  16281. * Returns the triangle fan draw mode
  16282. */
  16283. static readonly TriangleFanDrawMode: number;
  16284. /**
  16285. * Stores the clock-wise side orientation
  16286. */
  16287. private static _ClockWiseSideOrientation;
  16288. /**
  16289. * Stores the counter clock-wise side orientation
  16290. */
  16291. private static _CounterClockWiseSideOrientation;
  16292. /**
  16293. * Returns the clock-wise side orientation
  16294. */
  16295. static readonly ClockWiseSideOrientation: number;
  16296. /**
  16297. * Returns the counter clock-wise side orientation
  16298. */
  16299. static readonly CounterClockWiseSideOrientation: number;
  16300. /**
  16301. * The dirty texture flag value
  16302. */
  16303. private static _TextureDirtyFlag;
  16304. /**
  16305. * The dirty light flag value
  16306. */
  16307. private static _LightDirtyFlag;
  16308. /**
  16309. * The dirty fresnel flag value
  16310. */
  16311. private static _FresnelDirtyFlag;
  16312. /**
  16313. * The dirty attribute flag value
  16314. */
  16315. private static _AttributesDirtyFlag;
  16316. /**
  16317. * The dirty misc flag value
  16318. */
  16319. private static _MiscDirtyFlag;
  16320. /**
  16321. * Returns the dirty texture flag value
  16322. */
  16323. static readonly TextureDirtyFlag: number;
  16324. /**
  16325. * Returns the dirty light flag value
  16326. */
  16327. static readonly LightDirtyFlag: number;
  16328. /**
  16329. * Returns the dirty fresnel flag value
  16330. */
  16331. static readonly FresnelDirtyFlag: number;
  16332. /**
  16333. * Returns the dirty attributes flag value
  16334. */
  16335. static readonly AttributesDirtyFlag: number;
  16336. /**
  16337. * Returns the dirty misc flag value
  16338. */
  16339. static readonly MiscDirtyFlag: number;
  16340. /**
  16341. * The ID of the material
  16342. */
  16343. id: string;
  16344. /**
  16345. * The name of the material
  16346. */
  16347. name: string;
  16348. /**
  16349. * Specifies if the ready state should be checked on each call
  16350. */
  16351. checkReadyOnEveryCall: boolean;
  16352. /**
  16353. * Specifies if the ready state should be checked once
  16354. */
  16355. checkReadyOnlyOnce: boolean;
  16356. /**
  16357. * The state of the material
  16358. */
  16359. state: string;
  16360. /**
  16361. * The alpha value of the material
  16362. */
  16363. protected _alpha: number;
  16364. /**
  16365. * Gets the alpha value of the material
  16366. */
  16367. /**
  16368. * Sets the alpha value of the material
  16369. */
  16370. alpha: number;
  16371. /**
  16372. * Specifies if back face culling is enabled
  16373. */
  16374. protected _backFaceCulling: boolean;
  16375. /**
  16376. * Gets the back-face culling state
  16377. */
  16378. /**
  16379. * Sets the back-face culling state
  16380. */
  16381. backFaceCulling: boolean;
  16382. /**
  16383. * Stores the value for side orientation
  16384. */
  16385. sideOrientation: number;
  16386. /**
  16387. * Callback triggered when the material is compiled
  16388. */
  16389. onCompiled: (effect: Effect) => void;
  16390. /**
  16391. * Callback triggered when an error occurs
  16392. */
  16393. onError: (effect: Effect, errors: string) => void;
  16394. /**
  16395. * Callback triggered to get the render target textures
  16396. */
  16397. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  16398. /**
  16399. * Specifies if the material should be serialized
  16400. */
  16401. doNotSerialize: boolean;
  16402. /**
  16403. * Specifies if the effect should be stored on sub meshes
  16404. */
  16405. storeEffectOnSubMeshes: boolean;
  16406. /**
  16407. * Stores the animations for the material
  16408. */
  16409. animations: Array<Animation>;
  16410. /**
  16411. * An event triggered when the material is disposed
  16412. */
  16413. onDisposeObservable: Observable<Material>;
  16414. /**
  16415. * An observer which watches for dispose events
  16416. */
  16417. private _onDisposeObserver;
  16418. /**
  16419. * Called during a dispose event
  16420. */
  16421. onDispose: () => void;
  16422. /**
  16423. * An event triggered when the material is bound
  16424. */
  16425. onBindObservable: Observable<AbstractMesh>;
  16426. /**
  16427. * An observer which watches for bind events
  16428. */
  16429. private _onBindObserver;
  16430. /**
  16431. * Called during a bind event
  16432. */
  16433. onBind: (Mesh: AbstractMesh) => void;
  16434. /**
  16435. * An event triggered when the material is unbound
  16436. */
  16437. onUnBindObservable: Observable<Material>;
  16438. /**
  16439. * Stores the value of the alpha mode
  16440. */
  16441. private _alphaMode;
  16442. /**
  16443. * Gets the value of the alpha mode
  16444. */
  16445. /**
  16446. * Sets the value of the alpha mode.
  16447. *
  16448. * | Value | Type | Description |
  16449. * | --- | --- | --- |
  16450. * | 0 | ALPHA_DISABLE | |
  16451. * | 1 | ALPHA_ADD | |
  16452. * | 2 | ALPHA_COMBINE | |
  16453. * | 3 | ALPHA_SUBTRACT | |
  16454. * | 4 | ALPHA_MULTIPLY | |
  16455. * | 5 | ALPHA_MAXIMIZED | |
  16456. * | 6 | ALPHA_ONEONE | |
  16457. * | 7 | ALPHA_PREMULTIPLIED | |
  16458. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  16459. * | 9 | ALPHA_INTERPOLATE | |
  16460. * | 10 | ALPHA_SCREENMODE | |
  16461. *
  16462. */
  16463. alphaMode: number;
  16464. /**
  16465. * Stores the state of the need depth pre-pass value
  16466. */
  16467. private _needDepthPrePass;
  16468. /**
  16469. * Gets the depth pre-pass value
  16470. */
  16471. /**
  16472. * Sets the need depth pre-pass value
  16473. */
  16474. needDepthPrePass: boolean;
  16475. /**
  16476. * Specifies if depth writing should be disabled
  16477. */
  16478. disableDepthWrite: boolean;
  16479. /**
  16480. * Specifies if depth writing should be forced
  16481. */
  16482. forceDepthWrite: boolean;
  16483. /**
  16484. * Specifies if there should be a separate pass for culling
  16485. */
  16486. separateCullingPass: boolean;
  16487. /**
  16488. * Stores the state specifing if fog should be enabled
  16489. */
  16490. private _fogEnabled;
  16491. /**
  16492. * Gets the value of the fog enabled state
  16493. */
  16494. /**
  16495. * Sets the state for enabling fog
  16496. */
  16497. fogEnabled: boolean;
  16498. /**
  16499. * Stores the size of points
  16500. */
  16501. pointSize: number;
  16502. /**
  16503. * Stores the z offset value
  16504. */
  16505. zOffset: number;
  16506. /**
  16507. * Gets a value specifying if wireframe mode is enabled
  16508. */
  16509. /**
  16510. * Sets the state of wireframe mode
  16511. */
  16512. wireframe: boolean;
  16513. /**
  16514. * Gets the value specifying if point clouds are enabled
  16515. */
  16516. /**
  16517. * Sets the state of point cloud mode
  16518. */
  16519. pointsCloud: boolean;
  16520. /**
  16521. * Gets the material fill mode
  16522. */
  16523. /**
  16524. * Sets the material fill mode
  16525. */
  16526. fillMode: number;
  16527. /**
  16528. * Stores the effects for the material
  16529. */
  16530. _effect: Nullable<Effect>;
  16531. /**
  16532. * Specifies if the material was previously ready
  16533. */
  16534. _wasPreviouslyReady: boolean;
  16535. /**
  16536. * Specifies if uniform buffers should be used
  16537. */
  16538. private _useUBO;
  16539. /**
  16540. * Stores a reference to the scene
  16541. */
  16542. private _scene;
  16543. /**
  16544. * Stores the fill mode state
  16545. */
  16546. private _fillMode;
  16547. /**
  16548. * Specifies if the depth write state should be cached
  16549. */
  16550. private _cachedDepthWriteState;
  16551. /**
  16552. * Stores the uniform buffer
  16553. */
  16554. protected _uniformBuffer: UniformBuffer;
  16555. /**
  16556. * Creates a material instance
  16557. * @param name defines the name of the material
  16558. * @param scene defines the scene to reference
  16559. * @param doNotAdd specifies if the material should be added to the scene
  16560. */
  16561. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  16562. /**
  16563. * Returns a string representation of the current material
  16564. * @param fullDetails defines a boolean indicating which levels of logging is desired
  16565. * @returns a string with material information
  16566. */
  16567. toString(fullDetails?: boolean): string;
  16568. /**
  16569. * Gets the class name of the material
  16570. * @returns a string with the class name of the material
  16571. */
  16572. getClassName(): string;
  16573. /**
  16574. * Specifies if updates for the material been locked
  16575. */
  16576. readonly isFrozen: boolean;
  16577. /**
  16578. * Locks updates for the material
  16579. */
  16580. freeze(): void;
  16581. /**
  16582. * Unlocks updates for the material
  16583. */
  16584. unfreeze(): void;
  16585. /**
  16586. * Specifies if the material is ready to be used
  16587. * @param mesh defines the mesh to check
  16588. * @param useInstances specifies if instances should be used
  16589. * @returns a boolean indicating if the material is ready to be used
  16590. */
  16591. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16592. /**
  16593. * Specifies that the submesh is ready to be used
  16594. * @param mesh defines the mesh to check
  16595. * @param subMesh defines which submesh to check
  16596. * @param useInstances specifies that instances should be used
  16597. * @returns a boolean indicating that the submesh is ready or not
  16598. */
  16599. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16600. /**
  16601. * Returns the material effect
  16602. * @returns the effect associated with the material
  16603. */
  16604. getEffect(): Nullable<Effect>;
  16605. /**
  16606. * Returns the current scene
  16607. * @returns a Scene
  16608. */
  16609. getScene(): Scene;
  16610. /**
  16611. * Specifies if the material will require alpha blending
  16612. * @returns a boolean specifying if alpha blending is needed
  16613. */
  16614. needAlphaBlending(): boolean;
  16615. /**
  16616. * Specifies if the mesh will require alpha blending
  16617. * @param mesh defines the mesh to check
  16618. * @returns a boolean specifying if alpha blending is needed for the mesh
  16619. */
  16620. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  16621. /**
  16622. * Specifies if this material should be rendered in alpha test mode
  16623. * @returns a boolean specifying if an alpha test is needed.
  16624. */
  16625. needAlphaTesting(): boolean;
  16626. /**
  16627. * Gets the texture used for the alpha test
  16628. * @returns the texture to use for alpha testing
  16629. */
  16630. getAlphaTestTexture(): Nullable<BaseTexture>;
  16631. /**
  16632. * Marks the material to indicate that it needs to be re-calculated
  16633. */
  16634. markDirty(): void;
  16635. /** @hidden */
  16636. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  16637. /**
  16638. * Binds the material to the mesh
  16639. * @param world defines the world transformation matrix
  16640. * @param mesh defines the mesh to bind the material to
  16641. */
  16642. bind(world: Matrix, mesh?: Mesh): void;
  16643. /**
  16644. * Binds the submesh to the material
  16645. * @param world defines the world transformation matrix
  16646. * @param mesh defines the mesh containing the submesh
  16647. * @param subMesh defines the submesh to bind the material to
  16648. */
  16649. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16650. /**
  16651. * Binds the world matrix to the material
  16652. * @param world defines the world transformation matrix
  16653. */
  16654. bindOnlyWorldMatrix(world: Matrix): void;
  16655. /**
  16656. * Binds the scene's uniform buffer to the effect.
  16657. * @param effect defines the effect to bind to the scene uniform buffer
  16658. * @param sceneUbo defines the uniform buffer storing scene data
  16659. */
  16660. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  16661. /**
  16662. * Binds the view matrix to the effect
  16663. * @param effect defines the effect to bind the view matrix to
  16664. */
  16665. bindView(effect: Effect): void;
  16666. /**
  16667. * Binds the view projection matrix to the effect
  16668. * @param effect defines the effect to bind the view projection matrix to
  16669. */
  16670. bindViewProjection(effect: Effect): void;
  16671. /**
  16672. * Specifies if material alpha testing should be turned on for the mesh
  16673. * @param mesh defines the mesh to check
  16674. */
  16675. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  16676. /**
  16677. * Processes to execute after binding the material to a mesh
  16678. * @param mesh defines the rendered mesh
  16679. */
  16680. protected _afterBind(mesh?: Mesh): void;
  16681. /**
  16682. * Unbinds the material from the mesh
  16683. */
  16684. unbind(): void;
  16685. /**
  16686. * Gets the active textures from the material
  16687. * @returns an array of textures
  16688. */
  16689. getActiveTextures(): BaseTexture[];
  16690. /**
  16691. * Specifies if the material uses a texture
  16692. * @param texture defines the texture to check against the material
  16693. * @returns a boolean specifying if the material uses the texture
  16694. */
  16695. hasTexture(texture: BaseTexture): boolean;
  16696. /**
  16697. * Makes a duplicate of the material, and gives it a new name
  16698. * @param name defines the new name for the duplicated material
  16699. * @returns the cloned material
  16700. */
  16701. clone(name: string): Nullable<Material>;
  16702. /**
  16703. * Gets the meshes bound to the material
  16704. * @returns an array of meshes bound to the material
  16705. */
  16706. getBindedMeshes(): AbstractMesh[];
  16707. /**
  16708. * Force shader compilation
  16709. * @param mesh defines the mesh associated with this material
  16710. * @param onCompiled defines a function to execute once the material is compiled
  16711. * @param options defines the options to configure the compilation
  16712. */
  16713. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  16714. clipPlane: boolean;
  16715. }>): void;
  16716. /**
  16717. * Force shader compilation
  16718. * @param mesh defines the mesh that will use this material
  16719. * @param options defines additional options for compiling the shaders
  16720. * @returns a promise that resolves when the compilation completes
  16721. */
  16722. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  16723. clipPlane: boolean;
  16724. }>): Promise<void>;
  16725. /**
  16726. * Marks a define in the material to indicate that it needs to be re-computed
  16727. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  16728. */
  16729. markAsDirty(flag: number): void;
  16730. /**
  16731. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  16732. * @param func defines a function which checks material defines against the submeshes
  16733. */
  16734. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  16735. /**
  16736. * Indicates that image processing needs to be re-calculated for all submeshes
  16737. */
  16738. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  16739. /**
  16740. * Indicates that textures need to be re-calculated for all submeshes
  16741. */
  16742. protected _markAllSubMeshesAsTexturesDirty(): void;
  16743. /**
  16744. * Indicates that fresnel needs to be re-calculated for all submeshes
  16745. */
  16746. protected _markAllSubMeshesAsFresnelDirty(): void;
  16747. /**
  16748. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  16749. */
  16750. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  16751. /**
  16752. * Indicates that lights need to be re-calculated for all submeshes
  16753. */
  16754. protected _markAllSubMeshesAsLightsDirty(): void;
  16755. /**
  16756. * Indicates that attributes need to be re-calculated for all submeshes
  16757. */
  16758. protected _markAllSubMeshesAsAttributesDirty(): void;
  16759. /**
  16760. * Indicates that misc needs to be re-calculated for all submeshes
  16761. */
  16762. protected _markAllSubMeshesAsMiscDirty(): void;
  16763. /**
  16764. * Indicates that textures and misc need to be re-calculated for all submeshes
  16765. */
  16766. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  16767. /**
  16768. * Disposes the material
  16769. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16770. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16771. */
  16772. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  16773. /**
  16774. * Serializes this material
  16775. * @returns the serialized material object
  16776. */
  16777. serialize(): any;
  16778. /**
  16779. * Creates a MultiMaterial from parsed MultiMaterial data.
  16780. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  16781. * @param scene defines the hosting scene
  16782. * @returns a new MultiMaterial
  16783. */
  16784. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  16785. /**
  16786. * Creates a material from parsed material data
  16787. * @param parsedMaterial defines parsed material data
  16788. * @param scene defines the hosting scene
  16789. * @param rootUrl defines the root URL to use to load textures
  16790. * @returns a new material
  16791. */
  16792. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  16793. }
  16794. }
  16795. declare module BABYLON {
  16796. /**
  16797. * "Static Class" containing the most commonly used helper while dealing with material for
  16798. * rendering purpose.
  16799. *
  16800. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  16801. *
  16802. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  16803. */
  16804. class MaterialHelper {
  16805. /**
  16806. * Bind the current view position to an effect.
  16807. * @param effect The effect to be bound
  16808. * @param scene The scene the eyes position is used from
  16809. */
  16810. static BindEyePosition(effect: Effect, scene: Scene): void;
  16811. /**
  16812. * Helps preparing the defines values about the UVs in used in the effect.
  16813. * UVs are shared as much as we can accross chanels in the shaders.
  16814. * @param texture The texture we are preparing the UVs for
  16815. * @param defines The defines to update
  16816. * @param key The chanel key "diffuse", "specular"... used in the shader
  16817. */
  16818. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  16819. /**
  16820. * Binds a texture matrix value to its corrsponding uniform
  16821. * @param texture The texture to bind the matrix for
  16822. * @param uniformBuffer The uniform buffer receivin the data
  16823. * @param key The chanel key "diffuse", "specular"... used in the shader
  16824. */
  16825. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  16826. /**
  16827. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  16828. * @param mesh defines the current mesh
  16829. * @param scene defines the current scene
  16830. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  16831. * @param pointsCloud defines if point cloud rendering has to be turned on
  16832. * @param fogEnabled defines if fog has to be turned on
  16833. * @param alphaTest defines if alpha testing has to be turned on
  16834. * @param defines defines the current list of defines
  16835. */
  16836. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  16837. /**
  16838. * Helper used to prepare the list of defines associated with frame values for shader compilation
  16839. * @param scene defines the current scene
  16840. * @param engine defines the current engine
  16841. * @param defines specifies the list of active defines
  16842. * @param useInstances defines if instances have to be turned on
  16843. * @param useClipPlane defines if clip plane have to be turned on
  16844. */
  16845. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  16846. /**
  16847. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  16848. * @param mesh The mesh containing the geometry data we will draw
  16849. * @param defines The defines to update
  16850. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  16851. * @param useBones Precise whether bones should be used or not (override mesh info)
  16852. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  16853. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  16854. * @returns false if defines are considered not dirty and have not been checked
  16855. */
  16856. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  16857. /**
  16858. * Prepares the defines related to the light information passed in parameter
  16859. * @param scene The scene we are intending to draw
  16860. * @param mesh The mesh the effect is compiling for
  16861. * @param defines The defines to update
  16862. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  16863. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  16864. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  16865. * @returns true if normals will be required for the rest of the effect
  16866. */
  16867. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  16868. /**
  16869. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  16870. * that won t be acctive due to defines being turned off.
  16871. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  16872. * @param samplersList The samplers list
  16873. * @param defines The defines helping in the list generation
  16874. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  16875. */
  16876. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  16877. /**
  16878. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  16879. * @param defines The defines to update while falling back
  16880. * @param fallbacks The authorized effect fallbacks
  16881. * @param maxSimultaneousLights The maximum number of lights allowed
  16882. * @param rank the current rank of the Effect
  16883. * @returns The newly affected rank
  16884. */
  16885. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  16886. /**
  16887. * Prepares the list of attributes required for morph targets according to the effect defines.
  16888. * @param attribs The current list of supported attribs
  16889. * @param mesh The mesh to prepare the morph targets attributes for
  16890. * @param defines The current Defines of the effect
  16891. */
  16892. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  16893. /**
  16894. * Prepares the list of attributes required for bones according to the effect defines.
  16895. * @param attribs The current list of supported attribs
  16896. * @param mesh The mesh to prepare the bones attributes for
  16897. * @param defines The current Defines of the effect
  16898. * @param fallbacks The current efffect fallback strategy
  16899. */
  16900. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  16901. /**
  16902. * Prepares the list of attributes required for instances according to the effect defines.
  16903. * @param attribs The current list of supported attribs
  16904. * @param defines The current Defines of the effect
  16905. */
  16906. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  16907. /**
  16908. * Binds the light shadow information to the effect for the given mesh.
  16909. * @param light The light containing the generator
  16910. * @param scene The scene the lights belongs to
  16911. * @param mesh The mesh we are binding the information to render
  16912. * @param lightIndex The light index in the effect used to render the mesh
  16913. * @param effect The effect we are binding the data to
  16914. */
  16915. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  16916. /**
  16917. * Binds the light information to the effect.
  16918. * @param light The light containing the generator
  16919. * @param effect The effect we are binding the data to
  16920. * @param lightIndex The light index in the effect used to render
  16921. */
  16922. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  16923. /**
  16924. * Binds the lights information from the scene to the effect for the given mesh.
  16925. * @param scene The scene the lights belongs to
  16926. * @param mesh The mesh we are binding the information to render
  16927. * @param effect The effect we are binding the data to
  16928. * @param defines The generated defines for the effect
  16929. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  16930. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  16931. */
  16932. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  16933. /**
  16934. * Binds the fog information from the scene to the effect for the given mesh.
  16935. * @param scene The scene the lights belongs to
  16936. * @param mesh The mesh we are binding the information to render
  16937. * @param effect The effect we are binding the data to
  16938. */
  16939. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  16940. /**
  16941. * Binds the bones information from the mesh to the effect.
  16942. * @param mesh The mesh we are binding the information to render
  16943. * @param effect The effect we are binding the data to
  16944. */
  16945. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  16946. /**
  16947. * Binds the morph targets information from the mesh to the effect.
  16948. * @param abstractMesh The mesh we are binding the information to render
  16949. * @param effect The effect we are binding the data to
  16950. */
  16951. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  16952. /**
  16953. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  16954. * @param defines The generated defines used in the effect
  16955. * @param effect The effect we are binding the data to
  16956. * @param scene The scene we are willing to render with logarithmic scale for
  16957. */
  16958. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  16959. /**
  16960. * Binds the clip plane information from the scene to the effect.
  16961. * @param scene The scene the clip plane information are extracted from
  16962. * @param effect The effect we are binding the data to
  16963. */
  16964. static BindClipPlane(effect: Effect, scene: Scene): void;
  16965. }
  16966. }
  16967. declare module BABYLON {
  16968. class MultiMaterial extends Material {
  16969. private _subMaterials;
  16970. subMaterials: Nullable<Material>[];
  16971. constructor(name: string, scene: Scene);
  16972. private _hookArray(array);
  16973. getSubMaterial(index: number): Nullable<Material>;
  16974. getActiveTextures(): BaseTexture[];
  16975. getClassName(): string;
  16976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16977. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  16978. serialize(): any;
  16979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  16980. }
  16981. }
  16982. declare module BABYLON {
  16983. class PushMaterial extends Material {
  16984. protected _activeEffect: Effect;
  16985. protected _normalMatrix: Matrix;
  16986. constructor(name: string, scene: Scene);
  16987. getEffect(): Effect;
  16988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16989. /**
  16990. * Binds the given world matrix to the active effect
  16991. *
  16992. * @param world the matrix to bind
  16993. */
  16994. bindOnlyWorldMatrix(world: Matrix): void;
  16995. /**
  16996. * Binds the given normal matrix to the active effect
  16997. *
  16998. * @param normalMatrix the matrix to bind
  16999. */
  17000. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17001. bind(world: Matrix, mesh?: Mesh): void;
  17002. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17003. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17004. }
  17005. }
  17006. declare module BABYLON {
  17007. class ShaderMaterial extends Material {
  17008. private _shaderPath;
  17009. private _options;
  17010. private _textures;
  17011. private _textureArrays;
  17012. private _floats;
  17013. private _ints;
  17014. private _floatsArrays;
  17015. private _colors3;
  17016. private _colors3Arrays;
  17017. private _colors4;
  17018. private _vectors2;
  17019. private _vectors3;
  17020. private _vectors4;
  17021. private _matrices;
  17022. private _matrices3x3;
  17023. private _matrices2x2;
  17024. private _vectors2Arrays;
  17025. private _vectors3Arrays;
  17026. private _cachedWorldViewMatrix;
  17027. private _renderId;
  17028. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  17029. getClassName(): string;
  17030. needAlphaBlending(): boolean;
  17031. needAlphaTesting(): boolean;
  17032. private _checkUniform(uniformName);
  17033. setTexture(name: string, texture: Texture): ShaderMaterial;
  17034. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17035. setFloat(name: string, value: number): ShaderMaterial;
  17036. setInt(name: string, value: number): ShaderMaterial;
  17037. setFloats(name: string, value: number[]): ShaderMaterial;
  17038. setColor3(name: string, value: Color3): ShaderMaterial;
  17039. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17040. setColor4(name: string, value: Color4): ShaderMaterial;
  17041. setVector2(name: string, value: Vector2): ShaderMaterial;
  17042. setVector3(name: string, value: Vector3): ShaderMaterial;
  17043. setVector4(name: string, value: Vector4): ShaderMaterial;
  17044. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17045. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17046. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17047. setArray2(name: string, value: number[]): ShaderMaterial;
  17048. setArray3(name: string, value: number[]): ShaderMaterial;
  17049. private _checkCache(scene, mesh?, useInstances?);
  17050. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17051. bindOnlyWorldMatrix(world: Matrix): void;
  17052. bind(world: Matrix, mesh?: Mesh): void;
  17053. getActiveTextures(): BaseTexture[];
  17054. hasTexture(texture: BaseTexture): boolean;
  17055. clone(name: string): ShaderMaterial;
  17056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17057. serialize(): any;
  17058. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17059. }
  17060. }
  17061. declare module BABYLON {
  17062. /** @hidden */
  17063. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17064. MAINUV1: boolean;
  17065. MAINUV2: boolean;
  17066. DIFFUSE: boolean;
  17067. DIFFUSEDIRECTUV: number;
  17068. AMBIENT: boolean;
  17069. AMBIENTDIRECTUV: number;
  17070. OPACITY: boolean;
  17071. OPACITYDIRECTUV: number;
  17072. OPACITYRGB: boolean;
  17073. REFLECTION: boolean;
  17074. EMISSIVE: boolean;
  17075. EMISSIVEDIRECTUV: number;
  17076. SPECULAR: boolean;
  17077. SPECULARDIRECTUV: number;
  17078. BUMP: boolean;
  17079. BUMPDIRECTUV: number;
  17080. PARALLAX: boolean;
  17081. PARALLAXOCCLUSION: boolean;
  17082. SPECULAROVERALPHA: boolean;
  17083. CLIPPLANE: boolean;
  17084. ALPHATEST: boolean;
  17085. DEPTHPREPASS: boolean;
  17086. ALPHAFROMDIFFUSE: boolean;
  17087. POINTSIZE: boolean;
  17088. FOG: boolean;
  17089. SPECULARTERM: boolean;
  17090. DIFFUSEFRESNEL: boolean;
  17091. OPACITYFRESNEL: boolean;
  17092. REFLECTIONFRESNEL: boolean;
  17093. REFRACTIONFRESNEL: boolean;
  17094. EMISSIVEFRESNEL: boolean;
  17095. FRESNEL: boolean;
  17096. NORMAL: boolean;
  17097. UV1: boolean;
  17098. UV2: boolean;
  17099. VERTEXCOLOR: boolean;
  17100. VERTEXALPHA: boolean;
  17101. NUM_BONE_INFLUENCERS: number;
  17102. BonesPerMesh: number;
  17103. INSTANCES: boolean;
  17104. GLOSSINESS: boolean;
  17105. ROUGHNESS: boolean;
  17106. EMISSIVEASILLUMINATION: boolean;
  17107. LINKEMISSIVEWITHDIFFUSE: boolean;
  17108. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17109. LIGHTMAP: boolean;
  17110. LIGHTMAPDIRECTUV: number;
  17111. OBJECTSPACE_NORMALMAP: boolean;
  17112. USELIGHTMAPASSHADOWMAP: boolean;
  17113. REFLECTIONMAP_3D: boolean;
  17114. REFLECTIONMAP_SPHERICAL: boolean;
  17115. REFLECTIONMAP_PLANAR: boolean;
  17116. REFLECTIONMAP_CUBIC: boolean;
  17117. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17118. REFLECTIONMAP_PROJECTION: boolean;
  17119. REFLECTIONMAP_SKYBOX: boolean;
  17120. REFLECTIONMAP_EXPLICIT: boolean;
  17121. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17122. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17123. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17124. INVERTCUBICMAP: boolean;
  17125. LOGARITHMICDEPTH: boolean;
  17126. REFRACTION: boolean;
  17127. REFRACTIONMAP_3D: boolean;
  17128. REFLECTIONOVERALPHA: boolean;
  17129. TWOSIDEDLIGHTING: boolean;
  17130. SHADOWFLOAT: boolean;
  17131. MORPHTARGETS: boolean;
  17132. MORPHTARGETS_NORMAL: boolean;
  17133. MORPHTARGETS_TANGENT: boolean;
  17134. NUM_MORPH_INFLUENCERS: number;
  17135. NONUNIFORMSCALING: boolean;
  17136. PREMULTIPLYALPHA: boolean;
  17137. IMAGEPROCESSING: boolean;
  17138. VIGNETTE: boolean;
  17139. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17140. VIGNETTEBLENDMODEOPAQUE: boolean;
  17141. TONEMAPPING: boolean;
  17142. CONTRAST: boolean;
  17143. COLORCURVES: boolean;
  17144. COLORGRADING: boolean;
  17145. COLORGRADING3D: boolean;
  17146. SAMPLER3DGREENDEPTH: boolean;
  17147. SAMPLER3DBGRMAP: boolean;
  17148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17149. /**
  17150. * If the reflection texture on this material is in linear color space
  17151. * @hidden
  17152. */
  17153. IS_REFLECTION_LINEAR: boolean;
  17154. /**
  17155. * If the refraction texture on this material is in linear color space
  17156. * @hidden
  17157. */
  17158. IS_REFRACTION_LINEAR: boolean;
  17159. EXPOSURE: boolean;
  17160. constructor();
  17161. setReflectionMode(modeToEnable: string): void;
  17162. }
  17163. class StandardMaterial extends PushMaterial {
  17164. private _diffuseTexture;
  17165. diffuseTexture: Nullable<BaseTexture>;
  17166. private _ambientTexture;
  17167. ambientTexture: Nullable<BaseTexture>;
  17168. private _opacityTexture;
  17169. opacityTexture: Nullable<BaseTexture>;
  17170. private _reflectionTexture;
  17171. reflectionTexture: Nullable<BaseTexture>;
  17172. private _emissiveTexture;
  17173. emissiveTexture: Nullable<BaseTexture>;
  17174. private _specularTexture;
  17175. specularTexture: Nullable<BaseTexture>;
  17176. private _bumpTexture;
  17177. bumpTexture: Nullable<BaseTexture>;
  17178. private _lightmapTexture;
  17179. lightmapTexture: Nullable<BaseTexture>;
  17180. private _refractionTexture;
  17181. refractionTexture: Nullable<BaseTexture>;
  17182. ambientColor: Color3;
  17183. diffuseColor: Color3;
  17184. specularColor: Color3;
  17185. emissiveColor: Color3;
  17186. specularPower: number;
  17187. private _useAlphaFromDiffuseTexture;
  17188. useAlphaFromDiffuseTexture: boolean;
  17189. private _useEmissiveAsIllumination;
  17190. useEmissiveAsIllumination: boolean;
  17191. private _linkEmissiveWithDiffuse;
  17192. linkEmissiveWithDiffuse: boolean;
  17193. private _useSpecularOverAlpha;
  17194. useSpecularOverAlpha: boolean;
  17195. private _useReflectionOverAlpha;
  17196. useReflectionOverAlpha: boolean;
  17197. private _disableLighting;
  17198. disableLighting: boolean;
  17199. private _useObjectSpaceNormalMap;
  17200. /**
  17201. * Allows using an object space normal map (instead of tangent space).
  17202. */
  17203. useObjectSpaceNormalMap: boolean;
  17204. private _useParallax;
  17205. useParallax: boolean;
  17206. private _useParallaxOcclusion;
  17207. useParallaxOcclusion: boolean;
  17208. parallaxScaleBias: number;
  17209. private _roughness;
  17210. roughness: number;
  17211. indexOfRefraction: number;
  17212. invertRefractionY: boolean;
  17213. /**
  17214. * Defines the alpha limits in alpha test mode
  17215. */
  17216. alphaCutOff: number;
  17217. private _useLightmapAsShadowmap;
  17218. useLightmapAsShadowmap: boolean;
  17219. private _diffuseFresnelParameters;
  17220. diffuseFresnelParameters: FresnelParameters;
  17221. private _opacityFresnelParameters;
  17222. opacityFresnelParameters: FresnelParameters;
  17223. private _reflectionFresnelParameters;
  17224. reflectionFresnelParameters: FresnelParameters;
  17225. private _refractionFresnelParameters;
  17226. refractionFresnelParameters: FresnelParameters;
  17227. private _emissiveFresnelParameters;
  17228. emissiveFresnelParameters: FresnelParameters;
  17229. private _useReflectionFresnelFromSpecular;
  17230. useReflectionFresnelFromSpecular: boolean;
  17231. private _useGlossinessFromSpecularMapAlpha;
  17232. useGlossinessFromSpecularMapAlpha: boolean;
  17233. private _maxSimultaneousLights;
  17234. maxSimultaneousLights: number;
  17235. /**
  17236. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  17237. */
  17238. private _invertNormalMapX;
  17239. invertNormalMapX: boolean;
  17240. /**
  17241. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  17242. */
  17243. private _invertNormalMapY;
  17244. invertNormalMapY: boolean;
  17245. /**
  17246. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  17247. */
  17248. private _twoSidedLighting;
  17249. twoSidedLighting: boolean;
  17250. /**
  17251. * Default configuration related to image processing available in the standard Material.
  17252. */
  17253. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17254. /**
  17255. * Gets the image processing configuration used either in this material.
  17256. */
  17257. /**
  17258. * Sets the Default image processing configuration used either in the this material.
  17259. *
  17260. * If sets to null, the scene one is in use.
  17261. */
  17262. imageProcessingConfiguration: ImageProcessingConfiguration;
  17263. /**
  17264. * Keep track of the image processing observer to allow dispose and replace.
  17265. */
  17266. private _imageProcessingObserver;
  17267. /**
  17268. * Attaches a new image processing configuration to the Standard Material.
  17269. * @param configuration
  17270. */
  17271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17272. /**
  17273. * Gets wether the color curves effect is enabled.
  17274. */
  17275. /**
  17276. * Sets wether the color curves effect is enabled.
  17277. */
  17278. cameraColorCurvesEnabled: boolean;
  17279. /**
  17280. * Gets wether the color grading effect is enabled.
  17281. */
  17282. /**
  17283. * Gets wether the color grading effect is enabled.
  17284. */
  17285. cameraColorGradingEnabled: boolean;
  17286. /**
  17287. * Gets wether tonemapping is enabled or not.
  17288. */
  17289. /**
  17290. * Sets wether tonemapping is enabled or not
  17291. */
  17292. cameraToneMappingEnabled: boolean;
  17293. /**
  17294. * The camera exposure used on this material.
  17295. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17296. * This corresponds to a photographic exposure.
  17297. */
  17298. /**
  17299. * The camera exposure used on this material.
  17300. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17301. * This corresponds to a photographic exposure.
  17302. */
  17303. cameraExposure: number;
  17304. /**
  17305. * Gets The camera contrast used on this material.
  17306. */
  17307. /**
  17308. * Sets The camera contrast used on this material.
  17309. */
  17310. cameraContrast: number;
  17311. /**
  17312. * Gets the Color Grading 2D Lookup Texture.
  17313. */
  17314. /**
  17315. * Sets the Color Grading 2D Lookup Texture.
  17316. */
  17317. cameraColorGradingTexture: Nullable<BaseTexture>;
  17318. /**
  17319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17321. * 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;
  17322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17323. */
  17324. /**
  17325. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17326. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17327. * 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;
  17328. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17329. */
  17330. cameraColorCurves: Nullable<ColorCurves>;
  17331. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  17332. protected _renderTargets: SmartArray<RenderTargetTexture>;
  17333. protected _worldViewProjectionMatrix: Matrix;
  17334. protected _globalAmbientColor: Color3;
  17335. protected _useLogarithmicDepth: boolean;
  17336. constructor(name: string, scene: Scene);
  17337. getClassName(): string;
  17338. useLogarithmicDepth: boolean;
  17339. needAlphaBlending(): boolean;
  17340. needAlphaTesting(): boolean;
  17341. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  17342. getAlphaTestTexture(): Nullable<BaseTexture>;
  17343. /**
  17344. * Child classes can use it to update shaders
  17345. */
  17346. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17347. buildUniformLayout(): void;
  17348. unbind(): void;
  17349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17350. getAnimatables(): IAnimatable[];
  17351. getActiveTextures(): BaseTexture[];
  17352. hasTexture(texture: BaseTexture): boolean;
  17353. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17354. clone(name: string): StandardMaterial;
  17355. serialize(): any;
  17356. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  17357. static _DiffuseTextureEnabled: boolean;
  17358. static DiffuseTextureEnabled: boolean;
  17359. static _AmbientTextureEnabled: boolean;
  17360. static AmbientTextureEnabled: boolean;
  17361. static _OpacityTextureEnabled: boolean;
  17362. static OpacityTextureEnabled: boolean;
  17363. static _ReflectionTextureEnabled: boolean;
  17364. static ReflectionTextureEnabled: boolean;
  17365. static _EmissiveTextureEnabled: boolean;
  17366. static EmissiveTextureEnabled: boolean;
  17367. static _SpecularTextureEnabled: boolean;
  17368. static SpecularTextureEnabled: boolean;
  17369. static _BumpTextureEnabled: boolean;
  17370. static BumpTextureEnabled: boolean;
  17371. static _LightmapTextureEnabled: boolean;
  17372. static LightmapTextureEnabled: boolean;
  17373. static _RefractionTextureEnabled: boolean;
  17374. static RefractionTextureEnabled: boolean;
  17375. static _ColorGradingTextureEnabled: boolean;
  17376. static ColorGradingTextureEnabled: boolean;
  17377. static _FresnelEnabled: boolean;
  17378. static FresnelEnabled: boolean;
  17379. }
  17380. }
  17381. declare module BABYLON {
  17382. class UniformBuffer {
  17383. private _engine;
  17384. private _buffer;
  17385. private _data;
  17386. private _bufferData;
  17387. private _dynamic?;
  17388. private _uniformLocations;
  17389. private _uniformSizes;
  17390. private _uniformLocationPointer;
  17391. private _needSync;
  17392. private _noUBO;
  17393. private _currentEffect;
  17394. private static _MAX_UNIFORM_SIZE;
  17395. private static _tempBuffer;
  17396. /**
  17397. * Wrapper for updateUniform.
  17398. * @method updateMatrix3x3
  17399. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17400. * @param {Float32Array} matrix
  17401. */
  17402. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  17403. /**
  17404. * Wrapper for updateUniform.
  17405. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17406. * @param {Float32Array} matrix
  17407. */
  17408. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  17409. /**
  17410. * Wrapper for updateUniform.
  17411. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17412. * @param {number} x
  17413. */
  17414. updateFloat: (name: string, x: number) => void;
  17415. /**
  17416. * Wrapper for updateUniform.
  17417. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17418. * @param {number} x
  17419. * @param {number} y
  17420. * @param {string} [suffix] Suffix to add to the uniform name.
  17421. */
  17422. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  17423. /**
  17424. * Wrapper for updateUniform.
  17425. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17426. * @param {number} x
  17427. * @param {number} y
  17428. * @param {number} z
  17429. * @param {string} [suffix] Suffix to add to the uniform name.
  17430. */
  17431. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  17432. /**
  17433. * Wrapper for updateUniform.
  17434. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17435. * @param {number} x
  17436. * @param {number} y
  17437. * @param {number} z
  17438. * @param {number} w
  17439. * @param {string} [suffix] Suffix to add to the uniform name.
  17440. */
  17441. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  17442. /**
  17443. * Wrapper for updateUniform.
  17444. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17445. * @param {Matrix} A 4x4 matrix.
  17446. */
  17447. updateMatrix: (name: string, mat: Matrix) => void;
  17448. /**
  17449. * Wrapper for updateUniform.
  17450. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17451. * @param {Vector3} vector
  17452. */
  17453. updateVector3: (name: string, vector: Vector3) => void;
  17454. /**
  17455. * Wrapper for updateUniform.
  17456. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17457. * @param {Vector4} vector
  17458. */
  17459. updateVector4: (name: string, vector: Vector4) => void;
  17460. /**
  17461. * Wrapper for updateUniform.
  17462. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17463. * @param {Color3} color
  17464. * @param {string} [suffix] Suffix to add to the uniform name.
  17465. */
  17466. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  17467. /**
  17468. * Wrapper for updateUniform.
  17469. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17470. * @param {Color3} color
  17471. * @param {number} alpha
  17472. * @param {string} [suffix] Suffix to add to the uniform name.
  17473. */
  17474. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  17475. /**
  17476. * Uniform buffer objects.
  17477. *
  17478. * Handles blocks of uniform on the GPU.
  17479. *
  17480. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  17481. *
  17482. * For more information, please refer to :
  17483. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  17484. */
  17485. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  17486. /**
  17487. * Indicates if the buffer is using the WebGL2 UBO implementation,
  17488. * or just falling back on setUniformXXX calls.
  17489. */
  17490. readonly useUbo: boolean;
  17491. /**
  17492. * Indicates if the WebGL underlying uniform buffer is in sync
  17493. * with the javascript cache data.
  17494. */
  17495. readonly isSync: boolean;
  17496. /**
  17497. * Indicates if the WebGL underlying uniform buffer is dynamic.
  17498. * Also, a dynamic UniformBuffer will disable cache verification and always
  17499. * update the underlying WebGL uniform buffer to the GPU.
  17500. */
  17501. isDynamic(): boolean;
  17502. /**
  17503. * The data cache on JS side.
  17504. */
  17505. getData(): Float32Array;
  17506. /**
  17507. * The underlying WebGL Uniform buffer.
  17508. */
  17509. getBuffer(): Nullable<WebGLBuffer>;
  17510. /**
  17511. * std140 layout specifies how to align data within an UBO structure.
  17512. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  17513. * for specs.
  17514. */
  17515. private _fillAlignment(size);
  17516. /**
  17517. * Adds an uniform in the buffer.
  17518. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  17519. * for the layout to be correct !
  17520. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17521. * @param {number|number[]} size Data size, or data directly.
  17522. */
  17523. addUniform(name: string, size: number | number[]): void;
  17524. /**
  17525. * Wrapper for addUniform.
  17526. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17527. * @param {Matrix} mat A 4x4 matrix.
  17528. */
  17529. addMatrix(name: string, mat: Matrix): void;
  17530. /**
  17531. * Wrapper for addUniform.
  17532. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17533. * @param {number} x
  17534. * @param {number} y
  17535. */
  17536. addFloat2(name: string, x: number, y: number): void;
  17537. /**
  17538. * Wrapper for addUniform.
  17539. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17540. * @param {number} x
  17541. * @param {number} y
  17542. * @param {number} z
  17543. */
  17544. addFloat3(name: string, x: number, y: number, z: number): void;
  17545. /**
  17546. * Wrapper for addUniform.
  17547. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17548. * @param {Color3} color
  17549. */
  17550. addColor3(name: string, color: Color3): void;
  17551. /**
  17552. * Wrapper for addUniform.
  17553. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17554. * @param {Color3} color
  17555. * @param {number} alpha
  17556. */
  17557. addColor4(name: string, color: Color3, alpha: number): void;
  17558. /**
  17559. * Wrapper for addUniform.
  17560. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17561. * @param {Vector3} vector
  17562. */
  17563. addVector3(name: string, vector: Vector3): void;
  17564. /**
  17565. * Wrapper for addUniform.
  17566. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17567. */
  17568. addMatrix3x3(name: string): void;
  17569. /**
  17570. * Wrapper for addUniform.
  17571. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17572. */
  17573. addMatrix2x2(name: string): void;
  17574. /**
  17575. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  17576. */
  17577. create(): void;
  17578. _rebuild(): void;
  17579. /**
  17580. * Updates the WebGL Uniform Buffer on the GPU.
  17581. * If the `dynamic` flag is set to true, no cache comparison is done.
  17582. * Otherwise, the buffer will be updated only if the cache differs.
  17583. */
  17584. update(): void;
  17585. /**
  17586. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  17587. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17588. * @param {number[]|Float32Array} data Flattened data
  17589. * @param {number} size Size of the data.
  17590. */
  17591. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  17592. private _updateMatrix3x3ForUniform(name, matrix);
  17593. private _updateMatrix3x3ForEffect(name, matrix);
  17594. private _updateMatrix2x2ForEffect(name, matrix);
  17595. private _updateMatrix2x2ForUniform(name, matrix);
  17596. private _updateFloatForEffect(name, x);
  17597. private _updateFloatForUniform(name, x);
  17598. private _updateFloat2ForEffect(name, x, y, suffix?);
  17599. private _updateFloat2ForUniform(name, x, y, suffix?);
  17600. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  17601. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  17602. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  17603. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  17604. private _updateMatrixForEffect(name, mat);
  17605. private _updateMatrixForUniform(name, mat);
  17606. private _updateVector3ForEffect(name, vector);
  17607. private _updateVector3ForUniform(name, vector);
  17608. private _updateVector4ForEffect(name, vector);
  17609. private _updateVector4ForUniform(name, vector);
  17610. private _updateColor3ForEffect(name, color, suffix?);
  17611. private _updateColor3ForUniform(name, color, suffix?);
  17612. private _updateColor4ForEffect(name, color, alpha, suffix?);
  17613. private _updateColor4ForUniform(name, color, alpha, suffix?);
  17614. /**
  17615. * Sets a sampler uniform on the effect.
  17616. * @param {string} name Name of the sampler.
  17617. * @param {Texture} texture
  17618. */
  17619. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  17620. /**
  17621. * Directly updates the value of the uniform in the cache AND on the GPU.
  17622. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17623. * @param {number[]|Float32Array} data Flattened data
  17624. */
  17625. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  17626. /**
  17627. * Binds this uniform buffer to an effect.
  17628. * @param {Effect} effect
  17629. * @param {string} name Name of the uniform block in the shader.
  17630. */
  17631. bindToEffect(effect: Effect, name: string): void;
  17632. /**
  17633. * Disposes the uniform buffer.
  17634. */
  17635. dispose(): void;
  17636. }
  17637. }
  17638. declare module BABYLON {
  17639. /**
  17640. * Defines a target to use with MorphTargetManager
  17641. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17642. */
  17643. class MorphTarget implements IAnimatable {
  17644. /** defines the name of the target */
  17645. name: string;
  17646. /**
  17647. * Gets or sets the list of animations
  17648. */
  17649. animations: Animation[];
  17650. private _positions;
  17651. private _normals;
  17652. private _tangents;
  17653. private _influence;
  17654. /**
  17655. * Observable raised when the influence changes
  17656. */
  17657. onInfluenceChanged: Observable<boolean>;
  17658. /**
  17659. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  17660. */
  17661. influence: number;
  17662. /**
  17663. * Creates a new MorphTarget
  17664. * @param name defines the name of the target
  17665. * @param influence defines the influence to use
  17666. */
  17667. constructor(
  17668. /** defines the name of the target */
  17669. name: string, influence?: number);
  17670. /**
  17671. * Gets a boolean defining if the target contains position data
  17672. */
  17673. readonly hasPositions: boolean;
  17674. /**
  17675. * Gets a boolean defining if the target contains normal data
  17676. */
  17677. readonly hasNormals: boolean;
  17678. /**
  17679. * Gets a boolean defining if the target contains tangent data
  17680. */
  17681. readonly hasTangents: boolean;
  17682. /**
  17683. * Affects position data to this target
  17684. * @param data defines the position data to use
  17685. */
  17686. setPositions(data: Nullable<FloatArray>): void;
  17687. /**
  17688. * Gets the position data stored in this target
  17689. * @returns a FloatArray containing the position data (or null if not present)
  17690. */
  17691. getPositions(): Nullable<FloatArray>;
  17692. /**
  17693. * Affects normal data to this target
  17694. * @param data defines the normal data to use
  17695. */
  17696. setNormals(data: Nullable<FloatArray>): void;
  17697. /**
  17698. * Gets the normal data stored in this target
  17699. * @returns a FloatArray containing the normal data (or null if not present)
  17700. */
  17701. getNormals(): Nullable<FloatArray>;
  17702. /**
  17703. * Affects tangent data to this target
  17704. * @param data defines the tangent data to use
  17705. */
  17706. setTangents(data: Nullable<FloatArray>): void;
  17707. /**
  17708. * Gets the tangent data stored in this target
  17709. * @returns a FloatArray containing the tangent data (or null if not present)
  17710. */
  17711. getTangents(): Nullable<FloatArray>;
  17712. /**
  17713. * Serializes the current target into a Serialization object
  17714. * @returns the serialized object
  17715. */
  17716. serialize(): any;
  17717. /**
  17718. * Creates a new target from serialized data
  17719. * @param serializationObject defines the serialized data to use
  17720. * @returns a new MorphTarget
  17721. */
  17722. static Parse(serializationObject: any): MorphTarget;
  17723. /**
  17724. * Creates a MorphTarget from mesh data
  17725. * @param mesh defines the source mesh
  17726. * @param name defines the name to use for the new target
  17727. * @param influence defines the influence to attach to the target
  17728. * @returns a new MorphTarget
  17729. */
  17730. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17731. }
  17732. }
  17733. declare module BABYLON {
  17734. /**
  17735. * This class is used to deform meshes using morphing between different targets
  17736. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17737. */
  17738. class MorphTargetManager {
  17739. private _targets;
  17740. private _targetObservable;
  17741. private _activeTargets;
  17742. private _scene;
  17743. private _influences;
  17744. private _supportsNormals;
  17745. private _supportsTangents;
  17746. private _vertexCount;
  17747. private _uniqueId;
  17748. private _tempInfluences;
  17749. /**
  17750. * Creates a new MorphTargetManager
  17751. * @param scene defines the current scene
  17752. */
  17753. constructor(scene?: Nullable<Scene>);
  17754. /**
  17755. * Gets the unique ID of this manager
  17756. */
  17757. readonly uniqueId: number;
  17758. /**
  17759. * Gets the number of vertices handled by this manager
  17760. */
  17761. readonly vertexCount: number;
  17762. /**
  17763. * Gets a boolean indicating if this manager supports morphing of normals
  17764. */
  17765. readonly supportsNormals: boolean;
  17766. /**
  17767. * Gets a boolean indicating if this manager supports morphing of tangents
  17768. */
  17769. readonly supportsTangents: boolean;
  17770. /**
  17771. * Gets the number of targets stored in this manager
  17772. */
  17773. readonly numTargets: number;
  17774. /**
  17775. * Gets the number of influencers (ie. the number of targets with influences > 0)
  17776. */
  17777. readonly numInfluencers: number;
  17778. /**
  17779. * Gets the list of influences (one per target)
  17780. */
  17781. readonly influences: Float32Array;
  17782. /**
  17783. * Gets the active target at specified index. An active target is a target with an influence > 0
  17784. * @param index defines the index to check
  17785. * @returns the requested target
  17786. */
  17787. getActiveTarget(index: number): MorphTarget;
  17788. /**
  17789. * Gets the target at specified index
  17790. * @param index defines the index to check
  17791. * @returns the requested target
  17792. */
  17793. getTarget(index: number): MorphTarget;
  17794. /**
  17795. * Add a new target to this manager
  17796. * @param target defines the target to add
  17797. */
  17798. addTarget(target: MorphTarget): void;
  17799. /**
  17800. * Removes a target from the manager
  17801. * @param target defines the target to remove
  17802. */
  17803. removeTarget(target: MorphTarget): void;
  17804. /**
  17805. * Serializes the current manager into a Serialization object
  17806. * @returns the serialized object
  17807. */
  17808. serialize(): any;
  17809. private _syncActiveTargets(needUpdate);
  17810. /**
  17811. * Syncrhonize the targets with all the meshes using this morph target manager
  17812. */
  17813. synchronize(): void;
  17814. /**
  17815. * Creates a new MorphTargetManager from serialized data
  17816. * @param serializationObject defines the serialized data
  17817. * @param scene defines the hosting scene
  17818. * @returns the new MorphTargetManager
  17819. */
  17820. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17821. }
  17822. }
  17823. declare module BABYLON {
  17824. /**
  17825. * This represents a GPU particle system in Babylon
  17826. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  17827. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  17828. */
  17829. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  17830. /**
  17831. * The id of the Particle system.
  17832. */
  17833. id: string;
  17834. /**
  17835. * The friendly name of the Particle system.
  17836. */
  17837. name: string;
  17838. /**
  17839. * The emitter represents the Mesh or position we are attaching the particle system to.
  17840. */
  17841. emitter: Nullable<AbstractMesh | Vector3>;
  17842. /**
  17843. * The rendering group used by the Particle system to chose when to render.
  17844. */
  17845. renderingGroupId: number;
  17846. /**
  17847. * The layer mask we are rendering the particles through.
  17848. */
  17849. layerMask: number;
  17850. private _capacity;
  17851. private _activeCount;
  17852. private _currentActiveCount;
  17853. private _renderEffect;
  17854. private _updateEffect;
  17855. private _buffer0;
  17856. private _buffer1;
  17857. private _spriteBuffer;
  17858. private _updateVAO;
  17859. private _renderVAO;
  17860. private _targetIndex;
  17861. private _sourceBuffer;
  17862. private _targetBuffer;
  17863. private _scene;
  17864. private _engine;
  17865. private _currentRenderId;
  17866. private _started;
  17867. private _stopped;
  17868. private _timeDelta;
  17869. private _randomTexture;
  17870. private readonly _attributesStrideSize;
  17871. private _updateEffectOptions;
  17872. private _randomTextureSize;
  17873. private _actualFrame;
  17874. /**
  17875. * List of animations used by the particle system.
  17876. */
  17877. animations: Animation[];
  17878. /**
  17879. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  17880. */
  17881. static readonly IsSupported: boolean;
  17882. /**
  17883. * An event triggered when the system is disposed.
  17884. */
  17885. onDisposeObservable: Observable<GPUParticleSystem>;
  17886. /**
  17887. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17888. */
  17889. updateSpeed: number;
  17890. /**
  17891. * The amount of time the particle system is running (depends of the overall update speed).
  17892. */
  17893. targetStopDuration: number;
  17894. /**
  17895. * The texture used to render each particle. (this can be a spritesheet)
  17896. */
  17897. particleTexture: Nullable<Texture>;
  17898. /**
  17899. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17900. */
  17901. blendMode: number;
  17902. /**
  17903. * Minimum life time of emitting particles.
  17904. */
  17905. minLifeTime: number;
  17906. /**
  17907. * Maximum life time of emitting particles.
  17908. */
  17909. maxLifeTime: number;
  17910. /**
  17911. * Minimum Size of emitting particles.
  17912. */
  17913. minSize: number;
  17914. /**
  17915. * Maximum Size of emitting particles.
  17916. */
  17917. maxSize: number;
  17918. /**
  17919. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17920. */
  17921. color1: Color4;
  17922. /**
  17923. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17924. */
  17925. color2: Color4;
  17926. /**
  17927. * Color the particle will have at the end of its lifetime.
  17928. */
  17929. colorDead: Color4;
  17930. /**
  17931. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17932. */
  17933. emitRate: number;
  17934. /**
  17935. * You can use gravity if you want to give an orientation to your particles.
  17936. */
  17937. gravity: Vector3;
  17938. /**
  17939. * Minimum power of emitting particles.
  17940. */
  17941. minEmitPower: number;
  17942. /**
  17943. * Maximum power of emitting particles.
  17944. */
  17945. maxEmitPower: number;
  17946. /**
  17947. * The particle emitter type defines the emitter used by the particle system.
  17948. * It can be for example box, sphere, or cone...
  17949. */
  17950. particleEmitterType: Nullable<IParticleEmitterType>;
  17951. /**
  17952. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17953. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17954. */
  17955. direction1: Vector3;
  17956. /**
  17957. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17958. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17959. */
  17960. direction2: Vector3;
  17961. /**
  17962. * 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.
  17963. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17964. */
  17965. minEmitBox: Vector3;
  17966. /**
  17967. * 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.
  17968. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17969. */
  17970. maxEmitBox: Vector3;
  17971. /**
  17972. * Gets the maximum number of particles active at the same time.
  17973. * @returns The max number of active particles.
  17974. */
  17975. getCapacity(): number;
  17976. /**
  17977. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17978. * to override the particles.
  17979. */
  17980. forceDepthWrite: boolean;
  17981. /**
  17982. * Gets or set the number of active particles
  17983. */
  17984. activeParticleCount: number;
  17985. /**
  17986. * Is this system ready to be used/rendered
  17987. * @return true if the system is ready
  17988. */
  17989. isReady(): boolean;
  17990. /**
  17991. * Gets Wether the system has been started.
  17992. * @returns True if it has been started, otherwise false.
  17993. */
  17994. isStarted(): boolean;
  17995. /**
  17996. * Starts the particle system and begins to emit.
  17997. */
  17998. start(): void;
  17999. /**
  18000. * Stops the particle system.
  18001. */
  18002. stop(): void;
  18003. /**
  18004. * Remove all active particles
  18005. */
  18006. reset(): void;
  18007. /**
  18008. * Returns the string "GPUParticleSystem"
  18009. * @returns a string containing the class name
  18010. */
  18011. getClassName(): string;
  18012. /**
  18013. * Instantiates a GPU particle system.
  18014. * 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.
  18015. * @param name The name of the particle system
  18016. * @param capacity The max number of particles alive at the same time
  18017. * @param scene The scene the particle system belongs to
  18018. */
  18019. constructor(name: string, options: Partial<{
  18020. capacity: number;
  18021. randomTextureSize: number;
  18022. }>, scene: Scene);
  18023. private _createUpdateVAO(source);
  18024. private _createRenderVAO(source, spriteSource);
  18025. private _initialize(force?);
  18026. /** @hidden */
  18027. _recreateUpdateEffect(): void;
  18028. /** @hidden */
  18029. _recreateRenderEffect(): void;
  18030. /**
  18031. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18032. */
  18033. animate(): void;
  18034. /**
  18035. * Renders the particle system in its current state.
  18036. * @returns the current number of particles
  18037. */
  18038. render(): number;
  18039. /**
  18040. * Rebuilds the particle system
  18041. */
  18042. rebuild(): void;
  18043. private _releaseBuffers();
  18044. private _releaseVAOs();
  18045. /**
  18046. * Disposes the particle system and free the associated resources
  18047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18048. */
  18049. dispose(disposeTexture?: boolean): void;
  18050. /**
  18051. * Clones the particle system.
  18052. * @param name The name of the cloned object
  18053. * @param newEmitter The new emitter to use
  18054. * @returns the cloned particle system
  18055. */
  18056. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  18057. /**
  18058. * Serializes the particle system to a JSON object.
  18059. * @returns the JSON object
  18060. */
  18061. serialize(): any;
  18062. /**
  18063. * Parses a JSON object to create a GPU particle system.
  18064. * @param parsedParticleSystem The JSON object to parse
  18065. * @param scene The scene to create the particle system in
  18066. * @param rootUrl The root url to use to load external dependencies like texture
  18067. * @returns the parsed GPU particle system
  18068. */
  18069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  18070. }
  18071. }
  18072. declare module BABYLON {
  18073. /**
  18074. * Interface representing a particle system in Babylon.
  18075. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18076. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18077. */
  18078. interface IParticleSystem {
  18079. /**
  18080. * The id of the Particle system.
  18081. */
  18082. id: string;
  18083. /**
  18084. * The name of the Particle system.
  18085. */
  18086. name: string;
  18087. /**
  18088. * The emitter represents the Mesh or position we are attaching the particle system to.
  18089. */
  18090. emitter: Nullable<AbstractMesh | Vector3>;
  18091. /**
  18092. * The rendering group used by the Particle system to chose when to render.
  18093. */
  18094. renderingGroupId: number;
  18095. /**
  18096. * The layer mask we are rendering the particles through.
  18097. */
  18098. layerMask: number;
  18099. /**
  18100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18101. */
  18102. updateSpeed: number;
  18103. /**
  18104. * The amount of time the particle system is running (depends of the overall update speed).
  18105. */
  18106. targetStopDuration: number;
  18107. /**
  18108. * The texture used to render each particle. (this can be a spritesheet)
  18109. */
  18110. particleTexture: Nullable<Texture>;
  18111. /**
  18112. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18113. */
  18114. blendMode: number;
  18115. /**
  18116. * Minimum life time of emitting particles.
  18117. */
  18118. minLifeTime: number;
  18119. /**
  18120. * Maximum life time of emitting particles.
  18121. */
  18122. maxLifeTime: number;
  18123. /**
  18124. * Minimum Size of emitting particles.
  18125. */
  18126. minSize: number;
  18127. /**
  18128. * Maximum Size of emitting particles.
  18129. */
  18130. maxSize: number;
  18131. /**
  18132. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18133. */
  18134. color1: Color4;
  18135. /**
  18136. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18137. */
  18138. color2: Color4;
  18139. /**
  18140. * Color the particle will have at the end of its lifetime.
  18141. */
  18142. colorDead: Color4;
  18143. /**
  18144. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18145. */
  18146. emitRate: number;
  18147. /**
  18148. * You can use gravity if you want to give an orientation to your particles.
  18149. */
  18150. gravity: Vector3;
  18151. /**
  18152. * Minimum power of emitting particles.
  18153. */
  18154. minEmitPower: number;
  18155. /**
  18156. * Maximum power of emitting particles.
  18157. */
  18158. maxEmitPower: number;
  18159. /**
  18160. * The particle emitter type defines the emitter used by the particle system.
  18161. * It can be for example box, sphere, or cone...
  18162. */
  18163. particleEmitterType: Nullable<IParticleEmitterType>;
  18164. /**
  18165. * Gets the maximum number of particles active at the same time.
  18166. * @returns The max number of active particles.
  18167. */
  18168. getCapacity(): number;
  18169. /**
  18170. * Gets Wether the system has been started.
  18171. * @returns True if it has been started, otherwise false.
  18172. */
  18173. isStarted(): boolean;
  18174. /**
  18175. * Gets if the particle system has been started.
  18176. * @return true if the system has been started, otherwise false.
  18177. */
  18178. isStarted(): boolean;
  18179. /**
  18180. * Animates the particle system for this frame.
  18181. */
  18182. animate(): void;
  18183. /**
  18184. * Renders the particle system in its current state.
  18185. * @returns the current number of particles
  18186. */
  18187. render(): number;
  18188. /**
  18189. * Dispose the particle system and frees its associated resources.
  18190. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18191. */
  18192. dispose(disposeTexture?: boolean): void;
  18193. /**
  18194. * Clones the particle system.
  18195. * @param name The name of the cloned object
  18196. * @param newEmitter The new emitter to use
  18197. * @returns the cloned particle system
  18198. */
  18199. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18200. /**
  18201. * Serializes the particle system to a JSON object.
  18202. * @returns the JSON object
  18203. */
  18204. serialize(): any;
  18205. /**
  18206. * Rebuild the particle system
  18207. */
  18208. rebuild(): void;
  18209. /**
  18210. * Starts the particle system and begins to emit.
  18211. */
  18212. start(): void;
  18213. /**
  18214. * Stops the particle system.
  18215. */
  18216. stop(): void;
  18217. /**
  18218. * Remove all active particles
  18219. */
  18220. reset(): void;
  18221. /**
  18222. * Is this system ready to be used/rendered
  18223. * @return true if the system is ready
  18224. */
  18225. isReady(): boolean;
  18226. }
  18227. }
  18228. declare module BABYLON {
  18229. /**
  18230. * A particle represents one of the element emitted by a particle system.
  18231. * This is mainly define by its coordinates, direction, velocity and age.
  18232. */
  18233. class Particle {
  18234. /**
  18235. * particleSystem the particle system the particle belongs to.
  18236. */
  18237. particleSystem: ParticleSystem;
  18238. /**
  18239. * The world position of the particle in the scene.
  18240. */
  18241. position: Vector3;
  18242. /**
  18243. * The world direction of the particle in the scene.
  18244. */
  18245. direction: Vector3;
  18246. /**
  18247. * The color of the particle.
  18248. */
  18249. color: Color4;
  18250. /**
  18251. * The color change of the particle per step.
  18252. */
  18253. colorStep: Color4;
  18254. /**
  18255. * Defines how long will the life of the particle be.
  18256. */
  18257. lifeTime: number;
  18258. /**
  18259. * The current age of the particle.
  18260. */
  18261. age: number;
  18262. /**
  18263. * The current size of the particle.
  18264. */
  18265. size: number;
  18266. /**
  18267. * The current angle of the particle.
  18268. */
  18269. angle: number;
  18270. /**
  18271. * Defines how fast is the angle changing.
  18272. */
  18273. angularSpeed: number;
  18274. /**
  18275. * Defines the cell index used by the particle to be rendered from a sprite.
  18276. */
  18277. cellIndex: number;
  18278. private _currentFrameCounter;
  18279. /**
  18280. * Creates a new instance Particle
  18281. * @param particleSystem the particle system the particle belongs to
  18282. */
  18283. constructor(
  18284. /**
  18285. * particleSystem the particle system the particle belongs to.
  18286. */
  18287. particleSystem: ParticleSystem);
  18288. private updateCellInfoFromSystem();
  18289. /**
  18290. * Defines how the sprite cell index is updated for the particle. This is
  18291. * defined as a callback.
  18292. */
  18293. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18294. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18295. private _updateCellIndexWithCustomSpeed();
  18296. /**
  18297. * Copy the properties of particle to another one.
  18298. * @param other the particle to copy the information to.
  18299. */
  18300. copyTo(other: Particle): void;
  18301. }
  18302. }
  18303. declare module BABYLON {
  18304. /**
  18305. * This represents a particle system in Babylon.
  18306. * 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.
  18307. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18308. * @example https://doc.babylonjs.com/babylon101/particles
  18309. */
  18310. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18311. /**
  18312. * Source color is added to the destination color without alpha affecting the result.
  18313. */
  18314. static BLENDMODE_ONEONE: number;
  18315. /**
  18316. * Blend current color and particle color using particle’s alpha.
  18317. */
  18318. static BLENDMODE_STANDARD: number;
  18319. /**
  18320. * List of animations used by the particle system.
  18321. */
  18322. animations: Animation[];
  18323. /**
  18324. * The id of the Particle system.
  18325. */
  18326. id: string;
  18327. /**
  18328. * The friendly name of the Particle system.
  18329. */
  18330. name: string;
  18331. /**
  18332. * The rendering group used by the Particle system to chose when to render.
  18333. */
  18334. renderingGroupId: number;
  18335. /**
  18336. * The emitter represents the Mesh or position we are attaching the particle system to.
  18337. */
  18338. emitter: Nullable<AbstractMesh | Vector3>;
  18339. /**
  18340. * The maximum number of particles to emit per frame
  18341. */
  18342. emitRate: number;
  18343. /**
  18344. * If you want to launch only a few particles at once, that can be done, as well.
  18345. */
  18346. manualEmitCount: number;
  18347. /**
  18348. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18349. */
  18350. updateSpeed: number;
  18351. /**
  18352. * The amount of time the particle system is running (depends of the overall update speed).
  18353. */
  18354. targetStopDuration: number;
  18355. /**
  18356. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18357. */
  18358. disposeOnStop: boolean;
  18359. /**
  18360. * Minimum power of emitting particles.
  18361. */
  18362. minEmitPower: number;
  18363. /**
  18364. * Maximum power of emitting particles.
  18365. */
  18366. maxEmitPower: number;
  18367. /**
  18368. * Minimum life time of emitting particles.
  18369. */
  18370. minLifeTime: number;
  18371. /**
  18372. * Maximum life time of emitting particles.
  18373. */
  18374. maxLifeTime: number;
  18375. /**
  18376. * Minimum Size of emitting particles.
  18377. */
  18378. minSize: number;
  18379. /**
  18380. * Maximum Size of emitting particles.
  18381. */
  18382. maxSize: number;
  18383. /**
  18384. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18385. */
  18386. minAngularSpeed: number;
  18387. /**
  18388. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18389. */
  18390. maxAngularSpeed: number;
  18391. /**
  18392. * The texture used to render each particle. (this can be a spritesheet)
  18393. */
  18394. particleTexture: Nullable<Texture>;
  18395. /**
  18396. * The layer mask we are rendering the particles through.
  18397. */
  18398. layerMask: number;
  18399. /**
  18400. * This can help using your own shader to render the particle system.
  18401. * The according effect will be created
  18402. */
  18403. customShader: any;
  18404. /**
  18405. * By default particle system starts as soon as they are created. This prevents the
  18406. * automatic start to happen and let you decide when to start emitting particles.
  18407. */
  18408. preventAutoStart: boolean;
  18409. /**
  18410. * This function can be defined to provide custom update for active particles.
  18411. * This function will be called instead of regular update (age, position, color, etc.).
  18412. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18413. */
  18414. updateFunction: (particles: Particle[]) => void;
  18415. /**
  18416. * Callback triggered when the particle animation is ending.
  18417. */
  18418. onAnimationEnd: Nullable<() => void>;
  18419. /**
  18420. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18421. */
  18422. blendMode: number;
  18423. /**
  18424. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18425. * to override the particles.
  18426. */
  18427. forceDepthWrite: boolean;
  18428. /**
  18429. * You can use gravity if you want to give an orientation to your particles.
  18430. */
  18431. gravity: Vector3;
  18432. /**
  18433. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18434. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18435. */
  18436. direction1: Vector3;
  18437. /**
  18438. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18439. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18440. */
  18441. direction2: Vector3;
  18442. /**
  18443. * 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.
  18444. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18445. */
  18446. minEmitBox: Vector3;
  18447. /**
  18448. * 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.
  18449. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18450. */
  18451. maxEmitBox: Vector3;
  18452. /**
  18453. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18454. */
  18455. color1: Color4;
  18456. /**
  18457. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18458. */
  18459. color2: Color4;
  18460. /**
  18461. * Color the particle will have at the end of its lifetime.
  18462. */
  18463. colorDead: Color4;
  18464. /**
  18465. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  18466. */
  18467. textureMask: Color4;
  18468. /**
  18469. * The particle emitter type defines the emitter used by the particle system.
  18470. * It can be for example box, sphere, or cone...
  18471. */
  18472. particleEmitterType: IParticleEmitterType;
  18473. /**
  18474. * This function can be defined to specify initial direction for every new particle.
  18475. * It by default use the emitterType defined function.
  18476. */
  18477. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  18478. /**
  18479. * This function can be defined to specify initial position for every new particle.
  18480. * It by default use the emitterType defined function.
  18481. */
  18482. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  18483. /**
  18484. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  18485. */
  18486. spriteCellLoop: boolean;
  18487. /**
  18488. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  18489. */
  18490. spriteCellChangeSpeed: number;
  18491. /**
  18492. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  18493. */
  18494. startSpriteCellID: number;
  18495. /**
  18496. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  18497. */
  18498. endSpriteCellID: number;
  18499. /**
  18500. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  18501. */
  18502. spriteCellWidth: number;
  18503. /**
  18504. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  18505. */
  18506. spriteCellHeight: number;
  18507. /**
  18508. * An event triggered when the system is disposed.
  18509. */
  18510. onDisposeObservable: Observable<ParticleSystem>;
  18511. private _onDisposeObserver;
  18512. /**
  18513. * Sets a callback that will be triggered when the system is disposed.
  18514. */
  18515. onDispose: () => void;
  18516. /**
  18517. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  18518. */
  18519. readonly isAnimationSheetEnabled: Boolean;
  18520. private _particles;
  18521. private _epsilon;
  18522. private _capacity;
  18523. private _scene;
  18524. private _stockParticles;
  18525. private _newPartsExcess;
  18526. private _vertexData;
  18527. private _vertexBuffer;
  18528. private _vertexBuffers;
  18529. private _indexBuffer;
  18530. private _effect;
  18531. private _customEffect;
  18532. private _cachedDefines;
  18533. private _scaledColorStep;
  18534. private _colorDiff;
  18535. private _scaledDirection;
  18536. private _scaledGravity;
  18537. private _currentRenderId;
  18538. private _alive;
  18539. private _started;
  18540. private _stopped;
  18541. private _actualFrame;
  18542. private _scaledUpdateSpeed;
  18543. private _vertexBufferSize;
  18544. private _isAnimationSheetEnabled;
  18545. /**
  18546. * 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.
  18547. */
  18548. subEmitters: ParticleSystem[];
  18549. /**
  18550. * The current active Sub-systems, this property is used by the root particle system only.
  18551. */
  18552. activeSubSystems: Array<ParticleSystem>;
  18553. private _rootParticleSystem;
  18554. /**
  18555. * Gets the current list of active particles
  18556. */
  18557. readonly particles: Particle[];
  18558. /**
  18559. * Returns the string "ParticleSystem"
  18560. * @returns a string containing the class name
  18561. */
  18562. getClassName(): string;
  18563. /**
  18564. * Instantiates a particle system.
  18565. * 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.
  18566. * @param name The name of the particle system
  18567. * @param capacity The max number of particles alive at the same time
  18568. * @param scene The scene the particle system belongs to
  18569. * @param customEffect a custom effect used to change the way particles are rendered by default
  18570. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18571. * @param epsilon Offset used to render the particles
  18572. */
  18573. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18574. private _createIndexBuffer();
  18575. /**
  18576. * Gets the maximum number of particles active at the same time.
  18577. * @returns The max number of active particles.
  18578. */
  18579. getCapacity(): number;
  18580. /**
  18581. * Gets Wether there are still active particles in the system.
  18582. * @returns True if it is alive, otherwise false.
  18583. */
  18584. isAlive(): boolean;
  18585. /**
  18586. * Gets Wether the system has been started.
  18587. * @returns True if it has been started, otherwise false.
  18588. */
  18589. isStarted(): boolean;
  18590. /**
  18591. * Starts the particle system and begins to emit.
  18592. */
  18593. start(): void;
  18594. /**
  18595. * Stops the particle system.
  18596. * @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.
  18597. */
  18598. stop(stopSubEmitters?: boolean): void;
  18599. /**
  18600. * Remove all active particles
  18601. */
  18602. reset(): void;
  18603. /**
  18604. * @hidden (for internal use only)
  18605. */
  18606. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18607. /**
  18608. * @hidden (for internal use only)
  18609. */
  18610. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18611. /**
  18612. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18613. * Its lifetime will start back at 0.
  18614. */
  18615. recycleParticle: (particle: Particle) => void;
  18616. private _stopSubEmitters();
  18617. private _createParticle;
  18618. private _removeFromRoot();
  18619. private _emitFromParticle;
  18620. private _update(newParticles);
  18621. private _getEffect();
  18622. /**
  18623. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18624. */
  18625. animate(): void;
  18626. private _appendParticleVertexes;
  18627. private _appenedParticleVertexesWithSheet(offset, particle);
  18628. private _appenedParticleVertexesNoSheet(offset, particle);
  18629. /**
  18630. * Rebuilds the particle system.
  18631. */
  18632. rebuild(): void;
  18633. /**
  18634. * Is this system ready to be used/rendered
  18635. * @return true if the system is ready
  18636. */
  18637. isReady(): boolean;
  18638. /**
  18639. * Renders the particle system in its current state.
  18640. * @returns the current number of particles
  18641. */
  18642. render(): number;
  18643. /**
  18644. * Disposes the particle system and free the associated resources
  18645. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18646. */
  18647. dispose(disposeTexture?: boolean): void;
  18648. /**
  18649. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  18650. * @param radius The radius of the sphere to emit from
  18651. * @returns the emitter
  18652. */
  18653. createSphereEmitter(radius?: number): SphereParticleEmitter;
  18654. /**
  18655. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  18656. * @param radius The radius of the sphere to emit from
  18657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18659. * @returns the emitter
  18660. */
  18661. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  18662. /**
  18663. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  18664. * @param radius The radius of the cone to emit from
  18665. * @param angle The base angle of the cone
  18666. * @returns the emitter
  18667. */
  18668. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  18669. /**
  18670. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18673. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18674. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18675. * @returns the emitter
  18676. */
  18677. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18678. /**
  18679. * Clones the particle system.
  18680. * @param name The name of the cloned object
  18681. * @param newEmitter The new emitter to use
  18682. * @returns the cloned particle system
  18683. */
  18684. clone(name: string, newEmitter: any): ParticleSystem;
  18685. /**
  18686. * Serializes the particle system to a JSON object.
  18687. * @returns the JSON object
  18688. */
  18689. serialize(): any;
  18690. /**
  18691. * Parses a JSON object to create a particle system.
  18692. * @param parsedParticleSystem The JSON object to parse
  18693. * @param scene The scene to create the particle system in
  18694. * @param rootUrl The root url to use to load external dependencies like texture
  18695. * @returns the Parsed particle system
  18696. */
  18697. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  18698. }
  18699. }
  18700. declare module BABYLON {
  18701. /**
  18702. * Represents one particle of a solid particle system.
  18703. */
  18704. class SolidParticle {
  18705. /**
  18706. * particle global index
  18707. */
  18708. idx: number;
  18709. /**
  18710. * The color of the particle
  18711. */
  18712. color: Nullable<Color4>;
  18713. /**
  18714. * The world space position of the particle.
  18715. */
  18716. position: Vector3;
  18717. /**
  18718. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  18719. */
  18720. rotation: Vector3;
  18721. /**
  18722. * The world space rotation quaternion of the particle.
  18723. */
  18724. rotationQuaternion: Nullable<Quaternion>;
  18725. /**
  18726. * The scaling of the particle.
  18727. */
  18728. scaling: Vector3;
  18729. /**
  18730. * The uvs of the particle.
  18731. */
  18732. uvs: Vector4;
  18733. /**
  18734. * The current speed of the particle.
  18735. */
  18736. velocity: Vector3;
  18737. /**
  18738. * The pivot point in the particle local space.
  18739. */
  18740. pivot: Vector3;
  18741. /**
  18742. * Must the particle be translated from its pivot point in its local space ?
  18743. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  18744. * Default : false
  18745. */
  18746. translateFromPivot: boolean;
  18747. /**
  18748. * Is the particle active or not ?
  18749. */
  18750. alive: boolean;
  18751. /**
  18752. * Is the particle visible or not ?
  18753. */
  18754. isVisible: boolean;
  18755. /**
  18756. * Index of this particle in the global "positions" array (Internal use)
  18757. */
  18758. _pos: number;
  18759. /**
  18760. * Index of this particle in the global "indices" array (Internal use)
  18761. */
  18762. _ind: number;
  18763. /**
  18764. * ModelShape of this particle (Internal use)
  18765. */
  18766. _model: ModelShape;
  18767. /**
  18768. * ModelShape id of this particle
  18769. */
  18770. shapeId: number;
  18771. /**
  18772. * Index of the particle in its shape id (Internal use)
  18773. */
  18774. idxInShape: number;
  18775. /**
  18776. * Reference to the shape model BoundingInfo object (Internal use)
  18777. */
  18778. _modelBoundingInfo: BoundingInfo;
  18779. /**
  18780. * Particle BoundingInfo object (Internal use)
  18781. */
  18782. _boundingInfo: BoundingInfo;
  18783. /**
  18784. * Reference to the SPS what the particle belongs to (Internal use)
  18785. */
  18786. _sps: SolidParticleSystem;
  18787. /**
  18788. * Still set as invisible in order to skip useless computations (Internal use)
  18789. */
  18790. _stillInvisible: boolean;
  18791. /**
  18792. * Last computed particle rotation matrix
  18793. */
  18794. _rotationMatrix: number[];
  18795. /**
  18796. * Parent particle Id, if any.
  18797. * Default null.
  18798. */
  18799. parentId: Nullable<number>;
  18800. /**
  18801. * Internal global position in the SPS.
  18802. */
  18803. _globalPosition: Vector3;
  18804. /**
  18805. * Creates a Solid Particle object.
  18806. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18807. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18808. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18809. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18810. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18811. * @param shapeId (integer) is the model shape identifier in the SPS.
  18812. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18813. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18814. */
  18815. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18816. /**
  18817. * Legacy support, changed scale to scaling
  18818. */
  18819. /**
  18820. * Legacy support, changed scale to scaling
  18821. */
  18822. scale: Vector3;
  18823. /**
  18824. * Legacy support, changed quaternion to rotationQuaternion
  18825. */
  18826. /**
  18827. * Legacy support, changed quaternion to rotationQuaternion
  18828. */
  18829. quaternion: Nullable<Quaternion>;
  18830. /**
  18831. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18832. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18833. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18834. * @returns true if it intersects
  18835. */
  18836. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18837. }
  18838. /**
  18839. * Represents the shape of the model used by one particle of a solid particle system.
  18840. * SPS internal tool, don't use it manually.
  18841. */
  18842. class ModelShape {
  18843. /**
  18844. * The shape id.
  18845. */
  18846. shapeID: number;
  18847. /**
  18848. * flat array of model positions (internal use)
  18849. */
  18850. _shape: Vector3[];
  18851. /**
  18852. * flat array of model UVs (internal use)
  18853. */
  18854. _shapeUV: number[];
  18855. /**
  18856. * length of the shape in the model indices array (internal use)
  18857. */
  18858. _indicesLength: number;
  18859. /**
  18860. * Custom position function (internal use)
  18861. */
  18862. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  18863. /**
  18864. * Custom vertex function (internal use)
  18865. */
  18866. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  18867. /**
  18868. * 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.
  18869. * SPS internal tool, don't use it manually.
  18870. * @hidden
  18871. */
  18872. 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>);
  18873. }
  18874. /**
  18875. * Represents a Depth Sorted Particle in the solid particle system.
  18876. */
  18877. class DepthSortedParticle {
  18878. /**
  18879. * Index of the particle in the "indices" array
  18880. */
  18881. ind: number;
  18882. /**
  18883. * Length of the particle shape in the "indices" array
  18884. */
  18885. indicesLength: number;
  18886. /**
  18887. * Squared distance from the particle to the camera
  18888. */
  18889. sqDistance: number;
  18890. }
  18891. }
  18892. declare module BABYLON {
  18893. /**
  18894. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18895. *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.
  18896. * The SPS is also a particle system. It provides some methods to manage the particles.
  18897. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18898. *
  18899. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18900. */
  18901. class SolidParticleSystem implements IDisposable {
  18902. /**
  18903. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18904. * Example : var p = SPS.particles[i];
  18905. */
  18906. particles: SolidParticle[];
  18907. /**
  18908. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18909. */
  18910. nbParticles: number;
  18911. /**
  18912. * If the particles must ever face the camera (default false). Useful for planar particles.
  18913. */
  18914. billboard: boolean;
  18915. /**
  18916. * Recompute normals when adding a shape
  18917. */
  18918. recomputeNormals: boolean;
  18919. /**
  18920. * This a counter ofr your own usage. It's not set by any SPS functions.
  18921. */
  18922. counter: number;
  18923. /**
  18924. * The SPS name. This name is also given to the underlying mesh.
  18925. */
  18926. name: string;
  18927. /**
  18928. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18929. */
  18930. mesh: Mesh;
  18931. /**
  18932. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18933. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18934. */
  18935. vars: any;
  18936. /**
  18937. * This array is populated when the SPS is set as 'pickable'.
  18938. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18939. * Each element of this array is an object `{idx: int, faceId: int}`.
  18940. * `idx` is the picked particle index in the `SPS.particles` array
  18941. * `faceId` is the picked face index counted within this particle.
  18942. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18943. */
  18944. pickedParticles: {
  18945. idx: number;
  18946. faceId: number;
  18947. }[];
  18948. /**
  18949. * This array is populated when `enableDepthSort` is set to true.
  18950. * Each element of this array is an instance of the class DepthSortedParticle.
  18951. */
  18952. depthSortedParticles: DepthSortedParticle[];
  18953. /**
  18954. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  18955. */
  18956. _bSphereOnly: boolean;
  18957. /**
  18958. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  18959. */
  18960. _bSphereRadiusFactor: number;
  18961. private _scene;
  18962. private _positions;
  18963. private _indices;
  18964. private _normals;
  18965. private _colors;
  18966. private _uvs;
  18967. private _indices32;
  18968. private _positions32;
  18969. private _normals32;
  18970. private _fixedNormal32;
  18971. private _colors32;
  18972. private _uvs32;
  18973. private _index;
  18974. private _updatable;
  18975. private _pickable;
  18976. private _isVisibilityBoxLocked;
  18977. private _alwaysVisible;
  18978. private _depthSort;
  18979. private _shapeCounter;
  18980. private _copy;
  18981. private _shape;
  18982. private _shapeUV;
  18983. private _color;
  18984. private _computeParticleColor;
  18985. private _computeParticleTexture;
  18986. private _computeParticleRotation;
  18987. private _computeParticleVertex;
  18988. private _computeBoundingBox;
  18989. private _depthSortParticles;
  18990. private _cam_axisZ;
  18991. private _cam_axisY;
  18992. private _cam_axisX;
  18993. private _axisZ;
  18994. private _camera;
  18995. private _particle;
  18996. private _camDir;
  18997. private _camInvertedPosition;
  18998. private _rotMatrix;
  18999. private _invertMatrix;
  19000. private _rotated;
  19001. private _quaternion;
  19002. private _vertex;
  19003. private _normal;
  19004. private _yaw;
  19005. private _pitch;
  19006. private _roll;
  19007. private _halfroll;
  19008. private _halfpitch;
  19009. private _halfyaw;
  19010. private _sinRoll;
  19011. private _cosRoll;
  19012. private _sinPitch;
  19013. private _cosPitch;
  19014. private _sinYaw;
  19015. private _cosYaw;
  19016. private _mustUnrotateFixedNormals;
  19017. private _minimum;
  19018. private _maximum;
  19019. private _minBbox;
  19020. private _maxBbox;
  19021. private _particlesIntersect;
  19022. private _depthSortFunction;
  19023. private _needs32Bits;
  19024. private _pivotBackTranslation;
  19025. private _scaledPivot;
  19026. private _particleHasParent;
  19027. private _parent;
  19028. /**
  19029. * Creates a SPS (Solid Particle System) object.
  19030. * @param name (String) is the SPS name, this will be the underlying mesh name.
  19031. * @param scene (Scene) is the scene in which the SPS is added.
  19032. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  19033. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  19034. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  19035. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  19036. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  19037. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  19038. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  19039. */
  19040. constructor(name: string, scene: Scene, options?: {
  19041. updatable?: boolean;
  19042. isPickable?: boolean;
  19043. enableDepthSort?: boolean;
  19044. particleIntersection?: boolean;
  19045. boundingSphereOnly?: boolean;
  19046. bSphereRadiusFactor?: number;
  19047. });
  19048. /**
  19049. * Builds the SPS underlying mesh. Returns a standard Mesh.
  19050. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  19051. * @returns the created mesh
  19052. */
  19053. buildMesh(): Mesh;
  19054. /**
  19055. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  19056. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  19057. * Thus the particles generated from `digest()` have their property `position` set yet.
  19058. * @param mesh ( Mesh ) is the mesh to be digested
  19059. * @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
  19060. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  19061. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  19062. * @returns the current SPS
  19063. */
  19064. digest(mesh: Mesh, options?: {
  19065. facetNb?: number;
  19066. number?: number;
  19067. delta?: number;
  19068. }): SolidParticleSystem;
  19069. private _unrotateFixedNormals();
  19070. private _resetCopy();
  19071. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  19072. private _posToShape(positions);
  19073. private _uvsToShapeUV(uvs);
  19074. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  19075. /**
  19076. * Adds some particles to the SPS from the model shape. Returns the shape id.
  19077. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  19078. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  19079. * @param nb (positive integer) the number of particles to be created from this model
  19080. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  19081. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  19082. * @returns the number of shapes in the system
  19083. */
  19084. addShape(mesh: Mesh, nb: number, options?: {
  19085. positionFunction?: any;
  19086. vertexFunction?: any;
  19087. }): number;
  19088. private _rebuildParticle(particle);
  19089. /**
  19090. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  19091. * @returns the SPS.
  19092. */
  19093. rebuildMesh(): SolidParticleSystem;
  19094. /**
  19095. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  19096. * This method calls `updateParticle()` for each particle of the SPS.
  19097. * For an animated SPS, it is usually called within the render loop.
  19098. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  19099. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  19100. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  19101. * @returns the SPS.
  19102. */
  19103. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  19104. private _quaternionRotationYPR();
  19105. private _quaternionToRotationMatrix();
  19106. /**
  19107. * Disposes the SPS.
  19108. */
  19109. dispose(): void;
  19110. /**
  19111. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  19112. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19113. * @returns the SPS.
  19114. */
  19115. refreshVisibleSize(): SolidParticleSystem;
  19116. /**
  19117. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  19118. * @param size the size (float) of the visibility box
  19119. * note : this doesn't lock the SPS mesh bounding box.
  19120. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19121. */
  19122. setVisibilityBox(size: number): void;
  19123. /**
  19124. * Gets whether the SPS as always visible or not
  19125. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19126. */
  19127. /**
  19128. * Sets the SPS as always visible or not
  19129. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19130. */
  19131. isAlwaysVisible: boolean;
  19132. /**
  19133. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19134. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19135. */
  19136. /**
  19137. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19138. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19139. */
  19140. isVisibilityBoxLocked: boolean;
  19141. /**
  19142. * Gets if `setParticles()` computes the particle rotations or not.
  19143. * Default value : true. The SPS is faster when it's set to false.
  19144. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19145. */
  19146. /**
  19147. * Tells to `setParticles()` to compute the particle rotations or not.
  19148. * Default value : true. The SPS is faster when it's set to false.
  19149. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19150. */
  19151. computeParticleRotation: boolean;
  19152. /**
  19153. * Gets if `setParticles()` computes the particle colors or not.
  19154. * Default value : true. The SPS is faster when it's set to false.
  19155. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19156. */
  19157. /**
  19158. * Tells to `setParticles()` to compute the particle colors or not.
  19159. * Default value : true. The SPS is faster when it's set to false.
  19160. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19161. */
  19162. computeParticleColor: boolean;
  19163. /**
  19164. * Gets if `setParticles()` computes the particle textures or not.
  19165. * Default value : true. The SPS is faster when it's set to false.
  19166. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19167. */
  19168. computeParticleTexture: boolean;
  19169. /**
  19170. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19171. * Default value : false. The SPS is faster when it's set to false.
  19172. * Note : the particle custom vertex positions aren't stored values.
  19173. */
  19174. /**
  19175. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19176. * Default value : false. The SPS is faster when it's set to false.
  19177. * Note : the particle custom vertex positions aren't stored values.
  19178. */
  19179. computeParticleVertex: boolean;
  19180. /**
  19181. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19182. */
  19183. /**
  19184. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19185. */
  19186. computeBoundingBox: boolean;
  19187. /**
  19188. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19189. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19190. * Default : `true`
  19191. */
  19192. /**
  19193. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19194. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19195. * Default : `true`
  19196. */
  19197. depthSortParticles: boolean;
  19198. /**
  19199. * This function does nothing. It may be overwritten to set all the particle first values.
  19200. * The SPS doesn't call this function, you may have to call it by your own.
  19201. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19202. */
  19203. initParticles(): void;
  19204. /**
  19205. * This function does nothing. It may be overwritten to recycle a particle.
  19206. * The SPS doesn't call this function, you may have to call it by your own.
  19207. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19208. * @param particle The particle to recycle
  19209. * @returns the recycled particle
  19210. */
  19211. recycleParticle(particle: SolidParticle): SolidParticle;
  19212. /**
  19213. * Updates a particle : this function should be overwritten by the user.
  19214. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19215. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19216. * @example : just set a particle position or velocity and recycle conditions
  19217. * @param particle The particle to update
  19218. * @returns the updated particle
  19219. */
  19220. updateParticle(particle: SolidParticle): SolidParticle;
  19221. /**
  19222. * Updates a vertex of a particle : it can be overwritten by the user.
  19223. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19224. * @param particle the current particle
  19225. * @param vertex the current index of the current particle
  19226. * @param pt the index of the current vertex in the particle shape
  19227. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19228. * @example : just set a vertex particle position
  19229. * @returns the updated vertex
  19230. */
  19231. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19232. /**
  19233. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19234. * This does nothing and may be overwritten by the user.
  19235. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19236. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19237. * @param update the boolean update value actually passed to setParticles()
  19238. */
  19239. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19240. /**
  19241. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19242. * This will be passed three parameters.
  19243. * This does nothing and may be overwritten by the user.
  19244. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19245. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19246. * @param update the boolean update value actually passed to setParticles()
  19247. */
  19248. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19249. }
  19250. }
  19251. declare module BABYLON {
  19252. /**
  19253. * Class used to store all common mesh properties
  19254. */
  19255. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19256. /** No occlusion */
  19257. static OCCLUSION_TYPE_NONE: number;
  19258. /** Occlusion set to optimisitic */
  19259. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19260. /** Occlusion set to strict */
  19261. static OCCLUSION_TYPE_STRICT: number;
  19262. /** Use an accurante occlusion algorithm */
  19263. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19264. /** Use a conservative occlusion algorithm */
  19265. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19266. /**
  19267. * No billboard
  19268. */
  19269. static readonly BILLBOARDMODE_NONE: number;
  19270. /** Billboard on X axis */
  19271. static readonly BILLBOARDMODE_X: number;
  19272. /** Billboard on Y axis */
  19273. static readonly BILLBOARDMODE_Y: number;
  19274. /** Billboard on Z axis */
  19275. static readonly BILLBOARDMODE_Z: number;
  19276. /** Billboard on all axes */
  19277. static readonly BILLBOARDMODE_ALL: number;
  19278. private _facetPositions;
  19279. private _facetNormals;
  19280. private _facetPartitioning;
  19281. private _facetNb;
  19282. private _partitioningSubdivisions;
  19283. private _partitioningBBoxRatio;
  19284. private _facetDataEnabled;
  19285. private _facetParameters;
  19286. private _bbSize;
  19287. private _subDiv;
  19288. private _facetDepthSort;
  19289. private _facetDepthSortEnabled;
  19290. private _depthSortedIndices;
  19291. private _depthSortedFacets;
  19292. private _facetDepthSortFunction;
  19293. private _facetDepthSortFrom;
  19294. private _facetDepthSortOrigin;
  19295. private _invertedMatrix;
  19296. /**
  19297. * Gets the number of facets in the mesh
  19298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19299. */
  19300. readonly facetNb: number;
  19301. /**
  19302. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19304. */
  19305. partitioningSubdivisions: number;
  19306. /**
  19307. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19308. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19310. */
  19311. partitioningBBoxRatio: number;
  19312. /**
  19313. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19314. * Works only for updatable meshes.
  19315. * Doesn't work with multi-materials
  19316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19317. */
  19318. mustDepthSortFacets: boolean;
  19319. /**
  19320. * The location (Vector3) where the facet depth sort must be computed from.
  19321. * By default, the active camera position.
  19322. * Used only when facet depth sort is enabled
  19323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19324. */
  19325. facetDepthSortFrom: Vector3;
  19326. /**
  19327. * gets a boolean indicating if facetData is enabled
  19328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19329. */
  19330. readonly isFacetDataEnabled: boolean;
  19331. /** @hidden */
  19332. _updateNonUniformScalingState(value: boolean): boolean;
  19333. /**
  19334. * An event triggered when this mesh collides with another one
  19335. */
  19336. onCollideObservable: Observable<AbstractMesh>;
  19337. private _onCollideObserver;
  19338. /** Set a function to call when this mesh collides with another one */
  19339. onCollide: () => void;
  19340. /**
  19341. * An event triggered when the collision's position changes
  19342. */
  19343. onCollisionPositionChangeObservable: Observable<Vector3>;
  19344. private _onCollisionPositionChangeObserver;
  19345. /** Set a function to call when the collision's position changes */
  19346. onCollisionPositionChange: () => void;
  19347. /**
  19348. * An event triggered when material is changed
  19349. */
  19350. onMaterialChangedObservable: Observable<AbstractMesh>;
  19351. /**
  19352. * Gets or sets the orientation for POV movement & rotation
  19353. */
  19354. definedFacingForward: boolean;
  19355. /**
  19356. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19357. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19358. * * 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.
  19359. * @see http://doc.babylonjs.com/features/occlusionquery
  19360. */
  19361. occlusionQueryAlgorithmType: number;
  19362. /**
  19363. * 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:
  19364. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19365. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19366. * * 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.
  19367. * @see http://doc.babylonjs.com/features/occlusionquery
  19368. */
  19369. occlusionType: number;
  19370. /**
  19371. * 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.
  19372. * The default value is -1 which means don't break the query and wait till the result
  19373. * @see http://doc.babylonjs.com/features/occlusionquery
  19374. */
  19375. occlusionRetryCount: number;
  19376. private _occlusionInternalRetryCounter;
  19377. protected _isOccluded: boolean;
  19378. /**
  19379. * 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
  19380. * @see http://doc.babylonjs.com/features/occlusionquery
  19381. */
  19382. isOccluded: boolean;
  19383. private _isOcclusionQueryInProgress;
  19384. /**
  19385. * Flag to check the progress status of the query
  19386. * @see http://doc.babylonjs.com/features/occlusionquery
  19387. */
  19388. readonly isOcclusionQueryInProgress: boolean;
  19389. private _occlusionQuery;
  19390. private _visibility;
  19391. /**
  19392. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19393. */
  19394. /**
  19395. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19396. */
  19397. visibility: number;
  19398. /** Gets or sets the alpha index used to sort transparent meshes
  19399. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19400. */
  19401. alphaIndex: number;
  19402. /**
  19403. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19404. */
  19405. isVisible: boolean;
  19406. /**
  19407. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19408. */
  19409. isPickable: boolean;
  19410. /**
  19411. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  19412. */
  19413. showBoundingBox: boolean;
  19414. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19415. showSubMeshesBoundingBox: boolean;
  19416. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19417. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19418. */
  19419. isBlocker: boolean;
  19420. /**
  19421. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19422. */
  19423. enablePointerMoveEvents: boolean;
  19424. /**
  19425. * Specifies the rendering group id for this mesh (0 by default)
  19426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19427. */
  19428. renderingGroupId: number;
  19429. private _material;
  19430. /** Gets or sets current material */
  19431. material: Nullable<Material>;
  19432. private _receiveShadows;
  19433. /**
  19434. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19435. * @see http://doc.babylonjs.com/babylon101/shadows
  19436. */
  19437. receiveShadows: boolean;
  19438. /**
  19439. * Gets or sets a boolean indicating if the outline must be rendered as well
  19440. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19441. */
  19442. renderOutline: boolean;
  19443. /** Defines color to use when rendering outline */
  19444. outlineColor: Color3;
  19445. /** Define width to use when rendering outline */
  19446. outlineWidth: number;
  19447. /**
  19448. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19449. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19450. */
  19451. renderOverlay: boolean;
  19452. /** Defines color to use when rendering overlay */
  19453. overlayColor: Color3;
  19454. /** Defines alpha to use when rendering overlay */
  19455. overlayAlpha: number;
  19456. private _hasVertexAlpha;
  19457. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19458. hasVertexAlpha: boolean;
  19459. private _useVertexColors;
  19460. /** 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) */
  19461. useVertexColors: boolean;
  19462. private _computeBonesUsingShaders;
  19463. /**
  19464. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19465. */
  19466. computeBonesUsingShaders: boolean;
  19467. private _numBoneInfluencers;
  19468. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19469. numBoneInfluencers: number;
  19470. private _applyFog;
  19471. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19472. applyFog: boolean;
  19473. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19474. useOctreeForRenderingSelection: boolean;
  19475. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19476. useOctreeForPicking: boolean;
  19477. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19478. useOctreeForCollisions: boolean;
  19479. private _layerMask;
  19480. /**
  19481. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19482. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19483. */
  19484. layerMask: number;
  19485. /**
  19486. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19487. */
  19488. alwaysSelectAsActiveMesh: boolean;
  19489. /**
  19490. * Gets or sets the current action manager
  19491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19492. */
  19493. actionManager: Nullable<ActionManager>;
  19494. /**
  19495. * Gets or sets impostor used for physic simulation
  19496. * @see http://doc.babylonjs.com/features/physics_engine
  19497. */
  19498. physicsImpostor: Nullable<PhysicsImpostor>;
  19499. private _checkCollisions;
  19500. private _collisionMask;
  19501. private _collisionGroup;
  19502. /**
  19503. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19505. */
  19506. ellipsoid: Vector3;
  19507. /**
  19508. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19509. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19510. */
  19511. ellipsoidOffset: Vector3;
  19512. private _collider;
  19513. private _oldPositionForCollisions;
  19514. private _diffPositionForCollisions;
  19515. /**
  19516. * Gets or sets a collision mask used to mask collisions (default is -1).
  19517. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19518. */
  19519. collisionMask: number;
  19520. /**
  19521. * Gets or sets the current collision group mask (-1 by default).
  19522. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19523. */
  19524. collisionGroup: number;
  19525. /**
  19526. * Defines edge width used when edgesRenderer is enabled
  19527. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19528. */
  19529. edgesWidth: number;
  19530. /**
  19531. * Defines edge color used when edgesRenderer is enabled
  19532. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19533. */
  19534. edgesColor: Color4;
  19535. /** @hidden */
  19536. _edgesRenderer: Nullable<EdgesRenderer>;
  19537. private _collisionsTransformMatrix;
  19538. private _collisionsScalingMatrix;
  19539. /** @hidden */
  19540. _masterMesh: Nullable<AbstractMesh>;
  19541. /** @hidden */
  19542. _boundingInfo: Nullable<BoundingInfo>;
  19543. /** @hidden */
  19544. _renderId: number;
  19545. /**
  19546. * Gets or sets the list of subMeshes
  19547. * @see http://doc.babylonjs.com/how_to/multi_materials
  19548. */
  19549. subMeshes: SubMesh[];
  19550. /** @hidden */
  19551. _submeshesOctree: Octree<SubMesh>;
  19552. /** @hidden */
  19553. _intersectionsInProgress: AbstractMesh[];
  19554. /** @hidden */
  19555. _unIndexed: boolean;
  19556. /** @hidden */
  19557. _lightSources: Light[];
  19558. /** @hidden */
  19559. readonly _positions: Nullable<Vector3[]>;
  19560. /** @hidden */
  19561. _waitingActions: any;
  19562. /** @hidden */
  19563. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19564. private _skeleton;
  19565. /** @hidden */
  19566. _bonesTransformMatrices: Nullable<Float32Array>;
  19567. /**
  19568. * Gets or sets a skeleton to apply skining transformations
  19569. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19570. */
  19571. skeleton: Nullable<Skeleton>;
  19572. /**
  19573. * Creates a new AbstractMesh
  19574. * @param name defines the name of the mesh
  19575. * @param scene defines the hosting scene
  19576. */
  19577. constructor(name: string, scene?: Nullable<Scene>);
  19578. /**
  19579. * Returns the string "AbstractMesh"
  19580. * @returns "AbstractMesh"
  19581. */
  19582. getClassName(): string;
  19583. /**
  19584. * Gets a string representation of the current mesh
  19585. * @param fullDetails defines a boolean indicating if full details must be included
  19586. * @returns a string representation of the current mesh
  19587. */
  19588. toString(fullDetails?: boolean): string;
  19589. /** @hidden */
  19590. _rebuild(): void;
  19591. /** @hidden */
  19592. _resyncLightSources(): void;
  19593. /** @hidden */
  19594. _resyncLighSource(light: Light): void;
  19595. /** @hidden */
  19596. _unBindEffect(): void;
  19597. /** @hidden */
  19598. _removeLightSource(light: Light): void;
  19599. private _markSubMeshesAsDirty(func);
  19600. /** @hidden */
  19601. _markSubMeshesAsLightDirty(): void;
  19602. /** @hidden */
  19603. _markSubMeshesAsAttributesDirty(): void;
  19604. /** @hidden */
  19605. _markSubMeshesAsMiscDirty(): void;
  19606. /**
  19607. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19608. */
  19609. scaling: Vector3;
  19610. /**
  19611. * Disables the mesh edge rendering mode
  19612. * @returns the currentAbstractMesh
  19613. */
  19614. disableEdgesRendering(): AbstractMesh;
  19615. /**
  19616. * Enables the edge rendering mode on the mesh.
  19617. * This mode makes the mesh edges visible
  19618. * @param epsilon defines the maximal distance between two angles to detect a face
  19619. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19620. * @returns the currentAbstractMesh
  19621. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19622. */
  19623. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19624. /**
  19625. * Returns true if the mesh is blocked. Implemented by child classes
  19626. */
  19627. readonly isBlocked: boolean;
  19628. /**
  19629. * Returns the mesh itself by default. Implemented by child classes
  19630. * @param camera defines the camera to use to pick the right LOD level
  19631. * @returns the currentAbstractMesh
  19632. */
  19633. getLOD(camera: Camera): AbstractMesh;
  19634. /**
  19635. * Returns 0 by default. Implemented by child classes
  19636. * @returns an integer
  19637. */
  19638. getTotalVertices(): number;
  19639. /**
  19640. * Returns null by default. Implemented by child classes
  19641. * @returns null
  19642. */
  19643. getIndices(): Nullable<IndicesArray>;
  19644. /**
  19645. * Returns the array of the requested vertex data kind. Implemented by child classes
  19646. * @param kind defines the vertex data kind to use
  19647. * @returns null
  19648. */
  19649. getVerticesData(kind: string): Nullable<FloatArray>;
  19650. /**
  19651. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19652. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19653. * Note that a new underlying VertexBuffer object is created each call.
  19654. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19655. * @param kind defines vertex data kind:
  19656. * * BABYLON.VertexBuffer.PositionKind
  19657. * * BABYLON.VertexBuffer.UVKind
  19658. * * BABYLON.VertexBuffer.UV2Kind
  19659. * * BABYLON.VertexBuffer.UV3Kind
  19660. * * BABYLON.VertexBuffer.UV4Kind
  19661. * * BABYLON.VertexBuffer.UV5Kind
  19662. * * BABYLON.VertexBuffer.UV6Kind
  19663. * * BABYLON.VertexBuffer.ColorKind
  19664. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19665. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19666. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19667. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19668. * @param data defines the data source
  19669. * @param updatable defines if the data must be flagged as updatable (or static)
  19670. * @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
  19671. * @returns the current mesh
  19672. */
  19673. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19674. /**
  19675. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19676. * If the mesh has no geometry, it is simply returned as it is.
  19677. * @param kind defines vertex data kind:
  19678. * * BABYLON.VertexBuffer.PositionKind
  19679. * * BABYLON.VertexBuffer.UVKind
  19680. * * BABYLON.VertexBuffer.UV2Kind
  19681. * * BABYLON.VertexBuffer.UV3Kind
  19682. * * BABYLON.VertexBuffer.UV4Kind
  19683. * * BABYLON.VertexBuffer.UV5Kind
  19684. * * BABYLON.VertexBuffer.UV6Kind
  19685. * * BABYLON.VertexBuffer.ColorKind
  19686. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19687. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19688. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19689. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19690. * @param data defines the data source
  19691. * @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
  19692. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19693. * @returns the current mesh
  19694. */
  19695. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19696. /**
  19697. * Sets the mesh indices,
  19698. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19699. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19700. * @param totalVertices Defines the total number of vertices
  19701. * @returns the current mesh
  19702. */
  19703. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19704. /**
  19705. * Gets a boolean indicating if specific vertex data is present
  19706. * @param kind defines the vertex data kind to use
  19707. * @returns true is data kind is present
  19708. */
  19709. isVerticesDataPresent(kind: string): boolean;
  19710. /**
  19711. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19712. * @returns a BoundingInfo
  19713. */
  19714. getBoundingInfo(): BoundingInfo;
  19715. /**
  19716. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19717. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19718. * @returns the current mesh
  19719. */
  19720. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19721. /**
  19722. * Overwrite the current bounding info
  19723. * @param boundingInfo defines the new bounding info
  19724. * @returns the current mesh
  19725. */
  19726. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19727. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19728. readonly useBones: boolean;
  19729. /** @hidden */
  19730. _preActivate(): void;
  19731. /** @hidden */
  19732. _preActivateForIntermediateRendering(renderId: number): void;
  19733. /** @hidden */
  19734. _activate(renderId: number): void;
  19735. /**
  19736. * Gets the current world matrix
  19737. * @returns a Matrix
  19738. */
  19739. getWorldMatrix(): Matrix;
  19740. /** @hidden */
  19741. _getWorldMatrixDeterminant(): number;
  19742. /**
  19743. * Perform relative position change from the point of view of behind the front of the mesh.
  19744. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19745. * Supports definition of mesh facing forward or backward
  19746. * @param amountRight defines the distance on the right axis
  19747. * @param amountUp defines the distance on the up axis
  19748. * @param amountForward defines the distance on the forward axis
  19749. * @returns the current mesh
  19750. */
  19751. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19752. /**
  19753. * Calculate relative position change from the point of view of behind the front of the mesh.
  19754. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19755. * Supports definition of mesh facing forward or backward
  19756. * @param amountRight defines the distance on the right axis
  19757. * @param amountUp defines the distance on the up axis
  19758. * @param amountForward defines the distance on the forward axis
  19759. * @returns the new displacement vector
  19760. */
  19761. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19762. /**
  19763. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19764. * Supports definition of mesh facing forward or backward
  19765. * @param flipBack defines the flip
  19766. * @param twirlClockwise defines the twirl
  19767. * @param tiltRight defines the tilt
  19768. * @returns the current mesh
  19769. */
  19770. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19771. /**
  19772. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19773. * Supports definition of mesh facing forward or backward.
  19774. * @param flipBack defines the flip
  19775. * @param twirlClockwise defines the twirl
  19776. * @param tiltRight defines the tilt
  19777. * @returns the new rotation vector
  19778. */
  19779. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19780. /**
  19781. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19782. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19783. * @returns the new bounding vectors
  19784. */
  19785. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  19786. min: Vector3;
  19787. max: Vector3;
  19788. };
  19789. /** @hidden */
  19790. _updateBoundingInfo(): AbstractMesh;
  19791. /** @hidden */
  19792. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19793. /** @hidden */
  19794. protected _afterComputeWorldMatrix(): void;
  19795. /**
  19796. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19797. * A mesh is in the frustum if its bounding box intersects the frustum
  19798. * @param frustumPlanes defines the frustum to test
  19799. * @returns true if the mesh is in the frustum planes
  19800. */
  19801. isInFrustum(frustumPlanes: Plane[]): boolean;
  19802. /**
  19803. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19804. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19805. * @param frustumPlanes defines the frustum to test
  19806. * @returns true if the mesh is completely in the frustum planes
  19807. */
  19808. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19809. /**
  19810. * True if the mesh intersects another mesh or a SolidParticle object
  19811. * @param mesh defines a target mesh or SolidParticle to test
  19812. * @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)
  19813. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19814. * @returns true if there is an intersection
  19815. */
  19816. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19817. /**
  19818. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19819. * @param point defines the point to test
  19820. * @returns true if there is an intersection
  19821. */
  19822. intersectsPoint(point: Vector3): boolean;
  19823. /**
  19824. * Gets the current physics impostor
  19825. * @see http://doc.babylonjs.com/features/physics_engine
  19826. * @returns a physics impostor or null
  19827. */
  19828. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19829. /**
  19830. * Gets the position of the current mesh in camera space
  19831. * @param camera defines the camera to use
  19832. * @returns a position
  19833. */
  19834. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19835. /**
  19836. * Returns the distance from the mesh to the active camera
  19837. * @param camera defines the camera to use
  19838. * @returns the distance
  19839. */
  19840. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19841. /**
  19842. * Apply a physic impulse to the mesh
  19843. * @param force defines the force to apply
  19844. * @param contactPoint defines where to apply the force
  19845. * @returns the current mesh
  19846. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19847. */
  19848. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19849. /**
  19850. * Creates a physic joint between two meshes
  19851. * @param otherMesh defines the other mesh to use
  19852. * @param pivot1 defines the pivot to use on this mesh
  19853. * @param pivot2 defines the pivot to use on the other mesh
  19854. * @param options defines additional options (can be plugin dependent)
  19855. * @returns the current mesh
  19856. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19857. */
  19858. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19859. /**
  19860. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19861. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19862. */
  19863. checkCollisions: boolean;
  19864. /**
  19865. * Gets Collider object used to compute collisions (not physics)
  19866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19867. */
  19868. readonly collider: Collider;
  19869. /**
  19870. * Move the mesh using collision engine
  19871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19872. * @param displacement defines the requested displacement vector
  19873. * @returns the current mesh
  19874. */
  19875. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19876. private _onCollisionPositionChange;
  19877. /**
  19878. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19879. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19880. * @param maxCapacity defines the maximum size of each block (64 by default)
  19881. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19882. * @returns the new octree
  19883. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19885. */
  19886. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19887. /** @hidden */
  19888. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19889. /** @hidden */
  19890. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19891. /** @hidden */
  19892. _checkCollision(collider: Collider): AbstractMesh;
  19893. /** @hidden */
  19894. _generatePointsArray(): boolean;
  19895. /**
  19896. * Checks if the passed Ray intersects with the mesh
  19897. * @param ray defines the ray to use
  19898. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19899. * @returns the picking info
  19900. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19901. */
  19902. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19903. /**
  19904. * Clones the current mesh
  19905. * @param name defines the mesh name
  19906. * @param newParent defines the new mesh parent
  19907. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19908. * @returns the new mesh
  19909. */
  19910. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19911. /**
  19912. * Disposes all the submeshes of the current meshnp
  19913. * @returns the current mesh
  19914. */
  19915. releaseSubMeshes(): AbstractMesh;
  19916. /**
  19917. * Releases resources associated with this abstract mesh.
  19918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19920. */
  19921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19922. /**
  19923. * Adds the passed mesh as a child to the current mesh
  19924. * @param mesh defines the child mesh
  19925. * @returns the current mesh
  19926. */
  19927. addChild(mesh: AbstractMesh): AbstractMesh;
  19928. /**
  19929. * Removes the passed mesh from the current mesh children list
  19930. * @param mesh defines the child mesh
  19931. * @returns the current mesh
  19932. */
  19933. removeChild(mesh: AbstractMesh): AbstractMesh;
  19934. /** @hidden */
  19935. private _initFacetData();
  19936. /**
  19937. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19938. * This method can be called within the render loop.
  19939. * 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
  19940. * @returns the current mesh
  19941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19942. */
  19943. updateFacetData(): AbstractMesh;
  19944. /**
  19945. * Returns the facetLocalNormals array.
  19946. * The normals are expressed in the mesh local spac
  19947. * @returns an array of Vector3
  19948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19949. */
  19950. getFacetLocalNormals(): Vector3[];
  19951. /**
  19952. * Returns the facetLocalPositions array.
  19953. * The facet positions are expressed in the mesh local space
  19954. * @returns an array of Vector3
  19955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19956. */
  19957. getFacetLocalPositions(): Vector3[];
  19958. /**
  19959. * Returns the facetLocalPartioning array
  19960. * @returns an array of array of numbers
  19961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19962. */
  19963. getFacetLocalPartitioning(): number[][];
  19964. /**
  19965. * Returns the i-th facet position in the world system.
  19966. * This method allocates a new Vector3 per call
  19967. * @param i defines the facet index
  19968. * @returns a new Vector3
  19969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19970. */
  19971. getFacetPosition(i: number): Vector3;
  19972. /**
  19973. * Sets the reference Vector3 with the i-th facet position in the world system
  19974. * @param i defines the facet index
  19975. * @param ref defines the target vector
  19976. * @returns the current mesh
  19977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19978. */
  19979. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19980. /**
  19981. * Returns the i-th facet normal in the world system.
  19982. * This method allocates a new Vector3 per call
  19983. * @param i defines the facet index
  19984. * @returns a new Vector3
  19985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19986. */
  19987. getFacetNormal(i: number): Vector3;
  19988. /**
  19989. * Sets the reference Vector3 with the i-th facet normal in the world system
  19990. * @param i defines the facet index
  19991. * @param ref defines the target vector
  19992. * @returns the current mesh
  19993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19994. */
  19995. getFacetNormalToRef(i: number, ref: Vector3): this;
  19996. /**
  19997. * 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)
  19998. * @param x defines x coordinate
  19999. * @param y defines y coordinate
  20000. * @param z defines z coordinate
  20001. * @returns the array of facet indexes
  20002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20003. */
  20004. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20005. /**
  20006. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20007. * @param projected sets as the (x,y,z) world projection on the facet
  20008. * @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
  20009. * @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
  20010. * @param x defines x coordinate
  20011. * @param y defines y coordinate
  20012. * @param z defines z coordinate
  20013. * @returns the face index if found (or null instead)
  20014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20015. */
  20016. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20017. /**
  20018. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20019. * @param projected sets as the (x,y,z) local projection on the facet
  20020. * @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
  20021. * @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
  20022. * @param x defines x coordinate
  20023. * @param y defines y coordinate
  20024. * @param z defines z coordinate
  20025. * @returns the face index if found (or null instead)
  20026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20027. */
  20028. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20029. /**
  20030. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20031. * @returns the parameters
  20032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20033. */
  20034. getFacetDataParameters(): any;
  20035. /**
  20036. * Disables the feature FacetData and frees the related memory
  20037. * @returns the current mesh
  20038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20039. */
  20040. disableFacetData(): AbstractMesh;
  20041. /**
  20042. * Updates the AbstractMesh indices array
  20043. * @param indices defines the data source
  20044. * @returns the current mesh
  20045. */
  20046. updateIndices(indices: IndicesArray): AbstractMesh;
  20047. /**
  20048. * Creates new normals data for the mesh
  20049. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20050. * @returns the current mesh
  20051. */
  20052. createNormals(updatable: boolean): AbstractMesh;
  20053. /**
  20054. * Align the mesh with a normal
  20055. * @param normal defines the normal to use
  20056. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20057. * @returns the current mesh
  20058. */
  20059. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20060. /** @hidden */
  20061. protected _checkOcclusionQuery(): void;
  20062. }
  20063. }
  20064. declare module BABYLON {
  20065. class Buffer {
  20066. private _engine;
  20067. private _buffer;
  20068. private _data;
  20069. private _updatable;
  20070. private _instanced;
  20071. /**
  20072. * Gets the byte stride.
  20073. */
  20074. readonly byteStride: number;
  20075. /**
  20076. * Constructor
  20077. * @param engine the engine
  20078. * @param data the data to use for this buffer
  20079. * @param updatable whether the data is updatable
  20080. * @param stride the stride (optional)
  20081. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20082. * @param instanced whether the buffer is instanced (optional)
  20083. * @param useBytes set to true if the stride in in bytes (optional)
  20084. */
  20085. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20086. /**
  20087. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20088. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20089. * @param offset defines offset in the buffer (0 by default)
  20090. * @param size defines the size in floats of attributes (position is 3 for instance)
  20091. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20092. * @param instanced defines if the vertex buffer contains indexed data
  20093. * @param useBytes defines if the offset and stride are in bytes
  20094. * @returns the new vertex buffer
  20095. */
  20096. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20097. isUpdatable(): boolean;
  20098. getData(): Nullable<DataArray>;
  20099. getBuffer(): Nullable<WebGLBuffer>;
  20100. /**
  20101. * Gets the stride in float32 units (i.e. byte stride / 4).
  20102. * May not be an integer if the byte stride is not divisible by 4.
  20103. * DEPRECATED. Use byteStride instead.
  20104. * @returns the stride in float32 units
  20105. */
  20106. getStrideSize(): number;
  20107. create(data?: Nullable<DataArray>): void;
  20108. _rebuild(): void;
  20109. update(data: DataArray): void;
  20110. /**
  20111. * Updates the data directly.
  20112. * @param data the new data
  20113. * @param offset the new offset
  20114. * @param vertexCount the vertex count (optional)
  20115. * @param useBytes set to true if the offset is in bytes
  20116. */
  20117. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20118. dispose(): void;
  20119. }
  20120. }
  20121. declare module BABYLON {
  20122. class CSG {
  20123. private polygons;
  20124. matrix: Matrix;
  20125. position: Vector3;
  20126. rotation: Vector3;
  20127. rotationQuaternion: Nullable<Quaternion>;
  20128. scaling: Vector3;
  20129. static FromMesh(mesh: Mesh): CSG;
  20130. private static FromPolygons(polygons);
  20131. clone(): CSG;
  20132. union(csg: CSG): CSG;
  20133. unionInPlace(csg: CSG): void;
  20134. subtract(csg: CSG): CSG;
  20135. subtractInPlace(csg: CSG): void;
  20136. intersect(csg: CSG): CSG;
  20137. intersectInPlace(csg: CSG): void;
  20138. inverse(): CSG;
  20139. inverseInPlace(): void;
  20140. copyTransformAttributes(csg: CSG): CSG;
  20141. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20142. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20143. }
  20144. }
  20145. declare module BABYLON {
  20146. /**
  20147. * Class used to store geometry data (vertex buffers + index buffer)
  20148. */
  20149. class Geometry implements IGetSetVerticesData {
  20150. /**
  20151. * Gets or sets the unique ID of the geometry
  20152. */
  20153. id: string;
  20154. /**
  20155. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20156. */
  20157. delayLoadState: number;
  20158. /**
  20159. * Gets the file containing the data to load when running in delay load state
  20160. */
  20161. delayLoadingFile: Nullable<string>;
  20162. /**
  20163. * Callback called when the geometry is updated
  20164. */
  20165. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20166. private _scene;
  20167. private _engine;
  20168. private _meshes;
  20169. private _totalVertices;
  20170. private _indices;
  20171. private _vertexBuffers;
  20172. private _isDisposed;
  20173. private _extend;
  20174. private _boundingBias;
  20175. /** @hidden */
  20176. _delayInfo: Array<string>;
  20177. private _indexBuffer;
  20178. private _indexBufferIsUpdatable;
  20179. /** @hidden */
  20180. _boundingInfo: Nullable<BoundingInfo>;
  20181. /** @hidden */
  20182. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20183. /** @hidden */
  20184. _softwareSkinningRenderId: number;
  20185. private _vertexArrayObjects;
  20186. private _updatable;
  20187. /** @hidden */
  20188. _positions: Nullable<Vector3[]>;
  20189. /**
  20190. * 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
  20191. */
  20192. /**
  20193. * 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
  20194. */
  20195. boundingBias: Vector2;
  20196. /**
  20197. * Static function used to attach a new empty geometry to a mesh
  20198. * @param mesh defines the mesh to attach the geometry to
  20199. * @returns the new {BABYLON.Geometry}
  20200. */
  20201. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20202. /**
  20203. * Creates a new geometry
  20204. * @param id defines the unique ID
  20205. * @param scene defines the hosting scene
  20206. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20207. * @param updatable defines if geometry must be updatable (false by default)
  20208. * @param mesh defines the mesh that will be associated with the geometry
  20209. */
  20210. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20211. /**
  20212. * Gets the current extend of the geometry
  20213. */
  20214. readonly extend: {
  20215. minimum: Vector3;
  20216. maximum: Vector3;
  20217. };
  20218. /**
  20219. * Gets the hosting scene
  20220. * @returns the hosting {BABYLON.Scene}
  20221. */
  20222. getScene(): Scene;
  20223. /**
  20224. * Gets the hosting engine
  20225. * @returns the hosting {BABYLON.Engine}
  20226. */
  20227. getEngine(): Engine;
  20228. /**
  20229. * Defines if the geometry is ready to use
  20230. * @returns true if the geometry is ready to be used
  20231. */
  20232. isReady(): boolean;
  20233. /**
  20234. * Gets a value indicating that the geometry should not be serialized
  20235. */
  20236. readonly doNotSerialize: boolean;
  20237. /** @hidden */
  20238. _rebuild(): void;
  20239. /**
  20240. * Affects all gemetry data in one call
  20241. * @param vertexData defines the geometry data
  20242. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20243. */
  20244. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20245. /**
  20246. * Set specific vertex data
  20247. * @param kind defines the data kind (Position, normal, etc...)
  20248. * @param data defines the vertex data to use
  20249. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20250. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20251. */
  20252. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20253. /**
  20254. * Removes a specific vertex data
  20255. * @param kind defines the data kind (Position, normal, etc...)
  20256. */
  20257. removeVerticesData(kind: string): void;
  20258. /**
  20259. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20260. * @param buffer defines the vertex buffer to use
  20261. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20262. */
  20263. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20264. /**
  20265. * Update a specific vertex buffer
  20266. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20267. * It will do nothing if the buffer is not updatable
  20268. * @param kind defines the data kind (Position, normal, etc...)
  20269. * @param data defines the data to use
  20270. * @param offset defines the offset in the target buffer where to store the data
  20271. * @param useBytes set to true if the offset is in bytes
  20272. */
  20273. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20274. /**
  20275. * Update a specific vertex buffer
  20276. * This function will create a new buffer if the current one is not updatable
  20277. * @param kind defines the data kind (Position, normal, etc...)
  20278. * @param data defines the data to use
  20279. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20280. */
  20281. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20282. private _updateBoundingInfo(updateExtends, data);
  20283. /** @hidden */
  20284. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20285. /**
  20286. * Gets total number of vertices
  20287. * @returns the total number of vertices
  20288. */
  20289. getTotalVertices(): number;
  20290. /**
  20291. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20292. * @param kind defines the data kind (Position, normal, etc...)
  20293. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20295. * @returns a float array containing vertex data
  20296. */
  20297. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20298. /**
  20299. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20300. * @param kind defines the data kind (Position, normal, etc...)
  20301. * @returns true if the vertex buffer with the specified kind is updatable
  20302. */
  20303. isVertexBufferUpdatable(kind: string): boolean;
  20304. /**
  20305. * Gets a specific vertex buffer
  20306. * @param kind defines the data kind (Position, normal, etc...)
  20307. * @returns a {BABYLON.VertexBuffer}
  20308. */
  20309. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20310. /**
  20311. * Returns all vertex buffers
  20312. * @return an object holding all vertex buffers indexed by kind
  20313. */
  20314. getVertexBuffers(): Nullable<{
  20315. [key: string]: VertexBuffer;
  20316. }>;
  20317. /**
  20318. * Gets a boolean indicating if specific vertex buffer is present
  20319. * @param kind defines the data kind (Position, normal, etc...)
  20320. * @returns true if data is present
  20321. */
  20322. isVerticesDataPresent(kind: string): boolean;
  20323. /**
  20324. * Gets a list of all attached data kinds (Position, normal, etc...)
  20325. * @returns a list of string containing all kinds
  20326. */
  20327. getVerticesDataKinds(): string[];
  20328. /**
  20329. * Update index buffer
  20330. * @param indices defines the indices to store in the index buffer
  20331. * @param offset defines the offset in the target buffer where to store the data
  20332. */
  20333. updateIndices(indices: IndicesArray, offset?: number): void;
  20334. /**
  20335. * Creates a new index buffer
  20336. * @param indices defines the indices to store in the index buffer
  20337. * @param totalVertices defines the total number of vertices (could be null)
  20338. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20339. */
  20340. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20341. /**
  20342. * Return the total number of indices
  20343. * @returns the total number of indices
  20344. */
  20345. getTotalIndices(): number;
  20346. /**
  20347. * Gets the index buffer array
  20348. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20349. * @returns the index buffer array
  20350. */
  20351. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20352. /**
  20353. * Gets the index buffer
  20354. * @return the index buffer
  20355. */
  20356. getIndexBuffer(): Nullable<WebGLBuffer>;
  20357. /** @hidden */
  20358. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20359. /**
  20360. * Release the associated resources for a specific mesh
  20361. * @param mesh defines the source mesh
  20362. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20363. */
  20364. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20365. /**
  20366. * Apply current geometry to a given mesh
  20367. * @param mesh defines the mesh to apply geometry to
  20368. */
  20369. applyToMesh(mesh: Mesh): void;
  20370. private _updateExtend(data?);
  20371. private _applyToMesh(mesh);
  20372. private notifyUpdate(kind?);
  20373. /**
  20374. * Load the geometry if it was flagged as delay loaded
  20375. * @param scene defines the hosting scene
  20376. * @param onLoaded defines a callback called when the geometry is loaded
  20377. */
  20378. load(scene: Scene, onLoaded?: () => void): void;
  20379. private _queueLoad(scene, onLoaded?);
  20380. /**
  20381. * Invert the geometry to move from a right handed system to a left handed one.
  20382. */
  20383. toLeftHanded(): void;
  20384. /** @hidden */
  20385. _resetPointsArrayCache(): void;
  20386. /** @hidden */
  20387. _generatePointsArray(): boolean;
  20388. /**
  20389. * Gets a value indicating if the geometry is disposed
  20390. * @returns true if the geometry was disposed
  20391. */
  20392. isDisposed(): boolean;
  20393. private _disposeVertexArrayObjects();
  20394. /**
  20395. * Free all associated resources
  20396. */
  20397. dispose(): void;
  20398. /**
  20399. * Clone the current geometry into a new geometry
  20400. * @param id defines the unique ID of the new geometry
  20401. * @returns a new geometry object
  20402. */
  20403. copy(id: string): Geometry;
  20404. /**
  20405. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20406. * @return a JSON representation of the current geometry data (without the vertices data)
  20407. */
  20408. serialize(): any;
  20409. private toNumberArray(origin);
  20410. /**
  20411. * Serialize all vertices data into a JSON oject
  20412. * @returns a JSON representation of the current geometry data
  20413. */
  20414. serializeVerticeData(): any;
  20415. /**
  20416. * Extracts a clone of a mesh geometry
  20417. * @param mesh defines the source mesh
  20418. * @param id defines the unique ID of the new geometry object
  20419. * @returns the new geometry object
  20420. */
  20421. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20422. /**
  20423. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20424. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20425. * Be aware Math.random() could cause collisions, but:
  20426. * "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"
  20427. * @returns a string containing a new GUID
  20428. */
  20429. static RandomId(): string;
  20430. /** @hidden */
  20431. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20432. private static _CleanMatricesWeights(parsedGeometry, mesh);
  20433. /**
  20434. * Create a new geometry from persisted data (Using .babylon file format)
  20435. * @param parsedVertexData defines the persisted data
  20436. * @param scene defines the hosting scene
  20437. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20438. * @returns the new geometry object
  20439. */
  20440. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20441. }
  20442. /**
  20443. * Abstract class used to provide common services for all typed geometries
  20444. * @hidden
  20445. */
  20446. class _PrimitiveGeometry extends Geometry {
  20447. private _canBeRegenerated;
  20448. private _beingRegenerated;
  20449. /**
  20450. * Creates a new typed geometry
  20451. * @param id defines the unique ID of the geometry
  20452. * @param scene defines the hosting scene
  20453. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20454. * @param mesh defines the hosting mesh (can be null)
  20455. */
  20456. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20457. /**
  20458. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20459. * @returns true if the geometry can be regenerated
  20460. */
  20461. canBeRegenerated(): boolean;
  20462. /**
  20463. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20464. */
  20465. regenerate(): void;
  20466. /**
  20467. * Clone the geometry
  20468. * @param id defines the unique ID of the new geometry
  20469. * @returns the new geometry
  20470. */
  20471. asNewGeometry(id: string): Geometry;
  20472. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20473. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20474. /** @hidden */
  20475. _regenerateVertexData(): VertexData;
  20476. copy(id: string): Geometry;
  20477. serialize(): any;
  20478. }
  20479. /**
  20480. * Creates a ribbon geometry
  20481. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20482. */
  20483. class RibbonGeometry extends _PrimitiveGeometry {
  20484. /**
  20485. * Defines the array of paths to use
  20486. */
  20487. pathArray: Vector3[][];
  20488. /**
  20489. * Defines if the last and first points of each path in your pathArray must be joined
  20490. */
  20491. closeArray: boolean;
  20492. /**
  20493. * Defines if the last and first points of each path in your pathArray must be joined
  20494. */
  20495. closePath: boolean;
  20496. /**
  20497. * Defines the offset between points
  20498. */
  20499. offset: number;
  20500. /**
  20501. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20502. */
  20503. side: number;
  20504. /**
  20505. * Creates a ribbon geometry
  20506. * @param id defines the unique ID of the geometry
  20507. * @param scene defines the hosting scene
  20508. * @param pathArray defines the array of paths to use
  20509. * @param closeArray defines if the last path and the first path must be joined
  20510. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20511. * @param offset defines the offset between points
  20512. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20513. * @param mesh defines the hosting mesh (can be null)
  20514. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20515. */
  20516. constructor(id: string, scene: Scene,
  20517. /**
  20518. * Defines the array of paths to use
  20519. */
  20520. pathArray: Vector3[][],
  20521. /**
  20522. * Defines if the last and first points of each path in your pathArray must be joined
  20523. */
  20524. closeArray: boolean,
  20525. /**
  20526. * Defines if the last and first points of each path in your pathArray must be joined
  20527. */
  20528. closePath: boolean,
  20529. /**
  20530. * Defines the offset between points
  20531. */
  20532. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20533. /**
  20534. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20535. */
  20536. side?: number);
  20537. /** @hidden */
  20538. _regenerateVertexData(): VertexData;
  20539. copy(id: string): Geometry;
  20540. }
  20541. /**
  20542. * Creates a box geometry
  20543. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20544. */
  20545. class BoxGeometry extends _PrimitiveGeometry {
  20546. /**
  20547. * Defines the zise of the box (width, height and depth are the same)
  20548. */
  20549. size: number;
  20550. /**
  20551. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20552. */
  20553. side: number;
  20554. /**
  20555. * Creates a box geometry
  20556. * @param id defines the unique ID of the geometry
  20557. * @param scene defines the hosting scene
  20558. * @param size defines the zise of the box (width, height and depth are the same)
  20559. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20560. * @param mesh defines the hosting mesh (can be null)
  20561. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20562. */
  20563. constructor(id: string, scene: Scene,
  20564. /**
  20565. * Defines the zise of the box (width, height and depth are the same)
  20566. */
  20567. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20568. /**
  20569. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20570. */
  20571. side?: number);
  20572. _regenerateVertexData(): VertexData;
  20573. copy(id: string): Geometry;
  20574. serialize(): any;
  20575. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20576. }
  20577. /**
  20578. * Creates a sphere geometry
  20579. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20580. */
  20581. class SphereGeometry extends _PrimitiveGeometry {
  20582. /**
  20583. * Defines the number of segments to use to create the sphere
  20584. */
  20585. segments: number;
  20586. /**
  20587. * Defines the diameter of the sphere
  20588. */
  20589. diameter: number;
  20590. /**
  20591. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20592. */
  20593. side: number;
  20594. /**
  20595. * Create a new sphere geometry
  20596. * @param id defines the unique ID of the geometry
  20597. * @param scene defines the hosting scene
  20598. * @param segments defines the number of segments to use to create the sphere
  20599. * @param diameter defines the diameter of the sphere
  20600. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20601. * @param mesh defines the hosting mesh (can be null)
  20602. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20603. */
  20604. constructor(id: string, scene: Scene,
  20605. /**
  20606. * Defines the number of segments to use to create the sphere
  20607. */
  20608. segments: number,
  20609. /**
  20610. * Defines the diameter of the sphere
  20611. */
  20612. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20613. /**
  20614. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20615. */
  20616. side?: number);
  20617. _regenerateVertexData(): VertexData;
  20618. copy(id: string): Geometry;
  20619. serialize(): any;
  20620. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20621. }
  20622. /**
  20623. * Creates a disc geometry
  20624. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20625. */
  20626. class DiscGeometry extends _PrimitiveGeometry {
  20627. /**
  20628. * Defines the radius of the disc
  20629. */
  20630. radius: number;
  20631. /**
  20632. * Defines the tesselation factor to apply to the disc
  20633. */
  20634. tessellation: number;
  20635. /**
  20636. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20637. */
  20638. side: number;
  20639. /**
  20640. * Creates a new disc geometry
  20641. * @param id defines the unique ID of the geometry
  20642. * @param scene defines the hosting scene
  20643. * @param radius defines the radius of the disc
  20644. * @param tessellation defines the tesselation factor to apply to the disc
  20645. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20646. * @param mesh defines the hosting mesh (can be null)
  20647. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20648. */
  20649. constructor(id: string, scene: Scene,
  20650. /**
  20651. * Defines the radius of the disc
  20652. */
  20653. radius: number,
  20654. /**
  20655. * Defines the tesselation factor to apply to the disc
  20656. */
  20657. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20658. /**
  20659. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20660. */
  20661. side?: number);
  20662. _regenerateVertexData(): VertexData;
  20663. copy(id: string): Geometry;
  20664. }
  20665. /**
  20666. * Creates a new cylinder geometry
  20667. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20668. */
  20669. class CylinderGeometry extends _PrimitiveGeometry {
  20670. /**
  20671. * Defines the height of the cylinder
  20672. */
  20673. height: number;
  20674. /**
  20675. * Defines the diameter of the cylinder's top cap
  20676. */
  20677. diameterTop: number;
  20678. /**
  20679. * Defines the diameter of the cylinder's bottom cap
  20680. */
  20681. diameterBottom: number;
  20682. /**
  20683. * Defines the tessellation factor to apply to the cylinder
  20684. */
  20685. tessellation: number;
  20686. /**
  20687. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20688. */
  20689. subdivisions: number;
  20690. /**
  20691. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20692. */
  20693. side: number;
  20694. /**
  20695. * Creates a new cylinder geometry
  20696. * @param id defines the unique ID of the geometry
  20697. * @param scene defines the hosting scene
  20698. * @param height defines the height of the cylinder
  20699. * @param diameterTop defines the diameter of the cylinder's top cap
  20700. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20701. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20702. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20703. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20704. * @param mesh defines the hosting mesh (can be null)
  20705. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20706. */
  20707. constructor(id: string, scene: Scene,
  20708. /**
  20709. * Defines the height of the cylinder
  20710. */
  20711. height: number,
  20712. /**
  20713. * Defines the diameter of the cylinder's top cap
  20714. */
  20715. diameterTop: number,
  20716. /**
  20717. * Defines the diameter of the cylinder's bottom cap
  20718. */
  20719. diameterBottom: number,
  20720. /**
  20721. * Defines the tessellation factor to apply to the cylinder
  20722. */
  20723. tessellation: number,
  20724. /**
  20725. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20726. */
  20727. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20728. /**
  20729. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20730. */
  20731. side?: number);
  20732. _regenerateVertexData(): VertexData;
  20733. copy(id: string): Geometry;
  20734. serialize(): any;
  20735. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20736. }
  20737. /**
  20738. * Creates a new torus geometry
  20739. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20740. */
  20741. class TorusGeometry extends _PrimitiveGeometry {
  20742. /**
  20743. * Defines the diameter of the torus
  20744. */
  20745. diameter: number;
  20746. /**
  20747. * Defines the thickness of the torus (ie. internal diameter)
  20748. */
  20749. thickness: number;
  20750. /**
  20751. * Defines the tesselation factor to apply to the torus
  20752. */
  20753. tessellation: number;
  20754. /**
  20755. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20756. */
  20757. side: number;
  20758. /**
  20759. * Creates a new torus geometry
  20760. * @param id defines the unique ID of the geometry
  20761. * @param scene defines the hosting scene
  20762. * @param diameter defines the diameter of the torus
  20763. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20764. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20765. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20766. * @param mesh defines the hosting mesh (can be null)
  20767. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20768. */
  20769. constructor(id: string, scene: Scene,
  20770. /**
  20771. * Defines the diameter of the torus
  20772. */
  20773. diameter: number,
  20774. /**
  20775. * Defines the thickness of the torus (ie. internal diameter)
  20776. */
  20777. thickness: number,
  20778. /**
  20779. * Defines the tesselation factor to apply to the torus
  20780. */
  20781. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20782. /**
  20783. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20784. */
  20785. side?: number);
  20786. _regenerateVertexData(): VertexData;
  20787. copy(id: string): Geometry;
  20788. serialize(): any;
  20789. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20790. }
  20791. /**
  20792. * Creates a new ground geometry
  20793. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20794. */
  20795. class GroundGeometry extends _PrimitiveGeometry {
  20796. /**
  20797. * Defines the width of the ground
  20798. */
  20799. width: number;
  20800. /**
  20801. * Defines the height of the ground
  20802. */
  20803. height: number;
  20804. /**
  20805. * Defines the subdivisions to apply to the ground
  20806. */
  20807. subdivisions: number;
  20808. /**
  20809. * Creates a new ground geometry
  20810. * @param id defines the unique ID of the geometry
  20811. * @param scene defines the hosting scene
  20812. * @param width defines the width of the ground
  20813. * @param height defines the height of the ground
  20814. * @param subdivisions defines the subdivisions to apply to the ground
  20815. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20816. * @param mesh defines the hosting mesh (can be null)
  20817. */
  20818. constructor(id: string, scene: Scene,
  20819. /**
  20820. * Defines the width of the ground
  20821. */
  20822. width: number,
  20823. /**
  20824. * Defines the height of the ground
  20825. */
  20826. height: number,
  20827. /**
  20828. * Defines the subdivisions to apply to the ground
  20829. */
  20830. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20831. _regenerateVertexData(): VertexData;
  20832. copy(id: string): Geometry;
  20833. serialize(): any;
  20834. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20835. }
  20836. /**
  20837. * Creates a tiled ground geometry
  20838. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20839. */
  20840. class TiledGroundGeometry extends _PrimitiveGeometry {
  20841. /**
  20842. * Defines the minimum value on X axis
  20843. */
  20844. xmin: number;
  20845. /**
  20846. * Defines the minimum value on Z axis
  20847. */
  20848. zmin: number;
  20849. /**
  20850. * Defines the maximum value on X axis
  20851. */
  20852. xmax: number;
  20853. /**
  20854. * Defines the maximum value on Z axis
  20855. */
  20856. zmax: number;
  20857. /**
  20858. * Defines the subdivisions to apply to the ground
  20859. */
  20860. subdivisions: {
  20861. w: number;
  20862. h: number;
  20863. };
  20864. /**
  20865. * Defines the precision to use when computing the tiles
  20866. */
  20867. precision: {
  20868. w: number;
  20869. h: number;
  20870. };
  20871. /**
  20872. * Creates a tiled ground geometry
  20873. * @param id defines the unique ID of the geometry
  20874. * @param scene defines the hosting scene
  20875. * @param xmin defines the minimum value on X axis
  20876. * @param zmin defines the minimum value on Z axis
  20877. * @param xmax defines the maximum value on X axis
  20878. * @param zmax defines the maximum value on Z axis
  20879. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20880. * @param precision defines the precision to use when computing the tiles
  20881. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20882. * @param mesh defines the hosting mesh (can be null)
  20883. */
  20884. constructor(id: string, scene: Scene,
  20885. /**
  20886. * Defines the minimum value on X axis
  20887. */
  20888. xmin: number,
  20889. /**
  20890. * Defines the minimum value on Z axis
  20891. */
  20892. zmin: number,
  20893. /**
  20894. * Defines the maximum value on X axis
  20895. */
  20896. xmax: number,
  20897. /**
  20898. * Defines the maximum value on Z axis
  20899. */
  20900. zmax: number,
  20901. /**
  20902. * Defines the subdivisions to apply to the ground
  20903. */
  20904. subdivisions: {
  20905. w: number;
  20906. h: number;
  20907. },
  20908. /**
  20909. * Defines the precision to use when computing the tiles
  20910. */
  20911. precision: {
  20912. w: number;
  20913. h: number;
  20914. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20915. _regenerateVertexData(): VertexData;
  20916. copy(id: string): Geometry;
  20917. }
  20918. /**
  20919. * Creates a plane geometry
  20920. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20921. */
  20922. class PlaneGeometry extends _PrimitiveGeometry {
  20923. /**
  20924. * Defines the size of the plane (width === height)
  20925. */
  20926. size: number;
  20927. /**
  20928. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20929. */
  20930. side: number;
  20931. /**
  20932. * Creates a plane geometry
  20933. * @param id defines the unique ID of the geometry
  20934. * @param scene defines the hosting scene
  20935. * @param size defines the size of the plane (width === height)
  20936. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20937. * @param mesh defines the hosting mesh (can be null)
  20938. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20939. */
  20940. constructor(id: string, scene: Scene,
  20941. /**
  20942. * Defines the size of the plane (width === height)
  20943. */
  20944. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20945. /**
  20946. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20947. */
  20948. side?: number);
  20949. _regenerateVertexData(): VertexData;
  20950. copy(id: string): Geometry;
  20951. serialize(): any;
  20952. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20953. }
  20954. /**
  20955. * Creates a torus knot geometry
  20956. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20957. */
  20958. class TorusKnotGeometry extends _PrimitiveGeometry {
  20959. /**
  20960. * Defines the radius of the torus knot
  20961. */
  20962. radius: number;
  20963. /**
  20964. * Defines the thickness of the torus knot tube
  20965. */
  20966. tube: number;
  20967. /**
  20968. * Defines the number of radial segments
  20969. */
  20970. radialSegments: number;
  20971. /**
  20972. * Defines the number of tubular segments
  20973. */
  20974. tubularSegments: number;
  20975. /**
  20976. * Defines the first number of windings
  20977. */
  20978. p: number;
  20979. /**
  20980. * Defines the second number of windings
  20981. */
  20982. q: number;
  20983. /**
  20984. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20985. */
  20986. side: number;
  20987. /**
  20988. * Creates a torus knot geometry
  20989. * @param id defines the unique ID of the geometry
  20990. * @param scene defines the hosting scene
  20991. * @param radius defines the radius of the torus knot
  20992. * @param tube defines the thickness of the torus knot tube
  20993. * @param radialSegments defines the number of radial segments
  20994. * @param tubularSegments defines the number of tubular segments
  20995. * @param p defines the first number of windings
  20996. * @param q defines the second number of windings
  20997. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20998. * @param mesh defines the hosting mesh (can be null)
  20999. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21000. */
  21001. constructor(id: string, scene: Scene,
  21002. /**
  21003. * Defines the radius of the torus knot
  21004. */
  21005. radius: number,
  21006. /**
  21007. * Defines the thickness of the torus knot tube
  21008. */
  21009. tube: number,
  21010. /**
  21011. * Defines the number of radial segments
  21012. */
  21013. radialSegments: number,
  21014. /**
  21015. * Defines the number of tubular segments
  21016. */
  21017. tubularSegments: number,
  21018. /**
  21019. * Defines the first number of windings
  21020. */
  21021. p: number,
  21022. /**
  21023. * Defines the second number of windings
  21024. */
  21025. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21026. /**
  21027. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21028. */
  21029. side?: number);
  21030. _regenerateVertexData(): VertexData;
  21031. copy(id: string): Geometry;
  21032. serialize(): any;
  21033. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21034. }
  21035. }
  21036. declare module BABYLON {
  21037. class GroundMesh extends Mesh {
  21038. generateOctree: boolean;
  21039. private _heightQuads;
  21040. _subdivisionsX: number;
  21041. _subdivisionsY: number;
  21042. _width: number;
  21043. _height: number;
  21044. _minX: number;
  21045. _maxX: number;
  21046. _minZ: number;
  21047. _maxZ: number;
  21048. constructor(name: string, scene: Scene);
  21049. getClassName(): string;
  21050. readonly subdivisions: number;
  21051. readonly subdivisionsX: number;
  21052. readonly subdivisionsY: number;
  21053. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21054. /**
  21055. * Returns a height (y) value in the Worl system :
  21056. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21057. * Returns the ground y position if (x, z) are outside the ground surface.
  21058. */
  21059. getHeightAtCoordinates(x: number, z: number): number;
  21060. /**
  21061. * Returns a normalized vector (Vector3) orthogonal to the ground
  21062. * at the ground coordinates (x, z) expressed in the World system.
  21063. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21064. */
  21065. getNormalAtCoordinates(x: number, z: number): Vector3;
  21066. /**
  21067. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21068. * at the ground coordinates (x, z) expressed in the World system.
  21069. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21070. * Returns the GroundMesh.
  21071. */
  21072. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21073. /**
  21074. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21075. * if the ground has been updated.
  21076. * This can be used in the render loop.
  21077. * Returns the GroundMesh.
  21078. */
  21079. updateCoordinateHeights(): GroundMesh;
  21080. private _getFacetAt(x, z);
  21081. private _initHeightQuads();
  21082. private _computeHeightQuads();
  21083. serialize(serializationObject: any): void;
  21084. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21085. }
  21086. }
  21087. declare module BABYLON {
  21088. /**
  21089. * Creates an instance based on a source mesh.
  21090. */
  21091. class InstancedMesh extends AbstractMesh {
  21092. private _sourceMesh;
  21093. private _currentLOD;
  21094. constructor(name: string, source: Mesh);
  21095. /**
  21096. * Returns the string "InstancedMesh".
  21097. */
  21098. getClassName(): string;
  21099. readonly receiveShadows: boolean;
  21100. readonly material: Nullable<Material>;
  21101. readonly visibility: number;
  21102. readonly skeleton: Nullable<Skeleton>;
  21103. renderingGroupId: number;
  21104. /**
  21105. * Returns the total number of vertices (integer).
  21106. */
  21107. getTotalVertices(): number;
  21108. readonly sourceMesh: Mesh;
  21109. /**
  21110. * Is this node ready to be used/rendered
  21111. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21112. * @return {boolean} is it ready
  21113. */
  21114. isReady(completeCheck?: boolean): boolean;
  21115. /**
  21116. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21117. */
  21118. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21119. /**
  21120. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21121. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21122. * The `data` are either a numeric array either a Float32Array.
  21123. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21124. * 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).
  21125. * Note that a new underlying VertexBuffer object is created each call.
  21126. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21127. *
  21128. * Possible `kind` values :
  21129. * - BABYLON.VertexBuffer.PositionKind
  21130. * - BABYLON.VertexBuffer.UVKind
  21131. * - BABYLON.VertexBuffer.UV2Kind
  21132. * - BABYLON.VertexBuffer.UV3Kind
  21133. * - BABYLON.VertexBuffer.UV4Kind
  21134. * - BABYLON.VertexBuffer.UV5Kind
  21135. * - BABYLON.VertexBuffer.UV6Kind
  21136. * - BABYLON.VertexBuffer.ColorKind
  21137. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21138. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21139. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21140. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21141. *
  21142. * Returns the Mesh.
  21143. */
  21144. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21145. /**
  21146. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21147. * If the mesh has no geometry, it is simply returned as it is.
  21148. * The `data` are either a numeric array either a Float32Array.
  21149. * No new underlying VertexBuffer object is created.
  21150. * 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.
  21151. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21152. *
  21153. * Possible `kind` values :
  21154. * - BABYLON.VertexBuffer.PositionKind
  21155. * - BABYLON.VertexBuffer.UVKind
  21156. * - BABYLON.VertexBuffer.UV2Kind
  21157. * - BABYLON.VertexBuffer.UV3Kind
  21158. * - BABYLON.VertexBuffer.UV4Kind
  21159. * - BABYLON.VertexBuffer.UV5Kind
  21160. * - BABYLON.VertexBuffer.UV6Kind
  21161. * - BABYLON.VertexBuffer.ColorKind
  21162. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21163. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21164. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21165. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21166. *
  21167. * Returns the Mesh.
  21168. */
  21169. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21170. /**
  21171. * Sets the mesh indices.
  21172. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21173. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21174. * This method creates a new index buffer each call.
  21175. * Returns the Mesh.
  21176. */
  21177. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21178. /**
  21179. * Boolean : True if the mesh owns the requested kind of data.
  21180. */
  21181. isVerticesDataPresent(kind: string): boolean;
  21182. /**
  21183. * Returns an array of indices (IndicesArray).
  21184. */
  21185. getIndices(): Nullable<IndicesArray>;
  21186. readonly _positions: Nullable<Vector3[]>;
  21187. /**
  21188. * Sets a new updated BoundingInfo to the mesh.
  21189. * Returns the mesh.
  21190. */
  21191. refreshBoundingInfo(): InstancedMesh;
  21192. _preActivate(): InstancedMesh;
  21193. _activate(renderId: number): InstancedMesh;
  21194. /**
  21195. * Returns the current associated LOD AbstractMesh.
  21196. */
  21197. getLOD(camera: Camera): AbstractMesh;
  21198. _syncSubMeshes(): InstancedMesh;
  21199. _generatePointsArray(): boolean;
  21200. /**
  21201. * Creates a new InstancedMesh from the current mesh.
  21202. * - name (string) : the cloned mesh name
  21203. * - newParent (optional Node) : the optional Node to parent the clone to.
  21204. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21205. *
  21206. * Returns the clone.
  21207. */
  21208. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21209. /**
  21210. * Disposes the InstancedMesh.
  21211. * Returns nothing.
  21212. */
  21213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21214. }
  21215. }
  21216. declare module BABYLON {
  21217. class LinesMesh extends Mesh {
  21218. useVertexColor: boolean | undefined;
  21219. useVertexAlpha: boolean | undefined;
  21220. color: Color3;
  21221. alpha: number;
  21222. /**
  21223. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21224. * This margin is expressed in world space coordinates, so its value may vary.
  21225. * Default value is 0.1
  21226. * @returns the intersection Threshold value.
  21227. */
  21228. /**
  21229. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21230. * This margin is expressed in world space coordinates, so its value may vary.
  21231. * @param value the new threshold to apply
  21232. */
  21233. intersectionThreshold: number;
  21234. private _intersectionThreshold;
  21235. private _colorShader;
  21236. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21237. /**
  21238. * Returns the string "LineMesh"
  21239. */
  21240. getClassName(): string;
  21241. material: Material;
  21242. readonly checkCollisions: boolean;
  21243. createInstance(name: string): InstancedMesh;
  21244. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21245. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21246. dispose(doNotRecurse?: boolean): void;
  21247. /**
  21248. * Returns a new LineMesh object cloned from the current one.
  21249. */
  21250. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21251. }
  21252. }
  21253. declare module BABYLON {
  21254. /**
  21255. * @hidden
  21256. **/
  21257. class _InstancesBatch {
  21258. mustReturn: boolean;
  21259. visibleInstances: Nullable<InstancedMesh[]>[];
  21260. renderSelf: boolean[];
  21261. }
  21262. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21263. static _FRONTSIDE: number;
  21264. static _BACKSIDE: number;
  21265. static _DOUBLESIDE: number;
  21266. static _DEFAULTSIDE: number;
  21267. static _NO_CAP: number;
  21268. static _CAP_START: number;
  21269. static _CAP_END: number;
  21270. static _CAP_ALL: number;
  21271. /**
  21272. * Mesh side orientation : usually the external or front surface
  21273. */
  21274. static readonly FRONTSIDE: number;
  21275. /**
  21276. * Mesh side orientation : usually the internal or back surface
  21277. */
  21278. static readonly BACKSIDE: number;
  21279. /**
  21280. * Mesh side orientation : both internal and external or front and back surfaces
  21281. */
  21282. static readonly DOUBLESIDE: number;
  21283. /**
  21284. * Mesh side orientation : by default, `FRONTSIDE`
  21285. */
  21286. static readonly DEFAULTSIDE: number;
  21287. /**
  21288. * Mesh cap setting : no cap
  21289. */
  21290. static readonly NO_CAP: number;
  21291. /**
  21292. * Mesh cap setting : one cap at the beginning of the mesh
  21293. */
  21294. static readonly CAP_START: number;
  21295. /**
  21296. * Mesh cap setting : one cap at the end of the mesh
  21297. */
  21298. static readonly CAP_END: number;
  21299. /**
  21300. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21301. */
  21302. static readonly CAP_ALL: number;
  21303. /**
  21304. * An event triggered before rendering the mesh
  21305. */
  21306. onBeforeRenderObservable: Observable<Mesh>;
  21307. /**
  21308. * An event triggered after rendering the mesh
  21309. */
  21310. onAfterRenderObservable: Observable<Mesh>;
  21311. /**
  21312. * An event triggered before drawing the mesh
  21313. */
  21314. onBeforeDrawObservable: Observable<Mesh>;
  21315. private _onBeforeDrawObserver;
  21316. onBeforeDraw: () => void;
  21317. delayLoadState: number;
  21318. instances: InstancedMesh[];
  21319. delayLoadingFile: string;
  21320. _binaryInfo: any;
  21321. private _LODLevels;
  21322. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  21323. private _morphTargetManager;
  21324. morphTargetManager: Nullable<MorphTargetManager>;
  21325. _geometry: Nullable<Geometry>;
  21326. _delayInfo: Array<string>;
  21327. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21328. _visibleInstances: any;
  21329. private _renderIdForInstances;
  21330. private _batchCache;
  21331. private _instancesBufferSize;
  21332. private _instancesBuffer;
  21333. private _instancesData;
  21334. private _overridenInstanceCount;
  21335. private _effectiveMaterial;
  21336. _shouldGenerateFlatShading: boolean;
  21337. private _preActivateId;
  21338. _originalBuilderSideOrientation: number;
  21339. overrideMaterialSideOrientation: Nullable<number>;
  21340. private _areNormalsFrozen;
  21341. private _sourcePositions;
  21342. private _sourceNormals;
  21343. private _source;
  21344. readonly source: Nullable<Mesh>;
  21345. isUnIndexed: boolean;
  21346. /**
  21347. * @constructor
  21348. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21349. * @param {Scene} scene The scene to add this mesh to.
  21350. * @param {Node} parent The parent of this mesh, if it has one
  21351. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21352. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21353. * When false, achieved by calling a clone(), also passing False.
  21354. * This will make creation of children, recursive.
  21355. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21356. */
  21357. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21358. /**
  21359. * Returns the string "Mesh".
  21360. */
  21361. getClassName(): string;
  21362. /**
  21363. * Returns a string.
  21364. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21365. */
  21366. toString(fullDetails?: boolean): string;
  21367. _unBindEffect(): void;
  21368. /**
  21369. * True if the mesh has some Levels Of Details (LOD).
  21370. * Returns a boolean.
  21371. */
  21372. readonly hasLODLevels: boolean;
  21373. /**
  21374. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21375. * @returns an array of {BABYLON.MeshLODLevel}
  21376. */
  21377. getLODLevels(): MeshLODLevel[];
  21378. private _sortLODLevels();
  21379. /**
  21380. * Add a mesh as LOD level triggered at the given distance.
  21381. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21382. * @param {number} distance The distance from the center of the object to show this level
  21383. * @param {Mesh} mesh The mesh to be added as LOD level
  21384. * @return {Mesh} This mesh (for chaining)
  21385. */
  21386. addLODLevel(distance: number, mesh: Mesh): Mesh;
  21387. /**
  21388. * Returns the LOD level mesh at the passed distance or null if not found.
  21389. * It is related to the method `addLODLevel(distance, mesh)`.
  21390. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21391. * Returns an object Mesh or `null`.
  21392. */
  21393. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21394. /**
  21395. * Remove a mesh from the LOD array
  21396. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21397. * @param {Mesh} mesh The mesh to be removed.
  21398. * @return {Mesh} This mesh (for chaining)
  21399. */
  21400. removeLODLevel(mesh: Mesh): Mesh;
  21401. /**
  21402. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21403. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21404. */
  21405. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  21406. /**
  21407. * Returns the mesh internal Geometry object.
  21408. */
  21409. readonly geometry: Nullable<Geometry>;
  21410. /**
  21411. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21412. */
  21413. getTotalVertices(): number;
  21414. /**
  21415. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21416. * 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.
  21417. * You can force the copy with forceCopy === true
  21418. * Returns null if the mesh has no geometry or no vertex buffer.
  21419. * Possible `kind` values :
  21420. * - BABYLON.VertexBuffer.PositionKind
  21421. * - BABYLON.VertexBuffer.UVKind
  21422. * - BABYLON.VertexBuffer.UV2Kind
  21423. * - BABYLON.VertexBuffer.UV3Kind
  21424. * - BABYLON.VertexBuffer.UV4Kind
  21425. * - BABYLON.VertexBuffer.UV5Kind
  21426. * - BABYLON.VertexBuffer.UV6Kind
  21427. * - BABYLON.VertexBuffer.ColorKind
  21428. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21429. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21430. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21431. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21432. */
  21433. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21434. /**
  21435. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21436. * Returns `null` if the mesh has no geometry.
  21437. * Possible `kind` values :
  21438. * - BABYLON.VertexBuffer.PositionKind
  21439. * - BABYLON.VertexBuffer.UVKind
  21440. * - BABYLON.VertexBuffer.UV2Kind
  21441. * - BABYLON.VertexBuffer.UV3Kind
  21442. * - BABYLON.VertexBuffer.UV4Kind
  21443. * - BABYLON.VertexBuffer.UV5Kind
  21444. * - BABYLON.VertexBuffer.UV6Kind
  21445. * - BABYLON.VertexBuffer.ColorKind
  21446. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21447. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21448. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21449. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21450. */
  21451. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21452. isVerticesDataPresent(kind: string): boolean;
  21453. /**
  21454. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21455. * Possible `kind` values :
  21456. * - BABYLON.VertexBuffer.PositionKind
  21457. * - BABYLON.VertexBuffer.UVKind
  21458. * - BABYLON.VertexBuffer.UV2Kind
  21459. * - BABYLON.VertexBuffer.UV3Kind
  21460. * - BABYLON.VertexBuffer.UV4Kind
  21461. * - BABYLON.VertexBuffer.UV5Kind
  21462. * - BABYLON.VertexBuffer.UV6Kind
  21463. * - BABYLON.VertexBuffer.ColorKind
  21464. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21465. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21466. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21467. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21468. */
  21469. isVertexBufferUpdatable(kind: string): boolean;
  21470. /**
  21471. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21472. * Possible `kind` values :
  21473. * - BABYLON.VertexBuffer.PositionKind
  21474. * - BABYLON.VertexBuffer.UVKind
  21475. * - BABYLON.VertexBuffer.UV2Kind
  21476. * - BABYLON.VertexBuffer.UV3Kind
  21477. * - BABYLON.VertexBuffer.UV4Kind
  21478. * - BABYLON.VertexBuffer.UV5Kind
  21479. * - BABYLON.VertexBuffer.UV6Kind
  21480. * - BABYLON.VertexBuffer.ColorKind
  21481. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21482. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21483. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21484. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21485. */
  21486. getVerticesDataKinds(): string[];
  21487. /**
  21488. * Returns a positive integer : the total number of indices in this mesh geometry.
  21489. * Returns zero if the mesh has no geometry.
  21490. */
  21491. getTotalIndices(): number;
  21492. /**
  21493. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21494. * 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.
  21495. * Returns an empty array if the mesh has no geometry.
  21496. */
  21497. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21498. readonly isBlocked: boolean;
  21499. /**
  21500. * Determine if the current mesh is ready to be rendered
  21501. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21502. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21503. * @returns true if all associated assets are ready (material, textures, shaders)
  21504. */
  21505. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21506. /**
  21507. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21508. * This property is pertinent only for updatable parametric shapes.
  21509. */
  21510. readonly areNormalsFrozen: boolean;
  21511. /**
  21512. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21513. * It has no effect at all on other shapes.
  21514. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21515. * Returns the Mesh.
  21516. */
  21517. freezeNormals(): Mesh;
  21518. /**
  21519. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21520. * It has no effect at all on other shapes.
  21521. * It reactivates the mesh normals computation if it was previously frozen.
  21522. * Returns the Mesh.
  21523. */
  21524. unfreezeNormals(): Mesh;
  21525. /**
  21526. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21527. */
  21528. overridenInstanceCount: number;
  21529. _preActivate(): Mesh;
  21530. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21531. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21532. /**
  21533. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21534. * This means the mesh underlying bounding box and sphere are recomputed.
  21535. * Returns the Mesh.
  21536. */
  21537. refreshBoundingInfo(): Mesh;
  21538. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21539. private _getPositionData(applySkeleton);
  21540. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21541. subdivide(count: number): void;
  21542. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21543. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21544. /**
  21545. * Sets the mesh VertexBuffer.
  21546. * Returns the Mesh.
  21547. */
  21548. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21549. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21550. /**
  21551. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21552. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21553. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21554. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21555. * Returns the Mesh.
  21556. */
  21557. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21558. /**
  21559. * Creates a un-shared specific occurence of the geometry for the mesh.
  21560. * Returns the Mesh.
  21561. */
  21562. makeGeometryUnique(): Mesh;
  21563. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21564. /**
  21565. * Update the current index buffer
  21566. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21567. * Returns the Mesh.
  21568. */
  21569. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21570. /**
  21571. * Invert the geometry to move from a right handed system to a left handed one.
  21572. * Returns the Mesh.
  21573. */
  21574. toLeftHanded(): Mesh;
  21575. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21576. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21577. /**
  21578. * Registers for this mesh a javascript function called just before the rendering process.
  21579. * This function is passed the current mesh.
  21580. * Return the Mesh.
  21581. */
  21582. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21583. /**
  21584. * Disposes a previously registered javascript function called before the rendering.
  21585. * This function is passed the current mesh.
  21586. * Returns the Mesh.
  21587. */
  21588. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21589. /**
  21590. * Registers for this mesh a javascript function called just after the rendering is complete.
  21591. * This function is passed the current mesh.
  21592. * Returns the Mesh.
  21593. */
  21594. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21595. /**
  21596. * Disposes a previously registered javascript function called after the rendering.
  21597. * This function is passed the current mesh.
  21598. * Return the Mesh.
  21599. */
  21600. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21601. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21602. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21603. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21604. /**
  21605. * Triggers the draw call for the mesh.
  21606. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  21607. * Returns the Mesh.
  21608. */
  21609. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21610. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21611. /**
  21612. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  21613. */
  21614. getEmittedParticleSystems(): IParticleSystem[];
  21615. /**
  21616. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21617. */
  21618. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21619. _checkDelayState(): Mesh;
  21620. private _queueLoad(scene);
  21621. /**
  21622. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21623. */
  21624. isInFrustum(frustumPlanes: Plane[]): boolean;
  21625. /**
  21626. * Sets the mesh material by the material or multiMaterial `id` property.
  21627. * The material `id` is a string identifying the material or the multiMaterial.
  21628. * This method returns the Mesh.
  21629. */
  21630. setMaterialByID(id: string): Mesh;
  21631. /**
  21632. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21633. */
  21634. getAnimatables(): IAnimatable[];
  21635. /**
  21636. * Modifies the mesh geometry according to the passed transformation matrix.
  21637. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21638. * The mesh normals are modified accordingly the same transformation.
  21639. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21640. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21641. * Returns the Mesh.
  21642. */
  21643. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21644. /**
  21645. * Modifies the mesh geometry according to its own current World Matrix.
  21646. * The mesh World Matrix is then reset.
  21647. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21648. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21649. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21650. * Returns the Mesh.
  21651. */
  21652. bakeCurrentTransformIntoVertices(): Mesh;
  21653. readonly _positions: Nullable<Vector3[]>;
  21654. _resetPointsArrayCache(): Mesh;
  21655. _generatePointsArray(): boolean;
  21656. /**
  21657. * Returns a new Mesh object generated from the current mesh properties.
  21658. * This method must not get confused with createInstance().
  21659. * The parameter `name` is a string, the name given to the new mesh.
  21660. * The optional parameter `newParent` can be any Node object (default `null`).
  21661. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21662. * 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.
  21663. */
  21664. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21665. /**
  21666. * Releases resources associated with this mesh.
  21667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21669. */
  21670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21671. /**
  21672. * Modifies the mesh geometry according to a displacement map.
  21673. * 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.
  21674. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21675. * This method returns nothing.
  21676. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21677. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21678. * 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.
  21679. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21680. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21681. *
  21682. * Returns the Mesh.
  21683. */
  21684. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21685. /**
  21686. * Modifies the mesh geometry according to a displacementMap buffer.
  21687. * 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.
  21688. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21689. * This method returns nothing.
  21690. * 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.
  21691. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21692. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21693. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21694. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21695. *
  21696. * Returns the Mesh.
  21697. */
  21698. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21699. /**
  21700. * Modify the mesh to get a flat shading rendering.
  21701. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21702. * This method returns the Mesh.
  21703. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21704. */
  21705. convertToFlatShadedMesh(): Mesh;
  21706. /**
  21707. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21708. * In other words, more vertices, no more indices and a single bigger VBO.
  21709. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21710. * Returns the Mesh.
  21711. */
  21712. convertToUnIndexedMesh(): Mesh;
  21713. /**
  21714. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21715. * This method returns the Mesh.
  21716. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21717. */
  21718. flipFaces(flipNormals?: boolean): Mesh;
  21719. /**
  21720. * Creates a new InstancedMesh object from the mesh model.
  21721. * An instance shares the same properties and the same material than its model.
  21722. * Only these properties of each instance can then be set individually :
  21723. * - position
  21724. * - rotation
  21725. * - rotationQuaternion
  21726. * - setPivotMatrix
  21727. * - scaling
  21728. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21729. * Warning : this method is not supported for Line mesh and LineSystem
  21730. */
  21731. createInstance(name: string): InstancedMesh;
  21732. /**
  21733. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21734. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21735. * This method returns the Mesh.
  21736. */
  21737. synchronizeInstances(): Mesh;
  21738. /**
  21739. * Simplify the mesh according to the given array of settings.
  21740. * Function will return immediately and will simplify async. It returns the Mesh.
  21741. * @param settings a collection of simplification settings.
  21742. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21743. * @param type the type of simplification to run.
  21744. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21745. */
  21746. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21747. /**
  21748. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21749. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21750. * This should be used together with the simplification to avoid disappearing triangles.
  21751. * Returns the Mesh.
  21752. * @param successCallback an optional success callback to be called after the optimization finished.
  21753. */
  21754. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21755. serialize(serializationObject: any): void;
  21756. _syncGeometryWithMorphTargetManager(): void;
  21757. /**
  21758. * Returns a new Mesh object parsed from the source provided.
  21759. * The parameter `parsedMesh` is the source.
  21760. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21761. */
  21762. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21763. /**
  21764. * Creates a ribbon mesh.
  21765. * Please consider using the same method from the MeshBuilder class instead.
  21766. * 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.
  21767. *
  21768. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21769. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21770. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21771. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21772. * 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.
  21773. * 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.
  21774. * 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
  21775. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21776. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21777. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21778. */
  21779. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21780. /**
  21781. * Creates a plane polygonal mesh. By default, this is a disc.
  21782. * Please consider using the same method from the MeshBuilder class instead.
  21783. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21784. * 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.
  21785. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21786. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21787. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21788. */
  21789. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21790. /**
  21791. * Creates a box mesh.
  21792. * Please consider using the same method from the MeshBuilder class instead.
  21793. * The parameter `size` sets the size (float) of each box side (default 1).
  21794. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21795. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21796. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21797. */
  21798. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21799. /**
  21800. * Creates a sphere mesh.
  21801. * Please consider using the same method from the MeshBuilder class instead.
  21802. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21803. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21804. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21805. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21806. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21807. */
  21808. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21809. /**
  21810. * Creates a cylinder or a cone mesh.
  21811. * Please consider using the same method from the MeshBuilder class instead.
  21812. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21813. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21814. * 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.
  21815. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21816. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21817. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21818. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21819. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21820. */
  21821. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21822. /**
  21823. * Creates a torus mesh.
  21824. * Please consider using the same method from the MeshBuilder class instead.
  21825. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21826. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21827. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21828. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21829. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21830. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21831. */
  21832. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21833. /**
  21834. * Creates a torus knot mesh.
  21835. * Please consider using the same method from the MeshBuilder class instead.
  21836. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21837. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21838. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21839. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21840. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21841. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21842. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21843. */
  21844. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21845. /**
  21846. * Creates a line mesh.
  21847. * Please consider using the same method from the MeshBuilder class instead.
  21848. * 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.
  21849. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21850. * The parameter `points` is an array successive Vector3.
  21851. * 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
  21852. * When updating an instance, remember that only point positions can change, not the number of points.
  21853. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21854. */
  21855. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21856. /**
  21857. * Creates a dashed line mesh.
  21858. * Please consider using the same method from the MeshBuilder class instead.
  21859. * 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.
  21860. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21861. * The parameter `points` is an array successive Vector3.
  21862. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21863. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21864. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21865. * 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
  21866. * When updating an instance, remember that only point positions can change, not the number of points.
  21867. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21868. */
  21869. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21870. /**
  21871. * Creates a polygon mesh.
  21872. * Please consider using the same method from the MeshBuilder class instead.
  21873. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21874. * 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.
  21875. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21876. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21877. * Remember you can only change the shape positions, not their number when updating a polygon.
  21878. */
  21879. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21880. /**
  21881. * Creates an extruded polygon mesh, with depth in the Y direction.
  21882. * Please consider using the same method from the MeshBuilder class instead.
  21883. */
  21884. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21885. /**
  21886. * Creates an extruded shape mesh.
  21887. * 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.
  21888. * Please consider using the same method from the MeshBuilder class instead.
  21889. *
  21890. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21891. * 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
  21892. * extruded along the Z axis.
  21893. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21894. * 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.
  21895. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21896. * 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
  21897. * 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
  21898. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21899. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21900. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21901. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21902. */
  21903. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21904. /**
  21905. * Creates an custom extruded shape mesh.
  21906. * 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.
  21907. * Please consider using the same method from the MeshBuilder class instead.
  21908. *
  21909. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21910. * 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
  21911. * extruded along the Z axis.
  21912. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21913. * 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
  21914. * and the distance of this point from the begining of the path :
  21915. * ```javascript
  21916. * var rotationFunction = function(i, distance) {
  21917. * // do things
  21918. * return rotationValue; }
  21919. * ```
  21920. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21921. * 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
  21922. * and the distance of this point from the begining of the path :
  21923. * ```javascript
  21924. * var scaleFunction = function(i, distance) {
  21925. * // do things
  21926. * return scaleValue;}
  21927. * ```
  21928. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21929. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21930. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21931. * 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
  21932. * 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
  21933. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21934. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21935. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21936. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21937. */
  21938. 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;
  21939. /**
  21940. * Creates lathe mesh.
  21941. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21942. * Please consider using the same method from the MeshBuilder class instead.
  21943. * 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
  21944. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21945. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21946. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21947. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21948. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21949. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21950. */
  21951. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21952. /**
  21953. * Creates a plane mesh.
  21954. * Please consider using the same method from the MeshBuilder class instead.
  21955. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21956. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21957. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21958. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21959. */
  21960. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21961. /**
  21962. * Creates a ground mesh.
  21963. * Please consider using the same method from the MeshBuilder class instead.
  21964. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21965. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21966. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21967. */
  21968. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21969. /**
  21970. * Creates a tiled ground mesh.
  21971. * Please consider using the same method from the MeshBuilder class instead.
  21972. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21973. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21974. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21975. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21976. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21977. * numbers of subdivisions on the ground width and height of each tile.
  21978. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21979. */
  21980. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21981. w: number;
  21982. h: number;
  21983. }, precision: {
  21984. w: number;
  21985. h: number;
  21986. }, scene: Scene, updatable?: boolean): Mesh;
  21987. /**
  21988. * Creates a ground mesh from a height map.
  21989. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21990. * Please consider using the same method from the MeshBuilder class instead.
  21991. * The parameter `url` sets the URL of the height map image resource.
  21992. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21993. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21994. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21995. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21996. * 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).
  21997. * This function is passed the newly built mesh :
  21998. * ```javascript
  21999. * function(mesh) { // do things
  22000. * return; }
  22001. * ```
  22002. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22003. */
  22004. 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;
  22005. /**
  22006. * Creates a tube mesh.
  22007. * 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.
  22008. * Please consider using the same method from the MeshBuilder class instead.
  22009. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22010. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22011. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22012. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22013. * 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.
  22014. * It must return a radius value (positive float) :
  22015. * ```javascript
  22016. * var radiusFunction = function(i, distance) {
  22017. * // do things
  22018. * return radius; }
  22019. * ```
  22020. * 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
  22021. * 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
  22022. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22023. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22024. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22025. */
  22026. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22027. (i: number, distance: number): number;
  22028. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22029. /**
  22030. * Creates a polyhedron mesh.
  22031. * Please consider using the same method from the MeshBuilder class instead.
  22032. * 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
  22033. * to choose the wanted type.
  22034. * The parameter `size` (positive float, default 1) sets the polygon size.
  22035. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22036. * 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`.
  22037. * 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
  22038. * 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)`).
  22039. * 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
  22040. * 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.
  22041. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22042. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22043. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22044. */
  22045. static CreatePolyhedron(name: string, options: {
  22046. type?: number;
  22047. size?: number;
  22048. sizeX?: number;
  22049. sizeY?: number;
  22050. sizeZ?: number;
  22051. custom?: any;
  22052. faceUV?: Vector4[];
  22053. faceColors?: Color4[];
  22054. updatable?: boolean;
  22055. sideOrientation?: number;
  22056. }, scene: Scene): Mesh;
  22057. /**
  22058. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22059. * Please consider using the same method from the MeshBuilder class instead.
  22060. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22061. * 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`).
  22062. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22063. * 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.
  22064. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22065. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22066. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22067. */
  22068. static CreateIcoSphere(name: string, options: {
  22069. radius?: number;
  22070. flat?: boolean;
  22071. subdivisions?: number;
  22072. sideOrientation?: number;
  22073. updatable?: boolean;
  22074. }, scene: Scene): Mesh;
  22075. /**
  22076. * Creates a decal mesh.
  22077. * Please consider using the same method from the MeshBuilder class instead.
  22078. * 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.
  22079. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22080. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22081. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22082. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22083. */
  22084. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22085. /**
  22086. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22087. */
  22088. setPositionsForCPUSkinning(): Float32Array;
  22089. /**
  22090. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22091. */
  22092. setNormalsForCPUSkinning(): Float32Array;
  22093. /**
  22094. * Updates the vertex buffer by applying transformation from the bones.
  22095. * Returns the Mesh.
  22096. *
  22097. * @param {skeleton} skeleton to apply
  22098. */
  22099. applySkeleton(skeleton: Skeleton): Mesh;
  22100. /**
  22101. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22102. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22103. */
  22104. static MinMax(meshes: AbstractMesh[]): {
  22105. min: Vector3;
  22106. max: Vector3;
  22107. };
  22108. /**
  22109. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22110. */
  22111. static Center(meshesOrMinMaxVector: {
  22112. min: Vector3;
  22113. max: Vector3;
  22114. } | AbstractMesh[]): Vector3;
  22115. /**
  22116. * Merge the array of meshes into a single mesh for performance reasons.
  22117. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  22118. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  22119. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22120. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22121. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22122. */
  22123. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22124. }
  22125. }
  22126. declare module BABYLON {
  22127. /**
  22128. * Define an interface for all classes that will get and set the data on vertices
  22129. */
  22130. interface IGetSetVerticesData {
  22131. isVerticesDataPresent(kind: string): boolean;
  22132. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22133. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22134. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22135. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22136. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22137. }
  22138. /**
  22139. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22140. */
  22141. class VertexData {
  22142. /**
  22143. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22144. */
  22145. positions: Nullable<FloatArray>;
  22146. /**
  22147. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22148. */
  22149. normals: Nullable<FloatArray>;
  22150. /**
  22151. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22152. */
  22153. tangents: Nullable<FloatArray>;
  22154. /**
  22155. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22156. */
  22157. uvs: Nullable<FloatArray>;
  22158. /**
  22159. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22160. */
  22161. uvs2: Nullable<FloatArray>;
  22162. /**
  22163. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22164. */
  22165. uvs3: Nullable<FloatArray>;
  22166. /**
  22167. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22168. */
  22169. uvs4: Nullable<FloatArray>;
  22170. /**
  22171. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22172. */
  22173. uvs5: Nullable<FloatArray>;
  22174. /**
  22175. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22176. */
  22177. uvs6: Nullable<FloatArray>;
  22178. /**
  22179. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22180. */
  22181. colors: Nullable<FloatArray>;
  22182. /**
  22183. * 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).
  22184. */
  22185. matricesIndices: Nullable<FloatArray>;
  22186. /**
  22187. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22188. */
  22189. matricesWeights: Nullable<FloatArray>;
  22190. /**
  22191. * An array extending the number of possible indices
  22192. */
  22193. matricesIndicesExtra: Nullable<FloatArray>;
  22194. /**
  22195. * An array extending the number of possible weights when the number of indices is extended
  22196. */
  22197. matricesWeightsExtra: Nullable<FloatArray>;
  22198. /**
  22199. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22200. */
  22201. indices: Nullable<IndicesArray>;
  22202. /**
  22203. * Uses the passed data array to set the set the values for the specified kind of data
  22204. * @param data a linear array of floating numbers
  22205. * @param kind the type of data that is being set, eg positions, colors etc
  22206. */
  22207. set(data: FloatArray, kind: string): void;
  22208. /**
  22209. * Associates the vertexData to the passed Mesh.
  22210. * Sets it as updatable or not (default `false`)
  22211. * @param mesh the mesh the vertexData is applied to
  22212. * @param updatable when used and having the value true allows new data to update the vertexData
  22213. * @returns the VertexData
  22214. */
  22215. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22216. /**
  22217. * Associates the vertexData to the passed Geometry.
  22218. * Sets it as updatable or not (default `false`)
  22219. * @param geometry the geometry the vertexData is applied to
  22220. * @param updatable when used and having the value true allows new data to update the vertexData
  22221. * @returns VertexData
  22222. */
  22223. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22224. /**
  22225. * Updates the associated mesh
  22226. * @param mesh the mesh to be updated
  22227. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22228. * @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
  22229. * @returns VertexData
  22230. */
  22231. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22232. /**
  22233. * Updates the associated geometry
  22234. * @param geometry the geometry to be updated
  22235. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22236. * @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
  22237. * @returns VertexData.
  22238. */
  22239. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22240. private _applyTo(meshOrGeometry, updatable?);
  22241. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  22242. /**
  22243. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22244. * @param matrix the transforming matrix
  22245. * @returns the VertexData
  22246. */
  22247. transform(matrix: Matrix): VertexData;
  22248. /**
  22249. * Merges the passed VertexData into the current one
  22250. * @param other the VertexData to be merged into the current one
  22251. * @returns the modified VertexData
  22252. */
  22253. merge(other: VertexData): VertexData;
  22254. private _mergeElement(source, other);
  22255. private _validate();
  22256. /**
  22257. * Serializes the VertexData
  22258. * @returns a serialized object
  22259. */
  22260. serialize(): any;
  22261. /**
  22262. * Extracts the vertexData from a mesh
  22263. * @param mesh the mesh from which to extract the VertexData
  22264. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22265. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22266. * @returns the object VertexData associated to the passed mesh
  22267. */
  22268. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22269. /**
  22270. * Extracts the vertexData from the geometry
  22271. * @param geometry the geometry from which to extract the VertexData
  22272. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22273. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22274. * @returns the object VertexData associated to the passed mesh
  22275. */
  22276. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22277. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  22278. /**
  22279. * Creates the VertexData for a Ribbon
  22280. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22281. * * pathArray array of paths, each of which an array of successive Vector3
  22282. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22283. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22284. * * 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
  22285. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22286. * * 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)
  22287. * * 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)
  22288. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22289. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22290. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22291. * @returns the VertexData of the ribbon
  22292. */
  22293. static CreateRibbon(options: {
  22294. pathArray: Vector3[][];
  22295. closeArray?: boolean;
  22296. closePath?: boolean;
  22297. offset?: number;
  22298. sideOrientation?: number;
  22299. frontUVs?: Vector4;
  22300. backUVs?: Vector4;
  22301. invertUV?: boolean;
  22302. uvs?: Vector2[];
  22303. colors?: Color4[];
  22304. }): VertexData;
  22305. /**
  22306. * Creates the VertexData for a box
  22307. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22308. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22309. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22310. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22311. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22312. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22313. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22314. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22315. * * 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)
  22316. * * 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)
  22317. * @returns the VertexData of the box
  22318. */
  22319. static CreateBox(options: {
  22320. size?: number;
  22321. width?: number;
  22322. height?: number;
  22323. depth?: number;
  22324. faceUV?: Vector4[];
  22325. faceColors?: Color4[];
  22326. sideOrientation?: number;
  22327. frontUVs?: Vector4;
  22328. backUVs?: Vector4;
  22329. }): VertexData;
  22330. /**
  22331. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22333. * * segments sets the number of horizontal strips optional, default 32
  22334. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22335. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22336. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22337. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22338. * * 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
  22339. * * 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
  22340. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22341. * * 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)
  22342. * * 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)
  22343. * @returns the VertexData of the ellipsoid
  22344. */
  22345. static CreateSphere(options: {
  22346. segments?: number;
  22347. diameter?: number;
  22348. diameterX?: number;
  22349. diameterY?: number;
  22350. diameterZ?: number;
  22351. arc?: number;
  22352. slice?: number;
  22353. sideOrientation?: number;
  22354. frontUVs?: Vector4;
  22355. backUVs?: Vector4;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a cylinder, cone or prism
  22359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22360. * * height sets the height (y direction) of the cylinder, optional, default 2
  22361. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22362. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22363. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22364. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22365. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22366. * * 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
  22367. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22368. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22369. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22370. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22371. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22372. * * 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)
  22373. * * 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)
  22374. * @returns the VertexData of the cylinder, cone or prism
  22375. */
  22376. static CreateCylinder(options: {
  22377. height?: number;
  22378. diameterTop?: number;
  22379. diameterBottom?: number;
  22380. diameter?: number;
  22381. tessellation?: number;
  22382. subdivisions?: number;
  22383. arc?: number;
  22384. faceColors?: Color4[];
  22385. faceUV?: Vector4[];
  22386. hasRings?: boolean;
  22387. enclose?: boolean;
  22388. sideOrientation?: number;
  22389. frontUVs?: Vector4;
  22390. backUVs?: Vector4;
  22391. }): VertexData;
  22392. /**
  22393. * Creates the VertexData for a torus
  22394. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22395. * * diameter the diameter of the torus, optional default 1
  22396. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22397. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22398. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22399. * * 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)
  22400. * * 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)
  22401. * @returns the VertexData of the torus
  22402. */
  22403. static CreateTorus(options: {
  22404. diameter?: number;
  22405. thickness?: number;
  22406. tessellation?: number;
  22407. sideOrientation?: number;
  22408. frontUVs?: Vector4;
  22409. backUVs?: Vector4;
  22410. }): VertexData;
  22411. /**
  22412. * Creates the VertexData of the LineSystem
  22413. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22414. * - lines an array of lines, each line being an array of successive Vector3
  22415. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22416. * @returns the VertexData of the LineSystem
  22417. */
  22418. static CreateLineSystem(options: {
  22419. lines: Vector3[][];
  22420. colors?: Nullable<Color4[][]>;
  22421. }): VertexData;
  22422. /**
  22423. * Create the VertexData for a DashedLines
  22424. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22425. * - points an array successive Vector3
  22426. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22427. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22428. * - dashNb the intended total number of dashes, optional, default 200
  22429. * @returns the VertexData for the DashedLines
  22430. */
  22431. static CreateDashedLines(options: {
  22432. points: Vector3[];
  22433. dashSize?: number;
  22434. gapSize?: number;
  22435. dashNb?: number;
  22436. }): VertexData;
  22437. /**
  22438. * Creates the VertexData for a Ground
  22439. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22440. * - width the width (x direction) of the ground, optional, default 1
  22441. * - height the height (z direction) of the ground, optional, default 1
  22442. * - subdivisions the number of subdivisions per side, optional, default 1
  22443. * @returns the VertexData of the Ground
  22444. */
  22445. static CreateGround(options: {
  22446. width?: number;
  22447. height?: number;
  22448. subdivisions?: number;
  22449. subdivisionsX?: number;
  22450. subdivisionsY?: number;
  22451. }): VertexData;
  22452. /**
  22453. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22454. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22455. * * xmin the ground minimum X coordinate, optional, default -1
  22456. * * zmin the ground minimum Z coordinate, optional, default -1
  22457. * * xmax the ground maximum X coordinate, optional, default 1
  22458. * * zmax the ground maximum Z coordinate, optional, default 1
  22459. * * 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}
  22460. * * 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}
  22461. * @returns the VertexData of the TiledGround
  22462. */
  22463. static CreateTiledGround(options: {
  22464. xmin: number;
  22465. zmin: number;
  22466. xmax: number;
  22467. zmax: number;
  22468. subdivisions?: {
  22469. w: number;
  22470. h: number;
  22471. };
  22472. precision?: {
  22473. w: number;
  22474. h: number;
  22475. };
  22476. }): VertexData;
  22477. /**
  22478. * Creates the VertexData of the Ground designed from a heightmap
  22479. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22480. * * width the width (x direction) of the ground
  22481. * * height the height (z direction) of the ground
  22482. * * subdivisions the number of subdivisions per side
  22483. * * minHeight the minimum altitude on the ground, optional, default 0
  22484. * * maxHeight the maximum altitude on the ground, optional default 1
  22485. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22486. * * buffer the array holding the image color data
  22487. * * bufferWidth the width of image
  22488. * * bufferHeight the height of image
  22489. * @returns the VertexData of the Ground designed from a heightmap
  22490. */
  22491. static CreateGroundFromHeightMap(options: {
  22492. width: number;
  22493. height: number;
  22494. subdivisions: number;
  22495. minHeight: number;
  22496. maxHeight: number;
  22497. colorFilter: Color3;
  22498. buffer: Uint8Array;
  22499. bufferWidth: number;
  22500. bufferHeight: number;
  22501. }): VertexData;
  22502. /**
  22503. * Creates the VertexData for a Plane
  22504. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22505. * * size sets the width and height of the plane to the value of size, optional default 1
  22506. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22507. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22508. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22509. * * 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)
  22510. * * 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)
  22511. * @returns the VertexData of the box
  22512. */
  22513. static CreatePlane(options: {
  22514. size?: number;
  22515. width?: number;
  22516. height?: number;
  22517. sideOrientation?: number;
  22518. frontUVs?: Vector4;
  22519. backUVs?: Vector4;
  22520. }): VertexData;
  22521. /**
  22522. * Creates the VertexData of the Disc or regular Polygon
  22523. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22524. * * radius the radius of the disc, optional default 0.5
  22525. * * tessellation the number of polygon sides, optional, default 64
  22526. * * 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
  22527. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the box
  22531. */
  22532. static CreateDisc(options: {
  22533. radius?: number;
  22534. tessellation?: number;
  22535. arc?: number;
  22536. sideOrientation?: number;
  22537. frontUVs?: Vector4;
  22538. backUVs?: Vector4;
  22539. }): VertexData;
  22540. /**
  22541. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22542. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22543. * @param polygon a mesh built from polygonTriangulation.build()
  22544. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22545. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22546. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22547. * @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)
  22548. * @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)
  22549. * @returns the VertexData of the Polygon
  22550. */
  22551. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22552. /**
  22553. * Creates the VertexData of the IcoSphere
  22554. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22555. * * radius the radius of the IcoSphere, optional default 1
  22556. * * radiusX allows stretching in the x direction, optional, default radius
  22557. * * radiusY allows stretching in the y direction, optional, default radius
  22558. * * radiusZ allows stretching in the z direction, optional, default radius
  22559. * * flat when true creates a flat shaded mesh, optional, default true
  22560. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22561. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22562. * * 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)
  22563. * * 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)
  22564. * @returns the VertexData of the IcoSphere
  22565. */
  22566. static CreateIcoSphere(options: {
  22567. radius?: number;
  22568. radiusX?: number;
  22569. radiusY?: number;
  22570. radiusZ?: number;
  22571. flat?: boolean;
  22572. subdivisions?: number;
  22573. sideOrientation?: number;
  22574. frontUVs?: Vector4;
  22575. backUVs?: Vector4;
  22576. }): VertexData;
  22577. /**
  22578. * Creates the VertexData for a Polyhedron
  22579. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22580. * * type provided types are:
  22581. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22582. * * 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)
  22583. * * size the size of the IcoSphere, optional default 1
  22584. * * sizeX allows stretching in the x direction, optional, default size
  22585. * * sizeY allows stretching in the y direction, optional, default size
  22586. * * sizeZ allows stretching in the z direction, optional, default size
  22587. * * 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
  22588. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22589. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22590. * * flat when true creates a flat shaded mesh, optional, default true
  22591. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22592. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22593. * * 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)
  22594. * * 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)
  22595. * @returns the VertexData of the Polyhedron
  22596. */
  22597. static CreatePolyhedron(options: {
  22598. type?: number;
  22599. size?: number;
  22600. sizeX?: number;
  22601. sizeY?: number;
  22602. sizeZ?: number;
  22603. custom?: any;
  22604. faceUV?: Vector4[];
  22605. faceColors?: Color4[];
  22606. flat?: boolean;
  22607. sideOrientation?: number;
  22608. frontUVs?: Vector4;
  22609. backUVs?: Vector4;
  22610. }): VertexData;
  22611. /**
  22612. * Creates the VertexData for a TorusKnot
  22613. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22614. * * radius the radius of the torus knot, optional, default 2
  22615. * * tube the thickness of the tube, optional, default 0.5
  22616. * * radialSegments the number of sides on each tube segments, optional, default 32
  22617. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22618. * * p the number of windings around the z axis, optional, default 2
  22619. * * q the number of windings around the x axis, optional, default 3
  22620. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22621. * * 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)
  22622. * * 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)
  22623. * @returns the VertexData of the Torus Knot
  22624. */
  22625. static CreateTorusKnot(options: {
  22626. radius?: number;
  22627. tube?: number;
  22628. radialSegments?: number;
  22629. tubularSegments?: number;
  22630. p?: number;
  22631. q?: number;
  22632. sideOrientation?: number;
  22633. frontUVs?: Vector4;
  22634. backUVs?: Vector4;
  22635. }): VertexData;
  22636. /**
  22637. * Compute normals for given positions and indices
  22638. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22639. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22640. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22641. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22642. * * facetNormals : optional array of facet normals (vector3)
  22643. * * facetPositions : optional array of facet positions (vector3)
  22644. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22645. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22646. * * bInfo : optional bounding info, required for facetPartitioning computation
  22647. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22648. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22649. * * useRightHandedSystem: optional boolean to for right handed system computation
  22650. * * depthSort : optional boolean to enable the facet depth sort computation
  22651. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22652. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22653. */
  22654. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22655. facetNormals?: any;
  22656. facetPositions?: any;
  22657. facetPartitioning?: any;
  22658. ratio?: number;
  22659. bInfo?: any;
  22660. bbSize?: Vector3;
  22661. subDiv?: any;
  22662. useRightHandedSystem?: boolean;
  22663. depthSort?: boolean;
  22664. distanceTo?: Vector3;
  22665. depthSortedFacets?: any;
  22666. }): void;
  22667. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22668. /**
  22669. * Applies VertexData created from the imported parameters to the geometry
  22670. * @param parsedVertexData the parsed data from an imported file
  22671. * @param geometry the geometry to apply the VertexData to
  22672. */
  22673. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22674. }
  22675. }
  22676. declare module BABYLON {
  22677. /**
  22678. * Class containing static functions to help procedurally build meshes
  22679. */
  22680. class MeshBuilder {
  22681. private static updateSideOrientation(orientation?);
  22682. /**
  22683. * Creates a box mesh
  22684. * * The parameter `size` sets the size (float) of each box side (default 1)
  22685. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22686. * * 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)
  22687. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22689. * * 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
  22690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22691. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22692. * @param name defines the name of the mesh
  22693. * @param options defines the options used to create the mesh
  22694. * @param scene defines the hosting scene
  22695. * @returns the box mesh
  22696. */
  22697. static CreateBox(name: string, options: {
  22698. size?: number;
  22699. width?: number;
  22700. height?: number;
  22701. depth?: number;
  22702. faceUV?: Vector4[];
  22703. faceColors?: Color4[];
  22704. sideOrientation?: number;
  22705. frontUVs?: Vector4;
  22706. backUVs?: Vector4;
  22707. updatable?: boolean;
  22708. }, scene?: Nullable<Scene>): Mesh;
  22709. /**
  22710. * Creates a sphere mesh
  22711. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22712. * * 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`)
  22713. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22714. * * 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
  22715. * * 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)
  22716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22717. * * 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
  22718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22719. * @param name defines the name of the mesh
  22720. * @param options defines the options used to create the mesh
  22721. * @param scene defines the hosting scene
  22722. * @returns the sphere mesh
  22723. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22724. */
  22725. static CreateSphere(name: string, options: {
  22726. segments?: number;
  22727. diameter?: number;
  22728. diameterX?: number;
  22729. diameterY?: number;
  22730. diameterZ?: number;
  22731. arc?: number;
  22732. slice?: number;
  22733. sideOrientation?: number;
  22734. frontUVs?: Vector4;
  22735. backUVs?: Vector4;
  22736. updatable?: boolean;
  22737. }, scene: any): Mesh;
  22738. /**
  22739. * Creates a plane polygonal mesh. By default, this is a disc
  22740. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22741. * * 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
  22742. * * 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
  22743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22744. * * 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
  22745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22746. * @param name defines the name of the mesh
  22747. * @param options defines the options used to create the mesh
  22748. * @param scene defines the hosting scene
  22749. * @returns the plane polygonal mesh
  22750. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22751. */
  22752. static CreateDisc(name: string, options: {
  22753. radius?: number;
  22754. tessellation?: number;
  22755. arc?: number;
  22756. updatable?: boolean;
  22757. sideOrientation?: number;
  22758. frontUVs?: Vector4;
  22759. backUVs?: Vector4;
  22760. }, scene?: Nullable<Scene>): Mesh;
  22761. /**
  22762. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22763. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22764. * * 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`)
  22765. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22766. * * 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
  22767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22768. * * 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
  22769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22770. * @param name defines the name of the mesh
  22771. * @param options defines the options used to create the mesh
  22772. * @param scene defines the hosting scene
  22773. * @returns the icosahedron mesh
  22774. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22775. */
  22776. static CreateIcoSphere(name: string, options: {
  22777. radius?: number;
  22778. radiusX?: number;
  22779. radiusY?: number;
  22780. radiusZ?: number;
  22781. flat?: boolean;
  22782. subdivisions?: number;
  22783. sideOrientation?: number;
  22784. frontUVs?: Vector4;
  22785. backUVs?: Vector4;
  22786. updatable?: boolean;
  22787. }, scene: Scene): Mesh;
  22788. /**
  22789. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22790. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22791. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22792. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22793. * * 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
  22794. * * 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
  22795. * * 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
  22796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22797. * * 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
  22798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22799. * * 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
  22800. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22801. * * 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
  22802. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22804. * @param name defines the name of the mesh
  22805. * @param options defines the options used to create the mesh
  22806. * @param scene defines the hosting scene
  22807. * @returns the ribbon mesh
  22808. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22809. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22810. */
  22811. static CreateRibbon(name: string, options: {
  22812. pathArray: Vector3[][];
  22813. closeArray?: boolean;
  22814. closePath?: boolean;
  22815. offset?: number;
  22816. updatable?: boolean;
  22817. sideOrientation?: number;
  22818. frontUVs?: Vector4;
  22819. backUVs?: Vector4;
  22820. instance?: Mesh;
  22821. invertUV?: boolean;
  22822. uvs?: Vector2[];
  22823. colors?: Color4[];
  22824. }, scene?: Nullable<Scene>): Mesh;
  22825. /**
  22826. * Creates a cylinder or a cone mesh
  22827. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22828. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22829. * * 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.
  22830. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22831. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22832. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22833. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22834. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22835. * * 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).
  22836. * * 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
  22837. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22838. * * 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
  22839. * * 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.
  22840. * * If `enclose` is false, a ring surface is one element.
  22841. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22842. * * 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
  22843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22844. * * 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
  22845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22846. * @param name defines the name of the mesh
  22847. * @param options defines the options used to create the mesh
  22848. * @param scene defines the hosting scene
  22849. * @returns the cylinder mesh
  22850. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22851. */
  22852. static CreateCylinder(name: string, options: {
  22853. height?: number;
  22854. diameterTop?: number;
  22855. diameterBottom?: number;
  22856. diameter?: number;
  22857. tessellation?: number;
  22858. subdivisions?: number;
  22859. arc?: number;
  22860. faceColors?: Color4[];
  22861. faceUV?: Vector4[];
  22862. updatable?: boolean;
  22863. hasRings?: boolean;
  22864. enclose?: boolean;
  22865. sideOrientation?: number;
  22866. frontUVs?: Vector4;
  22867. backUVs?: Vector4;
  22868. }, scene: any): Mesh;
  22869. /**
  22870. * Creates a torus mesh
  22871. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22872. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22873. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22875. * * 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
  22876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22877. * @param name defines the name of the mesh
  22878. * @param options defines the options used to create the mesh
  22879. * @param scene defines the hosting scene
  22880. * @returns the torus mesh
  22881. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22882. */
  22883. static CreateTorus(name: string, options: {
  22884. diameter?: number;
  22885. thickness?: number;
  22886. tessellation?: number;
  22887. updatable?: boolean;
  22888. sideOrientation?: number;
  22889. frontUVs?: Vector4;
  22890. backUVs?: Vector4;
  22891. }, scene: any): Mesh;
  22892. /**
  22893. * Creates a torus knot mesh
  22894. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22895. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22896. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22897. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22899. * * 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
  22900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22901. * @param name defines the name of the mesh
  22902. * @param options defines the options used to create the mesh
  22903. * @param scene defines the hosting scene
  22904. * @returns the torus knot mesh
  22905. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22906. */
  22907. static CreateTorusKnot(name: string, options: {
  22908. radius?: number;
  22909. tube?: number;
  22910. radialSegments?: number;
  22911. tubularSegments?: number;
  22912. p?: number;
  22913. q?: number;
  22914. updatable?: boolean;
  22915. sideOrientation?: number;
  22916. frontUVs?: Vector4;
  22917. backUVs?: Vector4;
  22918. }, scene: any): Mesh;
  22919. /**
  22920. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22921. * * 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
  22922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22923. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22924. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22925. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22926. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22927. * * 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
  22928. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22930. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22931. * @param name defines the name of the new line system
  22932. * @param options defines the options used to create the line system
  22933. * @param scene defines the hosting scene
  22934. * @returns a new line system mesh
  22935. */
  22936. static CreateLineSystem(name: string, options: {
  22937. lines: Vector3[][];
  22938. updatable?: boolean;
  22939. instance?: Nullable<LinesMesh>;
  22940. colors?: Nullable<Color4[][]>;
  22941. useVertexAlpha?: boolean;
  22942. }, scene: Nullable<Scene>): LinesMesh;
  22943. /**
  22944. * Creates a line mesh
  22945. * 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
  22946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22947. * * The parameter `points` is an array successive Vector3
  22948. * * 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
  22949. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22950. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22951. * * When updating an instance, remember that only point positions can change, not the number of points
  22952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22953. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22954. * @param name defines the name of the new line system
  22955. * @param options defines the options used to create the line system
  22956. * @param scene defines the hosting scene
  22957. * @returns a new line mesh
  22958. */
  22959. static CreateLines(name: string, options: {
  22960. points: Vector3[];
  22961. updatable?: boolean;
  22962. instance?: Nullable<LinesMesh>;
  22963. colors?: Color4[];
  22964. useVertexAlpha?: boolean;
  22965. }, scene?: Nullable<Scene>): LinesMesh;
  22966. /**
  22967. * Creates a dashed line mesh
  22968. * * 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
  22969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22970. * * The parameter `points` is an array successive Vector3
  22971. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22972. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22973. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22974. * * 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
  22975. * * When updating an instance, remember that only point positions can change, not the number of points
  22976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22977. * @param name defines the name of the mesh
  22978. * @param options defines the options used to create the mesh
  22979. * @param scene defines the hosting scene
  22980. * @returns the dashed line mesh
  22981. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22982. */
  22983. static CreateDashedLines(name: string, options: {
  22984. points: Vector3[];
  22985. dashSize?: number;
  22986. gapSize?: number;
  22987. dashNb?: number;
  22988. updatable?: boolean;
  22989. instance?: LinesMesh;
  22990. }, scene?: Nullable<Scene>): LinesMesh;
  22991. /**
  22992. * 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.
  22993. * * 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.
  22994. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22995. * * 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.
  22996. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22997. * * 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
  22998. * * 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
  22999. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23001. * * 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
  23002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23004. * @param name defines the name of the mesh
  23005. * @param options defines the options used to create the mesh
  23006. * @param scene defines the hosting scene
  23007. * @returns the extruded shape mesh
  23008. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23009. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23010. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23011. */
  23012. static ExtrudeShape(name: string, options: {
  23013. shape: Vector3[];
  23014. path: Vector3[];
  23015. scale?: number;
  23016. rotation?: number;
  23017. cap?: number;
  23018. updatable?: boolean;
  23019. sideOrientation?: number;
  23020. frontUVs?: Vector4;
  23021. backUVs?: Vector4;
  23022. instance?: Mesh;
  23023. invertUV?: boolean;
  23024. }, scene?: Nullable<Scene>): Mesh;
  23025. /**
  23026. * Creates an custom extruded shape mesh.
  23027. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23028. * * 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.
  23029. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23030. * * 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
  23031. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23032. * * 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
  23033. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23034. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23035. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23036. * * 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
  23037. * * 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
  23038. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23040. * * 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
  23041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23043. * @param name defines the name of the mesh
  23044. * @param options defines the options used to create the mesh
  23045. * @param scene defines the hosting scene
  23046. * @returns the custom extruded shape mesh
  23047. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23048. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23049. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23050. */
  23051. static ExtrudeShapeCustom(name: string, options: {
  23052. shape: Vector3[];
  23053. path: Vector3[];
  23054. scaleFunction?: any;
  23055. rotationFunction?: any;
  23056. ribbonCloseArray?: boolean;
  23057. ribbonClosePath?: boolean;
  23058. cap?: number;
  23059. updatable?: boolean;
  23060. sideOrientation?: number;
  23061. frontUVs?: Vector4;
  23062. backUVs?: Vector4;
  23063. instance?: Mesh;
  23064. invertUV?: boolean;
  23065. }, scene: Scene): Mesh;
  23066. /**
  23067. * Creates lathe mesh.
  23068. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23069. * * 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
  23070. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23071. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23072. * * 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
  23073. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23074. * * 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
  23075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23076. * * 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
  23077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23079. * @param name defines the name of the mesh
  23080. * @param options defines the options used to create the mesh
  23081. * @param scene defines the hosting scene
  23082. * @returns the lathe mesh
  23083. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23084. */
  23085. static CreateLathe(name: string, options: {
  23086. shape: Vector3[];
  23087. radius?: number;
  23088. tessellation?: number;
  23089. arc?: number;
  23090. closed?: boolean;
  23091. updatable?: boolean;
  23092. sideOrientation?: number;
  23093. frontUVs?: Vector4;
  23094. backUVs?: Vector4;
  23095. cap?: number;
  23096. invertUV?: boolean;
  23097. }, scene: Scene): Mesh;
  23098. /**
  23099. * Creates a plane mesh
  23100. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23101. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23102. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23104. * * 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
  23105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23106. * @param name defines the name of the mesh
  23107. * @param options defines the options used to create the mesh
  23108. * @param scene defines the hosting scene
  23109. * @returns the plane mesh
  23110. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23111. */
  23112. static CreatePlane(name: string, options: {
  23113. size?: number;
  23114. width?: number;
  23115. height?: number;
  23116. sideOrientation?: number;
  23117. frontUVs?: Vector4;
  23118. backUVs?: Vector4;
  23119. updatable?: boolean;
  23120. sourcePlane?: Plane;
  23121. }, scene: Scene): Mesh;
  23122. /**
  23123. * Creates a ground mesh
  23124. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23125. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23127. * @param name defines the name of the mesh
  23128. * @param options defines the options used to create the mesh
  23129. * @param scene defines the hosting scene
  23130. * @returns the ground mesh
  23131. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23132. */
  23133. static CreateGround(name: string, options: {
  23134. width?: number;
  23135. height?: number;
  23136. subdivisions?: number;
  23137. subdivisionsX?: number;
  23138. subdivisionsY?: number;
  23139. updatable?: boolean;
  23140. }, scene: any): Mesh;
  23141. /**
  23142. * Creates a tiled ground mesh
  23143. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23144. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23145. * * 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
  23146. * * 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
  23147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23148. * @param name defines the name of the mesh
  23149. * @param options defines the options used to create the mesh
  23150. * @param scene defines the hosting scene
  23151. * @returns the tiled ground mesh
  23152. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23153. */
  23154. static CreateTiledGround(name: string, options: {
  23155. xmin: number;
  23156. zmin: number;
  23157. xmax: number;
  23158. zmax: number;
  23159. subdivisions?: {
  23160. w: number;
  23161. h: number;
  23162. };
  23163. precision?: {
  23164. w: number;
  23165. h: number;
  23166. };
  23167. updatable?: boolean;
  23168. }, scene: Scene): Mesh;
  23169. /**
  23170. * Creates a ground mesh from a height map
  23171. * * The parameter `url` sets the URL of the height map image resource.
  23172. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23173. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23174. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23175. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23176. * * 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.
  23177. * * 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).
  23178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23179. * @param name defines the name of the mesh
  23180. * @param url defines the url to the height map
  23181. * @param options defines the options used to create the mesh
  23182. * @param scene defines the hosting scene
  23183. * @returns the ground mesh
  23184. * @see http://doc.babylonjs.com/babylon101/height_map
  23185. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23186. */
  23187. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23188. width?: number;
  23189. height?: number;
  23190. subdivisions?: number;
  23191. minHeight?: number;
  23192. maxHeight?: number;
  23193. colorFilter?: Color3;
  23194. updatable?: boolean;
  23195. onReady?: (mesh: GroundMesh) => void;
  23196. }, scene: Scene): GroundMesh;
  23197. /**
  23198. * Creates a polygon mesh
  23199. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23200. * * 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
  23201. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23203. * * 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)
  23204. * * Remember you can only change the shape positions, not their number when updating a polygon
  23205. * @param name defines the name of the mesh
  23206. * @param options defines the options used to create the mesh
  23207. * @param scene defines the hosting scene
  23208. * @returns the polygon mesh
  23209. */
  23210. static CreatePolygon(name: string, options: {
  23211. shape: Vector3[];
  23212. holes?: Vector3[][];
  23213. depth?: number;
  23214. faceUV?: Vector4[];
  23215. faceColors?: Color4[];
  23216. updatable?: boolean;
  23217. sideOrientation?: number;
  23218. frontUVs?: Vector4;
  23219. backUVs?: Vector4;
  23220. }, scene: Scene): Mesh;
  23221. /**
  23222. * Creates an extruded polygon mesh, with depth in the Y direction.
  23223. * * 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)
  23224. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23225. * @param name defines the name of the mesh
  23226. * @param options defines the options used to create the mesh
  23227. * @param scene defines the hosting scene
  23228. * @returns the polygon mesh
  23229. */
  23230. static ExtrudePolygon(name: string, options: {
  23231. shape: Vector3[];
  23232. holes?: Vector3[][];
  23233. depth?: number;
  23234. faceUV?: Vector4[];
  23235. faceColors?: Color4[];
  23236. updatable?: boolean;
  23237. sideOrientation?: number;
  23238. frontUVs?: Vector4;
  23239. backUVs?: Vector4;
  23240. }, scene: Scene): Mesh;
  23241. /**
  23242. * Creates a tube mesh.
  23243. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23244. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23245. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23246. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23247. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23248. * * 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)
  23249. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23250. * * 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
  23251. * * 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
  23252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23253. * * 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
  23254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23256. * @param name defines the name of the mesh
  23257. * @param options defines the options used to create the mesh
  23258. * @param scene defines the hosting scene
  23259. * @returns the tube mesh
  23260. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23261. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23262. */
  23263. static CreateTube(name: string, options: {
  23264. path: Vector3[];
  23265. radius?: number;
  23266. tessellation?: number;
  23267. radiusFunction?: {
  23268. (i: number, distance: number): number;
  23269. };
  23270. cap?: number;
  23271. arc?: number;
  23272. updatable?: boolean;
  23273. sideOrientation?: number;
  23274. frontUVs?: Vector4;
  23275. backUVs?: Vector4;
  23276. instance?: Mesh;
  23277. invertUV?: boolean;
  23278. }, scene: Scene): Mesh;
  23279. /**
  23280. * Creates a polyhedron mesh
  23281. * * 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
  23282. * * The parameter `size` (positive float, default 1) sets the polygon size
  23283. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23284. * * 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`
  23285. * * 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
  23286. * * 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)`)
  23287. * * 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
  23288. * * 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
  23289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23290. * * 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
  23291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23292. * @param name defines the name of the mesh
  23293. * @param options defines the options used to create the mesh
  23294. * @param scene defines the hosting scene
  23295. * @returns the polyhedron mesh
  23296. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23297. */
  23298. static CreatePolyhedron(name: string, options: {
  23299. type?: number;
  23300. size?: number;
  23301. sizeX?: number;
  23302. sizeY?: number;
  23303. sizeZ?: number;
  23304. custom?: any;
  23305. faceUV?: Vector4[];
  23306. faceColors?: Color4[];
  23307. flat?: boolean;
  23308. updatable?: boolean;
  23309. sideOrientation?: number;
  23310. frontUVs?: Vector4;
  23311. backUVs?: Vector4;
  23312. }, scene: Scene): Mesh;
  23313. /**
  23314. * Creates a decal mesh.
  23315. * 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
  23316. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23317. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23318. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23319. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23320. * @param name defines the name of the mesh
  23321. * @param sourceMesh defines the mesh where the decal must be applied
  23322. * @param options defines the options used to create the mesh
  23323. * @param scene defines the hosting scene
  23324. * @returns the decal mesh
  23325. * @see http://doc.babylonjs.com/how_to/decals
  23326. */
  23327. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23328. position?: Vector3;
  23329. normal?: Vector3;
  23330. size?: Vector3;
  23331. angle?: number;
  23332. }): Mesh;
  23333. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  23334. }
  23335. }
  23336. declare module BABYLON {
  23337. class MeshLODLevel {
  23338. distance: number;
  23339. mesh: Mesh;
  23340. constructor(distance: number, mesh: Mesh);
  23341. }
  23342. }
  23343. declare module BABYLON {
  23344. /**
  23345. * A simplifier interface for future simplification implementations.
  23346. */
  23347. interface ISimplifier {
  23348. /**
  23349. * Simplification of a given mesh according to the given settings.
  23350. * Since this requires computation, it is assumed that the function runs async.
  23351. * @param settings The settings of the simplification, including quality and distance
  23352. * @param successCallback A callback that will be called after the mesh was simplified.
  23353. * @param errorCallback in case of an error, this callback will be called. optional.
  23354. */
  23355. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23356. }
  23357. /**
  23358. * Expected simplification settings.
  23359. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23360. */
  23361. interface ISimplificationSettings {
  23362. quality: number;
  23363. distance: number;
  23364. optimizeMesh?: boolean;
  23365. }
  23366. class SimplificationSettings implements ISimplificationSettings {
  23367. quality: number;
  23368. distance: number;
  23369. optimizeMesh: boolean | undefined;
  23370. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23371. }
  23372. interface ISimplificationTask {
  23373. settings: Array<ISimplificationSettings>;
  23374. simplificationType: SimplificationType;
  23375. mesh: Mesh;
  23376. successCallback?: () => void;
  23377. parallelProcessing: boolean;
  23378. }
  23379. class SimplificationQueue {
  23380. private _simplificationArray;
  23381. running: boolean;
  23382. constructor();
  23383. addTask(task: ISimplificationTask): void;
  23384. executeNext(): void;
  23385. runSimplification(task: ISimplificationTask): void;
  23386. private getSimplifier(task);
  23387. }
  23388. /**
  23389. * The implemented types of simplification
  23390. * At the moment only Quadratic Error Decimation is implemented
  23391. */
  23392. enum SimplificationType {
  23393. /** Quadratic error decimation */
  23394. QUADRATIC = 0,
  23395. }
  23396. class DecimationTriangle {
  23397. vertices: Array<DecimationVertex>;
  23398. normal: Vector3;
  23399. error: Array<number>;
  23400. deleted: boolean;
  23401. isDirty: boolean;
  23402. borderFactor: number;
  23403. deletePending: boolean;
  23404. originalOffset: number;
  23405. constructor(vertices: Array<DecimationVertex>);
  23406. }
  23407. class DecimationVertex {
  23408. position: Vector3;
  23409. id: number;
  23410. q: QuadraticMatrix;
  23411. isBorder: boolean;
  23412. triangleStart: number;
  23413. triangleCount: number;
  23414. originalOffsets: Array<number>;
  23415. constructor(position: Vector3, id: number);
  23416. updatePosition(newPosition: Vector3): void;
  23417. }
  23418. class QuadraticMatrix {
  23419. data: Array<number>;
  23420. constructor(data?: Array<number>);
  23421. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23422. addInPlace(matrix: QuadraticMatrix): void;
  23423. addArrayInPlace(data: Array<number>): void;
  23424. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23425. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23426. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23427. }
  23428. class Reference {
  23429. vertexId: number;
  23430. triangleId: number;
  23431. constructor(vertexId: number, triangleId: number);
  23432. }
  23433. /**
  23434. * An implementation of the Quadratic Error simplification algorithm.
  23435. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23436. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23437. * @author RaananW
  23438. */
  23439. class QuadraticErrorSimplification implements ISimplifier {
  23440. private _mesh;
  23441. private triangles;
  23442. private vertices;
  23443. private references;
  23444. private _reconstructedMesh;
  23445. syncIterations: number;
  23446. aggressiveness: number;
  23447. decimationIterations: number;
  23448. boundingBoxEpsilon: number;
  23449. constructor(_mesh: Mesh);
  23450. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23451. private runDecimation(settings, submeshIndex, successCallback);
  23452. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  23453. private init(callback);
  23454. private reconstructMesh(submeshIndex);
  23455. private initDecimatedMesh();
  23456. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  23457. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  23458. private identifyBorder();
  23459. private updateMesh(identifyBorders?);
  23460. private vertexError(q, point);
  23461. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  23462. }
  23463. }
  23464. declare module BABYLON {
  23465. class Polygon {
  23466. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23467. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23468. static Parse(input: string): Vector2[];
  23469. static StartingAt(x: number, y: number): Path2;
  23470. }
  23471. class PolygonMeshBuilder {
  23472. private _points;
  23473. private _outlinepoints;
  23474. private _holes;
  23475. private _name;
  23476. private _scene;
  23477. private _epoints;
  23478. private _eholes;
  23479. private _addToepoint(points);
  23480. constructor(name: string, contours: Path2, scene: Scene);
  23481. constructor(name: string, contours: Vector2[], scene: Scene);
  23482. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23483. build(updatable?: boolean, depth?: number): Mesh;
  23484. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  23485. }
  23486. }
  23487. declare module BABYLON {
  23488. class BaseSubMesh {
  23489. _materialDefines: Nullable<MaterialDefines>;
  23490. _materialEffect: Nullable<Effect>;
  23491. readonly effect: Nullable<Effect>;
  23492. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23493. }
  23494. class SubMesh extends BaseSubMesh implements ICullable {
  23495. materialIndex: number;
  23496. verticesStart: number;
  23497. verticesCount: number;
  23498. indexStart: number;
  23499. indexCount: number;
  23500. linesIndexCount: number;
  23501. private _mesh;
  23502. private _renderingMesh;
  23503. private _boundingInfo;
  23504. private _linesIndexBuffer;
  23505. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23506. _trianglePlanes: Plane[];
  23507. _lastColliderTransformMatrix: Matrix;
  23508. _renderId: number;
  23509. _alphaIndex: number;
  23510. _distanceToCamera: number;
  23511. _id: number;
  23512. private _currentMaterial;
  23513. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23514. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23515. readonly IsGlobal: boolean;
  23516. /**
  23517. * Returns the submesh BoudingInfo object.
  23518. */
  23519. getBoundingInfo(): BoundingInfo;
  23520. /**
  23521. * Sets the submesh BoundingInfo.
  23522. * Return the SubMesh.
  23523. */
  23524. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23525. /**
  23526. * Returns the mesh of the current submesh.
  23527. */
  23528. getMesh(): AbstractMesh;
  23529. /**
  23530. * Returns the rendering mesh of the submesh.
  23531. */
  23532. getRenderingMesh(): Mesh;
  23533. /**
  23534. * Returns the submesh material.
  23535. */
  23536. getMaterial(): Nullable<Material>;
  23537. /**
  23538. * Sets a new updated BoundingInfo object to the submesh.
  23539. * Returns the SubMesh.
  23540. */
  23541. refreshBoundingInfo(): SubMesh;
  23542. _checkCollision(collider: Collider): boolean;
  23543. /**
  23544. * Updates the submesh BoundingInfo.
  23545. * Returns the Submesh.
  23546. */
  23547. updateBoundingInfo(world: Matrix): SubMesh;
  23548. /**
  23549. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23550. * Boolean returned.
  23551. */
  23552. isInFrustum(frustumPlanes: Plane[]): boolean;
  23553. /**
  23554. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23555. * Boolean returned.
  23556. */
  23557. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23558. /**
  23559. * Renders the submesh.
  23560. * Returns it.
  23561. */
  23562. render(enableAlphaMode: boolean): SubMesh;
  23563. /**
  23564. * Returns a new Index Buffer.
  23565. * Type returned : WebGLBuffer.
  23566. */
  23567. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23568. /**
  23569. * True is the passed Ray intersects the submesh bounding box.
  23570. * Boolean returned.
  23571. */
  23572. canIntersects(ray: Ray): boolean;
  23573. /**
  23574. * Returns an object IntersectionInfo.
  23575. */
  23576. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23577. _rebuild(): void;
  23578. /**
  23579. * Creates a new Submesh from the passed Mesh.
  23580. */
  23581. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23582. /**
  23583. * Disposes the Submesh.
  23584. * Returns nothing.
  23585. */
  23586. dispose(): void;
  23587. /**
  23588. * Creates a new Submesh from the passed parameters :
  23589. * - materialIndex (integer) : the index of the main mesh material.
  23590. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23591. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23592. * - mesh (Mesh) : the main mesh to create the submesh from.
  23593. * - renderingMesh (optional Mesh) : rendering mesh.
  23594. */
  23595. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23596. }
  23597. }
  23598. declare module BABYLON {
  23599. class TransformNode extends Node {
  23600. static BILLBOARDMODE_NONE: number;
  23601. static BILLBOARDMODE_X: number;
  23602. static BILLBOARDMODE_Y: number;
  23603. static BILLBOARDMODE_Z: number;
  23604. static BILLBOARDMODE_ALL: number;
  23605. private _forward;
  23606. private _forwardInverted;
  23607. private _up;
  23608. private _right;
  23609. private _rightInverted;
  23610. private _rotation;
  23611. private _rotationQuaternion;
  23612. protected _scaling: Vector3;
  23613. protected _isDirty: boolean;
  23614. private _transformToBoneReferal;
  23615. billboardMode: number;
  23616. scalingDeterminant: number;
  23617. infiniteDistance: boolean;
  23618. position: Vector3;
  23619. _poseMatrix: Matrix;
  23620. private _localWorld;
  23621. _worldMatrix: Matrix;
  23622. _worldMatrixDeterminant: number;
  23623. private _absolutePosition;
  23624. private _pivotMatrix;
  23625. private _pivotMatrixInverse;
  23626. private _postMultiplyPivotMatrix;
  23627. protected _isWorldMatrixFrozen: boolean;
  23628. /**
  23629. * An event triggered after the world matrix is updated
  23630. */
  23631. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23632. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23633. /**
  23634. * Gets a string idenfifying the name of the class
  23635. * @returns "TransformNode" string
  23636. */
  23637. getClassName(): string;
  23638. /**
  23639. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23640. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23641. * Default : (0.0, 0.0, 0.0)
  23642. */
  23643. rotation: Vector3;
  23644. /**
  23645. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23646. * Default : (1.0, 1.0, 1.0)
  23647. */
  23648. /**
  23649. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23650. * Default : (1.0, 1.0, 1.0)
  23651. */
  23652. scaling: Vector3;
  23653. /**
  23654. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23655. * It's null by default.
  23656. * 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)
  23657. */
  23658. rotationQuaternion: Nullable<Quaternion>;
  23659. /**
  23660. * The forward direction of that transform in world space.
  23661. */
  23662. readonly forward: Vector3;
  23663. /**
  23664. * The up direction of that transform in world space.
  23665. */
  23666. readonly up: Vector3;
  23667. /**
  23668. * The right direction of that transform in world space.
  23669. */
  23670. readonly right: Vector3;
  23671. /**
  23672. * Returns the latest update of the World matrix
  23673. * Returns a Matrix.
  23674. */
  23675. getWorldMatrix(): Matrix;
  23676. /** @hidden */
  23677. _getWorldMatrixDeterminant(): number;
  23678. /**
  23679. * Returns directly the latest state of the mesh World matrix.
  23680. * A Matrix is returned.
  23681. */
  23682. readonly worldMatrixFromCache: Matrix;
  23683. /**
  23684. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23685. * Returns the TransformNode.
  23686. */
  23687. updatePoseMatrix(matrix: Matrix): TransformNode;
  23688. /**
  23689. * Returns the mesh Pose matrix.
  23690. * Returned object : Matrix
  23691. */
  23692. getPoseMatrix(): Matrix;
  23693. _isSynchronized(): boolean;
  23694. _initCache(): void;
  23695. markAsDirty(property: string): TransformNode;
  23696. /**
  23697. * Returns the current mesh absolute position.
  23698. * Retuns a Vector3.
  23699. */
  23700. readonly absolutePosition: Vector3;
  23701. /**
  23702. * Sets a new matrix to apply before all other transformation
  23703. * @param matrix defines the transform matrix
  23704. * @returns the current TransformNode
  23705. */
  23706. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23707. /**
  23708. * Sets a new pivot matrix to the current node
  23709. * @param matrix defines the new pivot matrix to use
  23710. * @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
  23711. * @returns the current TransformNode
  23712. */
  23713. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23714. /**
  23715. * Returns the mesh pivot matrix.
  23716. * Default : Identity.
  23717. * A Matrix is returned.
  23718. */
  23719. getPivotMatrix(): Matrix;
  23720. /**
  23721. * Prevents the World matrix to be computed any longer.
  23722. * Returns the TransformNode.
  23723. */
  23724. freezeWorldMatrix(): TransformNode;
  23725. /**
  23726. * Allows back the World matrix computation.
  23727. * Returns the TransformNode.
  23728. */
  23729. unfreezeWorldMatrix(): this;
  23730. /**
  23731. * True if the World matrix has been frozen.
  23732. * Returns a boolean.
  23733. */
  23734. readonly isWorldMatrixFrozen: boolean;
  23735. /**
  23736. * Retuns the mesh absolute position in the World.
  23737. * Returns a Vector3.
  23738. */
  23739. getAbsolutePosition(): Vector3;
  23740. /**
  23741. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23742. * Returns the TransformNode.
  23743. */
  23744. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23745. /**
  23746. * Sets the mesh position in its local space.
  23747. * Returns the TransformNode.
  23748. */
  23749. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23750. /**
  23751. * Returns the mesh position in the local space from the current World matrix values.
  23752. * Returns a new Vector3.
  23753. */
  23754. getPositionExpressedInLocalSpace(): Vector3;
  23755. /**
  23756. * Translates the mesh along the passed Vector3 in its local space.
  23757. * Returns the TransformNode.
  23758. */
  23759. locallyTranslate(vector3: Vector3): TransformNode;
  23760. private static _lookAtVectorCache;
  23761. /**
  23762. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23763. * @param targetPoint the position (must be in same space as current mesh) to look at
  23764. * @param yawCor optional yaw (y-axis) correction in radians
  23765. * @param pitchCor optional pitch (x-axis) correction in radians
  23766. * @param rollCor optional roll (z-axis) correction in radians
  23767. * @param space the choosen space of the target
  23768. * @returns the TransformNode.
  23769. */
  23770. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23771. /**
  23772. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23773. * This Vector3 is expressed in the World space.
  23774. */
  23775. getDirection(localAxis: Vector3): Vector3;
  23776. /**
  23777. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23778. * localAxis is expressed in the mesh local space.
  23779. * result is computed in the Wordl space from the mesh World matrix.
  23780. * Returns the TransformNode.
  23781. */
  23782. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23783. /**
  23784. * Sets a new pivot point to the current node
  23785. * @param point defines the new pivot point to use
  23786. * @param space defines if the point is in world or local space (local by default)
  23787. * @returns the current TransformNode
  23788. */
  23789. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23790. /**
  23791. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23792. */
  23793. getPivotPoint(): Vector3;
  23794. /**
  23795. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23796. * Returns the TransformNode.
  23797. */
  23798. getPivotPointToRef(result: Vector3): TransformNode;
  23799. /**
  23800. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23801. */
  23802. getAbsolutePivotPoint(): Vector3;
  23803. /**
  23804. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23805. * Returns the TransformNode.
  23806. */
  23807. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23808. /**
  23809. * Defines the passed node as the parent of the current node.
  23810. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23811. * Returns the TransformNode.
  23812. */
  23813. setParent(node: Nullable<Node>): TransformNode;
  23814. private _nonUniformScaling;
  23815. readonly nonUniformScaling: boolean;
  23816. _updateNonUniformScalingState(value: boolean): boolean;
  23817. /**
  23818. * Attach the current TransformNode to another TransformNode associated with a bone
  23819. * @param bone Bone affecting the TransformNode
  23820. * @param affectedTransformNode TransformNode associated with the bone
  23821. */
  23822. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23823. detachFromBone(): TransformNode;
  23824. private static _rotationAxisCache;
  23825. /**
  23826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23827. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23828. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23829. * The passed axis is also normalized.
  23830. * Returns the TransformNode.
  23831. */
  23832. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23833. /**
  23834. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23835. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23836. * The passed axis is also normalized.
  23837. * Returns the TransformNode.
  23838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23839. */
  23840. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23841. /**
  23842. * Translates the mesh along the axis vector for the passed distance in the given space.
  23843. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23844. * Returns the TransformNode.
  23845. */
  23846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23847. /**
  23848. * Adds a rotation step to the mesh current rotation.
  23849. * x, y, z are Euler angles expressed in radians.
  23850. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23851. * This means this rotation is made in the mesh local space only.
  23852. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23853. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23854. * ```javascript
  23855. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23856. * ```
  23857. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23858. * 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.
  23859. * Returns the TransformNode.
  23860. */
  23861. addRotation(x: number, y: number, z: number): TransformNode;
  23862. /**
  23863. * Computes the mesh World matrix and returns it.
  23864. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23865. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23866. * If the parameter `force`is set to `true`, the actual computation is done.
  23867. * Returns the mesh World Matrix.
  23868. */
  23869. computeWorldMatrix(force?: boolean): Matrix;
  23870. protected _afterComputeWorldMatrix(): void;
  23871. /**
  23872. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23873. * @param func: callback function to add
  23874. *
  23875. * Returns the TransformNode.
  23876. */
  23877. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23878. /**
  23879. * Removes a registered callback function.
  23880. * Returns the TransformNode.
  23881. */
  23882. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23883. /**
  23884. * Clone the current transform node
  23885. * Returns the new transform node
  23886. * @param name Name of the new clone
  23887. * @param newParent New parent for the clone
  23888. * @param doNotCloneChildren Do not clone children hierarchy
  23889. */
  23890. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23891. serialize(currentSerializationObject?: any): any;
  23892. /**
  23893. * Returns a new TransformNode object parsed from the source provided.
  23894. * The parameter `parsedMesh` is the source.
  23895. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23896. */
  23897. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23898. /**
  23899. * Releases resources associated with this transform node.
  23900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23902. */
  23903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23904. }
  23905. }
  23906. declare module BABYLON {
  23907. class VertexBuffer {
  23908. private _buffer;
  23909. private _kind;
  23910. private _size;
  23911. private _ownsBuffer;
  23912. private _instanced;
  23913. private _instanceDivisor;
  23914. /**
  23915. * The byte type.
  23916. */
  23917. static readonly BYTE: number;
  23918. /**
  23919. * The unsigned byte type.
  23920. */
  23921. static readonly UNSIGNED_BYTE: number;
  23922. /**
  23923. * The short type.
  23924. */
  23925. static readonly SHORT: number;
  23926. /**
  23927. * The unsigned short type.
  23928. */
  23929. static readonly UNSIGNED_SHORT: number;
  23930. /**
  23931. * The integer type.
  23932. */
  23933. static readonly INT: number;
  23934. /**
  23935. * The unsigned integer type.
  23936. */
  23937. static readonly UNSIGNED_INT: number;
  23938. /**
  23939. * The float type.
  23940. */
  23941. static readonly FLOAT: number;
  23942. /**
  23943. * Gets or sets the instance divisor when in instanced mode
  23944. */
  23945. instanceDivisor: number;
  23946. /**
  23947. * Gets the byte stride.
  23948. */
  23949. readonly byteStride: number;
  23950. /**
  23951. * Gets the byte offset.
  23952. */
  23953. readonly byteOffset: number;
  23954. /**
  23955. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23956. */
  23957. readonly normalized: boolean;
  23958. /**
  23959. * Gets the data type of each component in the array.
  23960. */
  23961. readonly type: number;
  23962. /**
  23963. * Constructor
  23964. * @param engine the engine
  23965. * @param data the data to use for this vertex buffer
  23966. * @param kind the vertex buffer kind
  23967. * @param updatable whether the data is updatable
  23968. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23969. * @param stride the stride (optional)
  23970. * @param instanced whether the buffer is instanced (optional)
  23971. * @param offset the offset of the data (optional)
  23972. * @param size the number of components (optional)
  23973. * @param type the type of the component (optional)
  23974. * @param normalized whether the data contains normalized data (optional)
  23975. * @param useBytes set to true if stride and offset are in bytes (optional)
  23976. */
  23977. 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);
  23978. _rebuild(): void;
  23979. /**
  23980. * Returns the kind of the VertexBuffer (string).
  23981. */
  23982. getKind(): string;
  23983. /**
  23984. * Boolean : is the VertexBuffer updatable ?
  23985. */
  23986. isUpdatable(): boolean;
  23987. /**
  23988. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23989. */
  23990. getData(): Nullable<DataArray>;
  23991. /**
  23992. * Returns the WebGLBuffer associated to the VertexBuffer.
  23993. */
  23994. getBuffer(): Nullable<WebGLBuffer>;
  23995. /**
  23996. * Returns the stride as a multiple of the type byte length.
  23997. * DEPRECATED. Use byteStride instead.
  23998. */
  23999. getStrideSize(): number;
  24000. /**
  24001. * Returns the offset as a multiple of the type byte length.
  24002. * DEPRECATED. Use byteOffset instead.
  24003. */
  24004. getOffset(): number;
  24005. /**
  24006. * Returns the number of components per vertex attribute (integer).
  24007. */
  24008. getSize(): number;
  24009. /**
  24010. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24011. */
  24012. getIsInstanced(): boolean;
  24013. /**
  24014. * Returns the instancing divisor, zero for non-instanced (integer).
  24015. */
  24016. getInstanceDivisor(): number;
  24017. /**
  24018. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24019. * Returns the created WebGLBuffer.
  24020. */
  24021. create(data?: DataArray): void;
  24022. /**
  24023. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24024. * This function will create a new buffer if the current one is not updatable
  24025. * Returns the updated WebGLBuffer.
  24026. */
  24027. update(data: DataArray): void;
  24028. /**
  24029. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24030. * Returns the directly updated WebGLBuffer.
  24031. * @param data the new data
  24032. * @param offset the new offset
  24033. * @param useBytes set to true if the offset is in bytes
  24034. */
  24035. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24036. /**
  24037. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24038. */
  24039. dispose(): void;
  24040. /**
  24041. * Enumerates each value of this vertex buffer as numbers.
  24042. * @param count the number of values to enumerate
  24043. * @param callback the callback function called for each value
  24044. */
  24045. forEach(count: number, callback: (value: number, index: number) => void): void;
  24046. private static _PositionKind;
  24047. private static _NormalKind;
  24048. private static _TangentKind;
  24049. private static _UVKind;
  24050. private static _UV2Kind;
  24051. private static _UV3Kind;
  24052. private static _UV4Kind;
  24053. private static _UV5Kind;
  24054. private static _UV6Kind;
  24055. private static _ColorKind;
  24056. private static _MatricesIndicesKind;
  24057. private static _MatricesWeightsKind;
  24058. private static _MatricesIndicesExtraKind;
  24059. private static _MatricesWeightsExtraKind;
  24060. static readonly PositionKind: string;
  24061. static readonly NormalKind: string;
  24062. static readonly TangentKind: string;
  24063. static readonly UVKind: string;
  24064. static readonly UV2Kind: string;
  24065. static readonly UV3Kind: string;
  24066. static readonly UV4Kind: string;
  24067. static readonly UV5Kind: string;
  24068. static readonly UV6Kind: string;
  24069. static readonly ColorKind: string;
  24070. static readonly MatricesIndicesKind: string;
  24071. static readonly MatricesWeightsKind: string;
  24072. static readonly MatricesIndicesExtraKind: string;
  24073. static readonly MatricesWeightsExtraKind: string;
  24074. /**
  24075. * Deduces the stride given a kind.
  24076. * @param kind The kind string to deduce
  24077. * @returns The deduced stride
  24078. */
  24079. static DeduceStride(kind: string): number;
  24080. /**
  24081. * Gets the byte length of the given type.
  24082. * @param type the type
  24083. * @returns the number of bytes
  24084. */
  24085. static GetTypeByteLength(type: number): number;
  24086. /**
  24087. * Enumerates each value of the given parameters as numbers.
  24088. * @param data the data to enumerate
  24089. * @param byteOffset the byte offset of the data
  24090. * @param byteStride the byte stride of the data
  24091. * @param componentCount the number of components per element
  24092. * @param componentType the type of the component
  24093. * @param count the total number of components
  24094. * @param normalized whether the data is normalized
  24095. * @param callback the callback function called for each value
  24096. */
  24097. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24098. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  24099. }
  24100. }
  24101. declare module BABYLON {
  24102. interface PhysicsImpostorJoint {
  24103. mainImpostor: PhysicsImpostor;
  24104. connectedImpostor: PhysicsImpostor;
  24105. joint: PhysicsJoint;
  24106. }
  24107. class PhysicsEngine {
  24108. private _physicsPlugin;
  24109. gravity: Vector3;
  24110. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24111. setGravity(gravity: Vector3): void;
  24112. /**
  24113. * Set the time step of the physics engine.
  24114. * default is 1/60.
  24115. * To slow it down, enter 1/600 for example.
  24116. * To speed it up, 1/30
  24117. * @param {number} newTimeStep the new timestep to apply to this world.
  24118. */
  24119. setTimeStep(newTimeStep?: number): void;
  24120. /**
  24121. * Get the time step of the physics engine.
  24122. */
  24123. getTimeStep(): number;
  24124. dispose(): void;
  24125. getPhysicsPluginName(): string;
  24126. static Epsilon: number;
  24127. private _impostors;
  24128. private _joints;
  24129. /**
  24130. * Adding a new impostor for the impostor tracking.
  24131. * This will be done by the impostor itself.
  24132. * @param {PhysicsImpostor} impostor the impostor to add
  24133. */
  24134. addImpostor(impostor: PhysicsImpostor): void;
  24135. /**
  24136. * Remove an impostor from the engine.
  24137. * This impostor and its mesh will not longer be updated by the physics engine.
  24138. * @param {PhysicsImpostor} impostor the impostor to remove
  24139. */
  24140. removeImpostor(impostor: PhysicsImpostor): void;
  24141. /**
  24142. * Add a joint to the physics engine
  24143. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24144. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24145. * @param {PhysicsJoint} the joint that will connect both impostors.
  24146. */
  24147. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24148. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24149. /**
  24150. * Called by the scene. no need to call it.
  24151. */
  24152. _step(delta: number): void;
  24153. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24154. getImpostors(): Array<PhysicsImpostor>;
  24155. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24156. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24157. }
  24158. interface IPhysicsEnginePlugin {
  24159. world: any;
  24160. name: string;
  24161. setGravity(gravity: Vector3): void;
  24162. setTimeStep(timeStep: number): void;
  24163. getTimeStep(): number;
  24164. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24165. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24166. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24167. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24168. removePhysicsBody(impostor: PhysicsImpostor): void;
  24169. generateJoint(joint: PhysicsImpostorJoint): void;
  24170. removeJoint(joint: PhysicsImpostorJoint): void;
  24171. isSupported(): boolean;
  24172. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24173. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24174. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24175. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24176. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24177. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24178. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24179. getBodyMass(impostor: PhysicsImpostor): number;
  24180. getBodyFriction(impostor: PhysicsImpostor): number;
  24181. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24182. getBodyRestitution(impostor: PhysicsImpostor): number;
  24183. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24184. sleepBody(impostor: PhysicsImpostor): void;
  24185. wakeUpBody(impostor: PhysicsImpostor): void;
  24186. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24187. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24188. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24189. getRadius(impostor: PhysicsImpostor): number;
  24190. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24191. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24192. dispose(): void;
  24193. }
  24194. }
  24195. declare module BABYLON {
  24196. class PhysicsHelper {
  24197. private _scene;
  24198. private _physicsEngine;
  24199. constructor(scene: Scene);
  24200. /**
  24201. * @param {Vector3} origin the origin of the explosion
  24202. * @param {number} radius the explosion radius
  24203. * @param {number} strength the explosion strength
  24204. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24205. */
  24206. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24207. /**
  24208. * @param {Vector3} origin the origin of the explosion
  24209. * @param {number} radius the explosion radius
  24210. * @param {number} strength the explosion strength
  24211. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24212. */
  24213. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24214. /**
  24215. * @param {Vector3} origin the origin of the explosion
  24216. * @param {number} radius the explosion radius
  24217. * @param {number} strength the explosion strength
  24218. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24219. */
  24220. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24221. /**
  24222. * @param {Vector3} origin the origin of the updraft
  24223. * @param {number} radius the radius of the updraft
  24224. * @param {number} strength the strength of the updraft
  24225. * @param {number} height the height of the updraft
  24226. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24227. */
  24228. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24229. /**
  24230. * @param {Vector3} origin the of the vortex
  24231. * @param {number} radius the radius of the vortex
  24232. * @param {number} strength the strength of the vortex
  24233. * @param {number} height the height of the vortex
  24234. */
  24235. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24236. }
  24237. /***** Radial explosion *****/
  24238. class PhysicsRadialExplosionEvent {
  24239. private _scene;
  24240. private _sphere;
  24241. private _sphereOptions;
  24242. private _rays;
  24243. private _dataFetched;
  24244. constructor(scene: Scene);
  24245. /**
  24246. * Returns the data related to the radial explosion event (sphere & rays).
  24247. * @returns {PhysicsRadialExplosionEventData}
  24248. */
  24249. getData(): PhysicsRadialExplosionEventData;
  24250. /**
  24251. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24252. * @param impostor
  24253. * @param {Vector3} origin the origin of the explosion
  24254. * @param {number} radius the explosion radius
  24255. * @param {number} strength the explosion strength
  24256. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24257. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24258. */
  24259. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24260. /**
  24261. * Disposes the sphere.
  24262. * @param {bolean} force
  24263. */
  24264. dispose(force?: boolean): void;
  24265. /*** Helpers ***/
  24266. private _prepareSphere();
  24267. private _intersectsWithSphere(impostor, origin, radius);
  24268. }
  24269. /***** Gravitational Field *****/
  24270. class PhysicsGravitationalFieldEvent {
  24271. private _physicsHelper;
  24272. private _scene;
  24273. private _origin;
  24274. private _radius;
  24275. private _strength;
  24276. private _falloff;
  24277. private _tickCallback;
  24278. private _sphere;
  24279. private _dataFetched;
  24280. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24281. /**
  24282. * Returns the data related to the gravitational field event (sphere).
  24283. * @returns {PhysicsGravitationalFieldEventData}
  24284. */
  24285. getData(): PhysicsGravitationalFieldEventData;
  24286. /**
  24287. * Enables the gravitational field.
  24288. */
  24289. enable(): void;
  24290. /**
  24291. * Disables the gravitational field.
  24292. */
  24293. disable(): void;
  24294. /**
  24295. * Disposes the sphere.
  24296. * @param {bolean} force
  24297. */
  24298. dispose(force?: boolean): void;
  24299. private _tick();
  24300. }
  24301. /***** Updraft *****/
  24302. class PhysicsUpdraftEvent {
  24303. private _scene;
  24304. private _origin;
  24305. private _radius;
  24306. private _strength;
  24307. private _height;
  24308. private _updraftMode;
  24309. private _physicsEngine;
  24310. private _originTop;
  24311. private _originDirection;
  24312. private _tickCallback;
  24313. private _cylinder;
  24314. private _cylinderPosition;
  24315. private _dataFetched;
  24316. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24317. /**
  24318. * Returns the data related to the updraft event (cylinder).
  24319. * @returns {PhysicsUpdraftEventData}
  24320. */
  24321. getData(): PhysicsUpdraftEventData;
  24322. /**
  24323. * Enables the updraft.
  24324. */
  24325. enable(): void;
  24326. /**
  24327. * Disables the cortex.
  24328. */
  24329. disable(): void;
  24330. /**
  24331. * Disposes the sphere.
  24332. * @param {bolean} force
  24333. */
  24334. dispose(force?: boolean): void;
  24335. private getImpostorForceAndContactPoint(impostor);
  24336. private _tick();
  24337. /*** Helpers ***/
  24338. private _prepareCylinder();
  24339. private _intersectsWithCylinder(impostor);
  24340. }
  24341. /***** Vortex *****/
  24342. class PhysicsVortexEvent {
  24343. private _scene;
  24344. private _origin;
  24345. private _radius;
  24346. private _strength;
  24347. private _height;
  24348. private _physicsEngine;
  24349. private _originTop;
  24350. private _centripetalForceThreshold;
  24351. private _updraftMultiplier;
  24352. private _tickCallback;
  24353. private _cylinder;
  24354. private _cylinderPosition;
  24355. private _dataFetched;
  24356. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24357. /**
  24358. * Returns the data related to the vortex event (cylinder).
  24359. * @returns {PhysicsVortexEventData}
  24360. */
  24361. getData(): PhysicsVortexEventData;
  24362. /**
  24363. * Enables the vortex.
  24364. */
  24365. enable(): void;
  24366. /**
  24367. * Disables the cortex.
  24368. */
  24369. disable(): void;
  24370. /**
  24371. * Disposes the sphere.
  24372. * @param {bolean} force
  24373. */
  24374. dispose(force?: boolean): void;
  24375. private getImpostorForceAndContactPoint(impostor);
  24376. private _tick();
  24377. /*** Helpers ***/
  24378. private _prepareCylinder();
  24379. private _intersectsWithCylinder(impostor);
  24380. }
  24381. /***** Enums *****/
  24382. /**
  24383. * The strenght of the force in correspondence to the distance of the affected object
  24384. */
  24385. enum PhysicsRadialImpulseFalloff {
  24386. /** Defines that impulse is constant in strength across it's whole radius */
  24387. Constant = 0,
  24388. /** DEfines that impulse gets weaker if it's further from the origin */
  24389. Linear = 1,
  24390. }
  24391. /**
  24392. * The strenght of the force in correspondence to the distance of the affected object
  24393. */
  24394. enum PhysicsUpdraftMode {
  24395. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24396. Center = 0,
  24397. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24398. Perpendicular = 1,
  24399. }
  24400. /***** Data interfaces *****/
  24401. interface PhysicsForceAndContactPoint {
  24402. force: Vector3;
  24403. contactPoint: Vector3;
  24404. }
  24405. interface PhysicsRadialExplosionEventData {
  24406. sphere: Mesh;
  24407. rays: Array<Ray>;
  24408. }
  24409. interface PhysicsGravitationalFieldEventData {
  24410. sphere: Mesh;
  24411. }
  24412. interface PhysicsUpdraftEventData {
  24413. cylinder: Mesh;
  24414. }
  24415. interface PhysicsVortexEventData {
  24416. cylinder: Mesh;
  24417. }
  24418. }
  24419. declare module BABYLON {
  24420. interface PhysicsImpostorParameters {
  24421. mass: number;
  24422. friction?: number;
  24423. restitution?: number;
  24424. nativeOptions?: any;
  24425. ignoreParent?: boolean;
  24426. disableBidirectionalTransformation?: boolean;
  24427. }
  24428. interface IPhysicsEnabledObject {
  24429. position: Vector3;
  24430. rotationQuaternion: Nullable<Quaternion>;
  24431. scaling: Vector3;
  24432. rotation?: Vector3;
  24433. parent?: any;
  24434. getBoundingInfo(): BoundingInfo;
  24435. computeWorldMatrix(force: boolean): Matrix;
  24436. getWorldMatrix?(): Matrix;
  24437. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24438. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24439. getIndices?(): Nullable<IndicesArray>;
  24440. getScene?(): Scene;
  24441. getAbsolutePosition(): Vector3;
  24442. getAbsolutePivotPoint(): Vector3;
  24443. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24445. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24446. getClassName(): string;
  24447. }
  24448. class PhysicsImpostor {
  24449. object: IPhysicsEnabledObject;
  24450. type: number;
  24451. private _options;
  24452. private _scene;
  24453. static DEFAULT_OBJECT_SIZE: Vector3;
  24454. static IDENTITY_QUATERNION: Quaternion;
  24455. private _physicsEngine;
  24456. private _physicsBody;
  24457. private _bodyUpdateRequired;
  24458. private _onBeforePhysicsStepCallbacks;
  24459. private _onAfterPhysicsStepCallbacks;
  24460. private _onPhysicsCollideCallbacks;
  24461. private _deltaPosition;
  24462. private _deltaRotation;
  24463. private _deltaRotationConjugated;
  24464. private _parent;
  24465. private _isDisposed;
  24466. private static _tmpVecs;
  24467. private static _tmpQuat;
  24468. readonly isDisposed: boolean;
  24469. mass: number;
  24470. friction: number;
  24471. restitution: number;
  24472. uniqueId: number;
  24473. private _joints;
  24474. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24475. /**
  24476. * This function will completly initialize this impostor.
  24477. * It will create a new body - but only if this mesh has no parent.
  24478. * If it has, this impostor will not be used other than to define the impostor
  24479. * of the child mesh.
  24480. */
  24481. _init(): void;
  24482. private _getPhysicsParent();
  24483. /**
  24484. * Should a new body be generated.
  24485. */
  24486. isBodyInitRequired(): boolean;
  24487. setScalingUpdated(updated: boolean): void;
  24488. /**
  24489. * Force a regeneration of this or the parent's impostor's body.
  24490. * Use under cautious - This will remove all joints already implemented.
  24491. */
  24492. forceUpdate(): void;
  24493. /**
  24494. * Gets the body that holds this impostor. Either its own, or its parent.
  24495. */
  24496. /**
  24497. * Set the physics body. Used mainly by the physics engine/plugin
  24498. */
  24499. physicsBody: any;
  24500. parent: Nullable<PhysicsImpostor>;
  24501. resetUpdateFlags(): void;
  24502. getObjectExtendSize(): Vector3;
  24503. getObjectCenter(): Vector3;
  24504. /**
  24505. * Get a specific parametes from the options parameter.
  24506. */
  24507. getParam(paramName: string): any;
  24508. /**
  24509. * Sets a specific parameter in the options given to the physics plugin
  24510. */
  24511. setParam(paramName: string, value: number): void;
  24512. /**
  24513. * Specifically change the body's mass option. Won't recreate the physics body object
  24514. */
  24515. setMass(mass: number): void;
  24516. getLinearVelocity(): Nullable<Vector3>;
  24517. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24518. getAngularVelocity(): Nullable<Vector3>;
  24519. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24520. /**
  24521. * Execute a function with the physics plugin native code.
  24522. * Provide a function the will have two variables - the world object and the physics body object.
  24523. */
  24524. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24525. /**
  24526. * Register a function that will be executed before the physics world is stepping forward.
  24527. */
  24528. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24529. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24530. /**
  24531. * Register a function that will be executed after the physics step
  24532. */
  24533. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24534. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24535. /**
  24536. * register a function that will be executed when this impostor collides against a different body.
  24537. */
  24538. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24539. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24540. private _tmpQuat;
  24541. private _tmpQuat2;
  24542. getParentsRotation(): Quaternion;
  24543. /**
  24544. * this function is executed by the physics engine.
  24545. */
  24546. beforeStep: () => void;
  24547. /**
  24548. * this function is executed by the physics engine.
  24549. */
  24550. afterStep: () => void;
  24551. /**
  24552. * Legacy collision detection event support
  24553. */
  24554. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24555. onCollide: (e: {
  24556. body: any;
  24557. }) => void;
  24558. /**
  24559. * Apply a force
  24560. */
  24561. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24562. /**
  24563. * Apply an impulse
  24564. */
  24565. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24566. /**
  24567. * A help function to create a joint.
  24568. */
  24569. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24570. /**
  24571. * Add a joint to this impostor with a different impostor.
  24572. */
  24573. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24574. /**
  24575. * Will keep this body still, in a sleep mode.
  24576. */
  24577. sleep(): PhysicsImpostor;
  24578. /**
  24579. * Wake the body up.
  24580. */
  24581. wakeUp(): PhysicsImpostor;
  24582. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24583. dispose(): void;
  24584. setDeltaPosition(position: Vector3): void;
  24585. setDeltaRotation(rotation: Quaternion): void;
  24586. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24587. getRadius(): number;
  24588. /**
  24589. * Sync a bone with this impostor
  24590. * @param bone The bone to sync to the impostor.
  24591. * @param boneMesh The mesh that the bone is influencing.
  24592. * @param jointPivot The pivot of the joint / bone in local space.
  24593. * @param distToJoint Optional distance from the impostor to the joint.
  24594. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24595. */
  24596. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24597. /**
  24598. * Sync impostor to a bone
  24599. * @param bone The bone that the impostor will be synced to.
  24600. * @param boneMesh The mesh that the bone is influencing.
  24601. * @param jointPivot The pivot of the joint / bone in local space.
  24602. * @param distToJoint Optional distance from the impostor to the joint.
  24603. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24604. * @param boneAxis Optional vector3 axis the bone is aligned with
  24605. */
  24606. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24607. static NoImpostor: number;
  24608. static SphereImpostor: number;
  24609. static BoxImpostor: number;
  24610. static PlaneImpostor: number;
  24611. static MeshImpostor: number;
  24612. static CylinderImpostor: number;
  24613. static ParticleImpostor: number;
  24614. static HeightmapImpostor: number;
  24615. }
  24616. }
  24617. declare module BABYLON {
  24618. interface PhysicsJointData {
  24619. mainPivot?: Vector3;
  24620. connectedPivot?: Vector3;
  24621. mainAxis?: Vector3;
  24622. connectedAxis?: Vector3;
  24623. collision?: boolean;
  24624. nativeParams?: any;
  24625. }
  24626. /**
  24627. * This is a holder class for the physics joint created by the physics plugin.
  24628. * It holds a set of functions to control the underlying joint.
  24629. */
  24630. class PhysicsJoint {
  24631. type: number;
  24632. jointData: PhysicsJointData;
  24633. private _physicsJoint;
  24634. protected _physicsPlugin: IPhysicsEnginePlugin;
  24635. constructor(type: number, jointData: PhysicsJointData);
  24636. physicsJoint: any;
  24637. physicsPlugin: IPhysicsEnginePlugin;
  24638. /**
  24639. * Execute a function that is physics-plugin specific.
  24640. * @param {Function} func the function that will be executed.
  24641. * It accepts two parameters: the physics world and the physics joint.
  24642. */
  24643. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24644. static DistanceJoint: number;
  24645. static HingeJoint: number;
  24646. static BallAndSocketJoint: number;
  24647. static WheelJoint: number;
  24648. static SliderJoint: number;
  24649. static PrismaticJoint: number;
  24650. static UniversalJoint: number;
  24651. static Hinge2Joint: number;
  24652. static PointToPointJoint: number;
  24653. static SpringJoint: number;
  24654. static LockJoint: number;
  24655. }
  24656. /**
  24657. * A class representing a physics distance joint.
  24658. */
  24659. class DistanceJoint extends PhysicsJoint {
  24660. constructor(jointData: DistanceJointData);
  24661. /**
  24662. * Update the predefined distance.
  24663. */
  24664. updateDistance(maxDistance: number, minDistance?: number): void;
  24665. }
  24666. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24667. constructor(type: number, jointData: PhysicsJointData);
  24668. /**
  24669. * Set the motor values.
  24670. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24671. * @param {number} force the force to apply
  24672. * @param {number} maxForce max force for this motor.
  24673. */
  24674. setMotor(force?: number, maxForce?: number): void;
  24675. /**
  24676. * Set the motor's limits.
  24677. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24678. */
  24679. setLimit(upperLimit: number, lowerLimit?: number): void;
  24680. }
  24681. /**
  24682. * This class represents a single hinge physics joint
  24683. */
  24684. class HingeJoint extends MotorEnabledJoint {
  24685. constructor(jointData: PhysicsJointData);
  24686. /**
  24687. * Set the motor values.
  24688. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24689. * @param {number} force the force to apply
  24690. * @param {number} maxForce max force for this motor.
  24691. */
  24692. setMotor(force?: number, maxForce?: number): void;
  24693. /**
  24694. * Set the motor's limits.
  24695. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24696. */
  24697. setLimit(upperLimit: number, lowerLimit?: number): void;
  24698. }
  24699. /**
  24700. * This class represents a dual hinge physics joint (same as wheel joint)
  24701. */
  24702. class Hinge2Joint extends MotorEnabledJoint {
  24703. constructor(jointData: PhysicsJointData);
  24704. /**
  24705. * Set the motor values.
  24706. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24707. * @param {number} force the force to apply
  24708. * @param {number} maxForce max force for this motor.
  24709. * @param {motorIndex} the motor's index, 0 or 1.
  24710. */
  24711. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24712. /**
  24713. * Set the motor limits.
  24714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24715. * @param {number} upperLimit the upper limit
  24716. * @param {number} lowerLimit lower limit
  24717. * @param {motorIndex} the motor's index, 0 or 1.
  24718. */
  24719. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24720. }
  24721. interface IMotorEnabledJoint {
  24722. physicsJoint: any;
  24723. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24724. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24725. }
  24726. interface DistanceJointData extends PhysicsJointData {
  24727. maxDistance: number;
  24728. }
  24729. interface SpringJointData extends PhysicsJointData {
  24730. length: number;
  24731. stiffness: number;
  24732. damping: number;
  24733. }
  24734. }
  24735. declare module BABYLON {
  24736. class ReflectionProbe {
  24737. name: string;
  24738. private _scene;
  24739. private _renderTargetTexture;
  24740. private _projectionMatrix;
  24741. private _viewMatrix;
  24742. private _target;
  24743. private _add;
  24744. private _attachedMesh;
  24745. private _invertYAxis;
  24746. position: Vector3;
  24747. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24748. samples: number;
  24749. refreshRate: number;
  24750. getScene(): Scene;
  24751. readonly cubeTexture: RenderTargetTexture;
  24752. readonly renderList: Nullable<AbstractMesh[]>;
  24753. attachToMesh(mesh: AbstractMesh): void;
  24754. /**
  24755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24756. *
  24757. * @param renderingGroupId The rendering group id corresponding to its index
  24758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24759. */
  24760. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24761. dispose(): void;
  24762. }
  24763. }
  24764. declare module BABYLON {
  24765. class BoundingBoxRenderer {
  24766. frontColor: Color3;
  24767. backColor: Color3;
  24768. showBackLines: boolean;
  24769. renderList: SmartArray<BoundingBox>;
  24770. private _scene;
  24771. private _colorShader;
  24772. private _vertexBuffers;
  24773. private _indexBuffer;
  24774. constructor(scene: Scene);
  24775. private _prepareRessources();
  24776. private _createIndexBuffer();
  24777. _rebuild(): void;
  24778. reset(): void;
  24779. render(): void;
  24780. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  24781. dispose(): void;
  24782. }
  24783. }
  24784. declare module BABYLON {
  24785. /**
  24786. * This represents a depth renderer in Babylon.
  24787. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  24788. */
  24789. class DepthRenderer {
  24790. private _scene;
  24791. private _depthMap;
  24792. private _effect;
  24793. private _cachedDefines;
  24794. private _camera;
  24795. /**
  24796. * Instantiates a depth renderer
  24797. * @param scene The scene the renderer belongs to
  24798. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  24799. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  24800. */
  24801. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  24802. /**
  24803. * Creates the depth rendering effect and checks if the effect is ready.
  24804. * @param subMesh The submesh to be used to render the depth map of
  24805. * @param useInstances If multiple world instances should be used
  24806. * @returns if the depth renderer is ready to render the depth map
  24807. */
  24808. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24809. /**
  24810. * Gets the texture which the depth map will be written to.
  24811. * @returns The depth map texture
  24812. */
  24813. getDepthMap(): RenderTargetTexture;
  24814. /**
  24815. * Disposes of the depth renderer.
  24816. */
  24817. dispose(): void;
  24818. }
  24819. }
  24820. declare module BABYLON {
  24821. class EdgesRenderer {
  24822. edgesWidthScalerForOrthographic: number;
  24823. edgesWidthScalerForPerspective: number;
  24824. private _source;
  24825. private _linesPositions;
  24826. private _linesNormals;
  24827. private _linesIndices;
  24828. private _epsilon;
  24829. private _indicesCount;
  24830. private _lineShader;
  24831. private _ib;
  24832. private _buffers;
  24833. private _checkVerticesInsteadOfIndices;
  24834. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  24835. private _prepareRessources();
  24836. _rebuild(): void;
  24837. dispose(): void;
  24838. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  24839. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  24840. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  24841. _generateEdgesLines(): void;
  24842. render(): void;
  24843. }
  24844. }
  24845. declare module BABYLON {
  24846. /**
  24847. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  24848. */
  24849. class GeometryBufferRenderer {
  24850. private _scene;
  24851. private _multiRenderTarget;
  24852. private _ratio;
  24853. private _enablePosition;
  24854. protected _effect: Effect;
  24855. protected _cachedDefines: string;
  24856. /**
  24857. * Set the render list (meshes to be rendered) used in the G buffer.
  24858. */
  24859. renderList: Mesh[];
  24860. /**
  24861. * Gets wether or not G buffer are supported by the running hardware.
  24862. * This requires draw buffer supports
  24863. */
  24864. readonly isSupported: boolean;
  24865. /**
  24866. * Gets wether or not position are enabled for the G buffer.
  24867. */
  24868. /**
  24869. * Sets wether or not position are enabled for the G buffer.
  24870. */
  24871. enablePosition: boolean;
  24872. /**
  24873. * Gets the scene associated with the buffer.
  24874. */
  24875. readonly scene: Scene;
  24876. /**
  24877. * Gets the ratio used by the buffer during its creation.
  24878. * How big is the buffer related to the main canvas.
  24879. */
  24880. readonly ratio: number;
  24881. /**
  24882. * Creates a new G Buffer for the scene
  24883. * @param scene The scene the buffer belongs to
  24884. * @param ratio How big is the buffer related to the main canvas.
  24885. */
  24886. constructor(scene: Scene, ratio?: number);
  24887. /**
  24888. * Checks wether everything is ready to render a submesh to the G buffer.
  24889. * @param subMesh the submesh to check readiness for
  24890. * @param useInstances is the mesh drawn using instance or not
  24891. * @returns true if ready otherwise false
  24892. */
  24893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24894. /**
  24895. * Gets the current underlying G Buffer.
  24896. * @returns the buffer
  24897. */
  24898. getGBuffer(): MultiRenderTarget;
  24899. /**
  24900. * Gets the number of samples used to render the buffer (anti aliasing).
  24901. */
  24902. /**
  24903. * Sets the number of samples used to render the buffer (anti aliasing).
  24904. */
  24905. samples: number;
  24906. /**
  24907. * Disposes the renderer and frees up associated resources.
  24908. */
  24909. dispose(): void;
  24910. protected _createRenderTargets(): void;
  24911. }
  24912. }
  24913. declare module BABYLON {
  24914. class OutlineRenderer {
  24915. private _scene;
  24916. private _effect;
  24917. private _cachedDefines;
  24918. zOffset: number;
  24919. constructor(scene: Scene);
  24920. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  24921. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24922. }
  24923. }
  24924. declare module BABYLON {
  24925. class RenderingGroup {
  24926. index: number;
  24927. private _scene;
  24928. private _opaqueSubMeshes;
  24929. private _transparentSubMeshes;
  24930. private _alphaTestSubMeshes;
  24931. private _depthOnlySubMeshes;
  24932. private _particleSystems;
  24933. private _spriteManagers;
  24934. private _opaqueSortCompareFn;
  24935. private _alphaTestSortCompareFn;
  24936. private _transparentSortCompareFn;
  24937. private _renderOpaque;
  24938. private _renderAlphaTest;
  24939. private _renderTransparent;
  24940. private _edgesRenderers;
  24941. onBeforeTransparentRendering: () => void;
  24942. /**
  24943. * Set the opaque sort comparison function.
  24944. * If null the sub meshes will be render in the order they were created
  24945. */
  24946. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24947. /**
  24948. * Set the alpha test sort comparison function.
  24949. * If null the sub meshes will be render in the order they were created
  24950. */
  24951. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24952. /**
  24953. * Set the transparent sort comparison function.
  24954. * If null the sub meshes will be render in the order they were created
  24955. */
  24956. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24957. /**
  24958. * Creates a new rendering group.
  24959. * @param index The rendering group index
  24960. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  24961. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  24962. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  24963. */
  24964. 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>);
  24965. /**
  24966. * Render all the sub meshes contained in the group.
  24967. * @param customRenderFunction Used to override the default render behaviour of the group.
  24968. * @returns true if rendered some submeshes.
  24969. */
  24970. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  24971. /**
  24972. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  24973. * @param subMeshes The submeshes to render
  24974. */
  24975. private renderOpaqueSorted(subMeshes);
  24976. /**
  24977. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  24978. * @param subMeshes The submeshes to render
  24979. */
  24980. private renderAlphaTestSorted(subMeshes);
  24981. /**
  24982. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  24983. * @param subMeshes The submeshes to render
  24984. */
  24985. private renderTransparentSorted(subMeshes);
  24986. /**
  24987. * Renders the submeshes in a specified order.
  24988. * @param subMeshes The submeshes to sort before render
  24989. * @param sortCompareFn The comparison function use to sort
  24990. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  24991. * @param transparent Specifies to activate blending if true
  24992. */
  24993. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  24994. /**
  24995. * Renders the submeshes in the order they were dispatched (no sort applied).
  24996. * @param subMeshes The submeshes to render
  24997. */
  24998. private static renderUnsorted(subMeshes);
  24999. /**
  25000. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25001. * are rendered back to front if in the same alpha index.
  25002. *
  25003. * @param a The first submesh
  25004. * @param b The second submesh
  25005. * @returns The result of the comparison
  25006. */
  25007. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25008. /**
  25009. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25010. * are rendered back to front.
  25011. *
  25012. * @param a The first submesh
  25013. * @param b The second submesh
  25014. * @returns The result of the comparison
  25015. */
  25016. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25017. /**
  25018. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25019. * are rendered front to back (prevent overdraw).
  25020. *
  25021. * @param a The first submesh
  25022. * @param b The second submesh
  25023. * @returns The result of the comparison
  25024. */
  25025. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25026. /**
  25027. * Resets the different lists of submeshes to prepare a new frame.
  25028. */
  25029. prepare(): void;
  25030. dispose(): void;
  25031. /**
  25032. * Inserts the submesh in its correct queue depending on its material.
  25033. * @param subMesh The submesh to dispatch
  25034. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25035. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25036. */
  25037. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25038. dispatchSprites(spriteManager: SpriteManager): void;
  25039. dispatchParticles(particleSystem: IParticleSystem): void;
  25040. private _renderParticles(activeMeshes);
  25041. private _renderSprites();
  25042. }
  25043. }
  25044. declare module BABYLON {
  25045. class RenderingManager {
  25046. /**
  25047. * The max id used for rendering groups (not included)
  25048. */
  25049. static MAX_RENDERINGGROUPS: number;
  25050. /**
  25051. * The min id used for rendering groups (included)
  25052. */
  25053. static MIN_RENDERINGGROUPS: number;
  25054. /**
  25055. * Used to globally prevent autoclearing scenes.
  25056. */
  25057. static AUTOCLEAR: boolean;
  25058. private _scene;
  25059. private _renderingGroups;
  25060. private _depthStencilBufferAlreadyCleaned;
  25061. private _autoClearDepthStencil;
  25062. private _customOpaqueSortCompareFn;
  25063. private _customAlphaTestSortCompareFn;
  25064. private _customTransparentSortCompareFn;
  25065. private _renderinGroupInfo;
  25066. constructor(scene: Scene);
  25067. private _clearDepthStencilBuffer(depth?, stencil?);
  25068. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25069. reset(): void;
  25070. dispose(): void;
  25071. /**
  25072. * Clear the info related to rendering groups preventing retention points during dispose.
  25073. */
  25074. freeRenderingGroups(): void;
  25075. private _prepareRenderingGroup(renderingGroupId);
  25076. dispatchSprites(spriteManager: SpriteManager): void;
  25077. dispatchParticles(particleSystem: IParticleSystem): void;
  25078. /**
  25079. * @param subMesh The submesh to dispatch
  25080. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25081. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25082. */
  25083. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25084. /**
  25085. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25086. * This allowed control for front to back rendering or reversly depending of the special needs.
  25087. *
  25088. * @param renderingGroupId The rendering group id corresponding to its index
  25089. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25090. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25091. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25092. */
  25093. 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;
  25094. /**
  25095. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25096. *
  25097. * @param renderingGroupId The rendering group id corresponding to its index
  25098. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25099. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25100. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25101. */
  25102. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25103. }
  25104. }
  25105. declare module BABYLON {
  25106. class Sprite {
  25107. name: string;
  25108. position: Vector3;
  25109. color: Color4;
  25110. width: number;
  25111. height: number;
  25112. angle: number;
  25113. cellIndex: number;
  25114. invertU: number;
  25115. invertV: number;
  25116. disposeWhenFinishedAnimating: boolean;
  25117. animations: Animation[];
  25118. isPickable: boolean;
  25119. actionManager: ActionManager;
  25120. private _animationStarted;
  25121. private _loopAnimation;
  25122. private _fromIndex;
  25123. private _toIndex;
  25124. private _delay;
  25125. private _direction;
  25126. private _manager;
  25127. private _time;
  25128. private _onAnimationEnd;
  25129. size: number;
  25130. constructor(name: string, manager: SpriteManager);
  25131. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  25132. stopAnimation(): void;
  25133. _animate(deltaTime: number): void;
  25134. dispose(): void;
  25135. }
  25136. }
  25137. declare module BABYLON {
  25138. class SpriteManager {
  25139. name: string;
  25140. sprites: Sprite[];
  25141. renderingGroupId: number;
  25142. layerMask: number;
  25143. fogEnabled: boolean;
  25144. isPickable: boolean;
  25145. cellWidth: number;
  25146. cellHeight: number;
  25147. /**
  25148. * An event triggered when the manager is disposed.
  25149. */
  25150. onDisposeObservable: Observable<SpriteManager>;
  25151. private _onDisposeObserver;
  25152. onDispose: () => void;
  25153. private _capacity;
  25154. private _spriteTexture;
  25155. private _epsilon;
  25156. private _scene;
  25157. private _vertexData;
  25158. private _buffer;
  25159. private _vertexBuffers;
  25160. private _indexBuffer;
  25161. private _effectBase;
  25162. private _effectFog;
  25163. texture: Texture;
  25164. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  25165. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  25166. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25167. render(): void;
  25168. dispose(): void;
  25169. }
  25170. }
  25171. declare module BABYLON {
  25172. /**
  25173. * Postprocess used to generate anaglyphic rendering
  25174. */
  25175. class AnaglyphPostProcess extends PostProcess {
  25176. private _passedProcess;
  25177. /**
  25178. * Creates a new AnaglyphPostProcess
  25179. * @param name defines postprocess name
  25180. * @param options defines creation options or target ratio scale
  25181. * @param rigCameras defines cameras using this postprocess
  25182. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25183. * @param engine defines hosting engine
  25184. * @param reusable defines if the postprocess will be reused multiple times per frame
  25185. */
  25186. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25187. }
  25188. }
  25189. declare module BABYLON {
  25190. class BlackAndWhitePostProcess extends PostProcess {
  25191. degree: number;
  25192. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25193. }
  25194. }
  25195. declare module BABYLON {
  25196. /**
  25197. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25198. */
  25199. class BloomEffect extends PostProcessRenderEffect {
  25200. private bloomScale;
  25201. /**
  25202. * Internal
  25203. */
  25204. _effects: Array<PostProcess>;
  25205. /**
  25206. * Internal
  25207. */
  25208. _downscale: ExtractHighlightsPostProcess;
  25209. private _blurX;
  25210. private _blurY;
  25211. private _merge;
  25212. /**
  25213. * The luminance threshold to find bright areas of the image to bloom.
  25214. */
  25215. threshold: number;
  25216. /**
  25217. * The strength of the bloom.
  25218. */
  25219. weight: number;
  25220. /**
  25221. * Specifies the size of the bloom blur kernel, relative to the final output size
  25222. */
  25223. kernel: number;
  25224. /**
  25225. * Creates a new instance of @see BloomEffect
  25226. * @param scene The scene the effect belongs to.
  25227. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25228. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25229. * @param bloomWeight The the strength of bloom.
  25230. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25231. * @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)
  25232. */
  25233. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25234. /**
  25235. * Disposes each of the internal effects for a given camera.
  25236. * @param camera The camera to dispose the effect on.
  25237. */
  25238. disposeEffects(camera: Camera): void;
  25239. /**
  25240. * Internal
  25241. */
  25242. _updateEffects(): void;
  25243. /**
  25244. * Internal
  25245. * @returns if all the contained post processes are ready.
  25246. */
  25247. _isReady(): boolean;
  25248. }
  25249. }
  25250. declare module BABYLON {
  25251. /**
  25252. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25253. */
  25254. class BloomMergePostProcess extends PostProcess {
  25255. /** Weight of the bloom to be added to the original input. */ weight: number;
  25256. /**
  25257. * Creates a new instance of @see BloomMergePostProcess
  25258. * @param name The name of the effect.
  25259. * @param originalFromInput Post process which's input will be used for the merge.
  25260. * @param blurred Blurred highlights post process which's output will be used.
  25261. * @param weight Weight of the bloom to be added to the original input.
  25262. * @param options The required width/height ratio to downsize to before computing the render pass.
  25263. * @param camera The camera to apply the render pass to.
  25264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25265. * @param engine The engine which the post process will be applied. (default: current engine)
  25266. * @param reusable If the post process can be reused on the same frame. (default: false)
  25267. * @param textureType Type of textures used when performing the post process. (default: 0)
  25268. * @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)
  25269. */
  25270. 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);
  25271. }
  25272. }
  25273. declare module BABYLON {
  25274. /**
  25275. * The Blur Post Process which blurs an image based on a kernel and direction.
  25276. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25277. */
  25278. class BlurPostProcess extends PostProcess {
  25279. /** The direction in which to blur the image. */ direction: Vector2;
  25280. private blockCompilation;
  25281. protected _kernel: number;
  25282. protected _idealKernel: number;
  25283. protected _packedFloat: boolean;
  25284. private _staticDefines;
  25285. /**
  25286. * Gets the length in pixels of the blur sample region
  25287. */
  25288. /**
  25289. * Sets the length in pixels of the blur sample region
  25290. */
  25291. kernel: number;
  25292. /**
  25293. * Gets wether or not the blur is unpacking/repacking floats
  25294. */
  25295. /**
  25296. * Sets wether or not the blur needs to unpack/repack floats
  25297. */
  25298. packedFloat: boolean;
  25299. /**
  25300. * Creates a new instance BlurPostProcess
  25301. * @param name The name of the effect.
  25302. * @param direction The direction in which to blur the image.
  25303. * @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.
  25304. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25305. * @param camera The camera to apply the render pass to.
  25306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25307. * @param engine The engine which the post process will be applied. (default: current engine)
  25308. * @param reusable If the post process can be reused on the same frame. (default: false)
  25309. * @param textureType Type of textures used when performing the post process. (default: 0)
  25310. * @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)
  25311. */
  25312. 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);
  25313. /**
  25314. * Updates the effect with the current post process compile time values and recompiles the shader.
  25315. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25316. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25317. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25318. * @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
  25319. * @param onCompiled Called when the shader has been compiled.
  25320. * @param onError Called if there is an error when compiling a shader.
  25321. */
  25322. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25323. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25324. /**
  25325. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25326. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25327. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25328. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25329. * The gaps between physical kernels are compensated for in the weighting of the samples
  25330. * @param idealKernel Ideal blur kernel.
  25331. * @return Nearest best kernel.
  25332. */
  25333. protected _nearestBestKernel(idealKernel: number): number;
  25334. /**
  25335. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25336. * @param x The point on the Gaussian distribution to sample.
  25337. * @return the value of the Gaussian function at x.
  25338. */
  25339. protected _gaussianWeight(x: number): number;
  25340. /**
  25341. * Generates a string that can be used as a floating point number in GLSL.
  25342. * @param x Value to print.
  25343. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25344. * @return GLSL float string.
  25345. */
  25346. protected _glslFloat(x: number, decimalFigures?: number): string;
  25347. }
  25348. }
  25349. declare module BABYLON {
  25350. /**
  25351. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25352. */
  25353. class ChromaticAberrationPostProcess extends PostProcess {
  25354. /**
  25355. * The amount of seperation of rgb channels (default: 30)
  25356. */
  25357. aberrationAmount: number;
  25358. /**
  25359. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25360. */
  25361. radialIntensity: number;
  25362. /**
  25363. * 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))
  25364. */
  25365. direction: Vector2;
  25366. /**
  25367. * 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))
  25368. */
  25369. centerPosition: Vector2;
  25370. /**
  25371. * Creates a new instance ChromaticAberrationPostProcess
  25372. * @param name The name of the effect.
  25373. * @param screenWidth The width of the screen to apply the effect on.
  25374. * @param screenHeight The height of the screen to apply the effect on.
  25375. * @param options The required width/height ratio to downsize to before computing the render pass.
  25376. * @param camera The camera to apply the render pass to.
  25377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25378. * @param engine The engine which the post process will be applied. (default: current engine)
  25379. * @param reusable If the post process can be reused on the same frame. (default: false)
  25380. * @param textureType Type of textures used when performing the post process. (default: 0)
  25381. * @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)
  25382. */
  25383. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25384. }
  25385. }
  25386. declare module BABYLON {
  25387. /**
  25388. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25389. */
  25390. class CircleOfConfusionPostProcess extends PostProcess {
  25391. /**
  25392. * 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.
  25393. */
  25394. lensSize: number;
  25395. /**
  25396. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25397. */
  25398. fStop: number;
  25399. /**
  25400. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25401. */
  25402. focusDistance: number;
  25403. /**
  25404. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25405. */
  25406. focalLength: number;
  25407. private _depthTexture;
  25408. /**
  25409. * Creates a new instance CircleOfConfusionPostProcess
  25410. * @param name The name of the effect.
  25411. * @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.
  25412. * @param options The required width/height ratio to downsize to before computing the render pass.
  25413. * @param camera The camera to apply the render pass to.
  25414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25415. * @param engine The engine which the post process will be applied. (default: current engine)
  25416. * @param reusable If the post process can be reused on the same frame. (default: false)
  25417. * @param textureType Type of textures used when performing the post process. (default: 0)
  25418. * @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)
  25419. */
  25420. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25421. /**
  25422. * 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.
  25423. */
  25424. depthTexture: RenderTargetTexture;
  25425. }
  25426. }
  25427. declare module BABYLON {
  25428. class ColorCorrectionPostProcess extends PostProcess {
  25429. private _colorTableTexture;
  25430. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25431. }
  25432. }
  25433. declare module BABYLON {
  25434. /**
  25435. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25436. * input texture to perform effects such as edge detection or sharpening
  25437. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25438. */
  25439. class ConvolutionPostProcess extends PostProcess {
  25440. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25441. /**
  25442. * Creates a new instance ConvolutionPostProcess
  25443. * @param name The name of the effect.
  25444. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25445. * @param options The required width/height ratio to downsize to before computing the render pass.
  25446. * @param camera The camera to apply the render pass to.
  25447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25448. * @param engine The engine which the post process will be applied. (default: current engine)
  25449. * @param reusable If the post process can be reused on the same frame. (default: false)
  25450. * @param textureType Type of textures used when performing the post process. (default: 0)
  25451. */
  25452. 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);
  25453. /**
  25454. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25455. */
  25456. static EdgeDetect0Kernel: number[];
  25457. /**
  25458. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25459. */
  25460. static EdgeDetect1Kernel: number[];
  25461. /**
  25462. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25463. */
  25464. static EdgeDetect2Kernel: number[];
  25465. /**
  25466. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25467. */
  25468. static SharpenKernel: number[];
  25469. /**
  25470. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25471. */
  25472. static EmbossKernel: number[];
  25473. /**
  25474. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25475. */
  25476. static GaussianKernel: number[];
  25477. }
  25478. }
  25479. declare module BABYLON {
  25480. /**
  25481. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25482. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25483. * based on samples that have a large difference in distance than the center pixel.
  25484. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25485. */
  25486. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25487. direction: Vector2;
  25488. /**
  25489. * Creates a new instance CircleOfConfusionPostProcess
  25490. * @param name The name of the effect.
  25491. * @param scene The scene the effect belongs to.
  25492. * @param direction The direction the blur should be applied.
  25493. * @param kernel The size of the kernel used to blur.
  25494. * @param options The required width/height ratio to downsize to before computing the render pass.
  25495. * @param camera The camera to apply the render pass to.
  25496. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25497. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25499. * @param engine The engine which the post process will be applied. (default: current engine)
  25500. * @param reusable If the post process can be reused on the same frame. (default: false)
  25501. * @param textureType Type of textures used when performing the post process. (default: 0)
  25502. * @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)
  25503. */
  25504. 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);
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. /**
  25509. * Specifies the level of max blur that should be applied when using the depth of field effect
  25510. */
  25511. enum DepthOfFieldEffectBlurLevel {
  25512. /**
  25513. * Subtle blur
  25514. */
  25515. Low = 0,
  25516. /**
  25517. * Medium blur
  25518. */
  25519. Medium = 1,
  25520. /**
  25521. * Large blur
  25522. */
  25523. High = 2,
  25524. }
  25525. /**
  25526. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25527. */
  25528. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25529. private _circleOfConfusion;
  25530. /**
  25531. * Internal, blurs from high to low
  25532. */
  25533. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25534. private _depthOfFieldBlurY;
  25535. private _dofMerge;
  25536. /**
  25537. * Internal post processes in depth of field effect
  25538. */
  25539. _effects: Array<PostProcess>;
  25540. /**
  25541. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25542. */
  25543. focalLength: number;
  25544. /**
  25545. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25546. */
  25547. fStop: number;
  25548. /**
  25549. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25550. */
  25551. focusDistance: number;
  25552. /**
  25553. * 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.
  25554. */
  25555. lensSize: number;
  25556. /**
  25557. * Creates a new instance DepthOfFieldEffect
  25558. * @param scene The scene the effect belongs to.
  25559. * @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.
  25560. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25561. * @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)
  25562. */
  25563. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25564. /**
  25565. * 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.
  25566. */
  25567. depthTexture: RenderTargetTexture;
  25568. /**
  25569. * Disposes each of the internal effects for a given camera.
  25570. * @param camera The camera to dispose the effect on.
  25571. */
  25572. disposeEffects(camera: Camera): void;
  25573. /**
  25574. * Internal
  25575. */
  25576. _updateEffects(): void;
  25577. /**
  25578. * Internal
  25579. * @returns if all the contained post processes are ready.
  25580. */
  25581. _isReady(): boolean;
  25582. }
  25583. }
  25584. declare module BABYLON {
  25585. /**
  25586. * Options to be set when merging outputs from the default pipeline.
  25587. */
  25588. class DepthOfFieldMergePostProcessOptions {
  25589. /**
  25590. * The original image to merge on top of
  25591. */
  25592. originalFromInput: PostProcess;
  25593. /**
  25594. * Parameters to perform the merge of the depth of field effect
  25595. */
  25596. depthOfField?: {
  25597. circleOfConfusion: PostProcess;
  25598. blurSteps: Array<PostProcess>;
  25599. };
  25600. /**
  25601. * Parameters to perform the merge of bloom effect
  25602. */
  25603. bloom?: {
  25604. blurred: PostProcess;
  25605. weight: number;
  25606. };
  25607. }
  25608. /**
  25609. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25610. */
  25611. class DepthOfFieldMergePostProcess extends PostProcess {
  25612. private blurSteps;
  25613. /**
  25614. * Creates a new instance of DepthOfFieldMergePostProcess
  25615. * @param name The name of the effect.
  25616. * @param originalFromInput Post process which's input will be used for the merge.
  25617. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25618. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25619. * @param options The required width/height ratio to downsize to before computing the render pass.
  25620. * @param camera The camera to apply the render pass to.
  25621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25622. * @param engine The engine which the post process will be applied. (default: current engine)
  25623. * @param reusable If the post process can be reused on the same frame. (default: false)
  25624. * @param textureType Type of textures used when performing the post process. (default: 0)
  25625. * @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)
  25626. */
  25627. 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);
  25628. /**
  25629. * Updates the effect with the current post process compile time values and recompiles the shader.
  25630. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25631. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25632. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25633. * @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
  25634. * @param onCompiled Called when the shader has been compiled.
  25635. * @param onError Called if there is an error when compiling a shader.
  25636. */
  25637. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25638. }
  25639. }
  25640. declare module BABYLON {
  25641. class DisplayPassPostProcess extends PostProcess {
  25642. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25643. }
  25644. }
  25645. declare module BABYLON {
  25646. /**
  25647. * 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.
  25648. */
  25649. class ExtractHighlightsPostProcess extends PostProcess {
  25650. /**
  25651. * The luminance threshold, pixels below this value will be set to black.
  25652. */
  25653. threshold: number;
  25654. /**
  25655. * Internal
  25656. */
  25657. _exposure: number;
  25658. /**
  25659. * Post process which has the input texture to be used when performing highlight extraction
  25660. */
  25661. _inputPostProcess: Nullable<PostProcess>;
  25662. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25663. }
  25664. }
  25665. declare module BABYLON {
  25666. class FilterPostProcess extends PostProcess {
  25667. kernelMatrix: Matrix;
  25668. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25669. }
  25670. }
  25671. declare module BABYLON {
  25672. class FxaaPostProcess extends PostProcess {
  25673. texelWidth: number;
  25674. texelHeight: number;
  25675. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25676. }
  25677. }
  25678. declare module BABYLON {
  25679. /**
  25680. * The GrainPostProcess adds noise to the image at mid luminance levels
  25681. */
  25682. class GrainPostProcess extends PostProcess {
  25683. /**
  25684. * The intensity of the grain added (default: 30)
  25685. */
  25686. intensity: number;
  25687. /**
  25688. * If the grain should be randomized on every frame
  25689. */
  25690. animated: boolean;
  25691. /**
  25692. * Creates a new instance of @see GrainPostProcess
  25693. * @param name The name of the effect.
  25694. * @param options The required width/height ratio to downsize to before computing the render pass.
  25695. * @param camera The camera to apply the render pass to.
  25696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25697. * @param engine The engine which the post process will be applied. (default: current engine)
  25698. * @param reusable If the post process can be reused on the same frame. (default: false)
  25699. * @param textureType Type of textures used when performing the post process. (default: 0)
  25700. * @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)
  25701. */
  25702. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25703. }
  25704. }
  25705. declare module BABYLON {
  25706. class HighlightsPostProcess extends PostProcess {
  25707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25708. }
  25709. }
  25710. declare module BABYLON {
  25711. class ImageProcessingPostProcess extends PostProcess {
  25712. /**
  25713. * Default configuration related to image processing available in the PBR Material.
  25714. */
  25715. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25716. /**
  25717. * Gets the image processing configuration used either in this material.
  25718. */
  25719. /**
  25720. * Sets the Default image processing configuration used either in the this material.
  25721. *
  25722. * If sets to null, the scene one is in use.
  25723. */
  25724. imageProcessingConfiguration: ImageProcessingConfiguration;
  25725. /**
  25726. * Keep track of the image processing observer to allow dispose and replace.
  25727. */
  25728. private _imageProcessingObserver;
  25729. /**
  25730. * Attaches a new image processing configuration to the PBR Material.
  25731. * @param configuration
  25732. */
  25733. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25734. /**
  25735. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25736. */
  25737. /**
  25738. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25739. */
  25740. colorCurves: Nullable<ColorCurves>;
  25741. /**
  25742. * Gets wether the color curves effect is enabled.
  25743. */
  25744. /**
  25745. * Sets wether the color curves effect is enabled.
  25746. */
  25747. colorCurvesEnabled: boolean;
  25748. /**
  25749. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25750. */
  25751. /**
  25752. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25753. */
  25754. colorGradingTexture: Nullable<BaseTexture>;
  25755. /**
  25756. * Gets wether the color grading effect is enabled.
  25757. */
  25758. /**
  25759. * Gets wether the color grading effect is enabled.
  25760. */
  25761. colorGradingEnabled: boolean;
  25762. /**
  25763. * Gets exposure used in the effect.
  25764. */
  25765. /**
  25766. * Sets exposure used in the effect.
  25767. */
  25768. exposure: number;
  25769. /**
  25770. * Gets wether tonemapping is enabled or not.
  25771. */
  25772. /**
  25773. * Sets wether tonemapping is enabled or not
  25774. */
  25775. toneMappingEnabled: boolean;
  25776. /**
  25777. * Gets contrast used in the effect.
  25778. */
  25779. /**
  25780. * Sets contrast used in the effect.
  25781. */
  25782. contrast: number;
  25783. /**
  25784. * Gets Vignette stretch size.
  25785. */
  25786. /**
  25787. * Sets Vignette stretch size.
  25788. */
  25789. vignetteStretch: number;
  25790. /**
  25791. * Gets Vignette centre X Offset.
  25792. */
  25793. /**
  25794. * Sets Vignette centre X Offset.
  25795. */
  25796. vignetteCentreX: number;
  25797. /**
  25798. * Gets Vignette centre Y Offset.
  25799. */
  25800. /**
  25801. * Sets Vignette centre Y Offset.
  25802. */
  25803. vignetteCentreY: number;
  25804. /**
  25805. * Gets Vignette weight or intensity of the vignette effect.
  25806. */
  25807. /**
  25808. * Sets Vignette weight or intensity of the vignette effect.
  25809. */
  25810. vignetteWeight: number;
  25811. /**
  25812. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25813. * if vignetteEnabled is set to true.
  25814. */
  25815. /**
  25816. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25817. * if vignetteEnabled is set to true.
  25818. */
  25819. vignetteColor: Color4;
  25820. /**
  25821. * Gets Camera field of view used by the Vignette effect.
  25822. */
  25823. /**
  25824. * Sets Camera field of view used by the Vignette effect.
  25825. */
  25826. vignetteCameraFov: number;
  25827. /**
  25828. * Gets the vignette blend mode allowing different kind of effect.
  25829. */
  25830. /**
  25831. * Sets the vignette blend mode allowing different kind of effect.
  25832. */
  25833. vignetteBlendMode: number;
  25834. /**
  25835. * Gets wether the vignette effect is enabled.
  25836. */
  25837. /**
  25838. * Sets wether the vignette effect is enabled.
  25839. */
  25840. vignetteEnabled: boolean;
  25841. private _fromLinearSpace;
  25842. /**
  25843. * Gets wether the input of the processing is in Gamma or Linear Space.
  25844. */
  25845. /**
  25846. * Sets wether the input of the processing is in Gamma or Linear Space.
  25847. */
  25848. fromLinearSpace: boolean;
  25849. /**
  25850. * Defines cache preventing GC.
  25851. */
  25852. private _defines;
  25853. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25854. getClassName(): string;
  25855. protected _updateParameters(): void;
  25856. dispose(camera?: Camera): void;
  25857. }
  25858. }
  25859. declare module BABYLON {
  25860. class PassPostProcess extends PostProcess {
  25861. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25862. }
  25863. }
  25864. declare module BABYLON {
  25865. type PostProcessOptions = {
  25866. width: number;
  25867. height: number;
  25868. };
  25869. /**
  25870. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25871. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25872. */
  25873. class PostProcess {
  25874. /** Name of the PostProcess. */ name: string;
  25875. /**
  25876. * Width of the texture to apply the post process on
  25877. */
  25878. width: number;
  25879. /**
  25880. * Height of the texture to apply the post process on
  25881. */
  25882. height: number;
  25883. /**
  25884. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25885. */
  25886. _outputTexture: Nullable<InternalTexture>;
  25887. /**
  25888. * Sampling mode used by the shader
  25889. * See https://doc.babylonjs.com/classes/3.1/texture
  25890. */
  25891. renderTargetSamplingMode: number;
  25892. /**
  25893. * Clear color to use when screen clearing
  25894. */
  25895. clearColor: Color4;
  25896. /**
  25897. * If the buffer needs to be cleared before applying the post process. (default: true)
  25898. * Should be set to false if shader will overwrite all previous pixels.
  25899. */
  25900. autoClear: boolean;
  25901. /**
  25902. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  25903. */
  25904. alphaMode: number;
  25905. /**
  25906. * Sets the setAlphaBlendConstants of the babylon engine
  25907. */
  25908. alphaConstants: Color4;
  25909. /**
  25910. * Animations to be used for the post processing
  25911. */
  25912. animations: Animation[];
  25913. /**
  25914. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  25915. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  25916. */
  25917. enablePixelPerfectMode: boolean;
  25918. /**
  25919. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  25920. */
  25921. scaleMode: number;
  25922. /**
  25923. * Force textures to be a power of two (default: false)
  25924. */
  25925. alwaysForcePOT: boolean;
  25926. /**
  25927. * Number of sample textures (default: 1)
  25928. */
  25929. samples: number;
  25930. /**
  25931. * Modify the scale of the post process to be the same as the viewport (default: false)
  25932. */
  25933. adaptScaleToCurrentViewport: boolean;
  25934. private _camera;
  25935. private _scene;
  25936. private _engine;
  25937. private _options;
  25938. private _reusable;
  25939. private _textureType;
  25940. /**
  25941. * Smart array of input and output textures for the post process.
  25942. */
  25943. _textures: SmartArray<InternalTexture>;
  25944. /**
  25945. * The index in _textures that corresponds to the output texture.
  25946. */
  25947. _currentRenderTextureInd: number;
  25948. private _effect;
  25949. private _samplers;
  25950. private _fragmentUrl;
  25951. private _vertexUrl;
  25952. private _parameters;
  25953. private _scaleRatio;
  25954. protected _indexParameters: any;
  25955. private _shareOutputWithPostProcess;
  25956. private _texelSize;
  25957. private _forcedOutputTexture;
  25958. /**
  25959. * An event triggered when the postprocess is activated.
  25960. */
  25961. onActivateObservable: Observable<Camera>;
  25962. private _onActivateObserver;
  25963. /**
  25964. * A function that is added to the onActivateObservable
  25965. */
  25966. onActivate: Nullable<(camera: Camera) => void>;
  25967. /**
  25968. * An event triggered when the postprocess changes its size.
  25969. */
  25970. onSizeChangedObservable: Observable<PostProcess>;
  25971. private _onSizeChangedObserver;
  25972. /**
  25973. * A function that is added to the onSizeChangedObservable
  25974. */
  25975. onSizeChanged: (postProcess: PostProcess) => void;
  25976. /**
  25977. * An event triggered when the postprocess applies its effect.
  25978. */
  25979. onApplyObservable: Observable<Effect>;
  25980. private _onApplyObserver;
  25981. /**
  25982. * A function that is added to the onApplyObservable
  25983. */
  25984. onApply: (effect: Effect) => void;
  25985. /**
  25986. * An event triggered before rendering the postprocess
  25987. */
  25988. onBeforeRenderObservable: Observable<Effect>;
  25989. private _onBeforeRenderObserver;
  25990. /**
  25991. * A function that is added to the onBeforeRenderObservable
  25992. */
  25993. onBeforeRender: (effect: Effect) => void;
  25994. /**
  25995. * An event triggered after rendering the postprocess
  25996. */
  25997. onAfterRenderObservable: Observable<Effect>;
  25998. private _onAfterRenderObserver;
  25999. /**
  26000. * A function that is added to the onAfterRenderObservable
  26001. */
  26002. onAfterRender: (efect: Effect) => void;
  26003. /**
  26004. * 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
  26005. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26006. */
  26007. inputTexture: InternalTexture;
  26008. /**
  26009. * Gets the camera which post process is applied to.
  26010. * @returns The camera the post process is applied to.
  26011. */
  26012. getCamera(): Camera;
  26013. /**
  26014. * Gets the texel size of the postprocess.
  26015. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26016. */
  26017. readonly texelSize: Vector2;
  26018. /**
  26019. * Creates a new instance PostProcess
  26020. * @param name The name of the PostProcess.
  26021. * @param fragmentUrl The url of the fragment shader to be used.
  26022. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26023. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26024. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26025. * @param camera The camera to apply the render pass to.
  26026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26027. * @param engine The engine which the post process will be applied. (default: current engine)
  26028. * @param reusable If the post process can be reused on the same frame. (default: false)
  26029. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26030. * @param textureType Type of textures used when performing the post process. (default: 0)
  26031. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26032. * @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
  26033. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26034. */
  26035. 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);
  26036. /**
  26037. * Gets the engine which this post process belongs to.
  26038. * @returns The engine the post process was enabled with.
  26039. */
  26040. getEngine(): Engine;
  26041. /**
  26042. * The effect that is created when initializing the post process.
  26043. * @returns The created effect corrisponding the the postprocess.
  26044. */
  26045. getEffect(): Effect;
  26046. /**
  26047. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26048. * @param postProcess The post process to share the output with.
  26049. * @returns This post process.
  26050. */
  26051. shareOutputWith(postProcess: PostProcess): PostProcess;
  26052. /**
  26053. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26054. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26055. */
  26056. useOwnOutput(): void;
  26057. /**
  26058. * Updates the effect with the current post process compile time values and recompiles the shader.
  26059. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26060. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26061. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26062. * @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
  26063. * @param onCompiled Called when the shader has been compiled.
  26064. * @param onError Called if there is an error when compiling a shader.
  26065. */
  26066. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26067. /**
  26068. * The post process is reusable if it can be used multiple times within one frame.
  26069. * @returns If the post process is reusable
  26070. */
  26071. isReusable(): boolean;
  26072. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26073. markTextureDirty(): void;
  26074. /**
  26075. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26076. * 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.
  26077. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26078. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26079. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26080. * @returns The target texture that was bound to be written to.
  26081. */
  26082. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26083. /**
  26084. * If the post process is supported.
  26085. */
  26086. readonly isSupported: boolean;
  26087. /**
  26088. * The aspect ratio of the output texture.
  26089. */
  26090. readonly aspectRatio: number;
  26091. /**
  26092. * Get a value indicating if the post-process is ready to be used
  26093. * @returns true if the post-process is ready (shader is compiled)
  26094. */
  26095. isReady(): boolean;
  26096. /**
  26097. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26098. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26099. */
  26100. apply(): Nullable<Effect>;
  26101. private _disposeTextures();
  26102. /**
  26103. * Disposes the post process.
  26104. * @param camera The camera to dispose the post process on.
  26105. */
  26106. dispose(camera?: Camera): void;
  26107. }
  26108. }
  26109. declare module BABYLON {
  26110. /**
  26111. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26112. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26113. */
  26114. class PostProcessManager {
  26115. private _scene;
  26116. private _indexBuffer;
  26117. private _vertexBuffers;
  26118. /**
  26119. * Creates a new instance PostProcess
  26120. * @param scene The scene that the post process is associated with.
  26121. */
  26122. constructor(scene: Scene);
  26123. private _prepareBuffers();
  26124. private _buildIndexBuffer();
  26125. /**
  26126. * Rebuilds the vertex buffers of the manager.
  26127. */
  26128. _rebuild(): void;
  26129. /**
  26130. * Prepares a frame to be run through a post process.
  26131. * @param sourceTexture The input texture to the post procesess. (default: null)
  26132. * @param postProcesses An array of post processes to be run. (default: null)
  26133. * @returns True if the post processes were able to be run.
  26134. */
  26135. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26136. /**
  26137. * Manually render a set of post processes to a texture.
  26138. * @param postProcesses An array of post processes to be run.
  26139. * @param targetTexture The target texture to render to.
  26140. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26141. */
  26142. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26143. /**
  26144. * Finalize the result of the output of the postprocesses.
  26145. * @param doNotPresent If true the result will not be displayed to the screen.
  26146. * @param targetTexture The target texture to render to.
  26147. * @param faceIndex The index of the face to bind the target texture to.
  26148. * @param postProcesses The array of post processes to render.
  26149. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26150. */
  26151. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26152. /**
  26153. * Disposes of the post process manager.
  26154. */
  26155. dispose(): void;
  26156. }
  26157. }
  26158. declare module BABYLON {
  26159. class RefractionPostProcess extends PostProcess {
  26160. color: Color3;
  26161. depth: number;
  26162. colorLevel: number;
  26163. private _refTexture;
  26164. private _ownRefractionTexture;
  26165. /**
  26166. * Gets or sets the refraction texture
  26167. * Please note that you are responsible for disposing the texture if you set it manually
  26168. */
  26169. refractionTexture: Texture;
  26170. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26171. dispose(camera: Camera): void;
  26172. }
  26173. }
  26174. declare module BABYLON {
  26175. /**
  26176. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26177. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26178. */
  26179. class SharpenPostProcess extends PostProcess {
  26180. /**
  26181. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26182. */
  26183. colorAmount: number;
  26184. /**
  26185. * How much sharpness should be applied (default: 0.3)
  26186. */
  26187. edgeAmount: number;
  26188. /**
  26189. * Creates a new instance ConvolutionPostProcess
  26190. * @param name The name of the effect.
  26191. * @param options The required width/height ratio to downsize to before computing the render pass.
  26192. * @param camera The camera to apply the render pass to.
  26193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26194. * @param engine The engine which the post process will be applied. (default: current engine)
  26195. * @param reusable If the post process can be reused on the same frame. (default: false)
  26196. * @param textureType Type of textures used when performing the post process. (default: 0)
  26197. * @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)
  26198. */
  26199. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26200. }
  26201. }
  26202. declare module BABYLON {
  26203. class StereoscopicInterlacePostProcess extends PostProcess {
  26204. private _stepSize;
  26205. private _passedProcess;
  26206. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26207. }
  26208. }
  26209. declare module BABYLON {
  26210. /** Defines operator used for tonemapping */
  26211. enum TonemappingOperator {
  26212. /** Hable */
  26213. Hable = 0,
  26214. /** Reinhard */
  26215. Reinhard = 1,
  26216. /** HejiDawson */
  26217. HejiDawson = 2,
  26218. /** Photographic */
  26219. Photographic = 3,
  26220. }
  26221. /**
  26222. * Defines a post process to apply tone mapping
  26223. */
  26224. class TonemapPostProcess extends PostProcess {
  26225. private _operator;
  26226. /** Defines the required exposure adjustement */
  26227. exposureAdjustment: number;
  26228. /**
  26229. * Creates a new TonemapPostProcess
  26230. * @param name defines the name of the postprocess
  26231. * @param _operator defines the operator to use
  26232. * @param exposureAdjustment defines the required exposure adjustement
  26233. * @param camera defines the camera to use (can be null)
  26234. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26235. * @param engine defines the hosting engine (can be ignore if camera is set)
  26236. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26237. */
  26238. constructor(name: string, _operator: TonemappingOperator,
  26239. /** Defines the required exposure adjustement */
  26240. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26241. }
  26242. }
  26243. declare module BABYLON {
  26244. class VolumetricLightScatteringPostProcess extends PostProcess {
  26245. private _volumetricLightScatteringPass;
  26246. private _volumetricLightScatteringRTT;
  26247. private _viewPort;
  26248. private _screenCoordinates;
  26249. private _cachedDefines;
  26250. /**
  26251. * If not undefined, the mesh position is computed from the attached node position
  26252. */
  26253. attachedNode: {
  26254. position: Vector3;
  26255. };
  26256. /**
  26257. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26258. */
  26259. customMeshPosition: Vector3;
  26260. /**
  26261. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26262. */
  26263. useCustomMeshPosition: boolean;
  26264. /**
  26265. * If the post-process should inverse the light scattering direction
  26266. */
  26267. invert: boolean;
  26268. /**
  26269. * The internal mesh used by the post-process
  26270. */
  26271. mesh: Mesh;
  26272. useDiffuseColor: boolean;
  26273. /**
  26274. * Array containing the excluded meshes not rendered in the internal pass
  26275. */
  26276. excludedMeshes: AbstractMesh[];
  26277. /**
  26278. * Controls the overall intensity of the post-process
  26279. */
  26280. exposure: number;
  26281. /**
  26282. * Dissipates each sample's contribution in range [0, 1]
  26283. */
  26284. decay: number;
  26285. /**
  26286. * Controls the overall intensity of each sample
  26287. */
  26288. weight: number;
  26289. /**
  26290. * Controls the density of each sample
  26291. */
  26292. density: number;
  26293. /**
  26294. * @constructor
  26295. * @param {string} name - The post-process name
  26296. * @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)
  26297. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26298. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26299. * @param {number} samples - The post-process quality, default 100
  26300. * @param {number} samplingMode - The post-process filtering mode
  26301. * @param {BABYLON.Engine} engine - The babylon engine
  26302. * @param {boolean} reusable - If the post-process is reusable
  26303. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26304. */
  26305. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26306. getClassName(): string;
  26307. private _isReady(subMesh, useInstances);
  26308. /**
  26309. * Sets the new light position for light scattering effect
  26310. * @param {BABYLON.Vector3} The new custom light position
  26311. */
  26312. setCustomMeshPosition(position: Vector3): void;
  26313. /**
  26314. * Returns the light position for light scattering effect
  26315. * @return {BABYLON.Vector3} The custom light position
  26316. */
  26317. getCustomMeshPosition(): Vector3;
  26318. /**
  26319. * Disposes the internal assets and detaches the post-process from the camera
  26320. */
  26321. dispose(camera: Camera): void;
  26322. /**
  26323. * Returns the render target texture used by the post-process
  26324. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26325. */
  26326. getPass(): RenderTargetTexture;
  26327. private _meshExcluded(mesh);
  26328. private _createPass(scene, ratio);
  26329. private _updateMeshScreenCoordinates(scene);
  26330. /**
  26331. * Creates a default mesh for the Volumeric Light Scattering post-process
  26332. * @param {string} The mesh name
  26333. * @param {BABYLON.Scene} The scene where to create the mesh
  26334. * @return {BABYLON.Mesh} the default mesh
  26335. */
  26336. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26337. }
  26338. }
  26339. declare module BABYLON {
  26340. class VRDistortionCorrectionPostProcess extends PostProcess {
  26341. private _isRightEye;
  26342. private _distortionFactors;
  26343. private _postProcessScaleFactor;
  26344. private _lensCenterOffset;
  26345. private _scaleIn;
  26346. private _scaleFactor;
  26347. private _lensCenter;
  26348. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26349. }
  26350. }
  26351. declare module BABYLON {
  26352. /**
  26353. * @hidden
  26354. **/
  26355. class _AlphaState {
  26356. private _isAlphaBlendDirty;
  26357. private _isBlendFunctionParametersDirty;
  26358. private _isBlendEquationParametersDirty;
  26359. private _isBlendConstantsDirty;
  26360. private _alphaBlend;
  26361. private _blendFunctionParameters;
  26362. private _blendEquationParameters;
  26363. private _blendConstants;
  26364. /**
  26365. * Initializes the state.
  26366. */
  26367. constructor();
  26368. readonly isDirty: boolean;
  26369. alphaBlend: boolean;
  26370. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26371. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26372. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26373. reset(): void;
  26374. apply(gl: WebGLRenderingContext): void;
  26375. }
  26376. }
  26377. declare module BABYLON {
  26378. /**
  26379. * @hidden
  26380. **/
  26381. class _DepthCullingState {
  26382. private _isDepthTestDirty;
  26383. private _isDepthMaskDirty;
  26384. private _isDepthFuncDirty;
  26385. private _isCullFaceDirty;
  26386. private _isCullDirty;
  26387. private _isZOffsetDirty;
  26388. private _isFrontFaceDirty;
  26389. private _depthTest;
  26390. private _depthMask;
  26391. private _depthFunc;
  26392. private _cull;
  26393. private _cullFace;
  26394. private _zOffset;
  26395. private _frontFace;
  26396. /**
  26397. * Initializes the state.
  26398. */
  26399. constructor();
  26400. readonly isDirty: boolean;
  26401. zOffset: number;
  26402. cullFace: Nullable<number>;
  26403. cull: Nullable<boolean>;
  26404. depthFunc: Nullable<number>;
  26405. depthMask: boolean;
  26406. depthTest: boolean;
  26407. frontFace: Nullable<number>;
  26408. reset(): void;
  26409. apply(gl: WebGLRenderingContext): void;
  26410. }
  26411. }
  26412. declare module BABYLON {
  26413. /**
  26414. * @hidden
  26415. **/
  26416. class _StencilState {
  26417. private _isStencilTestDirty;
  26418. private _isStencilMaskDirty;
  26419. private _isStencilFuncDirty;
  26420. private _isStencilOpDirty;
  26421. private _stencilTest;
  26422. private _stencilMask;
  26423. private _stencilFunc;
  26424. private _stencilFuncRef;
  26425. private _stencilFuncMask;
  26426. private _stencilOpStencilFail;
  26427. private _stencilOpDepthFail;
  26428. private _stencilOpStencilDepthPass;
  26429. readonly isDirty: boolean;
  26430. stencilFunc: number;
  26431. stencilFuncRef: number;
  26432. stencilFuncMask: number;
  26433. stencilOpStencilFail: number;
  26434. stencilOpDepthFail: number;
  26435. stencilOpStencilDepthPass: number;
  26436. stencilMask: number;
  26437. stencilTest: boolean;
  26438. constructor();
  26439. reset(): void;
  26440. apply(gl: WebGLRenderingContext): void;
  26441. }
  26442. }
  26443. declare module BABYLON {
  26444. /**
  26445. * Class used to evalaute queries containing `and` and `or` operators
  26446. */
  26447. class AndOrNotEvaluator {
  26448. /**
  26449. * Evaluate a query
  26450. * @param query defines the query to evaluate
  26451. * @param evaluateCallback defines the callback used to filter result
  26452. * @returns true if the query matches
  26453. */
  26454. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26455. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26456. private static _SimplifyNegation(booleanString);
  26457. }
  26458. }
  26459. declare module BABYLON {
  26460. /**
  26461. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26462. */
  26463. enum AssetTaskState {
  26464. /**
  26465. * Initialization
  26466. */
  26467. INIT = 0,
  26468. /**
  26469. * Running
  26470. */
  26471. RUNNING = 1,
  26472. /**
  26473. * Done
  26474. */
  26475. DONE = 2,
  26476. /**
  26477. * Error
  26478. */
  26479. ERROR = 3,
  26480. }
  26481. /**
  26482. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26483. */
  26484. abstract class AbstractAssetTask {
  26485. /**
  26486. * Task name
  26487. */ name: string;
  26488. /**
  26489. * Callback called when the task is successful
  26490. */
  26491. onSuccess: (task: any) => void;
  26492. /**
  26493. * Callback called when the task is not successful
  26494. */
  26495. onError: (task: any, message?: string, exception?: any) => void;
  26496. /**
  26497. * Creates a new {BABYLON.AssetsManager}
  26498. * @param name defines the name of the task
  26499. */
  26500. constructor(
  26501. /**
  26502. * Task name
  26503. */ name: string);
  26504. private _isCompleted;
  26505. private _taskState;
  26506. private _errorObject;
  26507. /**
  26508. * Get if the task is completed
  26509. */
  26510. readonly isCompleted: boolean;
  26511. /**
  26512. * Gets the current state of the task
  26513. */
  26514. readonly taskState: AssetTaskState;
  26515. /**
  26516. * Gets the current error object (if task is in error)
  26517. */
  26518. readonly errorObject: {
  26519. message?: string;
  26520. exception?: any;
  26521. };
  26522. /**
  26523. * Internal only
  26524. * @hidden
  26525. */
  26526. _setErrorObject(message?: string, exception?: any): void;
  26527. /**
  26528. * Execute the current task
  26529. * @param scene defines the scene where you want your assets to be loaded
  26530. * @param onSuccess is a callback called when the task is successfully executed
  26531. * @param onError is a callback called if an error occurs
  26532. */
  26533. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26534. /**
  26535. * Execute the current task
  26536. * @param scene defines the scene where you want your assets to be loaded
  26537. * @param onSuccess is a callback called when the task is successfully executed
  26538. * @param onError is a callback called if an error occurs
  26539. */
  26540. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26541. private onErrorCallback(onError, message?, exception?);
  26542. private onDoneCallback(onSuccess, onError);
  26543. }
  26544. /**
  26545. * Define the interface used by progress events raised during assets loading
  26546. */
  26547. interface IAssetsProgressEvent {
  26548. /**
  26549. * Defines the number of remaining tasks to process
  26550. */
  26551. remainingCount: number;
  26552. /**
  26553. * Defines the total number of tasks
  26554. */
  26555. totalCount: number;
  26556. /**
  26557. * Defines the task that was just processed
  26558. */
  26559. task: AbstractAssetTask;
  26560. }
  26561. /**
  26562. * Class used to share progress information about assets loading
  26563. */
  26564. class AssetsProgressEvent implements IAssetsProgressEvent {
  26565. /**
  26566. * Defines the number of remaining tasks to process
  26567. */
  26568. remainingCount: number;
  26569. /**
  26570. * Defines the total number of tasks
  26571. */
  26572. totalCount: number;
  26573. /**
  26574. * Defines the task that was just processed
  26575. */
  26576. task: AbstractAssetTask;
  26577. /**
  26578. * Creates a {BABYLON.AssetsProgressEvent}
  26579. * @param remainingCount defines the number of remaining tasks to process
  26580. * @param totalCount defines the total number of tasks
  26581. * @param task defines the task that was just processed
  26582. */
  26583. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26584. }
  26585. /**
  26586. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26587. */
  26588. class MeshAssetTask extends AbstractAssetTask {
  26589. /**
  26590. * Defines the name of the task
  26591. */
  26592. name: string;
  26593. /**
  26594. * Defines the list of mesh's names you want to load
  26595. */
  26596. meshesNames: any;
  26597. /**
  26598. * Defines the root url to use as a base to load your meshes and associated resources
  26599. */
  26600. rootUrl: string;
  26601. /**
  26602. * Defines the filename of the scene to load from
  26603. */
  26604. sceneFilename: string;
  26605. /**
  26606. * Gets the list of loaded meshes
  26607. */
  26608. loadedMeshes: Array<AbstractMesh>;
  26609. /**
  26610. * Gets the list of loaded particle systems
  26611. */
  26612. loadedParticleSystems: Array<ParticleSystem>;
  26613. /**
  26614. * Gets the list of loaded skeletons
  26615. */
  26616. loadedSkeletons: Array<Skeleton>;
  26617. /**
  26618. * Callback called when the task is successful
  26619. */
  26620. onSuccess: (task: MeshAssetTask) => void;
  26621. /**
  26622. * Callback called when the task is successful
  26623. */
  26624. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26625. /**
  26626. * Creates a new {BABYLON.MeshAssetTask}
  26627. * @param name defines the name of the task
  26628. * @param meshesNames defines the list of mesh's names you want to load
  26629. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26630. * @param sceneFilename defines the filename of the scene to load from
  26631. */
  26632. constructor(
  26633. /**
  26634. * Defines the name of the task
  26635. */
  26636. name: string,
  26637. /**
  26638. * Defines the list of mesh's names you want to load
  26639. */
  26640. meshesNames: any,
  26641. /**
  26642. * Defines the root url to use as a base to load your meshes and associated resources
  26643. */
  26644. rootUrl: string,
  26645. /**
  26646. * Defines the filename of the scene to load from
  26647. */
  26648. sceneFilename: string);
  26649. /**
  26650. * Execute the current task
  26651. * @param scene defines the scene where you want your assets to be loaded
  26652. * @param onSuccess is a callback called when the task is successfully executed
  26653. * @param onError is a callback called if an error occurs
  26654. */
  26655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26656. }
  26657. /**
  26658. * Define a task used by {BABYLON.AssetsManager} to load text content
  26659. */
  26660. class TextFileAssetTask extends AbstractAssetTask {
  26661. /**
  26662. * Defines the name of the task
  26663. */
  26664. name: string;
  26665. /**
  26666. * Defines the location of the file to load
  26667. */
  26668. url: string;
  26669. /**
  26670. * Gets the loaded text string
  26671. */
  26672. text: string;
  26673. /**
  26674. * Callback called when the task is successful
  26675. */
  26676. onSuccess: (task: TextFileAssetTask) => void;
  26677. /**
  26678. * Callback called when the task is successful
  26679. */
  26680. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26681. /**
  26682. * Creates a new TextFileAssetTask object
  26683. * @param name defines the name of the task
  26684. * @param url defines the location of the file to load
  26685. */
  26686. constructor(
  26687. /**
  26688. * Defines the name of the task
  26689. */
  26690. name: string,
  26691. /**
  26692. * Defines the location of the file to load
  26693. */
  26694. url: string);
  26695. /**
  26696. * Execute the current task
  26697. * @param scene defines the scene where you want your assets to be loaded
  26698. * @param onSuccess is a callback called when the task is successfully executed
  26699. * @param onError is a callback called if an error occurs
  26700. */
  26701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26702. }
  26703. /**
  26704. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26705. */
  26706. class BinaryFileAssetTask extends AbstractAssetTask {
  26707. /**
  26708. * Defines the name of the task
  26709. */
  26710. name: string;
  26711. /**
  26712. * Defines the location of the file to load
  26713. */
  26714. url: string;
  26715. /**
  26716. * Gets the lodaded data (as an array buffer)
  26717. */
  26718. data: ArrayBuffer;
  26719. /**
  26720. * Callback called when the task is successful
  26721. */
  26722. onSuccess: (task: BinaryFileAssetTask) => void;
  26723. /**
  26724. * Callback called when the task is successful
  26725. */
  26726. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  26727. /**
  26728. * Creates a new BinaryFileAssetTask object
  26729. * @param name defines the name of the new task
  26730. * @param url defines the location of the file to load
  26731. */
  26732. constructor(
  26733. /**
  26734. * Defines the name of the task
  26735. */
  26736. name: string,
  26737. /**
  26738. * Defines the location of the file to load
  26739. */
  26740. url: string);
  26741. /**
  26742. * Execute the current task
  26743. * @param scene defines the scene where you want your assets to be loaded
  26744. * @param onSuccess is a callback called when the task is successfully executed
  26745. * @param onError is a callback called if an error occurs
  26746. */
  26747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26748. }
  26749. /**
  26750. * Define a task used by {BABYLON.AssetsManager} to load images
  26751. */
  26752. class ImageAssetTask extends AbstractAssetTask {
  26753. /**
  26754. * Defines the name of the task
  26755. */
  26756. name: string;
  26757. /**
  26758. * Defines the location of the image to load
  26759. */
  26760. url: string;
  26761. /**
  26762. * Gets the loaded images
  26763. */
  26764. image: HTMLImageElement;
  26765. /**
  26766. * Callback called when the task is successful
  26767. */
  26768. onSuccess: (task: ImageAssetTask) => void;
  26769. /**
  26770. * Callback called when the task is successful
  26771. */
  26772. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  26773. /**
  26774. * Creates a new ImageAssetTask
  26775. * @param name defines the name of the task
  26776. * @param url defines the location of the image to load
  26777. */
  26778. constructor(
  26779. /**
  26780. * Defines the name of the task
  26781. */
  26782. name: string,
  26783. /**
  26784. * Defines the location of the image to load
  26785. */
  26786. url: string);
  26787. /**
  26788. * Execute the current task
  26789. * @param scene defines the scene where you want your assets to be loaded
  26790. * @param onSuccess is a callback called when the task is successfully executed
  26791. * @param onError is a callback called if an error occurs
  26792. */
  26793. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26794. }
  26795. /**
  26796. * Defines the interface used by texture loading tasks
  26797. */
  26798. interface ITextureAssetTask<TEX extends BaseTexture> {
  26799. /**
  26800. * Gets the loaded texture
  26801. */
  26802. texture: TEX;
  26803. }
  26804. /**
  26805. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  26806. */
  26807. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  26808. /**
  26809. * Defines the name of the task
  26810. */
  26811. name: string;
  26812. /**
  26813. * Defines the location of the file to load
  26814. */
  26815. url: string;
  26816. /**
  26817. * Defines if mipmap should not be generated (default is false)
  26818. */
  26819. noMipmap: boolean | undefined;
  26820. /**
  26821. * Defines if texture must be inverted on Y axis (default is false)
  26822. */
  26823. invertY: boolean | undefined;
  26824. /**
  26825. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26826. */
  26827. samplingMode: number;
  26828. /**
  26829. * Gets the loaded texture
  26830. */
  26831. texture: Texture;
  26832. /**
  26833. * Callback called when the task is successful
  26834. */
  26835. onSuccess: (task: TextureAssetTask) => void;
  26836. /**
  26837. * Callback called when the task is successful
  26838. */
  26839. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  26840. /**
  26841. * Creates a new TextureAssetTask object
  26842. * @param name defines the name of the task
  26843. * @param url defines the location of the file to load
  26844. * @param noMipmap defines if mipmap should not be generated (default is false)
  26845. * @param invertY defines if texture must be inverted on Y axis (default is false)
  26846. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26847. */
  26848. constructor(
  26849. /**
  26850. * Defines the name of the task
  26851. */
  26852. name: string,
  26853. /**
  26854. * Defines the location of the file to load
  26855. */
  26856. url: string,
  26857. /**
  26858. * Defines if mipmap should not be generated (default is false)
  26859. */
  26860. noMipmap?: boolean | undefined,
  26861. /**
  26862. * Defines if texture must be inverted on Y axis (default is false)
  26863. */
  26864. invertY?: boolean | undefined,
  26865. /**
  26866. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26867. */
  26868. samplingMode?: number);
  26869. /**
  26870. * Execute the current task
  26871. * @param scene defines the scene where you want your assets to be loaded
  26872. * @param onSuccess is a callback called when the task is successfully executed
  26873. * @param onError is a callback called if an error occurs
  26874. */
  26875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26876. }
  26877. /**
  26878. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  26879. */
  26880. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  26881. /**
  26882. * Defines the name of the task
  26883. */
  26884. name: string;
  26885. /**
  26886. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26887. */
  26888. url: string;
  26889. /**
  26890. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26891. */
  26892. extensions: string[] | undefined;
  26893. /**
  26894. * Defines if mipmaps should not be generated (default is false)
  26895. */
  26896. noMipmap: boolean | undefined;
  26897. /**
  26898. * Defines the explicit list of files (undefined by default)
  26899. */
  26900. files: string[] | undefined;
  26901. /**
  26902. * Gets the loaded texture
  26903. */
  26904. texture: CubeTexture;
  26905. /**
  26906. * Callback called when the task is successful
  26907. */
  26908. onSuccess: (task: CubeTextureAssetTask) => void;
  26909. /**
  26910. * Callback called when the task is successful
  26911. */
  26912. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  26913. /**
  26914. * Creates a new CubeTextureAssetTask
  26915. * @param name defines the name of the task
  26916. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26917. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26918. * @param noMipmap defines if mipmaps should not be generated (default is false)
  26919. * @param files defines the explicit list of files (undefined by default)
  26920. */
  26921. constructor(
  26922. /**
  26923. * Defines the name of the task
  26924. */
  26925. name: string,
  26926. /**
  26927. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26928. */
  26929. url: string,
  26930. /**
  26931. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26932. */
  26933. extensions?: string[] | undefined,
  26934. /**
  26935. * Defines if mipmaps should not be generated (default is false)
  26936. */
  26937. noMipmap?: boolean | undefined,
  26938. /**
  26939. * Defines the explicit list of files (undefined by default)
  26940. */
  26941. files?: string[] | undefined);
  26942. /**
  26943. * Execute the current task
  26944. * @param scene defines the scene where you want your assets to be loaded
  26945. * @param onSuccess is a callback called when the task is successfully executed
  26946. * @param onError is a callback called if an error occurs
  26947. */
  26948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26949. }
  26950. /**
  26951. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  26952. */
  26953. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  26954. /**
  26955. * Defines the name of the task
  26956. */
  26957. name: string;
  26958. /**
  26959. * Defines the location of the file to load
  26960. */
  26961. url: string;
  26962. /**
  26963. * Defines the desired size (the more it increases the longer the generation will be)
  26964. */
  26965. size: number;
  26966. /**
  26967. * Defines if mipmaps should not be generated (default is false)
  26968. */
  26969. noMipmap: boolean;
  26970. /**
  26971. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  26972. */
  26973. generateHarmonics: boolean;
  26974. /**
  26975. * 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)
  26976. */
  26977. gammaSpace: boolean;
  26978. /**
  26979. * Internal Use Only
  26980. */
  26981. reserved: boolean;
  26982. /**
  26983. * Gets the loaded texture
  26984. */
  26985. texture: HDRCubeTexture;
  26986. /**
  26987. * Callback called when the task is successful
  26988. */
  26989. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  26990. /**
  26991. * Callback called when the task is successful
  26992. */
  26993. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  26994. /**
  26995. * Creates a new HDRCubeTextureAssetTask object
  26996. * @param name defines the name of the task
  26997. * @param url defines the location of the file to load
  26998. * @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.
  26999. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27000. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27001. * @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)
  27002. * @param reserved Internal use only
  27003. */
  27004. constructor(
  27005. /**
  27006. * Defines the name of the task
  27007. */
  27008. name: string,
  27009. /**
  27010. * Defines the location of the file to load
  27011. */
  27012. url: string,
  27013. /**
  27014. * Defines the desired size (the more it increases the longer the generation will be)
  27015. */
  27016. size: number,
  27017. /**
  27018. * Defines if mipmaps should not be generated (default is false)
  27019. */
  27020. noMipmap?: boolean,
  27021. /**
  27022. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27023. */
  27024. generateHarmonics?: boolean,
  27025. /**
  27026. * 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)
  27027. */
  27028. gammaSpace?: boolean,
  27029. /**
  27030. * Internal Use Only
  27031. */
  27032. reserved?: boolean);
  27033. /**
  27034. * Execute the current task
  27035. * @param scene defines the scene where you want your assets to be loaded
  27036. * @param onSuccess is a callback called when the task is successfully executed
  27037. * @param onError is a callback called if an error occurs
  27038. */
  27039. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27040. }
  27041. /**
  27042. * This class can be used to easily import assets into a scene
  27043. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27044. */
  27045. class AssetsManager {
  27046. private _scene;
  27047. private _isLoading;
  27048. protected _tasks: AbstractAssetTask[];
  27049. protected _waitingTasksCount: number;
  27050. protected _totalTasksCount: number;
  27051. /**
  27052. * Callback called when all tasks are processed
  27053. */
  27054. onFinish: (tasks: AbstractAssetTask[]) => void;
  27055. /**
  27056. * Callback called when a task is successful
  27057. */
  27058. onTaskSuccess: (task: AbstractAssetTask) => void;
  27059. /**
  27060. * Callback called when a task had an error
  27061. */
  27062. onTaskError: (task: AbstractAssetTask) => void;
  27063. /**
  27064. * Callback called when a task is done (whatever the result is)
  27065. */
  27066. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27067. /**
  27068. * Observable called when all tasks are processed
  27069. */
  27070. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27071. /**
  27072. * Observable called when a task had an error
  27073. */
  27074. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27075. /**
  27076. * Observable called when a task is successful
  27077. */
  27078. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27079. /**
  27080. * Observable called when a task is done (whatever the result is)
  27081. */
  27082. onProgressObservable: Observable<IAssetsProgressEvent>;
  27083. /**
  27084. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27086. */
  27087. useDefaultLoadingScreen: boolean;
  27088. /**
  27089. * Creates a new AssetsManager
  27090. * @param scene defines the scene to work on
  27091. */
  27092. constructor(scene: Scene);
  27093. /**
  27094. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27095. * @param taskName defines the name of the new task
  27096. * @param meshesNames defines the name of meshes to load
  27097. * @param rootUrl defines the root url to use to locate files
  27098. * @param sceneFilename defines the filename of the scene file
  27099. * @returns a new {BABYLON.MeshAssetTask} object
  27100. */
  27101. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27102. /**
  27103. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27104. * @param taskName defines the name of the new task
  27105. * @param url defines the url of the file to load
  27106. * @returns a new {BABYLON.TextFileAssetTask} object
  27107. */
  27108. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27109. /**
  27110. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27111. * @param taskName defines the name of the new task
  27112. * @param url defines the url of the file to load
  27113. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27114. */
  27115. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27116. /**
  27117. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27118. * @param taskName defines the name of the new task
  27119. * @param url defines the url of the file to load
  27120. * @returns a new {BABYLON.ImageAssetTask} object
  27121. */
  27122. addImageTask(taskName: string, url: string): ImageAssetTask;
  27123. /**
  27124. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27125. * @param taskName defines the name of the new task
  27126. * @param url defines the url of the file to load
  27127. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27128. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27129. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27130. * @returns a new {BABYLON.TextureAssetTask} object
  27131. */
  27132. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27133. /**
  27134. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27135. * @param taskName defines the name of the new task
  27136. * @param url defines the url of the file to load
  27137. * @param extensions defines the extension to use to load the cube map (can be null)
  27138. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27139. * @param files defines the list of files to load (can be null)
  27140. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27141. */
  27142. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27143. /**
  27144. *
  27145. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27146. * @param taskName defines the name of the new task
  27147. * @param url defines the url of the file to load
  27148. * @param size defines the size you want for the cubemap (can be null)
  27149. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27150. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27151. * @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)
  27152. * @param reserved Internal use only
  27153. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27154. */
  27155. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27156. private _decreaseWaitingTasksCount(task);
  27157. private _runTask(task);
  27158. /**
  27159. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27160. * @return the current instance of the {BABYLON.AssetsManager}
  27161. */
  27162. reset(): AssetsManager;
  27163. /**
  27164. * Start the loading process
  27165. * @return the current instance of the {BABYLON.AssetsManager}
  27166. */
  27167. load(): AssetsManager;
  27168. }
  27169. }
  27170. declare module BABYLON {
  27171. /**
  27172. * Class used to enable access to IndexedDB
  27173. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27174. */
  27175. class Database {
  27176. private callbackManifestChecked;
  27177. private currentSceneUrl;
  27178. private db;
  27179. private _enableSceneOffline;
  27180. private _enableTexturesOffline;
  27181. private manifestVersionFound;
  27182. private mustUpdateRessources;
  27183. private hasReachedQuota;
  27184. private isSupported;
  27185. private idbFactory;
  27186. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27187. static IsUASupportingBlobStorage: boolean;
  27188. /** Gets a boolean indicating if Database storate is enabled */
  27189. static IDBStorageEnabled: boolean;
  27190. /**
  27191. * Gets a boolean indicating if scene must be saved in the database
  27192. */
  27193. readonly enableSceneOffline: boolean;
  27194. /**
  27195. * Gets a boolean indicating if textures must be saved in the database
  27196. */
  27197. readonly enableTexturesOffline: boolean;
  27198. /**
  27199. * Creates a new Database
  27200. * @param urlToScene defines the url to load the scene
  27201. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27202. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27203. */
  27204. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27205. private static _ParseURL;
  27206. private static _ReturnFullUrlLocation;
  27207. private _checkManifestFile();
  27208. /**
  27209. * Open the database and make it available
  27210. * @param successCallback defines the callback to call on success
  27211. * @param errorCallback defines the callback to call on error
  27212. */
  27213. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27214. /**
  27215. * Loads an image from the database
  27216. * @param url defines the url to load from
  27217. * @param image defines the target DOM image
  27218. */
  27219. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27220. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27221. private _saveImageIntoDBAsync(url, image);
  27222. private _checkVersionFromDB(url, versionLoaded);
  27223. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27224. private _saveVersionIntoDBAsync(url, callback);
  27225. /**
  27226. * Loads a file from database
  27227. * @param url defines the URL to load from
  27228. * @param sceneLoaded defines a callback to call on success
  27229. * @param progressCallBack defines a callback to call when progress changed
  27230. * @param errorCallback defines a callback to call on error
  27231. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27232. */
  27233. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27234. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27235. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27236. }
  27237. }
  27238. declare module BABYLON {
  27239. interface DDSInfo {
  27240. width: number;
  27241. height: number;
  27242. mipmapCount: number;
  27243. isFourCC: boolean;
  27244. isRGB: boolean;
  27245. isLuminance: boolean;
  27246. isCube: boolean;
  27247. isCompressed: boolean;
  27248. dxgiFormat: number;
  27249. textureType: number;
  27250. /** Sphericle polynomial created for the dds texture */
  27251. sphericalPolynomial?: SphericalPolynomial;
  27252. }
  27253. class DDSTools {
  27254. static StoreLODInAlphaChannel: boolean;
  27255. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27256. private static _FloatView;
  27257. private static _Int32View;
  27258. private static _ToHalfFloat(value);
  27259. private static _FromHalfFloat(value);
  27260. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27261. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27262. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27263. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27264. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27265. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27266. private static _ExtractLongWordOrder(value);
  27267. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27268. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27269. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27270. }
  27271. }
  27272. declare module BABYLON {
  27273. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27274. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27275. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27276. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27277. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27278. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27279. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27280. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27281. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27282. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27283. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27284. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27285. /**
  27286. * Decorator used to define property that can be serialized as reference to a camera
  27287. * @param sourceName defines the name of the property to decorate
  27288. */
  27289. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27290. class SerializationHelper {
  27291. static Serialize<T>(entity: T, serializationObject?: any): any;
  27292. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27293. static Clone<T>(creationFunction: () => T, source: T): T;
  27294. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27295. }
  27296. }
  27297. declare module BABYLON {
  27298. /**
  27299. * Wrapper class for promise with external resolve and reject.
  27300. */
  27301. class Deferred<T> {
  27302. /**
  27303. * The promise associated with this deferred object.
  27304. */
  27305. readonly promise: Promise<T>;
  27306. private _resolve;
  27307. private _reject;
  27308. /**
  27309. * The resolve method of the promise associated with this deferred object.
  27310. */
  27311. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27312. /**
  27313. * The reject method of the promise associated with this deferred object.
  27314. */
  27315. readonly reject: (reason?: any) => void;
  27316. /**
  27317. * Constructor for this deferred object.
  27318. */
  27319. constructor();
  27320. }
  27321. }
  27322. declare module BABYLON {
  27323. class FilesInput {
  27324. static FilesToLoad: {
  27325. [key: string]: File;
  27326. };
  27327. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27328. private _engine;
  27329. private _currentScene;
  27330. private _sceneLoadedCallback;
  27331. private _progressCallback;
  27332. private _additionalRenderLoopLogicCallback;
  27333. private _textureLoadingCallback;
  27334. private _startingProcessingFilesCallback;
  27335. private _onReloadCallback;
  27336. private _errorCallback;
  27337. private _elementToMonitor;
  27338. private _sceneFileToLoad;
  27339. private _filesToLoad;
  27340. 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);
  27341. private _dragEnterHandler;
  27342. private _dragOverHandler;
  27343. private _dropHandler;
  27344. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27345. dispose(): void;
  27346. private renderFunction();
  27347. private drag(e);
  27348. private drop(eventDrop);
  27349. private _traverseFolder(folder, files, remaining, callback);
  27350. private _processFiles(files);
  27351. loadFiles(event: any): void;
  27352. private _processReload();
  27353. reload(): void;
  27354. }
  27355. }
  27356. declare module BABYLON {
  27357. /**
  27358. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27359. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27360. */
  27361. class KhronosTextureContainer {
  27362. arrayBuffer: any;
  27363. static HEADER_LEN: number;
  27364. static COMPRESSED_2D: number;
  27365. static COMPRESSED_3D: number;
  27366. static TEX_2D: number;
  27367. static TEX_3D: number;
  27368. glType: number;
  27369. glTypeSize: number;
  27370. glFormat: number;
  27371. glInternalFormat: number;
  27372. glBaseInternalFormat: number;
  27373. pixelWidth: number;
  27374. pixelHeight: number;
  27375. pixelDepth: number;
  27376. numberOfArrayElements: number;
  27377. numberOfFaces: number;
  27378. numberOfMipmapLevels: number;
  27379. bytesOfKeyValueData: number;
  27380. loadType: number;
  27381. /**
  27382. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27383. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27384. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27385. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27386. */
  27387. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27388. switchEndainness(val: number): number;
  27389. /**
  27390. * It is assumed that the texture has already been created & is currently bound
  27391. */
  27392. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27393. private _upload2DCompressedLevels(gl, loadMipmaps);
  27394. }
  27395. }
  27396. declare module BABYLON {
  27397. /**
  27398. * A class serves as a medium between the observable and its observers
  27399. */
  27400. class EventState {
  27401. /**
  27402. * Create a new EventState
  27403. * @param mask defines the mask associated with this state
  27404. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27405. * @param target defines the original target of the state
  27406. * @param currentTarget defines the current target of the state
  27407. */
  27408. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27409. /**
  27410. * Initialize the current event state
  27411. * @param mask defines the mask associated with this state
  27412. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27413. * @param target defines the original target of the state
  27414. * @param currentTarget defines the current target of the state
  27415. * @returns the current event state
  27416. */
  27417. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27418. /**
  27419. * An Observer can set this property to true to prevent subsequent observers of being notified
  27420. */
  27421. skipNextObservers: boolean;
  27422. /**
  27423. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27424. */
  27425. mask: number;
  27426. /**
  27427. * The object that originally notified the event
  27428. */
  27429. target?: any;
  27430. /**
  27431. * The current object in the bubbling phase
  27432. */
  27433. currentTarget?: any;
  27434. /**
  27435. * This will be populated with the return value of the last function that was executed.
  27436. * If it is the first function in the callback chain it will be the event data.
  27437. */
  27438. lastReturnValue?: any;
  27439. }
  27440. /**
  27441. * Represent an Observer registered to a given Observable object.
  27442. */
  27443. class Observer<T> {
  27444. /**
  27445. * Defines the callback to call when the observer is notified
  27446. */
  27447. callback: (eventData: T, eventState: EventState) => void;
  27448. /**
  27449. * Defines the mask of the observer (used to filter notifications)
  27450. */
  27451. mask: number;
  27452. /**
  27453. * Defines the current scope used to restore the JS context
  27454. */
  27455. scope: any;
  27456. /** @hidden */
  27457. _willBeUnregistered: boolean;
  27458. /**
  27459. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27460. */
  27461. unregisterOnNextCall: boolean;
  27462. /**
  27463. * Creates a new observer
  27464. * @param callback defines the callback to call when the observer is notified
  27465. * @param mask defines the mask of the observer (used to filter notifications)
  27466. * @param scope defines the current scope used to restore the JS context
  27467. */
  27468. constructor(
  27469. /**
  27470. * Defines the callback to call when the observer is notified
  27471. */
  27472. callback: (eventData: T, eventState: EventState) => void,
  27473. /**
  27474. * Defines the mask of the observer (used to filter notifications)
  27475. */
  27476. mask: number,
  27477. /**
  27478. * Defines the current scope used to restore the JS context
  27479. */
  27480. scope?: any);
  27481. }
  27482. /**
  27483. * Represent a list of observers registered to multiple Observables object.
  27484. */
  27485. class MultiObserver<T> {
  27486. private _observers;
  27487. private _observables;
  27488. /**
  27489. * Release associated resources
  27490. */
  27491. dispose(): void;
  27492. /**
  27493. * Raise a callback when one of the observable will notify
  27494. * @param observables defines a list of observables to watch
  27495. * @param callback defines the callback to call on notification
  27496. * @param mask defines the mask used to filter notifications
  27497. * @param scope defines the current scope used to restore the JS context
  27498. * @returns the new MultiObserver
  27499. */
  27500. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27501. }
  27502. /**
  27503. * The Observable class is a simple implementation of the Observable pattern.
  27504. *
  27505. * 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.
  27506. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27507. * 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).
  27508. * 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.
  27509. */
  27510. class Observable<T> {
  27511. private _observers;
  27512. private _eventState;
  27513. private _onObserverAdded;
  27514. /**
  27515. * Creates a new observable
  27516. * @param onObserverAdded defines a callback to call when a new observer is added
  27517. */
  27518. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27519. /**
  27520. * Create a new Observer with the specified callback
  27521. * @param callback the callback that will be executed for that Observer
  27522. * @param mask the mask used to filter observers
  27523. * @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.
  27524. * @param scope optional scope for the callback to be called from
  27525. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27526. * @returns the new observer created for the callback
  27527. */
  27528. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27529. /**
  27530. * Remove an Observer from the Observable object
  27531. * @param observer the instance of the Observer to remove
  27532. * @returns false if it doesn't belong to this Observable
  27533. */
  27534. remove(observer: Nullable<Observer<T>>): boolean;
  27535. /**
  27536. * Remove a callback from the Observable object
  27537. * @param callback the callback to remove
  27538. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27539. * @returns false if it doesn't belong to this Observable
  27540. */
  27541. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27542. private _deferUnregister(observer);
  27543. /**
  27544. * Notify all Observers by calling their respective callback with the given data
  27545. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27546. * @param eventData defines the data to send to all observers
  27547. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27548. * @param target defines the original target of the state
  27549. * @param currentTarget defines the current target of the state
  27550. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27551. */
  27552. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27553. /**
  27554. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27555. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27556. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27557. * and it is crucial that all callbacks will be executed.
  27558. * The order of the callbacks is kept, callbacks are not executed parallel.
  27559. *
  27560. * @param eventData The data to be sent to each callback
  27561. * @param mask is used to filter observers defaults to -1
  27562. * @param target defines the callback target (see EventState)
  27563. * @param currentTarget defines he current object in the bubbling phase
  27564. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27565. */
  27566. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27567. /**
  27568. * Notify a specific observer
  27569. * @param observer defines the observer to notify
  27570. * @param eventData defines the data to be sent to each callback
  27571. * @param mask is used to filter observers defaults to -1
  27572. */
  27573. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27574. /**
  27575. * Gets a boolean indicating if the observable has at least one observer
  27576. * @returns true is the Observable has at least one Observer registered
  27577. */
  27578. hasObservers(): boolean;
  27579. /**
  27580. * Clear the list of observers
  27581. */
  27582. clear(): void;
  27583. /**
  27584. * Clone the current observable
  27585. * @returns a new observable
  27586. */
  27587. clone(): Observable<T>;
  27588. /**
  27589. * Does this observable handles observer registered with a given mask
  27590. * @param mask defines the mask to be tested
  27591. * @return whether or not one observer registered with the given mask is handeled
  27592. **/
  27593. hasSpecificMask(mask?: number): boolean;
  27594. }
  27595. }
  27596. declare module BABYLON {
  27597. /**
  27598. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27599. */
  27600. class PerformanceMonitor {
  27601. private _enabled;
  27602. private _rollingFrameTime;
  27603. private _lastFrameTimeMs;
  27604. /**
  27605. * constructor
  27606. * @param frameSampleSize The number of samples required to saturate the sliding window
  27607. */
  27608. constructor(frameSampleSize?: number);
  27609. /**
  27610. * Samples current frame
  27611. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27612. */
  27613. sampleFrame(timeMs?: number): void;
  27614. /**
  27615. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27616. * @return Average frame time in milliseconds
  27617. */
  27618. readonly averageFrameTime: number;
  27619. /**
  27620. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27621. * @return Frame time variance in milliseconds squared
  27622. */
  27623. readonly averageFrameTimeVariance: number;
  27624. /**
  27625. * Returns the frame time of the most recent frame
  27626. * @return Frame time in milliseconds
  27627. */
  27628. readonly instantaneousFrameTime: number;
  27629. /**
  27630. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27631. * @return Framerate in frames per second
  27632. */
  27633. readonly averageFPS: number;
  27634. /**
  27635. * Returns the average framerate in frames per second using the most recent frame time
  27636. * @return Framerate in frames per second
  27637. */
  27638. readonly instantaneousFPS: number;
  27639. /**
  27640. * Returns true if enough samples have been taken to completely fill the sliding window
  27641. * @return true if saturated
  27642. */
  27643. readonly isSaturated: boolean;
  27644. /**
  27645. * Enables contributions to the sliding window sample set
  27646. */
  27647. enable(): void;
  27648. /**
  27649. * Disables contributions to the sliding window sample set
  27650. * Samples will not be interpolated over the disabled period
  27651. */
  27652. disable(): void;
  27653. /**
  27654. * Returns true if sampling is enabled
  27655. * @return true if enabled
  27656. */
  27657. readonly isEnabled: boolean;
  27658. /**
  27659. * Resets performance monitor
  27660. */
  27661. reset(): void;
  27662. }
  27663. /**
  27664. * RollingAverage
  27665. *
  27666. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27667. */
  27668. class RollingAverage {
  27669. /**
  27670. * Current average
  27671. */
  27672. average: number;
  27673. /**
  27674. * Current variance
  27675. */
  27676. variance: number;
  27677. protected _samples: Array<number>;
  27678. protected _sampleCount: number;
  27679. protected _pos: number;
  27680. protected _m2: number;
  27681. /**
  27682. * constructor
  27683. * @param length The number of samples required to saturate the sliding window
  27684. */
  27685. constructor(length: number);
  27686. /**
  27687. * Adds a sample to the sample set
  27688. * @param v The sample value
  27689. */
  27690. add(v: number): void;
  27691. /**
  27692. * Returns previously added values or null if outside of history or outside the sliding window domain
  27693. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27694. * @return Value previously recorded with add() or null if outside of range
  27695. */
  27696. history(i: number): number;
  27697. /**
  27698. * Returns true if enough samples have been taken to completely fill the sliding window
  27699. * @return true if sample-set saturated
  27700. */
  27701. isSaturated(): boolean;
  27702. /**
  27703. * Resets the rolling average (equivalent to 0 samples taken so far)
  27704. */
  27705. reset(): void;
  27706. /**
  27707. * Wraps a value around the sample range boundaries
  27708. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27709. * @return Wrapped position in sample range
  27710. */
  27711. protected _wrapPosition(i: number): number;
  27712. }
  27713. }
  27714. declare module BABYLON {
  27715. /**
  27716. * Helper class that provides a small promise polyfill
  27717. */
  27718. class PromisePolyfill {
  27719. /**
  27720. * Static function used to check if the polyfill is required
  27721. * If this is the case then the function will inject the polyfill to window.Promise
  27722. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  27723. */
  27724. static Apply(force?: boolean): void;
  27725. }
  27726. }
  27727. declare module BABYLON {
  27728. /**
  27729. * Defines the root class used to create scene optimization to use with SceneOptimizer
  27730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27731. */
  27732. class SceneOptimization {
  27733. /**
  27734. * Defines the priority of this optimization (0 by default which means first in the list)
  27735. */
  27736. priority: number;
  27737. /**
  27738. * Gets a string describing the action executed by the current optimization
  27739. * @returns description string
  27740. */
  27741. getDescription(): string;
  27742. /**
  27743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27744. * @param scene defines the current scene where to apply this optimization
  27745. * @param optimizer defines the current optimizer
  27746. * @returns true if everything that can be done was applied
  27747. */
  27748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27749. /**
  27750. * Creates the SceneOptimization object
  27751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27752. * @param desc defines the description associated with the optimization
  27753. */
  27754. constructor(
  27755. /**
  27756. * Defines the priority of this optimization (0 by default which means first in the list)
  27757. */
  27758. priority?: number);
  27759. }
  27760. /**
  27761. * Defines an optimization used to reduce the size of render target textures
  27762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27763. */
  27764. class TextureOptimization extends SceneOptimization {
  27765. /**
  27766. * Defines the priority of this optimization (0 by default which means first in the list)
  27767. */
  27768. priority: number;
  27769. /**
  27770. * 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
  27771. */
  27772. maximumSize: number;
  27773. /**
  27774. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27775. */
  27776. step: number;
  27777. /**
  27778. * Gets a string describing the action executed by the current optimization
  27779. * @returns description string
  27780. */
  27781. getDescription(): string;
  27782. /**
  27783. * Creates the TextureOptimization object
  27784. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27785. * @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
  27786. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27787. */
  27788. constructor(
  27789. /**
  27790. * Defines the priority of this optimization (0 by default which means first in the list)
  27791. */
  27792. priority?: number,
  27793. /**
  27794. * 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
  27795. */
  27796. maximumSize?: number,
  27797. /**
  27798. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27799. */
  27800. step?: number);
  27801. /**
  27802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27803. * @param scene defines the current scene where to apply this optimization
  27804. * @param optimizer defines the current optimizer
  27805. * @returns true if everything that can be done was applied
  27806. */
  27807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27808. }
  27809. /**
  27810. * Defines an optimization used to increase or decrease the rendering resolution
  27811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27812. */
  27813. class HardwareScalingOptimization extends SceneOptimization {
  27814. /**
  27815. * Defines the priority of this optimization (0 by default which means first in the list)
  27816. */
  27817. priority: number;
  27818. /**
  27819. * Defines the maximum scale to use (2 by default)
  27820. */
  27821. maximumScale: number;
  27822. /**
  27823. * Defines the step to use between two passes (0.5 by default)
  27824. */
  27825. step: number;
  27826. private _currentScale;
  27827. private _directionOffset;
  27828. /**
  27829. * Gets a string describing the action executed by the current optimization
  27830. * @return description string
  27831. */
  27832. getDescription(): string;
  27833. /**
  27834. * Creates the HardwareScalingOptimization object
  27835. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27836. * @param maximumScale defines the maximum scale to use (2 by default)
  27837. * @param step defines the step to use between two passes (0.5 by default)
  27838. */
  27839. constructor(
  27840. /**
  27841. * Defines the priority of this optimization (0 by default which means first in the list)
  27842. */
  27843. priority?: number,
  27844. /**
  27845. * Defines the maximum scale to use (2 by default)
  27846. */
  27847. maximumScale?: number,
  27848. /**
  27849. * Defines the step to use between two passes (0.5 by default)
  27850. */
  27851. step?: number);
  27852. /**
  27853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27854. * @param scene defines the current scene where to apply this optimization
  27855. * @param optimizer defines the current optimizer
  27856. * @returns true if everything that can be done was applied
  27857. */
  27858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27859. }
  27860. /**
  27861. * Defines an optimization used to remove shadows
  27862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27863. */
  27864. class ShadowsOptimization extends SceneOptimization {
  27865. /**
  27866. * Gets a string describing the action executed by the current optimization
  27867. * @return description string
  27868. */
  27869. getDescription(): string;
  27870. /**
  27871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27872. * @param scene defines the current scene where to apply this optimization
  27873. * @param optimizer defines the current optimizer
  27874. * @returns true if everything that can be done was applied
  27875. */
  27876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27877. }
  27878. /**
  27879. * Defines an optimization used to turn post-processes off
  27880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27881. */
  27882. class PostProcessesOptimization extends SceneOptimization {
  27883. /**
  27884. * Gets a string describing the action executed by the current optimization
  27885. * @return description string
  27886. */
  27887. getDescription(): string;
  27888. /**
  27889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27890. * @param scene defines the current scene where to apply this optimization
  27891. * @param optimizer defines the current optimizer
  27892. * @returns true if everything that can be done was applied
  27893. */
  27894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27895. }
  27896. /**
  27897. * Defines an optimization used to turn lens flares off
  27898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27899. */
  27900. class LensFlaresOptimization extends SceneOptimization {
  27901. /**
  27902. * Gets a string describing the action executed by the current optimization
  27903. * @return description string
  27904. */
  27905. getDescription(): string;
  27906. /**
  27907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27908. * @param scene defines the current scene where to apply this optimization
  27909. * @param optimizer defines the current optimizer
  27910. * @returns true if everything that can be done was applied
  27911. */
  27912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27913. }
  27914. /**
  27915. * Defines an optimization based on user defined callback.
  27916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27917. */
  27918. class CustomOptimization extends SceneOptimization {
  27919. /**
  27920. * Callback called to apply the custom optimization.
  27921. */
  27922. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  27923. /**
  27924. * Callback called to get custom description
  27925. */
  27926. onGetDescription: () => string;
  27927. /**
  27928. * Gets a string describing the action executed by the current optimization
  27929. * @returns description string
  27930. */
  27931. getDescription(): string;
  27932. /**
  27933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27934. * @param scene defines the current scene where to apply this optimization
  27935. * @param optimizer defines the current optimizer
  27936. * @returns true if everything that can be done was applied
  27937. */
  27938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27939. }
  27940. /**
  27941. * Defines an optimization used to turn particles off
  27942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27943. */
  27944. class ParticlesOptimization extends SceneOptimization {
  27945. /**
  27946. * Gets a string describing the action executed by the current optimization
  27947. * @return description string
  27948. */
  27949. getDescription(): string;
  27950. /**
  27951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27952. * @param scene defines the current scene where to apply this optimization
  27953. * @param optimizer defines the current optimizer
  27954. * @returns true if everything that can be done was applied
  27955. */
  27956. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27957. }
  27958. /**
  27959. * Defines an optimization used to turn render targets off
  27960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27961. */
  27962. class RenderTargetsOptimization extends SceneOptimization {
  27963. /**
  27964. * Gets a string describing the action executed by the current optimization
  27965. * @return description string
  27966. */
  27967. getDescription(): string;
  27968. /**
  27969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27970. * @param scene defines the current scene where to apply this optimization
  27971. * @param optimizer defines the current optimizer
  27972. * @returns true if everything that can be done was applied
  27973. */
  27974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27975. }
  27976. /**
  27977. * Defines an optimization used to merge meshes with compatible materials
  27978. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27979. */
  27980. class MergeMeshesOptimization extends SceneOptimization {
  27981. private static _UpdateSelectionTree;
  27982. /**
  27983. * Gets or sets a boolean which defines if optimization octree has to be updated
  27984. */
  27985. /**
  27986. * Gets or sets a boolean which defines if optimization octree has to be updated
  27987. */
  27988. static UpdateSelectionTree: boolean;
  27989. /**
  27990. * Gets a string describing the action executed by the current optimization
  27991. * @return description string
  27992. */
  27993. getDescription(): string;
  27994. private _canBeMerged;
  27995. /**
  27996. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27997. * @param scene defines the current scene where to apply this optimization
  27998. * @param optimizer defines the current optimizer
  27999. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28000. * @returns true if everything that can be done was applied
  28001. */
  28002. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28003. }
  28004. /**
  28005. * Defines a list of options used by SceneOptimizer
  28006. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28007. */
  28008. class SceneOptimizerOptions {
  28009. /**
  28010. * Defines the target frame rate to reach (60 by default)
  28011. */
  28012. targetFrameRate: number;
  28013. /**
  28014. * Defines the interval between two checkes (2000ms by default)
  28015. */
  28016. trackerDuration: number;
  28017. /**
  28018. * Gets the list of optimizations to apply
  28019. */
  28020. optimizations: SceneOptimization[];
  28021. /**
  28022. * Creates a new list of options used by SceneOptimizer
  28023. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28024. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28025. */
  28026. constructor(
  28027. /**
  28028. * Defines the target frame rate to reach (60 by default)
  28029. */
  28030. targetFrameRate?: number,
  28031. /**
  28032. * Defines the interval between two checkes (2000ms by default)
  28033. */
  28034. trackerDuration?: number);
  28035. /**
  28036. * Add a new optimization
  28037. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28038. * @returns the current SceneOptimizerOptions
  28039. */
  28040. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28041. /**
  28042. * Add a new custom optimization
  28043. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28044. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28045. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28046. * @returns the current SceneOptimizerOptions
  28047. */
  28048. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28049. /**
  28050. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28051. * @param targetFrameRate defines the target frame rate (60 by default)
  28052. * @returns a SceneOptimizerOptions object
  28053. */
  28054. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28055. /**
  28056. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28057. * @param targetFrameRate defines the target frame rate (60 by default)
  28058. * @returns a SceneOptimizerOptions object
  28059. */
  28060. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28061. /**
  28062. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28063. * @param targetFrameRate defines the target frame rate (60 by default)
  28064. * @returns a SceneOptimizerOptions object
  28065. */
  28066. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28067. }
  28068. /**
  28069. * Class used to run optimizations in order to reach a target frame rate
  28070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28071. */
  28072. class SceneOptimizer implements IDisposable {
  28073. private _isRunning;
  28074. private _options;
  28075. private _scene;
  28076. private _currentPriorityLevel;
  28077. private _targetFrameRate;
  28078. private _trackerDuration;
  28079. private _currentFrameRate;
  28080. private _sceneDisposeObserver;
  28081. private _improvementMode;
  28082. /**
  28083. * Defines an observable called when the optimizer reaches the target frame rate
  28084. */
  28085. onSuccessObservable: Observable<SceneOptimizer>;
  28086. /**
  28087. * Defines an observable called when the optimizer enables an optimization
  28088. */
  28089. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28090. /**
  28091. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28092. */
  28093. onFailureObservable: Observable<SceneOptimizer>;
  28094. /**
  28095. * Gets a boolean indicating if the optimizer is in improvement mode
  28096. */
  28097. readonly isInImprovementMode: boolean;
  28098. /**
  28099. * Gets the current priority level (0 at start)
  28100. */
  28101. readonly currentPriorityLevel: number;
  28102. /**
  28103. * Gets the current frame rate checked by the SceneOptimizer
  28104. */
  28105. readonly currentFrameRate: number;
  28106. /**
  28107. * Gets or sets the current target frame rate (60 by default)
  28108. */
  28109. /**
  28110. * Gets or sets the current target frame rate (60 by default)
  28111. */
  28112. targetFrameRate: number;
  28113. /**
  28114. * Gets or sets the current interval between two checks (every 2000ms by default)
  28115. */
  28116. /**
  28117. * Gets or sets the current interval between two checks (every 2000ms by default)
  28118. */
  28119. trackerDuration: number;
  28120. /**
  28121. * Gets the list of active optimizations
  28122. */
  28123. readonly optimizations: SceneOptimization[];
  28124. /**
  28125. * Creates a new SceneOptimizer
  28126. * @param scene defines the scene to work on
  28127. * @param options defines the options to use with the SceneOptimizer
  28128. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28129. * @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)
  28130. */
  28131. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28132. /**
  28133. * Stops the current optimizer
  28134. */
  28135. stop(): void;
  28136. /**
  28137. * Reset the optimizer to initial step (current priority level = 0)
  28138. */
  28139. reset(): void;
  28140. /**
  28141. * Start the optimizer. By default it will try to reach a specific framerate
  28142. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28143. */
  28144. start(): void;
  28145. private _checkCurrentState();
  28146. /**
  28147. * Release all resources
  28148. */
  28149. dispose(): void;
  28150. /**
  28151. * Helper function to create a SceneOptimizer with one single line of code
  28152. * @param scene defines the scene to work on
  28153. * @param options defines the options to use with the SceneOptimizer
  28154. * @param onSuccess defines a callback to call on success
  28155. * @param onFailure defines a callback to call on failure
  28156. * @returns the new SceneOptimizer object
  28157. */
  28158. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28159. }
  28160. }
  28161. declare module BABYLON {
  28162. class SceneSerializer {
  28163. static ClearCache(): void;
  28164. static Serialize(scene: Scene): any;
  28165. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28166. }
  28167. }
  28168. declare module BABYLON {
  28169. class SmartArray<T> {
  28170. data: Array<T>;
  28171. length: number;
  28172. protected _id: number;
  28173. [index: number]: T;
  28174. constructor(capacity: number);
  28175. push(value: T): void;
  28176. forEach(func: (content: T) => void): void;
  28177. sort(compareFn: (a: T, b: T) => number): void;
  28178. reset(): void;
  28179. dispose(): void;
  28180. concat(array: any): void;
  28181. indexOf(value: T): number;
  28182. contains(value: T): boolean;
  28183. private static _GlobalId;
  28184. }
  28185. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28186. private _duplicateId;
  28187. [index: number]: T;
  28188. push(value: T): void;
  28189. pushNoDuplicate(value: T): boolean;
  28190. reset(): void;
  28191. concatWithNoDuplicate(array: any): void;
  28192. }
  28193. }
  28194. declare module BABYLON {
  28195. /**
  28196. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28197. * The underlying implementation relies on an associative array to ensure the best performances.
  28198. * The value can be anything including 'null' but except 'undefined'
  28199. */
  28200. class StringDictionary<T> {
  28201. /**
  28202. * This will clear this dictionary and copy the content from the 'source' one.
  28203. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28204. * @param source the dictionary to take the content from and copy to this dictionary
  28205. */
  28206. copyFrom(source: StringDictionary<T>): void;
  28207. /**
  28208. * Get a value based from its key
  28209. * @param key the given key to get the matching value from
  28210. * @return the value if found, otherwise undefined is returned
  28211. */
  28212. get(key: string): T | undefined;
  28213. /**
  28214. * Get a value from its key or add it if it doesn't exist.
  28215. * This method will ensure you that a given key/data will be present in the dictionary.
  28216. * @param key the given key to get the matching value from
  28217. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28218. * The factory will only be invoked if there's no data for the given key.
  28219. * @return the value corresponding to the key.
  28220. */
  28221. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28222. /**
  28223. * Get a value from its key if present in the dictionary otherwise add it
  28224. * @param key the key to get the value from
  28225. * @param val if there's no such key/value pair in the dictionary add it with this value
  28226. * @return the value corresponding to the key
  28227. */
  28228. getOrAdd(key: string, val: T): T;
  28229. /**
  28230. * Check if there's a given key in the dictionary
  28231. * @param key the key to check for
  28232. * @return true if the key is present, false otherwise
  28233. */
  28234. contains(key: string): boolean;
  28235. /**
  28236. * Add a new key and its corresponding value
  28237. * @param key the key to add
  28238. * @param value the value corresponding to the key
  28239. * @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
  28240. */
  28241. add(key: string, value: T): boolean;
  28242. set(key: string, value: T): boolean;
  28243. /**
  28244. * Get the element of the given key and remove it from the dictionary
  28245. * @param key
  28246. */
  28247. getAndRemove(key: string): Nullable<T>;
  28248. /**
  28249. * Remove a key/value from the dictionary.
  28250. * @param key the key to remove
  28251. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28252. */
  28253. remove(key: string): boolean;
  28254. /**
  28255. * Clear the whole content of the dictionary
  28256. */
  28257. clear(): void;
  28258. readonly count: number;
  28259. /**
  28260. * Execute a callback on each key/val of the dictionary.
  28261. * Note that you can remove any element in this dictionary in the callback implementation
  28262. * @param callback the callback to execute on a given key/value pair
  28263. */
  28264. forEach(callback: (key: string, val: T) => void): void;
  28265. /**
  28266. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28267. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28268. * Note that you can remove any element in this dictionary in the callback implementation
  28269. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28270. */
  28271. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28272. private _count;
  28273. private _data;
  28274. }
  28275. }
  28276. declare module BABYLON {
  28277. class Tags {
  28278. static EnableFor(obj: any): void;
  28279. static DisableFor(obj: any): void;
  28280. static HasTags(obj: any): boolean;
  28281. static GetTags(obj: any, asString?: boolean): any;
  28282. static AddTagsTo(obj: any, tagsString: string): void;
  28283. static _AddTagTo(obj: any, tag: string): void;
  28284. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28285. static _RemoveTagFrom(obj: any, tag: string): void;
  28286. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28287. }
  28288. }
  28289. declare module BABYLON {
  28290. class TextureTools {
  28291. /**
  28292. * Uses the GPU to create a copy texture rescaled at a given size
  28293. * @param texture Texture to copy from
  28294. * @param width Desired width
  28295. * @param height Desired height
  28296. * @return Generated texture
  28297. */
  28298. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28299. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28300. private static _environmentBRDFBase64Texture;
  28301. }
  28302. }
  28303. declare module BABYLON {
  28304. class TGATools {
  28305. private static _TYPE_INDEXED;
  28306. private static _TYPE_RGB;
  28307. private static _TYPE_GREY;
  28308. private static _TYPE_RLE_INDEXED;
  28309. private static _TYPE_RLE_RGB;
  28310. private static _TYPE_RLE_GREY;
  28311. private static _ORIGIN_MASK;
  28312. private static _ORIGIN_SHIFT;
  28313. private static _ORIGIN_BL;
  28314. private static _ORIGIN_BR;
  28315. private static _ORIGIN_UL;
  28316. private static _ORIGIN_UR;
  28317. static GetTGAHeader(data: Uint8Array): any;
  28318. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28319. 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;
  28320. 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;
  28321. 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;
  28322. 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;
  28323. 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;
  28324. 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;
  28325. }
  28326. }
  28327. declare module BABYLON {
  28328. interface IAnimatable {
  28329. animations: Array<Animation>;
  28330. }
  28331. class LoadFileError extends Error {
  28332. request: XMLHttpRequest | undefined;
  28333. private static _setPrototypeOf;
  28334. constructor(message: string, request?: XMLHttpRequest | undefined);
  28335. }
  28336. class RetryStrategy {
  28337. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28338. }
  28339. interface IFileRequest {
  28340. /**
  28341. * Raised when the request is complete (success or error).
  28342. */
  28343. onCompleteObservable: Observable<IFileRequest>;
  28344. /**
  28345. * Aborts the request for a file.
  28346. */
  28347. abort: () => void;
  28348. }
  28349. class Tools {
  28350. static BaseUrl: string;
  28351. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28352. /**
  28353. * Default behaviour for cors in the application.
  28354. * It can be a string if the expected behavior is identical in the entire app.
  28355. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28356. */
  28357. static CorsBehavior: string | ((url: string | string[]) => string);
  28358. static UseFallbackTexture: boolean;
  28359. /**
  28360. * Use this object to register external classes like custom textures or material
  28361. * to allow the laoders to instantiate them
  28362. */
  28363. static RegisteredExternalClasses: {
  28364. [key: string]: Object;
  28365. };
  28366. static fallbackTexture: string;
  28367. /**
  28368. * Interpolates between a and b via alpha
  28369. * @param a The lower value (returned when alpha = 0)
  28370. * @param b The upper value (returned when alpha = 1)
  28371. * @param alpha The interpolation-factor
  28372. * @return The mixed value
  28373. */
  28374. static Mix(a: number, b: number, alpha: number): number;
  28375. static Instantiate(className: string): any;
  28376. /**
  28377. * Provides a slice function that will work even on IE
  28378. * @param data defines the array to slice
  28379. * @param start defines the start of the data (optional)
  28380. * @param end defines the end of the data (optional)
  28381. * @returns the new sliced array
  28382. */
  28383. static Slice<T>(data: T, start?: number, end?: number): T;
  28384. static SetImmediate(action: () => void): void;
  28385. static IsExponentOfTwo(value: number): boolean;
  28386. private static _tmpFloatArray;
  28387. /**
  28388. * Returns the nearest 32-bit single precision float representation of a Number
  28389. * @param value A Number. If the parameter is of a different type, it will get converted
  28390. * to a number or to NaN if it cannot be converted
  28391. * @returns number
  28392. */
  28393. static FloatRound(value: number): number;
  28394. /**
  28395. * Find the next highest power of two.
  28396. * @param x Number to start search from.
  28397. * @return Next highest power of two.
  28398. */
  28399. static CeilingPOT(x: number): number;
  28400. /**
  28401. * Find the next lowest power of two.
  28402. * @param x Number to start search from.
  28403. * @return Next lowest power of two.
  28404. */
  28405. static FloorPOT(x: number): number;
  28406. /**
  28407. * Find the nearest power of two.
  28408. * @param x Number to start search from.
  28409. * @return Next nearest power of two.
  28410. */
  28411. static NearestPOT(x: number): number;
  28412. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28413. static GetFilename(path: string): string;
  28414. /**
  28415. * Extracts the "folder" part of a path (everything before the filename).
  28416. * @param uri The URI to extract the info from
  28417. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28418. * @returns The "folder" part of the path
  28419. */
  28420. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28421. static GetDOMTextContent(element: HTMLElement): string;
  28422. static ToDegrees(angle: number): number;
  28423. static ToRadians(angle: number): number;
  28424. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28425. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28426. minimum: Vector3;
  28427. maximum: Vector3;
  28428. };
  28429. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28430. minimum: Vector3;
  28431. maximum: Vector3;
  28432. };
  28433. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28434. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28435. minimum: Vector2;
  28436. maximum: Vector2;
  28437. };
  28438. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28439. static GetPointerPrefix(): string;
  28440. /**
  28441. * @param func - the function to be called
  28442. * @param requester - the object that will request the next frame. Falls back to window.
  28443. */
  28444. static QueueNewFrame(func: () => void, requester?: any): number;
  28445. static RequestFullscreen(element: HTMLElement): void;
  28446. static ExitFullscreen(): void;
  28447. static SetCorsBehavior(url: string | string[], element: {
  28448. crossOrigin: string | null;
  28449. }): void;
  28450. static CleanUrl(url: string): string;
  28451. static PreprocessUrl: (url: string) => string;
  28452. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28453. 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;
  28454. /**
  28455. * Load a script (identified by an url). When the url returns, the
  28456. * content of this file is added into a new script element, attached to the DOM (body element)
  28457. */
  28458. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28459. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28460. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28461. static FileAsURL(content: string): string;
  28462. static Format(value: number, decimals?: number): string;
  28463. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28464. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28465. static IsEmpty(obj: any): boolean;
  28466. static RegisterTopRootEvents(events: {
  28467. name: string;
  28468. handler: Nullable<(e: FocusEvent) => any>;
  28469. }[]): void;
  28470. static UnregisterTopRootEvents(events: {
  28471. name: string;
  28472. handler: Nullable<(e: FocusEvent) => any>;
  28473. }[]): void;
  28474. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28475. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28476. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28477. /**
  28478. * Generates an image screenshot from the specified camera.
  28479. *
  28480. * @param engine The engine to use for rendering
  28481. * @param camera The camera to use for rendering
  28482. * @param size This parameter can be set to a single number or to an object with the
  28483. * following (optional) properties: precision, width, height. If a single number is passed,
  28484. * it will be used for both width and height. If an object is passed, the screenshot size
  28485. * will be derived from the parameters. The precision property is a multiplier allowing
  28486. * rendering at a higher or lower resolution.
  28487. * @param successCallback The callback receives a single parameter which contains the
  28488. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28489. * src parameter of an <img> to display it.
  28490. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28491. * Check your browser for supported MIME types.
  28492. * @param samples Texture samples (default: 1)
  28493. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28494. * @param fileName A name for for the downloaded file.
  28495. * @constructor
  28496. */
  28497. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28498. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28499. /**
  28500. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28501. * Be aware Math.random() could cause collisions, but:
  28502. * "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"
  28503. */
  28504. static RandomId(): string;
  28505. /**
  28506. * Test if the given uri is a base64 string.
  28507. * @param uri The uri to test
  28508. * @return True if the uri is a base64 string or false otherwise.
  28509. */
  28510. static IsBase64(uri: string): boolean;
  28511. /**
  28512. * Decode the given base64 uri.
  28513. * @param uri The uri to decode
  28514. * @return The decoded base64 data.
  28515. */
  28516. static DecodeBase64(uri: string): ArrayBuffer;
  28517. private static _NoneLogLevel;
  28518. private static _MessageLogLevel;
  28519. private static _WarningLogLevel;
  28520. private static _ErrorLogLevel;
  28521. private static _LogCache;
  28522. static errorsCount: number;
  28523. static OnNewCacheEntry: (entry: string) => void;
  28524. static readonly NoneLogLevel: number;
  28525. static readonly MessageLogLevel: number;
  28526. static readonly WarningLogLevel: number;
  28527. static readonly ErrorLogLevel: number;
  28528. static readonly AllLogLevel: number;
  28529. private static _AddLogEntry(entry);
  28530. private static _FormatMessage(message);
  28531. private static _LogDisabled(message);
  28532. private static _LogEnabled(message);
  28533. private static _WarnDisabled(message);
  28534. private static _WarnEnabled(message);
  28535. private static _ErrorDisabled(message);
  28536. private static _ErrorEnabled(message);
  28537. static Log: (message: string) => void;
  28538. static Warn: (message: string) => void;
  28539. static Error: (message: string) => void;
  28540. static readonly LogCache: string;
  28541. static ClearLogCache(): void;
  28542. static LogLevels: number;
  28543. static IsWindowObjectExist(): boolean;
  28544. private static _PerformanceNoneLogLevel;
  28545. private static _PerformanceUserMarkLogLevel;
  28546. private static _PerformanceConsoleLogLevel;
  28547. private static _performance;
  28548. static readonly PerformanceNoneLogLevel: number;
  28549. static readonly PerformanceUserMarkLogLevel: number;
  28550. static readonly PerformanceConsoleLogLevel: number;
  28551. static PerformanceLogLevel: number;
  28552. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28553. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28554. static _StartUserMark(counterName: string, condition?: boolean): void;
  28555. static _EndUserMark(counterName: string, condition?: boolean): void;
  28556. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28557. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28558. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28559. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28560. static readonly Now: number;
  28561. /**
  28562. * This method will return the name of the class used to create the instance of the given object.
  28563. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28564. * @param object the object to get the class name from
  28565. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28566. */
  28567. static GetClassName(object: any, isType?: boolean): string;
  28568. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28569. /**
  28570. * This method will return the name of the full name of the class, including its owning module (if any).
  28571. * 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).
  28572. * @param object the object to get the class name from
  28573. * @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.
  28574. */
  28575. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28576. /**
  28577. * 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.
  28578. * @param array
  28579. */
  28580. static arrayOrStringFeeder(array: any): (i: number) => number;
  28581. /**
  28582. * Compute the hashCode of a stream of number
  28583. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28584. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28585. * @return the hash code computed
  28586. */
  28587. static hashCodeFromStream(feeder: (index: number) => number): number;
  28588. /**
  28589. * Returns a promise that resolves after the given amount of time.
  28590. * @param delay Number of milliseconds to delay
  28591. * @returns Promise that resolves after the given amount of time
  28592. */
  28593. static DelayAsync(delay: number): Promise<void>;
  28594. }
  28595. /**
  28596. * This class is used to track a performance counter which is number based.
  28597. * The user has access to many properties which give statistics of different nature
  28598. *
  28599. * The implementer can track two kinds of Performance Counter: time and count
  28600. * 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.
  28601. * 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.
  28602. */
  28603. class PerfCounter {
  28604. static Enabled: boolean;
  28605. /**
  28606. * Returns the smallest value ever
  28607. */
  28608. readonly min: number;
  28609. /**
  28610. * Returns the biggest value ever
  28611. */
  28612. readonly max: number;
  28613. /**
  28614. * Returns the average value since the performance counter is running
  28615. */
  28616. readonly average: number;
  28617. /**
  28618. * Returns the average value of the last second the counter was monitored
  28619. */
  28620. readonly lastSecAverage: number;
  28621. /**
  28622. * Returns the current value
  28623. */
  28624. readonly current: number;
  28625. readonly total: number;
  28626. readonly count: number;
  28627. constructor();
  28628. /**
  28629. * Call this method to start monitoring a new frame.
  28630. * 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.
  28631. */
  28632. fetchNewFrame(): void;
  28633. /**
  28634. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28635. * @param newCount the count value to add to the monitored count
  28636. * @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.
  28637. */
  28638. addCount(newCount: number, fetchResult: boolean): void;
  28639. /**
  28640. * Start monitoring this performance counter
  28641. */
  28642. beginMonitoring(): void;
  28643. /**
  28644. * Compute the time lapsed since the previous beginMonitoring() call.
  28645. * @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
  28646. */
  28647. endMonitoring(newFrame?: boolean): void;
  28648. private _fetchResult();
  28649. private _startMonitoringTime;
  28650. private _min;
  28651. private _max;
  28652. private _average;
  28653. private _current;
  28654. private _totalValueCount;
  28655. private _totalAccumulated;
  28656. private _lastSecAverage;
  28657. private _lastSecAccumulated;
  28658. private _lastSecTime;
  28659. private _lastSecValueCount;
  28660. }
  28661. /**
  28662. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28663. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28664. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28665. * @param name The name of the class, case should be preserved
  28666. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28667. */
  28668. function className(name: string, module?: string): (target: Object) => void;
  28669. /**
  28670. * An implementation of a loop for asynchronous functions.
  28671. */
  28672. class AsyncLoop {
  28673. iterations: number;
  28674. private _fn;
  28675. private _successCallback;
  28676. index: number;
  28677. private _done;
  28678. /**
  28679. * Constroctor.
  28680. * @param iterations the number of iterations.
  28681. * @param _fn the function to run each iteration
  28682. * @param _successCallback the callback that will be called upon succesful execution
  28683. * @param offset starting offset.
  28684. */
  28685. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28686. /**
  28687. * Execute the next iteration. Must be called after the last iteration was finished.
  28688. */
  28689. executeNext(): void;
  28690. /**
  28691. * Break the loop and run the success callback.
  28692. */
  28693. breakLoop(): void;
  28694. /**
  28695. * Helper function
  28696. */
  28697. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28698. /**
  28699. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28700. * @param iterations total number of iterations
  28701. * @param syncedIterations number of synchronous iterations in each async iteration.
  28702. * @param fn the function to call each iteration.
  28703. * @param callback a success call back that will be called when iterating stops.
  28704. * @param breakFunction a break condition (optional)
  28705. * @param timeout timeout settings for the setTimeout function. default - 0.
  28706. * @constructor
  28707. */
  28708. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28709. }
  28710. }
  28711. declare module BABYLON {
  28712. /**
  28713. * Defines the potential axis of a Joystick
  28714. */
  28715. enum JoystickAxis {
  28716. /** X axis */
  28717. X = 0,
  28718. /** Y axis */
  28719. Y = 1,
  28720. /** Z axis */
  28721. Z = 2,
  28722. }
  28723. /**
  28724. * Class used to define virtual joystick (used in touch mode)
  28725. */
  28726. class VirtualJoystick {
  28727. /**
  28728. * Gets or sets a boolean indicating that left and right values must be inverted
  28729. */
  28730. reverseLeftRight: boolean;
  28731. /**
  28732. * Gets or sets a boolean indicating that up and down values must be inverted
  28733. */
  28734. reverseUpDown: boolean;
  28735. /**
  28736. * Gets the offset value for the position (ie. the change of the position value)
  28737. */
  28738. deltaPosition: Vector3;
  28739. /**
  28740. * Gets a boolean indicating if the virtual joystick was pressed
  28741. */
  28742. pressed: boolean;
  28743. private static _globalJoystickIndex;
  28744. private static vjCanvas;
  28745. private static vjCanvasContext;
  28746. private static vjCanvasWidth;
  28747. private static vjCanvasHeight;
  28748. private static halfWidth;
  28749. private _action;
  28750. private _axisTargetedByLeftAndRight;
  28751. private _axisTargetedByUpAndDown;
  28752. private _joystickSensibility;
  28753. private _inversedSensibility;
  28754. private _joystickPointerID;
  28755. private _joystickColor;
  28756. private _joystickPointerPos;
  28757. private _joystickPreviousPointerPos;
  28758. private _joystickPointerStartPos;
  28759. private _deltaJoystickVector;
  28760. private _leftJoystick;
  28761. private _touches;
  28762. private _onPointerDownHandlerRef;
  28763. private _onPointerMoveHandlerRef;
  28764. private _onPointerUpHandlerRef;
  28765. private _onResize;
  28766. /**
  28767. * Creates a new virtual joystick
  28768. * @param leftJoystick defines that the joystick is for left hand (false by default)
  28769. */
  28770. constructor(leftJoystick?: boolean);
  28771. /**
  28772. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  28773. * @param newJoystickSensibility defines the new sensibility
  28774. */
  28775. setJoystickSensibility(newJoystickSensibility: number): void;
  28776. private _onPointerDown(e);
  28777. private _onPointerMove(e);
  28778. private _onPointerUp(e);
  28779. /**
  28780. * Change the color of the virtual joystick
  28781. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  28782. */
  28783. setJoystickColor(newColor: string): void;
  28784. /**
  28785. * Defines a callback to call when the joystick is touched
  28786. * @param action defines the callback
  28787. */
  28788. setActionOnTouch(action: () => any): void;
  28789. /**
  28790. * Defines which axis you'd like to control for left & right
  28791. * @param axis defines the axis to use
  28792. */
  28793. setAxisForLeftRight(axis: JoystickAxis): void;
  28794. /**
  28795. * Defines which axis you'd like to control for up & down
  28796. * @param axis defines the axis to use
  28797. */
  28798. setAxisForUpDown(axis: JoystickAxis): void;
  28799. private _drawVirtualJoystick();
  28800. /**
  28801. * Release internal HTML canvas
  28802. */
  28803. releaseCanvas(): void;
  28804. }
  28805. }
  28806. declare module BABYLON {
  28807. /**
  28808. * Helper class to push actions to a pool of workers.
  28809. */
  28810. class WorkerPool implements IDisposable {
  28811. private _workerInfos;
  28812. private _pendingActions;
  28813. /**
  28814. * Constructor
  28815. * @param workers Array of workers to use for actions
  28816. */
  28817. constructor(workers: Array<Worker>);
  28818. /**
  28819. * Terminates all workers and clears any pending actions.
  28820. */
  28821. dispose(): void;
  28822. /**
  28823. * Pushes an action to the worker pool. If all the workers are active, the action will be
  28824. * pended until a worker has completed its action.
  28825. * @param action The action to perform. Call onComplete when the action is complete.
  28826. */
  28827. push(action: (worker: Worker, onComplete: () => void) => void): void;
  28828. private _execute(workerInfo, action);
  28829. }
  28830. }
  28831. declare module BABYLON {
  28832. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  28833. readonly name: string;
  28834. private _zoomStopsAnimation;
  28835. private _idleRotationSpeed;
  28836. private _idleRotationWaitTime;
  28837. private _idleRotationSpinupTime;
  28838. /**
  28839. * Gets the flag that indicates if user zooming should stop animation.
  28840. */
  28841. /**
  28842. * Sets the flag that indicates if user zooming should stop animation.
  28843. */
  28844. zoomStopsAnimation: boolean;
  28845. /**
  28846. * Gets the default speed at which the camera rotates around the model.
  28847. */
  28848. /**
  28849. * Sets the default speed at which the camera rotates around the model.
  28850. */
  28851. idleRotationSpeed: number;
  28852. /**
  28853. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  28854. */
  28855. /**
  28856. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  28857. */
  28858. idleRotationWaitTime: number;
  28859. /**
  28860. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28861. */
  28862. /**
  28863. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28864. */
  28865. idleRotationSpinupTime: number;
  28866. /**
  28867. * Gets a value indicating if the camera is currently rotating because of this behavior
  28868. */
  28869. readonly rotationInProgress: boolean;
  28870. private _onPrePointerObservableObserver;
  28871. private _onAfterCheckInputsObserver;
  28872. private _attachedCamera;
  28873. private _isPointerDown;
  28874. private _lastFrameTime;
  28875. private _lastInteractionTime;
  28876. private _cameraRotationSpeed;
  28877. init(): void;
  28878. attach(camera: ArcRotateCamera): void;
  28879. detach(): void;
  28880. /**
  28881. * Returns true if user is scrolling.
  28882. * @return true if user is scrolling.
  28883. */
  28884. private _userIsZooming();
  28885. private _lastFrameRadius;
  28886. private _shouldAnimationStopForInteraction();
  28887. /**
  28888. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  28889. */
  28890. private _applyUserInteraction();
  28891. private _userIsMoving();
  28892. }
  28893. }
  28894. declare module BABYLON {
  28895. /**
  28896. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  28897. */
  28898. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  28899. readonly name: string;
  28900. /**
  28901. * The easing function used by animations
  28902. */
  28903. static EasingFunction: BackEase;
  28904. /**
  28905. * The easing mode used by animations
  28906. */
  28907. static EasingMode: number;
  28908. /**
  28909. * The duration of the animation, in milliseconds
  28910. */
  28911. transitionDuration: number;
  28912. /**
  28913. * Length of the distance animated by the transition when lower radius is reached
  28914. */
  28915. lowerRadiusTransitionRange: number;
  28916. /**
  28917. * Length of the distance animated by the transition when upper radius is reached
  28918. */
  28919. upperRadiusTransitionRange: number;
  28920. private _autoTransitionRange;
  28921. /**
  28922. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28923. */
  28924. /**
  28925. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28926. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  28927. */
  28928. autoTransitionRange: boolean;
  28929. private _attachedCamera;
  28930. private _onAfterCheckInputsObserver;
  28931. private _onMeshTargetChangedObserver;
  28932. init(): void;
  28933. attach(camera: ArcRotateCamera): void;
  28934. detach(): void;
  28935. private _radiusIsAnimating;
  28936. private _radiusBounceTransition;
  28937. private _animatables;
  28938. private _cachedWheelPrecision;
  28939. /**
  28940. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  28941. * @param radiusLimit The limit to check against.
  28942. * @return Bool to indicate if at limit.
  28943. */
  28944. private _isRadiusAtLimit(radiusLimit);
  28945. /**
  28946. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  28947. * @param radiusDelta The delta by which to animate to. Can be negative.
  28948. */
  28949. private _applyBoundRadiusAnimation(radiusDelta);
  28950. /**
  28951. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  28952. */
  28953. protected _clearAnimationLocks(): void;
  28954. /**
  28955. * Stops and removes all animations that have been applied to the camera
  28956. */
  28957. stopAllAnimations(): void;
  28958. }
  28959. }
  28960. declare module BABYLON {
  28961. class FramingBehavior implements Behavior<ArcRotateCamera> {
  28962. readonly name: string;
  28963. private _mode;
  28964. private _radiusScale;
  28965. private _positionScale;
  28966. private _defaultElevation;
  28967. private _elevationReturnTime;
  28968. private _elevationReturnWaitTime;
  28969. private _zoomStopsAnimation;
  28970. private _framingTime;
  28971. /**
  28972. * The easing function used by animations
  28973. */
  28974. static EasingFunction: ExponentialEase;
  28975. /**
  28976. * The easing mode used by animations
  28977. */
  28978. static EasingMode: number;
  28979. /**
  28980. * Gets current mode used by the behavior.
  28981. */
  28982. /**
  28983. * Sets the current mode used by the behavior
  28984. */
  28985. mode: number;
  28986. /**
  28987. * Gets the scale applied to the radius
  28988. */
  28989. /**
  28990. * Sets the scale applied to the radius (1 by default)
  28991. */
  28992. radiusScale: number;
  28993. /**
  28994. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  28995. */
  28996. /**
  28997. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  28998. */
  28999. positionScale: number;
  29000. /**
  29001. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29002. * behaviour is triggered, in radians.
  29003. */
  29004. /**
  29005. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29006. * behaviour is triggered, in radians.
  29007. */
  29008. defaultElevation: number;
  29009. /**
  29010. * Gets the time (in milliseconds) taken to return to the default beta position.
  29011. * Negative value indicates camera should not return to default.
  29012. */
  29013. /**
  29014. * Sets the time (in milliseconds) taken to return to the default beta position.
  29015. * Negative value indicates camera should not return to default.
  29016. */
  29017. elevationReturnTime: number;
  29018. /**
  29019. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29020. */
  29021. /**
  29022. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29023. */
  29024. elevationReturnWaitTime: number;
  29025. /**
  29026. * Gets the flag that indicates if user zooming should stop animation.
  29027. */
  29028. /**
  29029. * Sets the flag that indicates if user zooming should stop animation.
  29030. */
  29031. zoomStopsAnimation: boolean;
  29032. /**
  29033. * Gets the transition time when framing the mesh, in milliseconds
  29034. */
  29035. /**
  29036. * Sets the transition time when framing the mesh, in milliseconds
  29037. */
  29038. framingTime: number;
  29039. private _onPrePointerObservableObserver;
  29040. private _onAfterCheckInputsObserver;
  29041. private _onMeshTargetChangedObserver;
  29042. private _attachedCamera;
  29043. private _isPointerDown;
  29044. private _lastInteractionTime;
  29045. init(): void;
  29046. attach(camera: ArcRotateCamera): void;
  29047. detach(): void;
  29048. private _animatables;
  29049. private _betaIsAnimating;
  29050. private _betaTransition;
  29051. private _radiusTransition;
  29052. private _vectorTransition;
  29053. /**
  29054. * Targets the given mesh and updates zoom level accordingly.
  29055. * @param mesh The mesh to target.
  29056. * @param radius Optional. If a cached radius position already exists, overrides default.
  29057. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29058. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29059. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29060. */
  29061. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29062. /**
  29063. * Targets the given mesh with its children and updates zoom level accordingly.
  29064. * @param mesh The mesh to target.
  29065. * @param radius Optional. If a cached radius position already exists, overrides default.
  29066. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29067. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29068. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29069. */
  29070. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29071. /**
  29072. * Targets the given meshes with their children and updates zoom level accordingly.
  29073. * @param meshes The mesh to target.
  29074. * @param radius Optional. If a cached radius position already exists, overrides default.
  29075. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29076. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29077. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29078. */
  29079. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29080. /**
  29081. * Targets the given mesh and updates zoom level accordingly.
  29082. * @param mesh The mesh to target.
  29083. * @param radius Optional. If a cached radius position already exists, overrides default.
  29084. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29085. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29086. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29087. */
  29088. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29089. /**
  29090. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29091. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29092. * frustum width.
  29093. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29094. * to fully enclose the mesh in the viewing frustum.
  29095. */
  29096. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29097. /**
  29098. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29099. * is automatically returned to its default position (expected to be above ground plane).
  29100. */
  29101. private _maintainCameraAboveGround();
  29102. /**
  29103. * Returns the frustum slope based on the canvas ratio and camera FOV
  29104. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29105. */
  29106. private _getFrustumSlope();
  29107. /**
  29108. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29109. */
  29110. private _clearAnimationLocks();
  29111. /**
  29112. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29113. */
  29114. private _applyUserInteraction();
  29115. /**
  29116. * Stops and removes all animations that have been applied to the camera
  29117. */
  29118. stopAllAnimations(): void;
  29119. /**
  29120. * Gets a value indicating if the user is moving the camera
  29121. */
  29122. readonly isUserIsMoving: boolean;
  29123. /**
  29124. * The camera can move all the way towards the mesh.
  29125. */
  29126. static IgnoreBoundsSizeMode: number;
  29127. /**
  29128. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29129. */
  29130. static FitFrustumSidesMode: number;
  29131. }
  29132. }
  29133. declare module BABYLON {
  29134. class VRCameraMetrics {
  29135. hResolution: number;
  29136. vResolution: number;
  29137. hScreenSize: number;
  29138. vScreenSize: number;
  29139. vScreenCenter: number;
  29140. eyeToScreenDistance: number;
  29141. lensSeparationDistance: number;
  29142. interpupillaryDistance: number;
  29143. distortionK: number[];
  29144. chromaAbCorrection: number[];
  29145. postProcessScaleFactor: number;
  29146. lensCenterOffset: number;
  29147. compensateDistortion: boolean;
  29148. readonly aspectRatio: number;
  29149. readonly aspectRatioFov: number;
  29150. readonly leftHMatrix: Matrix;
  29151. readonly rightHMatrix: Matrix;
  29152. readonly leftPreViewMatrix: Matrix;
  29153. readonly rightPreViewMatrix: Matrix;
  29154. static GetDefault(): VRCameraMetrics;
  29155. }
  29156. }
  29157. declare module BABYLON {
  29158. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29159. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29160. getClassName(): string;
  29161. }
  29162. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29163. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29164. getClassName(): string;
  29165. }
  29166. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29167. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29168. getClassName(): string;
  29169. }
  29170. }
  29171. declare module BABYLON {
  29172. /**
  29173. * Options to modify the vr teleportation behavior.
  29174. */
  29175. interface VRTeleportationOptions {
  29176. /**
  29177. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29178. */
  29179. floorMeshName?: string;
  29180. /**
  29181. * A list of meshes to be used as the teleportation floor. (default: empty)
  29182. */
  29183. floorMeshes?: Mesh[];
  29184. }
  29185. /**
  29186. * Options to modify the vr experience helper's behavior.
  29187. */
  29188. interface VRExperienceHelperOptions extends WebVROptions {
  29189. /**
  29190. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  29191. */
  29192. createDeviceOrientationCamera?: boolean;
  29193. /**
  29194. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  29195. */
  29196. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29197. }
  29198. /**
  29199. * Helps to quickly add VR support to an existing scene.
  29200. * See http://doc.babylonjs.com/how_to/webvr_helper
  29201. */
  29202. class VRExperienceHelper {
  29203. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29204. private _scene;
  29205. private _position;
  29206. private _btnVR;
  29207. private _btnVRDisplayed;
  29208. private _webVRsupported;
  29209. private _webVRready;
  29210. private _webVRrequesting;
  29211. private _webVRpresenting;
  29212. private _fullscreenVRpresenting;
  29213. private _canvas;
  29214. private _webVRCamera;
  29215. private _vrDeviceOrientationCamera;
  29216. private _deviceOrientationCamera;
  29217. private _existingCamera;
  29218. private _onKeyDown;
  29219. private _onVrDisplayPresentChange;
  29220. private _onVRDisplayChanged;
  29221. private _onVRRequestPresentStart;
  29222. private _onVRRequestPresentComplete;
  29223. /**
  29224. * Observable raised when entering VR.
  29225. */
  29226. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29227. /**
  29228. * Observable raised when exiting VR.
  29229. */
  29230. onExitingVRObservable: Observable<VRExperienceHelper>;
  29231. /**
  29232. * Observable raised when controller mesh is loaded.
  29233. */
  29234. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29235. /** Return this.onEnteringVRObservable
  29236. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29237. */
  29238. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29239. /** Return this.onExitingVRObservable
  29240. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29241. */
  29242. readonly onExitingVR: Observable<VRExperienceHelper>;
  29243. /** Return this.onControllerMeshLoadedObservable
  29244. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29245. */
  29246. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29247. private _rayLength;
  29248. private _useCustomVRButton;
  29249. private _teleportationRequested;
  29250. private _teleportActive;
  29251. private _floorMeshName;
  29252. private _floorMeshesCollection;
  29253. private _rotationAllowed;
  29254. private _teleportBackwardsVector;
  29255. private _rotationRightAsked;
  29256. private _rotationLeftAsked;
  29257. private _teleportationTarget;
  29258. private _isDefaultTeleportationTarget;
  29259. private _postProcessMove;
  29260. private _teleportationFillColor;
  29261. private _teleportationBorderColor;
  29262. private _rotationAngle;
  29263. private _haloCenter;
  29264. private _cameraGazer;
  29265. private _padSensibilityUp;
  29266. private _padSensibilityDown;
  29267. private leftController;
  29268. private rightController;
  29269. /**
  29270. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29271. */
  29272. onNewMeshSelected: Observable<AbstractMesh>;
  29273. /**
  29274. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29275. */
  29276. onNewMeshPicked: Observable<PickingInfo>;
  29277. private _circleEase;
  29278. /**
  29279. * Observable raised before camera teleportation
  29280. */
  29281. onBeforeCameraTeleport: Observable<Vector3>;
  29282. /**
  29283. * Observable raised after camera teleportation
  29284. */
  29285. onAfterCameraTeleport: Observable<Vector3>;
  29286. /**
  29287. * Observable raised when current selected mesh gets unselected
  29288. */
  29289. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29290. private _raySelectionPredicate;
  29291. /**
  29292. * To be optionaly changed by user to define custom ray selection
  29293. */
  29294. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29295. /**
  29296. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29297. */
  29298. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29299. /**
  29300. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29301. */
  29302. teleportationEnabled: boolean;
  29303. private _defaultHeight;
  29304. private _teleportationInitialized;
  29305. private _interactionsEnabled;
  29306. private _interactionsRequested;
  29307. private _displayGaze;
  29308. private _displayLaserPointer;
  29309. /**
  29310. * The mesh used to display where the user is going to teleport.
  29311. */
  29312. /**
  29313. * Sets the mesh to be used to display where the user is going to teleport.
  29314. */
  29315. teleportationTarget: Mesh;
  29316. /**
  29317. * The mesh used to display where the user is selecting,
  29318. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29319. * See http://doc.babylonjs.com/resources/baking_transformations
  29320. */
  29321. gazeTrackerMesh: Mesh;
  29322. /**
  29323. * If the ray of the gaze should be displayed.
  29324. */
  29325. /**
  29326. * Sets if the ray of the gaze should be displayed.
  29327. */
  29328. displayGaze: boolean;
  29329. /**
  29330. * If the ray of the LaserPointer should be displayed.
  29331. */
  29332. /**
  29333. * Sets if the ray of the LaserPointer should be displayed.
  29334. */
  29335. displayLaserPointer: boolean;
  29336. /**
  29337. * The deviceOrientationCamera used as the camera when not in VR.
  29338. */
  29339. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29340. /**
  29341. * Based on the current WebVR support, returns the current VR camera used.
  29342. */
  29343. readonly currentVRCamera: Nullable<Camera>;
  29344. /**
  29345. * The webVRCamera which is used when in VR.
  29346. */
  29347. readonly webVRCamera: WebVRFreeCamera;
  29348. /**
  29349. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29350. */
  29351. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29352. private readonly _teleportationRequestInitiated;
  29353. /**
  29354. * Instantiates a VRExperienceHelper.
  29355. * Helps to quickly add VR support to an existing scene.
  29356. * @param scene The scene the VRExperienceHelper belongs to.
  29357. * @param webVROptions Options to modify the vr experience helper's behavior.
  29358. */
  29359. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29360. private _onDefaultMeshLoaded(webVRController);
  29361. private _onResize;
  29362. private _onFullscreenChange;
  29363. /**
  29364. * Gets a value indicating if we are currently in VR mode.
  29365. */
  29366. readonly isInVRMode: boolean;
  29367. private onVrDisplayPresentChange();
  29368. private onVRDisplayChanged(eventArgs);
  29369. private moveButtonToBottomRight();
  29370. private displayVRButton();
  29371. private updateButtonVisibility();
  29372. /**
  29373. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29374. * Otherwise, will use the fullscreen API.
  29375. */
  29376. enterVR(): void;
  29377. /**
  29378. * Attempt to exit VR, or fullscreen.
  29379. */
  29380. exitVR(): void;
  29381. /**
  29382. * The position of the vr experience helper.
  29383. */
  29384. /**
  29385. * Sets the position of the vr experience helper.
  29386. */
  29387. position: Vector3;
  29388. /**
  29389. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29390. */
  29391. enableInteractions(): void;
  29392. private beforeRender;
  29393. private _isTeleportationFloor(mesh);
  29394. /**
  29395. * Adds a floor mesh to be used for teleportation.
  29396. * @param floorMesh the mesh to be used for teleportation.
  29397. */
  29398. addFloorMesh(floorMesh: Mesh): void;
  29399. /**
  29400. * Removes a floor mesh from being used for teleportation.
  29401. * @param floorMesh the mesh to be removed.
  29402. */
  29403. removeFloorMesh(floorMesh: Mesh): void;
  29404. /**
  29405. * Enables interactions and teleportation using the VR controllers and gaze.
  29406. * @param vrTeleportationOptions options to modify teleportation behavior.
  29407. */
  29408. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29409. private _onNewGamepadConnected;
  29410. private _tryEnableInteractionOnController;
  29411. private _onNewGamepadDisconnected;
  29412. private _enableInteractionOnController(controller);
  29413. private _checkTeleportWithRay(stateObject, gazer);
  29414. private _checkRotate(stateObject, gazer);
  29415. private _checkTeleportBackwards(stateObject, gazer);
  29416. private _enableTeleportationOnController(controller);
  29417. private _createTeleportationCircles();
  29418. private _displayTeleportationTarget();
  29419. private _hideTeleportationTarget();
  29420. private _rotateCamera(right);
  29421. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29422. private _workingVector;
  29423. private _workingQuaternion;
  29424. private _workingMatrix;
  29425. private _teleportCamera(location);
  29426. private _convertNormalToDirectionOfRay(normal, ray);
  29427. private _castRayAndSelectObject(gazer);
  29428. private _notifySelectedMeshUnselected(mesh);
  29429. /**
  29430. * Sets the color of the laser ray from the vr controllers.
  29431. * @param color new color for the ray.
  29432. */
  29433. changeLaserColor(color: Color3): void;
  29434. /**
  29435. * Sets the color of the ray from the vr headsets gaze.
  29436. * @param color new color for the ray.
  29437. */
  29438. changeGazeColor(color: Color3): void;
  29439. /**
  29440. * Exits VR and disposes of the vr experience helper
  29441. */
  29442. dispose(): void;
  29443. /**
  29444. * Gets the name of the VRExperienceHelper class
  29445. * @returns "VRExperienceHelper"
  29446. */
  29447. getClassName(): string;
  29448. }
  29449. }
  29450. declare module BABYLON {
  29451. /**
  29452. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29453. * IMPORTANT!! The data is right-hand data.
  29454. * @export
  29455. * @interface DevicePose
  29456. */
  29457. interface DevicePose {
  29458. /**
  29459. * The position of the device, values in array are [x,y,z].
  29460. */
  29461. readonly position: Nullable<Float32Array>;
  29462. /**
  29463. * The linearVelocity of the device, values in array are [x,y,z].
  29464. */
  29465. readonly linearVelocity: Nullable<Float32Array>;
  29466. /**
  29467. * The linearAcceleration of the device, values in array are [x,y,z].
  29468. */
  29469. readonly linearAcceleration: Nullable<Float32Array>;
  29470. /**
  29471. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29472. */
  29473. readonly orientation: Nullable<Float32Array>;
  29474. /**
  29475. * The angularVelocity of the device, values in array are [x,y,z].
  29476. */
  29477. readonly angularVelocity: Nullable<Float32Array>;
  29478. /**
  29479. * The angularAcceleration of the device, values in array are [x,y,z].
  29480. */
  29481. readonly angularAcceleration: Nullable<Float32Array>;
  29482. }
  29483. /**
  29484. * Interface representing a pose controlled object in Babylon.
  29485. * A pose controlled object has both regular pose values as well as pose values
  29486. * from an external device such as a VR head mounted display
  29487. */
  29488. interface PoseControlled {
  29489. /**
  29490. * The position of the object in babylon space.
  29491. */
  29492. position: Vector3;
  29493. /**
  29494. * The rotation quaternion of the object in babylon space.
  29495. */
  29496. rotationQuaternion: Quaternion;
  29497. /**
  29498. * The position of the device in babylon space.
  29499. */
  29500. devicePosition?: Vector3;
  29501. /**
  29502. * The rotation quaternion of the device in babylon space.
  29503. */
  29504. deviceRotationQuaternion: Quaternion;
  29505. /**
  29506. * The raw pose coming from the device.
  29507. */
  29508. rawPose: Nullable<DevicePose>;
  29509. /**
  29510. * The scale of the device to be used when translating from device space to babylon space.
  29511. */
  29512. deviceScaleFactor: number;
  29513. /**
  29514. * Updates the poseControlled values based on the input device pose.
  29515. * @param poseData the pose data to update the object with
  29516. */
  29517. updateFromDevice(poseData: DevicePose): void;
  29518. }
  29519. /**
  29520. * Set of options to customize the webVRCamera
  29521. */
  29522. interface WebVROptions {
  29523. /**
  29524. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29525. */
  29526. trackPosition?: boolean;
  29527. /**
  29528. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29529. */
  29530. positionScale?: number;
  29531. /**
  29532. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29533. */
  29534. displayName?: string;
  29535. /**
  29536. * Should the native controller meshes be initialized. (default: true)
  29537. */
  29538. controllerMeshes?: boolean;
  29539. /**
  29540. * Creating a default HemiLight only on controllers. (default: true)
  29541. */
  29542. defaultLightingOnControllers?: boolean;
  29543. /**
  29544. * If you don't want to use the default VR button of the helper. (default: false)
  29545. */
  29546. useCustomVRButton?: boolean;
  29547. /**
  29548. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29549. */
  29550. customVRButton?: HTMLButtonElement;
  29551. /**
  29552. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29553. */
  29554. rayLength?: number;
  29555. /**
  29556. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29557. */
  29558. defaultHeight?: number;
  29559. }
  29560. /**
  29561. * This represents a WebVR camera.
  29562. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29563. * @example http://doc.babylonjs.com/how_to/webvr_camera
  29564. */
  29565. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29566. private webVROptions;
  29567. /**
  29568. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29569. */
  29570. _vrDevice: any;
  29571. /**
  29572. * The rawPose of the vrDevice.
  29573. */
  29574. rawPose: Nullable<DevicePose>;
  29575. private _onVREnabled;
  29576. private _specsVersion;
  29577. private _attached;
  29578. private _frameData;
  29579. protected _descendants: Array<Node>;
  29580. private _deviceRoomPosition;
  29581. private _deviceRoomRotationQuaternion;
  29582. private _standingMatrix;
  29583. /**
  29584. * Represents device position in babylon space.
  29585. */
  29586. devicePosition: Vector3;
  29587. /**
  29588. * Represents device rotation in babylon space.
  29589. */
  29590. deviceRotationQuaternion: Quaternion;
  29591. /**
  29592. * The scale of the device to be used when translating from device space to babylon space.
  29593. */
  29594. deviceScaleFactor: number;
  29595. private _deviceToWorld;
  29596. private _worldToDevice;
  29597. /**
  29598. * References to the webVR controllers for the vrDevice.
  29599. */
  29600. controllers: Array<WebVRController>;
  29601. /**
  29602. * Emits an event when a controller is attached.
  29603. */
  29604. onControllersAttachedObservable: Observable<WebVRController[]>;
  29605. /**
  29606. * Emits an event when a controller's mesh has been loaded;
  29607. */
  29608. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29609. /**
  29610. * If the rig cameras be used as parent instead of this camera.
  29611. */
  29612. rigParenting: boolean;
  29613. private _lightOnControllers;
  29614. private _defaultHeight?;
  29615. /**
  29616. * Instantiates a WebVRFreeCamera.
  29617. * @param name The name of the WebVRFreeCamera
  29618. * @param position The starting anchor position for the camera
  29619. * @param scene The scene the camera belongs to
  29620. * @param webVROptions a set of customizable options for the webVRCamera
  29621. */
  29622. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  29623. /**
  29624. * Gets the device distance from the ground in meters.
  29625. * @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.
  29626. */
  29627. deviceDistanceToRoomGround(): number;
  29628. /**
  29629. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29630. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  29631. */
  29632. useStandingMatrix(callback?: (bool: boolean) => void): void;
  29633. /**
  29634. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29635. * @returns A promise with a boolean set to if the standing matrix is supported.
  29636. */
  29637. useStandingMatrixAsync(): Promise<boolean>;
  29638. /**
  29639. * Disposes the camera
  29640. */
  29641. dispose(): void;
  29642. /**
  29643. * Gets a vrController by name.
  29644. * @param name The name of the controller to retreive
  29645. * @returns the controller matching the name specified or null if not found
  29646. */
  29647. getControllerByName(name: string): Nullable<WebVRController>;
  29648. private _leftController;
  29649. /**
  29650. * The controller corrisponding to the users left hand.
  29651. */
  29652. readonly leftController: Nullable<WebVRController>;
  29653. private _rightController;
  29654. /**
  29655. * The controller corrisponding to the users right hand.
  29656. */
  29657. readonly rightController: Nullable<WebVRController>;
  29658. /**
  29659. * Casts a ray forward from the vrCamera's gaze.
  29660. * @param length Length of the ray (default: 100)
  29661. * @returns the ray corrisponding to the gaze
  29662. */
  29663. getForwardRay(length?: number): Ray;
  29664. /**
  29665. * Updates the camera based on device's frame data
  29666. */
  29667. _checkInputs(): void;
  29668. /**
  29669. * Updates the poseControlled values based on the input device pose.
  29670. * @param poseData Pose coming from the device
  29671. */
  29672. updateFromDevice(poseData: DevicePose): void;
  29673. /**
  29674. * WebVR's attach control will start broadcasting frames to the device.
  29675. * Note that in certain browsers (chrome for example) this function must be called
  29676. * within a user-interaction callback. Example:
  29677. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  29678. *
  29679. * @param element html element to attach the vrDevice to
  29680. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  29681. */
  29682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29683. /**
  29684. * Detaches the camera from the html element and disables VR
  29685. *
  29686. * @param element html element to detach from
  29687. */
  29688. detachControl(element: HTMLElement): void;
  29689. /**
  29690. * @returns the name of this class
  29691. */
  29692. getClassName(): string;
  29693. /**
  29694. * Calls resetPose on the vrDisplay
  29695. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  29696. */
  29697. resetToCurrentRotation(): void;
  29698. /**
  29699. * Updates the rig cameras (left and right eye)
  29700. */
  29701. _updateRigCameras(): void;
  29702. private _workingVector;
  29703. private _oneVector;
  29704. private _workingMatrix;
  29705. private updateCacheCalled;
  29706. /**
  29707. * Updates the cached values of the camera
  29708. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  29709. */
  29710. _updateCache(ignoreParentClass?: boolean): void;
  29711. /**
  29712. * Updates the current device position and rotation in the babylon world
  29713. */
  29714. update(): void;
  29715. /**
  29716. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  29717. * @returns an identity matrix
  29718. */
  29719. _getViewMatrix(): Matrix;
  29720. /**
  29721. * This function is called by the two RIG cameras.
  29722. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  29723. */
  29724. protected _getWebVRViewMatrix(): Matrix;
  29725. protected _getWebVRProjectionMatrix(): Matrix;
  29726. private _onGamepadConnectedObserver;
  29727. private _onGamepadDisconnectedObserver;
  29728. /**
  29729. * Initializes the controllers and their meshes
  29730. */
  29731. initControllers(): void;
  29732. }
  29733. }
  29734. declare module BABYLON {
  29735. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  29736. camera: ArcRotateCamera;
  29737. gamepad: Nullable<Gamepad>;
  29738. private _onGamepadConnectedObserver;
  29739. private _onGamepadDisconnectedObserver;
  29740. gamepadRotationSensibility: number;
  29741. gamepadMoveSensibility: number;
  29742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29743. detachControl(element: Nullable<HTMLElement>): void;
  29744. checkInputs(): void;
  29745. getClassName(): string;
  29746. getSimpleName(): string;
  29747. }
  29748. }
  29749. declare module BABYLON {
  29750. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  29751. camera: ArcRotateCamera;
  29752. private _keys;
  29753. keysUp: number[];
  29754. keysDown: number[];
  29755. keysLeft: number[];
  29756. keysRight: number[];
  29757. keysReset: number[];
  29758. panningSensibility: number;
  29759. zoomingSensibility: number;
  29760. useAltToZoom: boolean;
  29761. private _ctrlPressed;
  29762. private _altPressed;
  29763. private _onCanvasBlurObserver;
  29764. private _onKeyboardObserver;
  29765. private _engine;
  29766. private _scene;
  29767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29768. detachControl(element: Nullable<HTMLElement>): void;
  29769. checkInputs(): void;
  29770. getClassName(): string;
  29771. getSimpleName(): string;
  29772. }
  29773. }
  29774. declare module BABYLON {
  29775. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  29776. camera: ArcRotateCamera;
  29777. private _wheel;
  29778. private _observer;
  29779. wheelPrecision: number;
  29780. /**
  29781. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  29782. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  29783. */
  29784. wheelDeltaPercentage: number;
  29785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29786. detachControl(element: Nullable<HTMLElement>): void;
  29787. getClassName(): string;
  29788. getSimpleName(): string;
  29789. }
  29790. }
  29791. declare module BABYLON {
  29792. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  29793. camera: ArcRotateCamera;
  29794. buttons: number[];
  29795. angularSensibilityX: number;
  29796. angularSensibilityY: number;
  29797. pinchPrecision: number;
  29798. /**
  29799. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  29800. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  29801. */
  29802. pinchDeltaPercentage: number;
  29803. panningSensibility: number;
  29804. multiTouchPanning: boolean;
  29805. multiTouchPanAndZoom: boolean;
  29806. private _isPanClick;
  29807. pinchInwards: boolean;
  29808. private _pointerInput;
  29809. private _observer;
  29810. private _onMouseMove;
  29811. private _onGestureStart;
  29812. private _onGesture;
  29813. private _MSGestureHandler;
  29814. private _onLostFocus;
  29815. private _onContextMenu;
  29816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29817. detachControl(element: Nullable<HTMLElement>): void;
  29818. getClassName(): string;
  29819. getSimpleName(): string;
  29820. }
  29821. }
  29822. declare module BABYLON {
  29823. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  29824. camera: ArcRotateCamera;
  29825. alphaCorrection: number;
  29826. betaCorrection: number;
  29827. gammaCorrection: number;
  29828. private _alpha;
  29829. private _gamma;
  29830. private _dirty;
  29831. private _deviceOrientationHandler;
  29832. constructor();
  29833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29834. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  29835. checkInputs(): void;
  29836. detachControl(element: Nullable<HTMLElement>): void;
  29837. getClassName(): string;
  29838. getSimpleName(): string;
  29839. }
  29840. }
  29841. declare module BABYLON {
  29842. /**
  29843. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  29844. * Screen rotation is taken into account.
  29845. */
  29846. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  29847. private _camera;
  29848. private _screenOrientationAngle;
  29849. private _constantTranform;
  29850. private _screenQuaternion;
  29851. private _alpha;
  29852. private _beta;
  29853. private _gamma;
  29854. constructor();
  29855. camera: FreeCamera;
  29856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29857. private _orientationChanged;
  29858. private _deviceOrientation;
  29859. detachControl(element: Nullable<HTMLElement>): void;
  29860. checkInputs(): void;
  29861. getClassName(): string;
  29862. getSimpleName(): string;
  29863. }
  29864. }
  29865. declare module BABYLON {
  29866. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  29867. camera: FreeCamera;
  29868. gamepad: Nullable<Gamepad>;
  29869. private _onGamepadConnectedObserver;
  29870. private _onGamepadDisconnectedObserver;
  29871. gamepadAngularSensibility: number;
  29872. gamepadMoveSensibility: number;
  29873. private _cameraTransform;
  29874. private _deltaTransform;
  29875. private _vector3;
  29876. private _vector2;
  29877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29878. detachControl(element: Nullable<HTMLElement>): void;
  29879. checkInputs(): void;
  29880. getClassName(): string;
  29881. getSimpleName(): string;
  29882. }
  29883. }
  29884. declare module BABYLON {
  29885. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  29886. camera: FreeCamera;
  29887. private _keys;
  29888. private _onCanvasBlurObserver;
  29889. private _onKeyboardObserver;
  29890. private _engine;
  29891. private _scene;
  29892. keysUp: number[];
  29893. keysDown: number[];
  29894. keysLeft: number[];
  29895. keysRight: number[];
  29896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29897. detachControl(element: Nullable<HTMLElement>): void;
  29898. checkInputs(): void;
  29899. getClassName(): string;
  29900. _onLostFocus(e: FocusEvent): void;
  29901. getSimpleName(): string;
  29902. }
  29903. }
  29904. declare module BABYLON {
  29905. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  29906. touchEnabled: boolean;
  29907. camera: FreeCamera;
  29908. buttons: number[];
  29909. angularSensibility: number;
  29910. private _pointerInput;
  29911. private _onMouseMove;
  29912. private _observer;
  29913. private previousPosition;
  29914. constructor(touchEnabled?: boolean);
  29915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29916. detachControl(element: Nullable<HTMLElement>): void;
  29917. getClassName(): string;
  29918. getSimpleName(): string;
  29919. }
  29920. }
  29921. declare module BABYLON {
  29922. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  29923. camera: FreeCamera;
  29924. private _offsetX;
  29925. private _offsetY;
  29926. private _pointerPressed;
  29927. private _pointerInput;
  29928. private _observer;
  29929. private _onLostFocus;
  29930. touchAngularSensibility: number;
  29931. touchMoveSensibility: number;
  29932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29933. detachControl(element: Nullable<HTMLElement>): void;
  29934. checkInputs(): void;
  29935. getClassName(): string;
  29936. getSimpleName(): string;
  29937. }
  29938. }
  29939. declare module BABYLON {
  29940. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29941. camera: FreeCamera;
  29942. private _leftjoystick;
  29943. private _rightjoystick;
  29944. getLeftJoystick(): VirtualJoystick;
  29945. getRightJoystick(): VirtualJoystick;
  29946. checkInputs(): void;
  29947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29948. detachControl(element: Nullable<HTMLElement>): void;
  29949. getClassName(): string;
  29950. getSimpleName(): string;
  29951. }
  29952. }
  29953. declare module BABYLON {
  29954. interface IOctreeContainer<T> {
  29955. blocks: Array<OctreeBlock<T>>;
  29956. }
  29957. class Octree<T> {
  29958. maxDepth: number;
  29959. blocks: Array<OctreeBlock<T>>;
  29960. dynamicContent: T[];
  29961. private _maxBlockCapacity;
  29962. private _selectionContent;
  29963. private _creationFunc;
  29964. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29965. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29966. addMesh(entry: T): void;
  29967. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29968. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29969. intersectsRay(ray: Ray): SmartArray<T>;
  29970. 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;
  29971. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29972. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29973. }
  29974. }
  29975. declare module BABYLON {
  29976. class OctreeBlock<T> {
  29977. entries: T[];
  29978. blocks: Array<OctreeBlock<T>>;
  29979. private _depth;
  29980. private _maxDepth;
  29981. private _capacity;
  29982. private _minPoint;
  29983. private _maxPoint;
  29984. private _boundingVectors;
  29985. private _creationFunc;
  29986. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  29987. readonly capacity: number;
  29988. readonly minPoint: Vector3;
  29989. readonly maxPoint: Vector3;
  29990. addEntry(entry: T): void;
  29991. addEntries(entries: T[]): void;
  29992. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29993. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29994. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  29995. createInnerBlocks(): void;
  29996. }
  29997. }
  29998. declare module BABYLON {
  29999. /**
  30000. * Google Daydream controller
  30001. */
  30002. class DaydreamController extends WebVRController {
  30003. /**
  30004. * Base Url for the controller model.
  30005. */
  30006. static MODEL_BASE_URL: string;
  30007. /**
  30008. * File name for the controller model.
  30009. */
  30010. static MODEL_FILENAME: string;
  30011. /**
  30012. * Gamepad Id prefix used to identify Daydream Controller.
  30013. */
  30014. static readonly GAMEPAD_ID_PREFIX: string;
  30015. /**
  30016. * Creates a new DaydreamController from a gamepad
  30017. * @param vrGamepad the gamepad that the controller should be created from
  30018. */
  30019. constructor(vrGamepad: any);
  30020. /**
  30021. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30022. * @param scene scene in which to add meshes
  30023. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30024. */
  30025. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30026. /**
  30027. * Called once for each button that changed state since the last frame
  30028. * @param buttonIdx Which button index changed
  30029. * @param state New state of the button
  30030. * @param changes Which properties on the state changed since last frame
  30031. */
  30032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30033. }
  30034. }
  30035. declare module BABYLON {
  30036. /**
  30037. * Gear VR Controller
  30038. */
  30039. class GearVRController extends WebVRController {
  30040. /**
  30041. * Base Url for the controller model.
  30042. */
  30043. static MODEL_BASE_URL: string;
  30044. /**
  30045. * File name for the controller model.
  30046. */
  30047. static MODEL_FILENAME: string;
  30048. /**
  30049. * Gamepad Id prefix used to identify this controller.
  30050. */
  30051. static readonly GAMEPAD_ID_PREFIX: string;
  30052. private readonly _buttonIndexToObservableNameMap;
  30053. /**
  30054. * Creates a new GearVRController from a gamepad
  30055. * @param vrGamepad the gamepad that the controller should be created from
  30056. */
  30057. constructor(vrGamepad: any);
  30058. /**
  30059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30060. * @param scene scene in which to add meshes
  30061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30062. */
  30063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30064. /**
  30065. * Called once for each button that changed state since the last frame
  30066. * @param buttonIdx Which button index changed
  30067. * @param state New state of the button
  30068. * @param changes Which properties on the state changed since last frame
  30069. */
  30070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30071. }
  30072. }
  30073. declare module BABYLON {
  30074. /**
  30075. * Generic Controller
  30076. */
  30077. class GenericController extends WebVRController {
  30078. /**
  30079. * Base Url for the controller model.
  30080. */
  30081. static readonly MODEL_BASE_URL: string;
  30082. /**
  30083. * File name for the controller model.
  30084. */
  30085. static readonly MODEL_FILENAME: string;
  30086. /**
  30087. * Creates a new GenericController from a gamepad
  30088. * @param vrGamepad the gamepad that the controller should be created from
  30089. */
  30090. constructor(vrGamepad: any);
  30091. /**
  30092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30093. * @param scene scene in which to add meshes
  30094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30095. */
  30096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30097. /**
  30098. * Called once for each button that changed state since the last frame
  30099. * @param buttonIdx Which button index changed
  30100. * @param state New state of the button
  30101. * @param changes Which properties on the state changed since last frame
  30102. */
  30103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30104. }
  30105. }
  30106. declare module BABYLON {
  30107. /**
  30108. * Oculus Touch Controller
  30109. */
  30110. class OculusTouchController extends WebVRController {
  30111. /**
  30112. * Base Url for the controller model.
  30113. */
  30114. static MODEL_BASE_URL: string;
  30115. /**
  30116. * File name for the left controller model.
  30117. */
  30118. static MODEL_LEFT_FILENAME: string;
  30119. /**
  30120. * File name for the right controller model.
  30121. */
  30122. static MODEL_RIGHT_FILENAME: string;
  30123. /**
  30124. * Fired when the secondary trigger on this controller is modified
  30125. */
  30126. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30127. /**
  30128. * Fired when the thumb rest on this controller is modified
  30129. */
  30130. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30131. /**
  30132. * Creates a new OculusTouchController from a gamepad
  30133. * @param vrGamepad the gamepad that the controller should be created from
  30134. */
  30135. constructor(vrGamepad: any);
  30136. /**
  30137. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30138. * @param scene scene in which to add meshes
  30139. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30140. */
  30141. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30142. /**
  30143. * Fired when the A button on this controller is modified
  30144. */
  30145. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30146. /**
  30147. * Fired when the B button on this controller is modified
  30148. */
  30149. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30150. /**
  30151. * Fired when the X button on this controller is modified
  30152. */
  30153. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30154. /**
  30155. * Fired when the Y button on this controller is modified
  30156. */
  30157. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30158. /**
  30159. * Called once for each button that changed state since the last frame
  30160. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30161. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30162. * 2) secondary trigger (same)
  30163. * 3) A (right) X (left), touch, pressed = value
  30164. * 4) B / Y
  30165. * 5) thumb rest
  30166. * @param buttonIdx Which button index changed
  30167. * @param state New state of the button
  30168. * @param changes Which properties on the state changed since last frame
  30169. */
  30170. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30171. }
  30172. }
  30173. declare module BABYLON {
  30174. /**
  30175. * Defines the types of pose enabled controllers that are supported
  30176. */
  30177. enum PoseEnabledControllerType {
  30178. /**
  30179. * HTC Vive
  30180. */
  30181. VIVE = 0,
  30182. /**
  30183. * Oculus Rift
  30184. */
  30185. OCULUS = 1,
  30186. /**
  30187. * Windows mixed reality
  30188. */
  30189. WINDOWS = 2,
  30190. /**
  30191. * Samsung gear VR
  30192. */
  30193. GEAR_VR = 3,
  30194. /**
  30195. * Google Daydream
  30196. */
  30197. DAYDREAM = 4,
  30198. /**
  30199. * Generic
  30200. */
  30201. GENERIC = 5,
  30202. }
  30203. /**
  30204. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30205. */
  30206. interface MutableGamepadButton {
  30207. /**
  30208. * Value of the button/trigger
  30209. */
  30210. value: number;
  30211. /**
  30212. * If the button/trigger is currently touched
  30213. */
  30214. touched: boolean;
  30215. /**
  30216. * If the button/trigger is currently pressed
  30217. */
  30218. pressed: boolean;
  30219. }
  30220. /**
  30221. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30222. * @hidden
  30223. */
  30224. interface ExtendedGamepadButton extends GamepadButton {
  30225. /**
  30226. * If the button/trigger is currently pressed
  30227. */
  30228. readonly pressed: boolean;
  30229. /**
  30230. * If the button/trigger is currently touched
  30231. */
  30232. readonly touched: boolean;
  30233. /**
  30234. * Value of the button/trigger
  30235. */
  30236. readonly value: number;
  30237. }
  30238. /**
  30239. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30240. */
  30241. class PoseEnabledControllerHelper {
  30242. /**
  30243. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30244. * @param vrGamepad the gamepad to initialized
  30245. * @returns a vr controller of the type the gamepad identified as
  30246. */
  30247. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30248. }
  30249. /**
  30250. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30251. */
  30252. class PoseEnabledController extends Gamepad implements PoseControlled {
  30253. private _deviceRoomPosition;
  30254. private _deviceRoomRotationQuaternion;
  30255. /**
  30256. * The device position in babylon space
  30257. */
  30258. devicePosition: Vector3;
  30259. /**
  30260. * The device rotation in babylon space
  30261. */
  30262. deviceRotationQuaternion: Quaternion;
  30263. /**
  30264. * The scale factor of the device in babylon space
  30265. */
  30266. deviceScaleFactor: number;
  30267. /**
  30268. * (Likely devicePosition should be used instead) The device position in its room space
  30269. */
  30270. position: Vector3;
  30271. /**
  30272. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30273. */
  30274. rotationQuaternion: Quaternion;
  30275. /**
  30276. * The type of controller (Eg. Windows mixed reality)
  30277. */
  30278. controllerType: PoseEnabledControllerType;
  30279. private _calculatedPosition;
  30280. private _calculatedRotation;
  30281. /**
  30282. * The raw pose from the device
  30283. */
  30284. rawPose: DevicePose;
  30285. /**
  30286. * Internal, the mesh attached to the controller
  30287. */
  30288. _mesh: Nullable<AbstractMesh>;
  30289. private _poseControlledCamera;
  30290. private _leftHandSystemQuaternion;
  30291. /**
  30292. * Internal, matrix used to convert room space to babylon space
  30293. */
  30294. _deviceToWorld: Matrix;
  30295. /**
  30296. * Node to be used when casting a ray from the controller
  30297. */
  30298. _pointingPoseNode: Nullable<AbstractMesh>;
  30299. /**
  30300. * Name of the child mesh that can be used to cast a ray from the controller
  30301. */
  30302. static readonly POINTING_POSE: string;
  30303. /**
  30304. * Creates a new PoseEnabledController from a gamepad
  30305. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30306. */
  30307. constructor(browserGamepad: any);
  30308. private _workingMatrix;
  30309. /**
  30310. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30311. */
  30312. update(): void;
  30313. /**
  30314. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30315. * @param poseData raw pose fromthe device
  30316. */
  30317. updateFromDevice(poseData: DevicePose): void;
  30318. /**
  30319. * @hidden
  30320. */
  30321. _meshAttachedObservable: Observable<AbstractMesh>;
  30322. /**
  30323. * Attaches a mesh to the controller
  30324. * @param mesh the mesh to be attached
  30325. */
  30326. attachToMesh(mesh: AbstractMesh): void;
  30327. /**
  30328. * Attaches the controllers mesh to a camera
  30329. * @param camera the camera the mesh should be attached to
  30330. */
  30331. attachToPoseControlledCamera(camera: TargetCamera): void;
  30332. /**
  30333. * Disposes of the controller
  30334. */
  30335. dispose(): void;
  30336. /**
  30337. * The mesh that is attached to the controller
  30338. */
  30339. readonly mesh: Nullable<AbstractMesh>;
  30340. /**
  30341. * Gets the ray of the controller in the direction the controller is pointing
  30342. * @param length the length the resulting ray should be
  30343. * @returns a ray in the direction the controller is pointing
  30344. */
  30345. getForwardRay(length?: number): Ray;
  30346. }
  30347. }
  30348. declare module BABYLON {
  30349. /**
  30350. * Vive Controller
  30351. */
  30352. class ViveController extends WebVRController {
  30353. /**
  30354. * Base Url for the controller model.
  30355. */
  30356. static MODEL_BASE_URL: string;
  30357. /**
  30358. * File name for the controller model.
  30359. */
  30360. static MODEL_FILENAME: string;
  30361. /**
  30362. * Creates a new ViveController from a gamepad
  30363. * @param vrGamepad the gamepad that the controller should be created from
  30364. */
  30365. constructor(vrGamepad: any);
  30366. /**
  30367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30368. * @param scene scene in which to add meshes
  30369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30370. */
  30371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30372. /**
  30373. * Fired when the left button on this controller is modified
  30374. */
  30375. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30376. /**
  30377. * Fired when the right button on this controller is modified
  30378. */
  30379. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30380. /**
  30381. * Fired when the menu button on this controller is modified
  30382. */
  30383. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30384. /**
  30385. * Called once for each button that changed state since the last frame
  30386. * Vive mapping:
  30387. * 0: touchpad
  30388. * 1: trigger
  30389. * 2: left AND right buttons
  30390. * 3: menu button
  30391. * @param buttonIdx Which button index changed
  30392. * @param state New state of the button
  30393. * @param changes Which properties on the state changed since last frame
  30394. */
  30395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30396. }
  30397. }
  30398. declare module BABYLON {
  30399. /**
  30400. * Defines the WebVRController object that represents controllers tracked in 3D space
  30401. */
  30402. abstract class WebVRController extends PoseEnabledController {
  30403. /**
  30404. * Internal, the default controller model for the controller
  30405. */
  30406. protected _defaultModel: AbstractMesh;
  30407. /**
  30408. * Fired when the trigger state has changed
  30409. */
  30410. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30411. /**
  30412. * Fired when the main button state has changed
  30413. */
  30414. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30415. /**
  30416. * Fired when the secondary button state has changed
  30417. */
  30418. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30419. /**
  30420. * Fired when the pad state has changed
  30421. */
  30422. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30423. /**
  30424. * Fired when controllers stick values have changed
  30425. */
  30426. onPadValuesChangedObservable: Observable<StickValues>;
  30427. /**
  30428. * Array of button availible on the controller
  30429. */
  30430. protected _buttons: Array<MutableGamepadButton>;
  30431. private _onButtonStateChange;
  30432. /**
  30433. * Fired when a controller button's state has changed
  30434. * @param callback the callback containing the button that was modified
  30435. */
  30436. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30437. /**
  30438. * X and Y axis corrisponding to the controllers joystick
  30439. */
  30440. pad: StickValues;
  30441. /**
  30442. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30443. */
  30444. hand: string;
  30445. /**
  30446. * The default controller model for the controller
  30447. */
  30448. readonly defaultModel: AbstractMesh;
  30449. /**
  30450. * Creates a new WebVRController from a gamepad
  30451. * @param vrGamepad the gamepad that the WebVRController should be created from
  30452. */
  30453. constructor(vrGamepad: any);
  30454. /**
  30455. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30456. */
  30457. update(): void;
  30458. /**
  30459. * Function to be called when a button is modified
  30460. */
  30461. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30462. /**
  30463. * Loads a mesh and attaches it to the controller
  30464. * @param scene the scene the mesh should be added to
  30465. * @param meshLoaded callback for when the mesh has been loaded
  30466. */
  30467. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30468. private _setButtonValue(newState, currentState, buttonIndex);
  30469. private _changes;
  30470. private _checkChanges(newState, currentState);
  30471. /**
  30472. * Disposes of th webVRCOntroller
  30473. */
  30474. dispose(): void;
  30475. }
  30476. }
  30477. declare module BABYLON {
  30478. /**
  30479. * Defines the WindowsMotionController object that the state of the windows motion controller
  30480. */
  30481. class WindowsMotionController extends WebVRController {
  30482. /**
  30483. * The base url used to load the left and right controller models
  30484. */
  30485. static MODEL_BASE_URL: string;
  30486. /**
  30487. * The name of the left controller model file
  30488. */
  30489. static MODEL_LEFT_FILENAME: string;
  30490. /**
  30491. * The name of the right controller model file
  30492. */
  30493. static MODEL_RIGHT_FILENAME: string;
  30494. /**
  30495. * The controller name prefix for this controller type
  30496. */
  30497. static readonly GAMEPAD_ID_PREFIX: string;
  30498. /**
  30499. * The controller id pattern for this controller type
  30500. */
  30501. private static readonly GAMEPAD_ID_PATTERN;
  30502. private _loadedMeshInfo;
  30503. private readonly _mapping;
  30504. /**
  30505. * Fired when the trackpad on this controller is clicked
  30506. */
  30507. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30508. /**
  30509. * Fired when the trackpad on this controller is modified
  30510. */
  30511. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30512. /**
  30513. * The current x and y values of this controller's trackpad
  30514. */
  30515. trackpad: StickValues;
  30516. /**
  30517. * Creates a new WindowsMotionController from a gamepad
  30518. * @param vrGamepad the gamepad that the controller should be created from
  30519. */
  30520. constructor(vrGamepad: any);
  30521. /**
  30522. * Fired when the trigger on this controller is modified
  30523. */
  30524. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30525. /**
  30526. * Fired when the menu button on this controller is modified
  30527. */
  30528. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30529. /**
  30530. * Fired when the grip button on this controller is modified
  30531. */
  30532. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30533. /**
  30534. * Fired when the thumbstick button on this controller is modified
  30535. */
  30536. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30537. /**
  30538. * Fired when the touchpad button on this controller is modified
  30539. */
  30540. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30541. /**
  30542. * Fired when the touchpad values on this controller are modified
  30543. */
  30544. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30545. /**
  30546. * Called once per frame by the engine.
  30547. */
  30548. update(): void;
  30549. /**
  30550. * Called once for each button that changed state since the last frame
  30551. * @param buttonIdx Which button index changed
  30552. * @param state New state of the button
  30553. * @param changes Which properties on the state changed since last frame
  30554. */
  30555. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30556. /**
  30557. * Moves the buttons on the controller mesh based on their current state
  30558. * @param buttonName the name of the button to move
  30559. * @param buttonValue the value of the button which determines the buttons new position
  30560. */
  30561. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30562. /**
  30563. * Moves the axis on the controller mesh based on its current state
  30564. * @param axis the index of the axis
  30565. * @param axisValue the value of the axis which determines the meshes new position
  30566. * @hidden
  30567. */
  30568. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30569. /**
  30570. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30571. * @param scene scene in which to add meshes
  30572. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30573. */
  30574. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30575. /**
  30576. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30577. * can be transformed by button presses and axes values, based on this._mapping.
  30578. *
  30579. * @param scene scene in which the meshes exist
  30580. * @param meshes list of meshes that make up the controller model to process
  30581. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30582. */
  30583. private processModel(scene, meshes);
  30584. private createMeshInfo(rootNode);
  30585. /**
  30586. * Gets the ray of the controller in the direction the controller is pointing
  30587. * @param length the length the resulting ray should be
  30588. * @returns a ray in the direction the controller is pointing
  30589. */
  30590. getForwardRay(length?: number): Ray;
  30591. /**
  30592. * Disposes of the controller
  30593. */
  30594. dispose(): void;
  30595. }
  30596. }
  30597. declare module BABYLON {
  30598. /**
  30599. * Interface to implement to create a shadow generator compatible with BJS.
  30600. */
  30601. interface IShadowGenerator {
  30602. /**
  30603. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30604. * @returns The render target texture if present otherwise, null
  30605. */
  30606. getShadowMap(): Nullable<RenderTargetTexture>;
  30607. /**
  30608. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30609. * @returns The render target texture if the shadow map is present otherwise, null
  30610. */
  30611. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30612. /**
  30613. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30614. * @param subMesh The submesh we want to render in the shadow map
  30615. * @param useInstances Defines wether will draw in the map using instances
  30616. * @returns true if ready otherwise, false
  30617. */
  30618. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30619. /**
  30620. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30621. * @param defines Defines of the material we want to update
  30622. * @param lightIndex Index of the light in the enabled light list of the material
  30623. */
  30624. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30625. /**
  30626. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30627. * defined in the generator but impacting the effect).
  30628. * It implies the unifroms available on the materials are the standard BJS ones.
  30629. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30630. * @param effect The effect we are binfing the information for
  30631. */
  30632. bindShadowLight(lightIndex: string, effect: Effect): void;
  30633. /**
  30634. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30635. * (eq to shadow prjection matrix * light transform matrix)
  30636. * @returns The transform matrix used to create the shadow map
  30637. */
  30638. getTransformMatrix(): Matrix;
  30639. /**
  30640. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30641. * Cube and 2D textures for instance.
  30642. */
  30643. recreateShadowMap(): void;
  30644. /**
  30645. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30646. * @param onCompiled Callback triggered at the and of the effects compilation
  30647. * @param options Sets of optional options forcing the compilation with different modes
  30648. */
  30649. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  30650. useInstances: boolean;
  30651. }>): void;
  30652. /**
  30653. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30654. * @param options Sets of optional options forcing the compilation with different modes
  30655. * @returns A promise that resolves when the compilation completes
  30656. */
  30657. forceCompilationAsync(options?: Partial<{
  30658. useInstances: boolean;
  30659. }>): Promise<void>;
  30660. /**
  30661. * Serializes the shadow generator setup to a json object.
  30662. * @returns The serialized JSON object
  30663. */
  30664. serialize(): any;
  30665. /**
  30666. * Disposes the Shadow map and related Textures and effects.
  30667. */
  30668. dispose(): void;
  30669. }
  30670. /**
  30671. * Default implementation IShadowGenerator.
  30672. * This is the main object responsible of generating shadows in the framework.
  30673. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30674. */
  30675. class ShadowGenerator implements IShadowGenerator {
  30676. /**
  30677. * Shadow generator mode None: no filtering applied.
  30678. */
  30679. static readonly FILTER_NONE: number;
  30680. /**
  30681. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30682. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30683. */
  30684. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30685. /**
  30686. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30687. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30688. */
  30689. static readonly FILTER_POISSONSAMPLING: number;
  30690. /**
  30691. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30692. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30693. */
  30694. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30695. /**
  30696. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30697. * edge artifacts on steep falloff.
  30698. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30699. */
  30700. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30701. /**
  30702. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30703. * edge artifacts on steep falloff.
  30704. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30705. */
  30706. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30707. /**
  30708. * Shadow generator mode PCF: Percentage Closer Filtering
  30709. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30710. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30711. */
  30712. static readonly FILTER_PCF: number;
  30713. /**
  30714. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30715. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30716. * Contact Hardening
  30717. */
  30718. static readonly FILTER_PCSS: number;
  30719. /**
  30720. * Reserved for PCF and PCSS
  30721. * Highest Quality.
  30722. *
  30723. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30724. *
  30725. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30726. */
  30727. static readonly QUALITY_HIGH: number;
  30728. /**
  30729. * Reserved for PCF and PCSS
  30730. * Good tradeoff for quality/perf cross devices
  30731. *
  30732. * Execute PCF on a 3*3 kernel.
  30733. *
  30734. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30735. */
  30736. static readonly QUALITY_MEDIUM: number;
  30737. /**
  30738. * Reserved for PCF and PCSS
  30739. * The lowest quality but the fastest.
  30740. *
  30741. * Execute PCF on a 1*1 kernel.
  30742. *
  30743. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30744. */
  30745. static readonly QUALITY_LOW: number;
  30746. private _bias;
  30747. /**
  30748. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30749. */
  30750. /**
  30751. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30752. */
  30753. bias: number;
  30754. private _normalBias;
  30755. /**
  30756. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30757. */
  30758. /**
  30759. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30760. */
  30761. normalBias: number;
  30762. private _blurBoxOffset;
  30763. /**
  30764. * Gets the blur box offset: offset applied during the blur pass.
  30765. * Only usefull if useKernelBlur = false
  30766. */
  30767. /**
  30768. * Sets the blur box offset: offset applied during the blur pass.
  30769. * Only usefull if useKernelBlur = false
  30770. */
  30771. blurBoxOffset: number;
  30772. private _blurScale;
  30773. /**
  30774. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30775. * 2 means half of the size.
  30776. */
  30777. /**
  30778. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30779. * 2 means half of the size.
  30780. */
  30781. blurScale: number;
  30782. private _blurKernel;
  30783. /**
  30784. * Gets the blur kernel: kernel size of the blur pass.
  30785. * Only usefull if useKernelBlur = true
  30786. */
  30787. /**
  30788. * Sets the blur kernel: kernel size of the blur pass.
  30789. * Only usefull if useKernelBlur = true
  30790. */
  30791. blurKernel: number;
  30792. private _useKernelBlur;
  30793. /**
  30794. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30795. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30796. */
  30797. /**
  30798. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30799. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30800. */
  30801. useKernelBlur: boolean;
  30802. private _depthScale;
  30803. /**
  30804. * Gets the depth scale used in ESM mode.
  30805. */
  30806. /**
  30807. * Sets the depth scale used in ESM mode.
  30808. * This can override the scale stored on the light.
  30809. */
  30810. depthScale: number;
  30811. private _filter;
  30812. /**
  30813. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30815. */
  30816. /**
  30817. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30818. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30819. */
  30820. filter: number;
  30821. /**
  30822. * Gets if the current filter is set to Poisson Sampling.
  30823. */
  30824. /**
  30825. * Sets the current filter to Poisson Sampling.
  30826. */
  30827. usePoissonSampling: boolean;
  30828. /**
  30829. * Gets if the current filter is set to VSM.
  30830. * DEPRECATED. Should use useExponentialShadowMap instead.
  30831. */
  30832. /**
  30833. * Sets the current filter is to VSM.
  30834. * DEPRECATED. Should use useExponentialShadowMap instead.
  30835. */
  30836. useVarianceShadowMap: boolean;
  30837. /**
  30838. * Gets if the current filter is set to blurred VSM.
  30839. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30840. */
  30841. /**
  30842. * Sets the current filter is to blurred VSM.
  30843. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30844. */
  30845. useBlurVarianceShadowMap: boolean;
  30846. /**
  30847. * Gets if the current filter is set to ESM.
  30848. */
  30849. /**
  30850. * Sets the current filter is to ESM.
  30851. */
  30852. useExponentialShadowMap: boolean;
  30853. /**
  30854. * Gets if the current filter is set to filtered ESM.
  30855. */
  30856. /**
  30857. * Gets if the current filter is set to filtered ESM.
  30858. */
  30859. useBlurExponentialShadowMap: boolean;
  30860. /**
  30861. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30862. * exponential to prevent steep falloff artifacts).
  30863. */
  30864. /**
  30865. * Sets the current filter to "close ESM" (using the inverse of the
  30866. * exponential to prevent steep falloff artifacts).
  30867. */
  30868. useCloseExponentialShadowMap: boolean;
  30869. /**
  30870. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30871. * exponential to prevent steep falloff artifacts).
  30872. */
  30873. /**
  30874. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30875. * exponential to prevent steep falloff artifacts).
  30876. */
  30877. useBlurCloseExponentialShadowMap: boolean;
  30878. /**
  30879. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30880. */
  30881. /**
  30882. * Sets the current filter to "PCF" (percentage closer filtering).
  30883. */
  30884. usePercentageCloserFiltering: boolean;
  30885. private _filteringQuality;
  30886. /**
  30887. * Gets the PCF or PCSS Quality.
  30888. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30889. */
  30890. /**
  30891. * Sets the PCF or PCSS Quality.
  30892. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30893. */
  30894. filteringQuality: number;
  30895. /**
  30896. * Gets if the current filter is set to "PCSS" (contact hardening).
  30897. */
  30898. /**
  30899. * Sets the current filter to "PCSS" (contact hardening).
  30900. */
  30901. useContactHardeningShadow: boolean;
  30902. private _contactHardeningLightSizeUVRatio;
  30903. /**
  30904. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30905. * Using a ratio helps keeping shape stability independently of the map size.
  30906. *
  30907. * It does not account for the light projection as it was having too much
  30908. * instability during the light setup or during light position changes.
  30909. *
  30910. * Only valid if useContactHardeningShadow is true.
  30911. */
  30912. /**
  30913. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30914. * Using a ratio helps keeping shape stability independently of the map size.
  30915. *
  30916. * It does not account for the light projection as it was having too much
  30917. * instability during the light setup or during light position changes.
  30918. *
  30919. * Only valid if useContactHardeningShadow is true.
  30920. */
  30921. contactHardeningLightSizeUVRatio: number;
  30922. private _darkness;
  30923. /**
  30924. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30925. * 0 means strongest and 1 would means no shadow.
  30926. * @returns the darkness.
  30927. */
  30928. getDarkness(): number;
  30929. /**
  30930. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30931. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30932. * @returns the shadow generator allowing fluent coding.
  30933. */
  30934. setDarkness(darkness: number): ShadowGenerator;
  30935. private _transparencyShadow;
  30936. /**
  30937. * Sets the ability to have transparent shadow (boolean).
  30938. * @param transparent True if transparent else False
  30939. * @returns the shadow generator allowing fluent coding
  30940. */
  30941. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30942. private _shadowMap;
  30943. private _shadowMap2;
  30944. /**
  30945. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30946. * @returns The render target texture if present otherwise, null
  30947. */
  30948. getShadowMap(): Nullable<RenderTargetTexture>;
  30949. /**
  30950. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30951. * @returns The render target texture if the shadow map is present otherwise, null
  30952. */
  30953. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30954. /**
  30955. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30956. * @param mesh Mesh to add
  30957. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30958. * @returns the Shadow Generator itself
  30959. */
  30960. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30961. /**
  30962. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30963. * @param mesh Mesh to remove
  30964. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30965. * @returns the Shadow Generator itself
  30966. */
  30967. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30968. /**
  30969. * Controls the extent to which the shadows fade out at the edge of the frustum
  30970. * Used only by directionals and spots
  30971. */
  30972. frustumEdgeFalloff: number;
  30973. private _light;
  30974. /**
  30975. * Returns the associated light object.
  30976. * @returns the light generating the shadow
  30977. */
  30978. getLight(): IShadowLight;
  30979. /**
  30980. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30981. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30982. * It might on the other hand introduce peter panning.
  30983. */
  30984. forceBackFacesOnly: boolean;
  30985. private _scene;
  30986. private _lightDirection;
  30987. private _effect;
  30988. private _viewMatrix;
  30989. private _projectionMatrix;
  30990. private _transformMatrix;
  30991. private _cachedPosition;
  30992. private _cachedDirection;
  30993. private _cachedDefines;
  30994. private _currentRenderID;
  30995. private _boxBlurPostprocess;
  30996. private _kernelBlurXPostprocess;
  30997. private _kernelBlurYPostprocess;
  30998. private _blurPostProcesses;
  30999. private _mapSize;
  31000. private _currentFaceIndex;
  31001. private _currentFaceIndexCache;
  31002. private _textureType;
  31003. private _defaultTextureMatrix;
  31004. /**
  31005. * Creates a ShadowGenerator object.
  31006. * A ShadowGenerator is the required tool to use the shadows.
  31007. * Each light casting shadows needs to use its own ShadowGenerator.
  31008. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31009. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31010. * @param light The light object generating the shadows.
  31011. * @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.
  31012. */
  31013. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31014. private _initializeGenerator();
  31015. private _initializeShadowMap();
  31016. private _initializeBlurRTTAndPostProcesses();
  31017. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31018. private _renderSubMeshForShadowMap(subMesh);
  31019. private _applyFilterValues();
  31020. /**
  31021. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31022. * @param onCompiled Callback triggered at the and of the effects compilation
  31023. * @param options Sets of optional options forcing the compilation with different modes
  31024. */
  31025. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31026. useInstances: boolean;
  31027. }>): void;
  31028. /**
  31029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31030. * @param options Sets of optional options forcing the compilation with different modes
  31031. * @returns A promise that resolves when the compilation completes
  31032. */
  31033. forceCompilationAsync(options?: Partial<{
  31034. useInstances: boolean;
  31035. }>): Promise<void>;
  31036. /**
  31037. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31038. * @param subMesh The submesh we want to render in the shadow map
  31039. * @param useInstances Defines wether will draw in the map using instances
  31040. * @returns true if ready otherwise, false
  31041. */
  31042. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31043. /**
  31044. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31045. * @param defines Defines of the material we want to update
  31046. * @param lightIndex Index of the light in the enabled light list of the material
  31047. */
  31048. prepareDefines(defines: any, lightIndex: number): void;
  31049. /**
  31050. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31051. * defined in the generator but impacting the effect).
  31052. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31053. * @param effect The effect we are binfing the information for
  31054. */
  31055. bindShadowLight(lightIndex: string, effect: Effect): void;
  31056. /**
  31057. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31058. * (eq to shadow prjection matrix * light transform matrix)
  31059. * @returns The transform matrix used to create the shadow map
  31060. */
  31061. getTransformMatrix(): Matrix;
  31062. /**
  31063. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31064. * Cube and 2D textures for instance.
  31065. */
  31066. recreateShadowMap(): void;
  31067. private _disposeBlurPostProcesses();
  31068. private _disposeRTTandPostProcesses();
  31069. /**
  31070. * Disposes the ShadowGenerator.
  31071. * Returns nothing.
  31072. */
  31073. dispose(): void;
  31074. /**
  31075. * Serializes the shadow generator setup to a json object.
  31076. * @returns The serialized JSON object
  31077. */
  31078. serialize(): any;
  31079. /**
  31080. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31081. * @param parsedShadowGenerator The JSON object to parse
  31082. * @param scene The scene to create the shadow map for
  31083. * @returns The parsed shadow generator
  31084. */
  31085. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31086. }
  31087. }
  31088. declare module BABYLON {
  31089. }
  31090. declare module BABYLON {
  31091. /**
  31092. * Background material used to create an efficient environement around your scene.
  31093. */
  31094. class BackgroundMaterial extends PushMaterial {
  31095. /**
  31096. * Standard reflectance value at parallel view angle.
  31097. */
  31098. static StandardReflectance0: number;
  31099. /**
  31100. * Standard reflectance value at grazing angle.
  31101. */
  31102. static StandardReflectance90: number;
  31103. protected _primaryColor: Color3;
  31104. /**
  31105. * Key light Color (multiply against the environement texture)
  31106. */
  31107. primaryColor: Color3;
  31108. protected __perceptualColor: Nullable<Color3>;
  31109. /**
  31110. * Experimental Internal Use Only.
  31111. *
  31112. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31113. * This acts as a helper to set the primary color to a more "human friendly" value.
  31114. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31115. * output color as close as possible from the chosen value.
  31116. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31117. * part of lighting setup.)
  31118. */
  31119. _perceptualColor: Nullable<Color3>;
  31120. protected _primaryColorShadowLevel: float;
  31121. /**
  31122. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31123. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31124. */
  31125. primaryColorShadowLevel: float;
  31126. protected _primaryColorHighlightLevel: float;
  31127. /**
  31128. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31129. * The primary color is used at the level chosen to define what the white area would look.
  31130. */
  31131. primaryColorHighlightLevel: float;
  31132. protected _reflectionTexture: Nullable<BaseTexture>;
  31133. /**
  31134. * Reflection Texture used in the material.
  31135. * Should be author in a specific way for the best result (refer to the documentation).
  31136. */
  31137. reflectionTexture: Nullable<BaseTexture>;
  31138. protected _reflectionBlur: float;
  31139. /**
  31140. * Reflection Texture level of blur.
  31141. *
  31142. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31143. * texture twice.
  31144. */
  31145. reflectionBlur: float;
  31146. protected _diffuseTexture: Nullable<BaseTexture>;
  31147. /**
  31148. * Diffuse Texture used in the material.
  31149. * Should be author in a specific way for the best result (refer to the documentation).
  31150. */
  31151. diffuseTexture: Nullable<BaseTexture>;
  31152. protected _shadowLights: Nullable<IShadowLight[]>;
  31153. /**
  31154. * Specify the list of lights casting shadow on the material.
  31155. * All scene shadow lights will be included if null.
  31156. */
  31157. shadowLights: Nullable<IShadowLight[]>;
  31158. protected _shadowLevel: float;
  31159. /**
  31160. * Helps adjusting the shadow to a softer level if required.
  31161. * 0 means black shadows and 1 means no shadows.
  31162. */
  31163. shadowLevel: float;
  31164. protected _sceneCenter: Vector3;
  31165. /**
  31166. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31167. * It is usually zero but might be interesting to modify according to your setup.
  31168. */
  31169. sceneCenter: Vector3;
  31170. protected _opacityFresnel: boolean;
  31171. /**
  31172. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31173. * This helps ensuring a nice transition when the camera goes under the ground.
  31174. */
  31175. opacityFresnel: boolean;
  31176. protected _reflectionFresnel: boolean;
  31177. /**
  31178. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31179. * This helps adding a mirror texture on the ground.
  31180. */
  31181. reflectionFresnel: boolean;
  31182. protected _reflectionFalloffDistance: number;
  31183. /**
  31184. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31185. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31186. */
  31187. reflectionFalloffDistance: number;
  31188. protected _reflectionAmount: number;
  31189. /**
  31190. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31191. */
  31192. reflectionAmount: number;
  31193. protected _reflectionReflectance0: number;
  31194. /**
  31195. * This specifies the weight of the reflection at grazing angle.
  31196. */
  31197. reflectionReflectance0: number;
  31198. protected _reflectionReflectance90: number;
  31199. /**
  31200. * This specifies the weight of the reflection at a perpendicular point of view.
  31201. */
  31202. reflectionReflectance90: number;
  31203. /**
  31204. * Sets the reflection reflectance fresnel values according to the default standard
  31205. * empirically know to work well :-)
  31206. */
  31207. reflectionStandardFresnelWeight: number;
  31208. protected _useRGBColor: boolean;
  31209. /**
  31210. * Helps to directly use the maps channels instead of their level.
  31211. */
  31212. useRGBColor: boolean;
  31213. protected _enableNoise: boolean;
  31214. /**
  31215. * This helps reducing the banding effect that could occur on the background.
  31216. */
  31217. enableNoise: boolean;
  31218. /**
  31219. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31220. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31221. * Recommended to be keep at 1.0 except for special cases.
  31222. */
  31223. fovMultiplier: number;
  31224. private _fovMultiplier;
  31225. /**
  31226. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31227. */
  31228. useEquirectangularFOV: boolean;
  31229. private _maxSimultaneousLights;
  31230. /**
  31231. * Number of Simultaneous lights allowed on the material.
  31232. */
  31233. maxSimultaneousLights: int;
  31234. /**
  31235. * Default configuration related to image processing available in the Background Material.
  31236. */
  31237. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31238. /**
  31239. * Keep track of the image processing observer to allow dispose and replace.
  31240. */
  31241. private _imageProcessingObserver;
  31242. /**
  31243. * Attaches a new image processing configuration to the PBR Material.
  31244. * @param configuration (if null the scene configuration will be use)
  31245. */
  31246. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31247. /**
  31248. * Gets the image processing configuration used either in this material.
  31249. */
  31250. /**
  31251. * Sets the Default image processing configuration used either in the this material.
  31252. *
  31253. * If sets to null, the scene one is in use.
  31254. */
  31255. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31256. /**
  31257. * Gets wether the color curves effect is enabled.
  31258. */
  31259. /**
  31260. * Sets wether the color curves effect is enabled.
  31261. */
  31262. cameraColorCurvesEnabled: boolean;
  31263. /**
  31264. * Gets wether the color grading effect is enabled.
  31265. */
  31266. /**
  31267. * Gets wether the color grading effect is enabled.
  31268. */
  31269. cameraColorGradingEnabled: boolean;
  31270. /**
  31271. * Gets wether tonemapping is enabled or not.
  31272. */
  31273. /**
  31274. * Sets wether tonemapping is enabled or not
  31275. */
  31276. cameraToneMappingEnabled: boolean;
  31277. /**
  31278. * The camera exposure used on this material.
  31279. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31280. * This corresponds to a photographic exposure.
  31281. */
  31282. /**
  31283. * The camera exposure used on this material.
  31284. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31285. * This corresponds to a photographic exposure.
  31286. */
  31287. cameraExposure: float;
  31288. /**
  31289. * Gets The camera contrast used on this material.
  31290. */
  31291. /**
  31292. * Sets The camera contrast used on this material.
  31293. */
  31294. cameraContrast: float;
  31295. /**
  31296. * Gets the Color Grading 2D Lookup Texture.
  31297. */
  31298. /**
  31299. * Sets the Color Grading 2D Lookup Texture.
  31300. */
  31301. cameraColorGradingTexture: Nullable<BaseTexture>;
  31302. /**
  31303. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31304. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31305. * 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;
  31306. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31307. */
  31308. /**
  31309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31311. * 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;
  31312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31313. */
  31314. cameraColorCurves: Nullable<ColorCurves>;
  31315. /**
  31316. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31317. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31318. */
  31319. switchToBGR: boolean;
  31320. private _renderTargets;
  31321. private _reflectionControls;
  31322. private _white;
  31323. private _primaryShadowColor;
  31324. private _primaryHighlightColor;
  31325. /**
  31326. * Instantiates a Background Material in the given scene
  31327. * @param name The friendly name of the material
  31328. * @param scene The scene to add the material to
  31329. */
  31330. constructor(name: string, scene: Scene);
  31331. /**
  31332. * The entire material has been created in order to prevent overdraw.
  31333. * @returns false
  31334. */
  31335. needAlphaTesting(): boolean;
  31336. /**
  31337. * The entire material has been created in order to prevent overdraw.
  31338. * @returns true if blending is enable
  31339. */
  31340. needAlphaBlending(): boolean;
  31341. /**
  31342. * Checks wether the material is ready to be rendered for a given mesh.
  31343. * @param mesh The mesh to render
  31344. * @param subMesh The submesh to check against
  31345. * @param useInstances Specify wether or not the material is used with instances
  31346. * @returns true if all the dependencies are ready (Textures, Effects...)
  31347. */
  31348. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31349. /**
  31350. * Compute the primary color according to the chosen perceptual color.
  31351. */
  31352. private _computePrimaryColorFromPerceptualColor();
  31353. /**
  31354. * Compute the highlights and shadow colors according to their chosen levels.
  31355. */
  31356. private _computePrimaryColors();
  31357. /**
  31358. * Build the uniform buffer used in the material.
  31359. */
  31360. buildUniformLayout(): void;
  31361. /**
  31362. * Unbind the material.
  31363. */
  31364. unbind(): void;
  31365. /**
  31366. * Bind only the world matrix to the material.
  31367. * @param world The world matrix to bind.
  31368. */
  31369. bindOnlyWorldMatrix(world: Matrix): void;
  31370. /**
  31371. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31372. * @param world The world matrix to bind.
  31373. * @param subMesh The submesh to bind for.
  31374. */
  31375. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31376. /**
  31377. * Dispose the material.
  31378. * @param forceDisposeEffect Force disposal of the associated effect.
  31379. * @param forceDisposeTextures Force disposal of the associated textures.
  31380. */
  31381. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31382. /**
  31383. * Clones the material.
  31384. * @param name The cloned name.
  31385. * @returns The cloned material.
  31386. */
  31387. clone(name: string): BackgroundMaterial;
  31388. /**
  31389. * Serializes the current material to its JSON representation.
  31390. * @returns The JSON representation.
  31391. */
  31392. serialize(): any;
  31393. /**
  31394. * Gets the class name of the material
  31395. * @returns "BackgroundMaterial"
  31396. */
  31397. getClassName(): string;
  31398. /**
  31399. * Parse a JSON input to create back a background material.
  31400. * @param source The JSON data to parse
  31401. * @param scene The scene to create the parsed material in
  31402. * @param rootUrl The root url of the assets the material depends upon
  31403. * @returns the instantiated BackgroundMaterial.
  31404. */
  31405. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31406. }
  31407. }
  31408. declare module BABYLON {
  31409. /**
  31410. * The Physically based material base class of BJS.
  31411. *
  31412. * This offers the main features of a standard PBR material.
  31413. * For more information, please refer to the documentation :
  31414. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31415. */
  31416. abstract class PBRBaseMaterial extends PushMaterial {
  31417. /**
  31418. * Intensity of the direct lights e.g. the four lights available in your scene.
  31419. * This impacts both the direct diffuse and specular highlights.
  31420. */
  31421. protected _directIntensity: number;
  31422. /**
  31423. * Intensity of the emissive part of the material.
  31424. * This helps controlling the emissive effect without modifying the emissive color.
  31425. */
  31426. protected _emissiveIntensity: number;
  31427. /**
  31428. * Intensity of the environment e.g. how much the environment will light the object
  31429. * either through harmonics for rough material or through the refelction for shiny ones.
  31430. */
  31431. protected _environmentIntensity: number;
  31432. /**
  31433. * This is a special control allowing the reduction of the specular highlights coming from the
  31434. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31435. */
  31436. protected _specularIntensity: number;
  31437. /**
  31438. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31439. */
  31440. private _lightingInfos;
  31441. /**
  31442. * Debug Control allowing disabling the bump map on this material.
  31443. */
  31444. protected _disableBumpMap: boolean;
  31445. /**
  31446. * AKA Diffuse Texture in standard nomenclature.
  31447. */
  31448. protected _albedoTexture: BaseTexture;
  31449. /**
  31450. * AKA Occlusion Texture in other nomenclature.
  31451. */
  31452. protected _ambientTexture: BaseTexture;
  31453. /**
  31454. * AKA Occlusion Texture Intensity in other nomenclature.
  31455. */
  31456. protected _ambientTextureStrength: number;
  31457. /**
  31458. * Stores the alpha values in a texture.
  31459. */
  31460. protected _opacityTexture: BaseTexture;
  31461. /**
  31462. * Stores the reflection values in a texture.
  31463. */
  31464. protected _reflectionTexture: BaseTexture;
  31465. /**
  31466. * Stores the refraction values in a texture.
  31467. */
  31468. protected _refractionTexture: BaseTexture;
  31469. /**
  31470. * Stores the emissive values in a texture.
  31471. */
  31472. protected _emissiveTexture: BaseTexture;
  31473. /**
  31474. * AKA Specular texture in other nomenclature.
  31475. */
  31476. protected _reflectivityTexture: BaseTexture;
  31477. /**
  31478. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31479. */
  31480. protected _metallicTexture: BaseTexture;
  31481. /**
  31482. * Specifies the metallic scalar of the metallic/roughness workflow.
  31483. * Can also be used to scale the metalness values of the metallic texture.
  31484. */
  31485. protected _metallic: number;
  31486. /**
  31487. * Specifies the roughness scalar of the metallic/roughness workflow.
  31488. * Can also be used to scale the roughness values of the metallic texture.
  31489. */
  31490. protected _roughness: number;
  31491. /**
  31492. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  31493. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  31494. */
  31495. protected _microSurfaceTexture: BaseTexture;
  31496. /**
  31497. * Stores surface normal data used to displace a mesh in a texture.
  31498. */
  31499. protected _bumpTexture: BaseTexture;
  31500. /**
  31501. * Stores the pre-calculated light information of a mesh in a texture.
  31502. */
  31503. protected _lightmapTexture: BaseTexture;
  31504. /**
  31505. * The color of a material in ambient lighting.
  31506. */
  31507. protected _ambientColor: Color3;
  31508. /**
  31509. * AKA Diffuse Color in other nomenclature.
  31510. */
  31511. protected _albedoColor: Color3;
  31512. /**
  31513. * AKA Specular Color in other nomenclature.
  31514. */
  31515. protected _reflectivityColor: Color3;
  31516. /**
  31517. * The color applied when light is reflected from a material.
  31518. */
  31519. protected _reflectionColor: Color3;
  31520. /**
  31521. * The color applied when light is emitted from a material.
  31522. */
  31523. protected _emissiveColor: Color3;
  31524. /**
  31525. * AKA Glossiness in other nomenclature.
  31526. */
  31527. protected _microSurface: number;
  31528. /**
  31529. * source material index of refraction (IOR)' / 'destination material IOR.
  31530. */
  31531. protected _indexOfRefraction: number;
  31532. /**
  31533. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  31534. */
  31535. protected _invertRefractionY: boolean;
  31536. /**
  31537. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  31538. * Materials half opaque for instance using refraction could benefit from this control.
  31539. */
  31540. protected _linkRefractionWithTransparency: boolean;
  31541. /**
  31542. * Specifies that the material will use the light map as a show map.
  31543. */
  31544. protected _useLightmapAsShadowmap: boolean;
  31545. /**
  31546. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  31547. * makes the reflect vector face the model (under horizon).
  31548. */
  31549. protected _useHorizonOcclusion: boolean;
  31550. /**
  31551. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  31552. * too much the area relying on ambient texture to define their ambient occlusion.
  31553. */
  31554. protected _useRadianceOcclusion: boolean;
  31555. /**
  31556. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  31557. */
  31558. protected _useAlphaFromAlbedoTexture: boolean;
  31559. /**
  31560. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  31561. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31562. */
  31563. protected _useSpecularOverAlpha: boolean;
  31564. /**
  31565. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  31566. */
  31567. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  31568. /**
  31569. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  31570. */
  31571. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  31572. /**
  31573. * Specifies if the metallic texture contains the roughness information in its green channel.
  31574. */
  31575. protected _useRoughnessFromMetallicTextureGreen: boolean;
  31576. /**
  31577. * Specifies if the metallic texture contains the metallness information in its blue channel.
  31578. */
  31579. protected _useMetallnessFromMetallicTextureBlue: boolean;
  31580. /**
  31581. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  31582. */
  31583. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  31584. /**
  31585. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  31586. */
  31587. protected _useAmbientInGrayScale: boolean;
  31588. /**
  31589. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  31590. * The material will try to infer what glossiness each pixel should be.
  31591. */
  31592. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  31593. /**
  31594. * BJS is using an harcoded light falloff based on a manually sets up range.
  31595. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  31596. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  31597. */
  31598. protected _usePhysicalLightFalloff: boolean;
  31599. /**
  31600. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31601. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31602. */
  31603. protected _useRadianceOverAlpha: boolean;
  31604. /**
  31605. * Allows using an object space normal map (instead of tangent space).
  31606. */
  31607. protected _useObjectSpaceNormalMap: boolean;
  31608. /**
  31609. * Allows using the bump map in parallax mode.
  31610. */
  31611. protected _useParallax: boolean;
  31612. /**
  31613. * Allows using the bump map in parallax occlusion mode.
  31614. */
  31615. protected _useParallaxOcclusion: boolean;
  31616. /**
  31617. * Controls the scale bias of the parallax mode.
  31618. */
  31619. protected _parallaxScaleBias: number;
  31620. /**
  31621. * If sets to true, disables all the lights affecting the material.
  31622. */
  31623. protected _disableLighting: boolean;
  31624. /**
  31625. * Number of Simultaneous lights allowed on the material.
  31626. */
  31627. protected _maxSimultaneousLights: number;
  31628. /**
  31629. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  31630. */
  31631. protected _invertNormalMapX: boolean;
  31632. /**
  31633. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  31634. */
  31635. protected _invertNormalMapY: boolean;
  31636. /**
  31637. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31638. */
  31639. protected _twoSidedLighting: boolean;
  31640. /**
  31641. * Defines the alpha limits in alpha test mode.
  31642. */
  31643. protected _alphaCutOff: number;
  31644. /**
  31645. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31646. */
  31647. protected _forceAlphaTest: boolean;
  31648. /**
  31649. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31650. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  31651. */
  31652. protected _useAlphaFresnel: boolean;
  31653. /**
  31654. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31655. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  31656. */
  31657. protected _useLinearAlphaFresnel: boolean;
  31658. /**
  31659. * The transparency mode of the material.
  31660. */
  31661. protected _transparencyMode: Nullable<number>;
  31662. /**
  31663. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  31664. * from cos thetav and roughness:
  31665. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  31666. */
  31667. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  31668. /**
  31669. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  31670. */
  31671. protected _forceIrradianceInFragment: boolean;
  31672. /**
  31673. * Force normal to face away from face.
  31674. */
  31675. protected _forceNormalForward: boolean;
  31676. /**
  31677. * Enables specular anti aliasing in the PBR shader.
  31678. * It will both interacts on the Geometry for analytical and IBL lighting.
  31679. * It also prefilter the roughness map based on the bump values.
  31680. */
  31681. protected _enableSpecularAntiAliasing: boolean;
  31682. /**
  31683. * Default configuration related to image processing available in the PBR Material.
  31684. */
  31685. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31686. /**
  31687. * Keep track of the image processing observer to allow dispose and replace.
  31688. */
  31689. private _imageProcessingObserver;
  31690. /**
  31691. * Attaches a new image processing configuration to the PBR Material.
  31692. * @param configuration
  31693. */
  31694. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31695. /**
  31696. * Stores the available render targets.
  31697. */
  31698. private _renderTargets;
  31699. /**
  31700. * Sets the global ambient color for the material used in lighting calculations.
  31701. */
  31702. private _globalAmbientColor;
  31703. /**
  31704. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  31705. */
  31706. private _useLogarithmicDepth;
  31707. /**
  31708. * If set to true, no lighting calculations will be applied.
  31709. */
  31710. private _unlit;
  31711. /**
  31712. * Instantiates a new PBRMaterial instance.
  31713. *
  31714. * @param name The material name
  31715. * @param scene The scene the material will be use in.
  31716. */
  31717. constructor(name: string, scene: Scene);
  31718. /**
  31719. * Gets the name of the material class.
  31720. */
  31721. getClassName(): string;
  31722. /**
  31723. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31724. */
  31725. /**
  31726. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31727. */
  31728. useLogarithmicDepth: boolean;
  31729. /**
  31730. * Gets the current transparency mode.
  31731. */
  31732. /**
  31733. * Sets the transparency mode of the material.
  31734. */
  31735. transparencyMode: Nullable<number>;
  31736. /**
  31737. * Returns true if alpha blending should be disabled.
  31738. */
  31739. private readonly _disableAlphaBlending;
  31740. /**
  31741. * Specifies whether or not this material should be rendered in alpha blend mode.
  31742. */
  31743. needAlphaBlending(): boolean;
  31744. /**
  31745. * Specifies if the mesh will require alpha blending.
  31746. * @param mesh - BJS mesh.
  31747. */
  31748. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31749. /**
  31750. * Specifies whether or not this material should be rendered in alpha test mode.
  31751. */
  31752. needAlphaTesting(): boolean;
  31753. /**
  31754. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  31755. */
  31756. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  31757. /**
  31758. * Gets the texture used for the alpha test.
  31759. */
  31760. getAlphaTestTexture(): BaseTexture;
  31761. /**
  31762. * Stores the reflectivity values based on metallic roughness workflow.
  31763. */
  31764. private static _scaledReflectivity;
  31765. /**
  31766. * Specifies that the submesh is ready to be used.
  31767. * @param mesh - BJS mesh.
  31768. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  31769. * @param useInstances - Specifies that instances should be used.
  31770. * @returns - boolean indicating that the submesh is ready or not.
  31771. */
  31772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31773. /**
  31774. * Specifies if the material uses metallic roughness workflow.
  31775. * @returns boolean specifiying if the material uses metallic roughness workflow.
  31776. */
  31777. isMetallicWorkflow(): boolean;
  31778. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  31779. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  31780. /**
  31781. * Force shader compilation
  31782. */
  31783. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  31784. clipPlane: boolean;
  31785. }>): void;
  31786. /**
  31787. * Initializes the uniform buffer layout for the shader.
  31788. */
  31789. buildUniformLayout(): void;
  31790. /**
  31791. * Unbinds the textures.
  31792. */
  31793. unbind(): void;
  31794. /**
  31795. * Binds the submesh data.
  31796. * @param world - The world matrix.
  31797. * @param mesh - The BJS mesh.
  31798. * @param subMesh - A submesh of the BJS mesh.
  31799. */
  31800. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31801. /**
  31802. * Returns the animatable textures.
  31803. * @returns - Array of animatable textures.
  31804. */
  31805. getAnimatables(): IAnimatable[];
  31806. /**
  31807. * Returns the texture used for reflections.
  31808. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  31809. */
  31810. private _getReflectionTexture();
  31811. /**
  31812. * Returns the texture used for refraction or null if none is used.
  31813. * @returns - Refection texture if present. If no refraction texture and refraction
  31814. * is linked with transparency, returns environment texture. Otherwise, returns null.
  31815. */
  31816. private _getRefractionTexture();
  31817. /**
  31818. * Disposes the resources of the material.
  31819. * @param forceDisposeEffect - Forces the disposal of effects.
  31820. * @param forceDisposeTextures - Forces the disposal of all textures.
  31821. */
  31822. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31823. }
  31824. }
  31825. declare module BABYLON {
  31826. /**
  31827. * The Physically based simple base material of BJS.
  31828. *
  31829. * This enables better naming and convention enforcements on top of the pbrMaterial.
  31830. * It is used as the base class for both the specGloss and metalRough conventions.
  31831. */
  31832. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  31833. /**
  31834. * Number of Simultaneous lights allowed on the material.
  31835. */
  31836. maxSimultaneousLights: number;
  31837. /**
  31838. * If sets to true, disables all the lights affecting the material.
  31839. */
  31840. disableLighting: boolean;
  31841. /**
  31842. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  31843. */
  31844. environmentTexture: BaseTexture;
  31845. /**
  31846. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31847. */
  31848. invertNormalMapX: boolean;
  31849. /**
  31850. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31851. */
  31852. invertNormalMapY: boolean;
  31853. /**
  31854. * Normal map used in the model.
  31855. */
  31856. normalTexture: BaseTexture;
  31857. /**
  31858. * Emissivie color used to self-illuminate the model.
  31859. */
  31860. emissiveColor: Color3;
  31861. /**
  31862. * Emissivie texture used to self-illuminate the model.
  31863. */
  31864. emissiveTexture: BaseTexture;
  31865. /**
  31866. * Occlusion Channel Strenght.
  31867. */
  31868. occlusionStrength: number;
  31869. /**
  31870. * Occlusion Texture of the material (adding extra occlusion effects).
  31871. */
  31872. occlusionTexture: BaseTexture;
  31873. /**
  31874. * Defines the alpha limits in alpha test mode.
  31875. */
  31876. alphaCutOff: number;
  31877. /**
  31878. * Gets the current double sided mode.
  31879. */
  31880. /**
  31881. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31882. */
  31883. doubleSided: boolean;
  31884. lightmapTexture: BaseTexture;
  31885. useLightmapAsShadowmap: boolean;
  31886. /**
  31887. * Return the active textures of the material.
  31888. */
  31889. getActiveTextures(): BaseTexture[];
  31890. hasTexture(texture: BaseTexture): boolean;
  31891. /**
  31892. * Instantiates a new PBRMaterial instance.
  31893. *
  31894. * @param name The material name
  31895. * @param scene The scene the material will be use in.
  31896. */
  31897. constructor(name: string, scene: Scene);
  31898. getClassName(): string;
  31899. }
  31900. }
  31901. declare module BABYLON {
  31902. /**
  31903. * The Physically based material of BJS.
  31904. *
  31905. * This offers the main features of a standard PBR material.
  31906. * For more information, please refer to the documentation :
  31907. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31908. */
  31909. class PBRMaterial extends PBRBaseMaterial {
  31910. private static _PBRMATERIAL_OPAQUE;
  31911. /**
  31912. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31913. */
  31914. static readonly PBRMATERIAL_OPAQUE: number;
  31915. /**
  31916. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31917. */
  31918. private static _PBRMATERIAL_ALPHATEST;
  31919. /**
  31920. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31921. */
  31922. static readonly PBRMATERIAL_ALPHATEST: number;
  31923. /**
  31924. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31925. */
  31926. private static _PBRMATERIAL_ALPHABLEND;
  31927. /**
  31928. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31929. */
  31930. static readonly PBRMATERIAL_ALPHABLEND: number;
  31931. /**
  31932. * 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.
  31933. * They are also discarded below the alpha cutoff threshold to improve performances.
  31934. */
  31935. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  31936. /**
  31937. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31938. * They are also discarded below the alpha cutoff threshold to improve performances.
  31939. */
  31940. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  31941. /**
  31942. * Intensity of the direct lights e.g. the four lights available in your scene.
  31943. * This impacts both the direct diffuse and specular highlights.
  31944. */
  31945. directIntensity: number;
  31946. /**
  31947. * Intensity of the emissive part of the material.
  31948. * This helps controlling the emissive effect without modifying the emissive color.
  31949. */
  31950. emissiveIntensity: number;
  31951. /**
  31952. * Intensity of the environment e.g. how much the environment will light the object
  31953. * either through harmonics for rough material or through the refelction for shiny ones.
  31954. */
  31955. environmentIntensity: number;
  31956. /**
  31957. * This is a special control allowing the reduction of the specular highlights coming from the
  31958. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31959. */
  31960. specularIntensity: number;
  31961. /**
  31962. * Debug Control allowing disabling the bump map on this material.
  31963. */
  31964. disableBumpMap: boolean;
  31965. /**
  31966. * AKA Diffuse Texture in standard nomenclature.
  31967. */
  31968. albedoTexture: BaseTexture;
  31969. /**
  31970. * AKA Occlusion Texture in other nomenclature.
  31971. */
  31972. ambientTexture: BaseTexture;
  31973. /**
  31974. * AKA Occlusion Texture Intensity in other nomenclature.
  31975. */
  31976. ambientTextureStrength: number;
  31977. /**
  31978. * Stores the alpha values in a texture.
  31979. */
  31980. opacityTexture: BaseTexture;
  31981. /**
  31982. * Stores the reflection values in a texture.
  31983. */
  31984. reflectionTexture: Nullable<BaseTexture>;
  31985. /**
  31986. * Stores the emissive values in a texture.
  31987. */
  31988. emissiveTexture: BaseTexture;
  31989. /**
  31990. * AKA Specular texture in other nomenclature.
  31991. */
  31992. reflectivityTexture: BaseTexture;
  31993. /**
  31994. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31995. */
  31996. metallicTexture: BaseTexture;
  31997. /**
  31998. * Specifies the metallic scalar of the metallic/roughness workflow.
  31999. * Can also be used to scale the metalness values of the metallic texture.
  32000. */
  32001. metallic: number;
  32002. /**
  32003. * Specifies the roughness scalar of the metallic/roughness workflow.
  32004. * Can also be used to scale the roughness values of the metallic texture.
  32005. */
  32006. roughness: number;
  32007. /**
  32008. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32009. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32010. */
  32011. microSurfaceTexture: BaseTexture;
  32012. /**
  32013. * Stores surface normal data used to displace a mesh in a texture.
  32014. */
  32015. bumpTexture: BaseTexture;
  32016. /**
  32017. * Stores the pre-calculated light information of a mesh in a texture.
  32018. */
  32019. lightmapTexture: BaseTexture;
  32020. /**
  32021. * Stores the refracted light information in a texture.
  32022. */
  32023. refractionTexture: BaseTexture;
  32024. /**
  32025. * The color of a material in ambient lighting.
  32026. */
  32027. ambientColor: Color3;
  32028. /**
  32029. * AKA Diffuse Color in other nomenclature.
  32030. */
  32031. albedoColor: Color3;
  32032. /**
  32033. * AKA Specular Color in other nomenclature.
  32034. */
  32035. reflectivityColor: Color3;
  32036. /**
  32037. * The color reflected from the material.
  32038. */
  32039. reflectionColor: Color3;
  32040. /**
  32041. * The color emitted from the material.
  32042. */
  32043. emissiveColor: Color3;
  32044. /**
  32045. * AKA Glossiness in other nomenclature.
  32046. */
  32047. microSurface: number;
  32048. /**
  32049. * source material index of refraction (IOR)' / 'destination material IOR.
  32050. */
  32051. indexOfRefraction: number;
  32052. /**
  32053. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32054. */
  32055. invertRefractionY: boolean;
  32056. /**
  32057. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32058. * Materials half opaque for instance using refraction could benefit from this control.
  32059. */
  32060. linkRefractionWithTransparency: boolean;
  32061. useLightmapAsShadowmap: boolean;
  32062. /**
  32063. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32064. */
  32065. useAlphaFromAlbedoTexture: boolean;
  32066. /**
  32067. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32068. */
  32069. forceAlphaTest: boolean;
  32070. /**
  32071. * Defines the alpha limits in alpha test mode.
  32072. */
  32073. alphaCutOff: number;
  32074. /**
  32075. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32076. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32077. */
  32078. useSpecularOverAlpha: boolean;
  32079. /**
  32080. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32081. */
  32082. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32083. /**
  32084. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32085. */
  32086. useRoughnessFromMetallicTextureAlpha: boolean;
  32087. /**
  32088. * Specifies if the metallic texture contains the roughness information in its green channel.
  32089. */
  32090. useRoughnessFromMetallicTextureGreen: boolean;
  32091. /**
  32092. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32093. */
  32094. useMetallnessFromMetallicTextureBlue: boolean;
  32095. /**
  32096. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32097. */
  32098. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32099. /**
  32100. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32101. */
  32102. useAmbientInGrayScale: boolean;
  32103. /**
  32104. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32105. * The material will try to infer what glossiness each pixel should be.
  32106. */
  32107. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32108. /**
  32109. * BJS is using an harcoded light falloff based on a manually sets up range.
  32110. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32111. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32112. */
  32113. usePhysicalLightFalloff: boolean;
  32114. /**
  32115. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32116. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32117. */
  32118. useRadianceOverAlpha: boolean;
  32119. /**
  32120. * Allows using an object space normal map (instead of tangent space).
  32121. */
  32122. useObjectSpaceNormalMap: boolean;
  32123. /**
  32124. * Allows using the bump map in parallax mode.
  32125. */
  32126. useParallax: boolean;
  32127. /**
  32128. * Allows using the bump map in parallax occlusion mode.
  32129. */
  32130. useParallaxOcclusion: boolean;
  32131. /**
  32132. * Controls the scale bias of the parallax mode.
  32133. */
  32134. parallaxScaleBias: number;
  32135. /**
  32136. * If sets to true, disables all the lights affecting the material.
  32137. */
  32138. disableLighting: boolean;
  32139. /**
  32140. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32141. */
  32142. forceIrradianceInFragment: boolean;
  32143. /**
  32144. * Number of Simultaneous lights allowed on the material.
  32145. */
  32146. maxSimultaneousLights: number;
  32147. /**
  32148. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32149. */
  32150. invertNormalMapX: boolean;
  32151. /**
  32152. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32153. */
  32154. invertNormalMapY: boolean;
  32155. /**
  32156. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32157. */
  32158. twoSidedLighting: boolean;
  32159. /**
  32160. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32161. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32162. */
  32163. useAlphaFresnel: boolean;
  32164. /**
  32165. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32166. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32167. */
  32168. useLinearAlphaFresnel: boolean;
  32169. /**
  32170. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32171. * And/Or occlude the blended part.
  32172. */
  32173. environmentBRDFTexture: Nullable<BaseTexture>;
  32174. /**
  32175. * Force normal to face away from face.
  32176. */
  32177. forceNormalForward: boolean;
  32178. /**
  32179. * Enables specular anti aliasing in the PBR shader.
  32180. * It will both interacts on the Geometry for analytical and IBL lighting.
  32181. * It also prefilter the roughness map based on the bump values.
  32182. */
  32183. enableSpecularAntiAliasing: boolean;
  32184. /**
  32185. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32186. * makes the reflect vector face the model (under horizon).
  32187. */
  32188. useHorizonOcclusion: boolean;
  32189. /**
  32190. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32191. * too much the area relying on ambient texture to define their ambient occlusion.
  32192. */
  32193. useRadianceOcclusion: boolean;
  32194. /**
  32195. * If set to true, no lighting calculations will be applied.
  32196. */
  32197. unlit: boolean;
  32198. /**
  32199. * Gets the image processing configuration used either in this material.
  32200. */
  32201. /**
  32202. * Sets the Default image processing configuration used either in the this material.
  32203. *
  32204. * If sets to null, the scene one is in use.
  32205. */
  32206. imageProcessingConfiguration: ImageProcessingConfiguration;
  32207. /**
  32208. * Gets wether the color curves effect is enabled.
  32209. */
  32210. /**
  32211. * Sets wether the color curves effect is enabled.
  32212. */
  32213. cameraColorCurvesEnabled: boolean;
  32214. /**
  32215. * Gets wether the color grading effect is enabled.
  32216. */
  32217. /**
  32218. * Gets wether the color grading effect is enabled.
  32219. */
  32220. cameraColorGradingEnabled: boolean;
  32221. /**
  32222. * Gets wether tonemapping is enabled or not.
  32223. */
  32224. /**
  32225. * Sets wether tonemapping is enabled or not
  32226. */
  32227. cameraToneMappingEnabled: boolean;
  32228. /**
  32229. * The camera exposure used on this material.
  32230. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32231. * This corresponds to a photographic exposure.
  32232. */
  32233. /**
  32234. * The camera exposure used on this material.
  32235. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32236. * This corresponds to a photographic exposure.
  32237. */
  32238. cameraExposure: number;
  32239. /**
  32240. * Gets The camera contrast used on this material.
  32241. */
  32242. /**
  32243. * Sets The camera contrast used on this material.
  32244. */
  32245. cameraContrast: number;
  32246. /**
  32247. * Gets the Color Grading 2D Lookup Texture.
  32248. */
  32249. /**
  32250. * Sets the Color Grading 2D Lookup Texture.
  32251. */
  32252. cameraColorGradingTexture: Nullable<BaseTexture>;
  32253. /**
  32254. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32255. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32256. * 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;
  32257. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32258. */
  32259. /**
  32260. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32261. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32262. * 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;
  32263. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32264. */
  32265. cameraColorCurves: Nullable<ColorCurves>;
  32266. /**
  32267. * Instantiates a new PBRMaterial instance.
  32268. *
  32269. * @param name The material name
  32270. * @param scene The scene the material will be use in.
  32271. */
  32272. constructor(name: string, scene: Scene);
  32273. /**
  32274. * Returns the name of this material class.
  32275. */
  32276. getClassName(): string;
  32277. /**
  32278. * Returns an array of the actively used textures.
  32279. * @returns - Array of BaseTextures
  32280. */
  32281. getActiveTextures(): BaseTexture[];
  32282. /**
  32283. * Checks to see if a texture is used in the material.
  32284. * @param texture - Base texture to use.
  32285. * @returns - Boolean specifying if a texture is used in the material.
  32286. */
  32287. hasTexture(texture: BaseTexture): boolean;
  32288. /**
  32289. * Makes a duplicate of the current material.
  32290. * @param name - name to use for the new material.
  32291. */
  32292. clone(name: string): PBRMaterial;
  32293. /**
  32294. * Serializes this PBR Material.
  32295. * @returns - An object with the serialized material.
  32296. */
  32297. serialize(): any;
  32298. /**
  32299. * Parses a PBR Material from a serialized object.
  32300. * @param source - Serialized object.
  32301. * @param scene - BJS scene instance.
  32302. * @param rootUrl - url for the scene object
  32303. * @returns - PBRMaterial
  32304. */
  32305. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32306. }
  32307. }
  32308. declare module BABYLON {
  32309. /**
  32310. * The PBR material of BJS following the metal roughness convention.
  32311. *
  32312. * This fits to the PBR convention in the GLTF definition:
  32313. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32314. */
  32315. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32316. /**
  32317. * The base color has two different interpretations depending on the value of metalness.
  32318. * When the material is a metal, the base color is the specific measured reflectance value
  32319. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32320. * of the material.
  32321. */
  32322. baseColor: Color3;
  32323. /**
  32324. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32325. * well as opacity information in the alpha channel.
  32326. */
  32327. baseTexture: BaseTexture;
  32328. /**
  32329. * Specifies the metallic scalar value of the material.
  32330. * Can also be used to scale the metalness values of the metallic texture.
  32331. */
  32332. metallic: number;
  32333. /**
  32334. * Specifies the roughness scalar value of the material.
  32335. * Can also be used to scale the roughness values of the metallic texture.
  32336. */
  32337. roughness: number;
  32338. /**
  32339. * Texture containing both the metallic value in the B channel and the
  32340. * roughness value in the G channel to keep better precision.
  32341. */
  32342. metallicRoughnessTexture: BaseTexture;
  32343. /**
  32344. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32345. *
  32346. * @param name The material name
  32347. * @param scene The scene the material will be use in.
  32348. */
  32349. constructor(name: string, scene: Scene);
  32350. /**
  32351. * Return the currrent class name of the material.
  32352. */
  32353. getClassName(): string;
  32354. /**
  32355. * Return the active textures of the material.
  32356. */
  32357. getActiveTextures(): BaseTexture[];
  32358. /**
  32359. * Checks to see if a texture is used in the material.
  32360. * @param texture - Base texture to use.
  32361. * @returns - Boolean specifying if a texture is used in the material.
  32362. */
  32363. hasTexture(texture: BaseTexture): boolean;
  32364. /**
  32365. * Makes a duplicate of the current material.
  32366. * @param name - name to use for the new material.
  32367. */
  32368. clone(name: string): PBRMetallicRoughnessMaterial;
  32369. /**
  32370. * Serialize the material to a parsable JSON object.
  32371. */
  32372. serialize(): any;
  32373. /**
  32374. * Parses a JSON object correponding to the serialize function.
  32375. */
  32376. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32377. }
  32378. }
  32379. declare module BABYLON {
  32380. /**
  32381. * The PBR material of BJS following the specular glossiness convention.
  32382. *
  32383. * This fits to the PBR convention in the GLTF definition:
  32384. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32385. */
  32386. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32387. /**
  32388. * Specifies the diffuse color of the material.
  32389. */
  32390. diffuseColor: Color3;
  32391. /**
  32392. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32393. * channel.
  32394. */
  32395. diffuseTexture: BaseTexture;
  32396. /**
  32397. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32398. */
  32399. specularColor: Color3;
  32400. /**
  32401. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32402. */
  32403. glossiness: number;
  32404. /**
  32405. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32406. */
  32407. specularGlossinessTexture: BaseTexture;
  32408. /**
  32409. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32410. *
  32411. * @param name The material name
  32412. * @param scene The scene the material will be use in.
  32413. */
  32414. constructor(name: string, scene: Scene);
  32415. /**
  32416. * Return the currrent class name of the material.
  32417. */
  32418. getClassName(): string;
  32419. /**
  32420. * Return the active textures of the material.
  32421. */
  32422. getActiveTextures(): BaseTexture[];
  32423. /**
  32424. * Checks to see if a texture is used in the material.
  32425. * @param texture - Base texture to use.
  32426. * @returns - Boolean specifying if a texture is used in the material.
  32427. */
  32428. hasTexture(texture: BaseTexture): boolean;
  32429. /**
  32430. * Makes a duplicate of the current material.
  32431. * @param name - name to use for the new material.
  32432. */
  32433. clone(name: string): PBRSpecularGlossinessMaterial;
  32434. /**
  32435. * Serialize the material to a parsable JSON object.
  32436. */
  32437. serialize(): any;
  32438. /**
  32439. * Parses a JSON object correponding to the serialize function.
  32440. */
  32441. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32442. }
  32443. }
  32444. declare module BABYLON {
  32445. class BaseTexture {
  32446. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32447. name: string;
  32448. private _hasAlpha;
  32449. hasAlpha: boolean;
  32450. getAlphaFromRGB: boolean;
  32451. level: number;
  32452. coordinatesIndex: number;
  32453. private _coordinatesMode;
  32454. /**
  32455. * How a texture is mapped.
  32456. *
  32457. * | Value | Type | Description |
  32458. * | ----- | ----------------------------------- | ----------- |
  32459. * | 0 | EXPLICIT_MODE | |
  32460. * | 1 | SPHERICAL_MODE | |
  32461. * | 2 | PLANAR_MODE | |
  32462. * | 3 | CUBIC_MODE | |
  32463. * | 4 | PROJECTION_MODE | |
  32464. * | 5 | SKYBOX_MODE | |
  32465. * | 6 | INVCUBIC_MODE | |
  32466. * | 7 | EQUIRECTANGULAR_MODE | |
  32467. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32468. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32469. */
  32470. coordinatesMode: number;
  32471. /**
  32472. * | Value | Type | Description |
  32473. * | ----- | ------------------ | ----------- |
  32474. * | 0 | CLAMP_ADDRESSMODE | |
  32475. * | 1 | WRAP_ADDRESSMODE | |
  32476. * | 2 | MIRROR_ADDRESSMODE | |
  32477. */
  32478. wrapU: number;
  32479. /**
  32480. * | Value | Type | Description |
  32481. * | ----- | ------------------ | ----------- |
  32482. * | 0 | CLAMP_ADDRESSMODE | |
  32483. * | 1 | WRAP_ADDRESSMODE | |
  32484. * | 2 | MIRROR_ADDRESSMODE | |
  32485. */
  32486. wrapV: number;
  32487. /**
  32488. * | Value | Type | Description |
  32489. * | ----- | ------------------ | ----------- |
  32490. * | 0 | CLAMP_ADDRESSMODE | |
  32491. * | 1 | WRAP_ADDRESSMODE | |
  32492. * | 2 | MIRROR_ADDRESSMODE | |
  32493. */
  32494. wrapR: number;
  32495. anisotropicFilteringLevel: number;
  32496. isCube: boolean;
  32497. is3D: boolean;
  32498. gammaSpace: boolean;
  32499. invertZ: boolean;
  32500. lodLevelInAlpha: boolean;
  32501. lodGenerationOffset: number;
  32502. lodGenerationScale: number;
  32503. isRenderTarget: boolean;
  32504. readonly uid: string;
  32505. toString(): string;
  32506. getClassName(): string;
  32507. animations: Animation[];
  32508. /**
  32509. * An event triggered when the texture is disposed.
  32510. */
  32511. onDisposeObservable: Observable<BaseTexture>;
  32512. private _onDisposeObserver;
  32513. onDispose: () => void;
  32514. delayLoadState: number;
  32515. private _scene;
  32516. _texture: Nullable<InternalTexture>;
  32517. private _uid;
  32518. readonly isBlocking: boolean;
  32519. constructor(scene: Nullable<Scene>);
  32520. getScene(): Nullable<Scene>;
  32521. getTextureMatrix(): Matrix;
  32522. getReflectionTextureMatrix(): Matrix;
  32523. getInternalTexture(): Nullable<InternalTexture>;
  32524. isReadyOrNotBlocking(): boolean;
  32525. isReady(): boolean;
  32526. getSize(): ISize;
  32527. getBaseSize(): ISize;
  32528. scale(ratio: number): void;
  32529. readonly canRescale: boolean;
  32530. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  32531. _rebuild(): void;
  32532. delayLoad(): void;
  32533. clone(): Nullable<BaseTexture>;
  32534. readonly textureType: number;
  32535. readonly textureFormat: number;
  32536. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  32537. releaseInternalTexture(): void;
  32538. sphericalPolynomial: Nullable<SphericalPolynomial>;
  32539. readonly _lodTextureHigh: Nullable<BaseTexture>;
  32540. readonly _lodTextureMid: Nullable<BaseTexture>;
  32541. readonly _lodTextureLow: Nullable<BaseTexture>;
  32542. dispose(): void;
  32543. serialize(): any;
  32544. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32545. }
  32546. }
  32547. declare module BABYLON {
  32548. /**
  32549. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  32550. * It can help converting any input color in a desired output one. This can then be used to create effects
  32551. * from sepia, black and white to sixties or futuristic rendering...
  32552. *
  32553. * The only supported format is currently 3dl.
  32554. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  32555. */
  32556. class ColorGradingTexture extends BaseTexture {
  32557. /**
  32558. * The current texture matrix. (will always be identity in color grading texture)
  32559. */
  32560. private _textureMatrix;
  32561. /**
  32562. * The texture URL.
  32563. */
  32564. url: string;
  32565. /**
  32566. * Empty line regex stored for GC.
  32567. */
  32568. private static _noneEmptyLineRegex;
  32569. private _engine;
  32570. /**
  32571. * Instantiates a ColorGradingTexture from the following parameters.
  32572. *
  32573. * @param url The location of the color gradind data (currently only supporting 3dl)
  32574. * @param scene The scene the texture will be used in
  32575. */
  32576. constructor(url: string, scene: Scene);
  32577. /**
  32578. * Returns the texture matrix used in most of the material.
  32579. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  32580. */
  32581. getTextureMatrix(): Matrix;
  32582. /**
  32583. * Occurs when the file being loaded is a .3dl LUT file.
  32584. */
  32585. private load3dlTexture();
  32586. /**
  32587. * Starts the loading process of the texture.
  32588. */
  32589. private loadTexture();
  32590. /**
  32591. * Clones the color gradind texture.
  32592. */
  32593. clone(): ColorGradingTexture;
  32594. /**
  32595. * Called during delayed load for textures.
  32596. */
  32597. delayLoad(): void;
  32598. /**
  32599. * Parses a color grading texture serialized by Babylon.
  32600. * @param parsedTexture The texture information being parsedTexture
  32601. * @param scene The scene to load the texture in
  32602. * @param rootUrl The root url of the data assets to load
  32603. * @return A color gradind texture
  32604. */
  32605. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  32606. /**
  32607. * Serializes the LUT texture to json format.
  32608. */
  32609. serialize(): any;
  32610. }
  32611. }
  32612. declare module BABYLON {
  32613. class CubeTexture extends BaseTexture {
  32614. url: string;
  32615. coordinatesMode: number;
  32616. /**
  32617. * Gets or sets the center of the bounding box associated with the cube texture
  32618. * It must define where the camera used to render the texture was set
  32619. */
  32620. boundingBoxPosition: Vector3;
  32621. private _boundingBoxSize;
  32622. /**
  32623. * Gets or sets the size of the bounding box associated with the cube texture
  32624. * When defined, the cubemap will switch to local mode
  32625. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32626. * @example https://www.babylonjs-playground.com/#RNASML
  32627. */
  32628. boundingBoxSize: Vector3;
  32629. protected _rotationY: number;
  32630. /**
  32631. * Gets texture matrix rotation angle around Y axis radians.
  32632. */
  32633. /**
  32634. * Sets texture matrix rotation angle around Y axis in radians.
  32635. */
  32636. rotationY: number;
  32637. private _noMipmap;
  32638. private _files;
  32639. private _extensions;
  32640. private _textureMatrix;
  32641. private _format;
  32642. private _prefiltered;
  32643. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  32644. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  32645. 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);
  32646. delayLoad(): void;
  32647. getReflectionTextureMatrix(): Matrix;
  32648. setReflectionTextureMatrix(value: Matrix): void;
  32649. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  32650. clone(): CubeTexture;
  32651. }
  32652. }
  32653. declare module BABYLON {
  32654. /**
  32655. * A class extending {BABYLON.Texture} allowing drawing on a texture
  32656. * @see http://doc.babylonjs.com/how_to/dynamictexture
  32657. */
  32658. class DynamicTexture extends Texture {
  32659. private _generateMipMaps;
  32660. private _canvas;
  32661. private _context;
  32662. private _engine;
  32663. /**
  32664. * Creates a {BABYLON.DynamicTexture}
  32665. * @param name defines the name of the texture
  32666. * @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
  32667. * @param scene defines the scene where you want the texture
  32668. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  32669. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  32670. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  32671. */
  32672. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  32673. /**
  32674. * Gets the current state of canRescale
  32675. */
  32676. readonly canRescale: boolean;
  32677. private _recreate(textureSize);
  32678. /**
  32679. * Scales the texture
  32680. * @param ratio the scale factor to apply to both width and height
  32681. */
  32682. scale(ratio: number): void;
  32683. /**
  32684. * Resizes the texture
  32685. * @param width the new width
  32686. * @param height the new height
  32687. */
  32688. scaleTo(width: number, height: number): void;
  32689. /**
  32690. * Gets the context of the canvas used by the texture
  32691. * @returns the canvas context of the dynamic texture
  32692. */
  32693. getContext(): CanvasRenderingContext2D;
  32694. /**
  32695. * Clears the texture
  32696. */
  32697. clear(): void;
  32698. /**
  32699. * Updates the texture
  32700. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32701. */
  32702. update(invertY?: boolean): void;
  32703. /**
  32704. * Draws text onto the texture
  32705. * @param text defines the text to be drawn
  32706. * @param x defines the placement of the text from the left
  32707. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  32708. * @param font defines the font to be used with font-style, font-size, font-name
  32709. * @param color defines the color used for the text
  32710. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  32711. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32712. * @param update defines whether texture is immediately update (default is true)
  32713. */
  32714. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  32715. /**
  32716. * Clones the texture
  32717. * @returns the clone of the texture.
  32718. */
  32719. clone(): DynamicTexture;
  32720. /** @hidden */
  32721. _rebuild(): void;
  32722. }
  32723. }
  32724. declare module BABYLON {
  32725. /**
  32726. * This represents a texture coming from an HDR input.
  32727. *
  32728. * The only supported format is currently panorama picture stored in RGBE format.
  32729. * Example of such files can be found on HDRLib: http://hdrlib.com/
  32730. */
  32731. class HDRCubeTexture extends BaseTexture {
  32732. private static _facesMapping;
  32733. private _generateHarmonics;
  32734. private _noMipmap;
  32735. private _textureMatrix;
  32736. private _size;
  32737. private _onLoad;
  32738. private _onError;
  32739. /**
  32740. * The texture URL.
  32741. */
  32742. url: string;
  32743. /**
  32744. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  32745. */
  32746. coordinatesMode: number;
  32747. protected _isBlocking: boolean;
  32748. /**
  32749. * Gets wether or not the texture is blocking during loading.
  32750. */
  32751. /**
  32752. * Sets wether or not the texture is blocking during loading.
  32753. */
  32754. isBlocking: boolean;
  32755. protected _rotationY: number;
  32756. /**
  32757. * Gets texture matrix rotation angle around Y axis radians.
  32758. */
  32759. /**
  32760. * Sets texture matrix rotation angle around Y axis in radians.
  32761. */
  32762. rotationY: number;
  32763. /**
  32764. * Gets or sets the center of the bounding box associated with the cube texture
  32765. * It must define where the camera used to render the texture was set
  32766. */
  32767. boundingBoxPosition: Vector3;
  32768. private _boundingBoxSize;
  32769. /**
  32770. * Gets or sets the size of the bounding box associated with the cube texture
  32771. * When defined, the cubemap will switch to local mode
  32772. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32773. * @example https://www.babylonjs-playground.com/#RNASML
  32774. */
  32775. boundingBoxSize: Vector3;
  32776. /**
  32777. * Instantiates an HDRTexture from the following parameters.
  32778. *
  32779. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  32780. * @param scene The scene the texture will be used in
  32781. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  32782. * @param noMipmap Forces to not generate the mipmap if true
  32783. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  32784. * @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)
  32785. * @param reserved Reserved flag for internal use.
  32786. */
  32787. 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>);
  32788. /**
  32789. * Occurs when the file is raw .hdr file.
  32790. */
  32791. private loadTexture();
  32792. clone(): HDRCubeTexture;
  32793. delayLoad(): void;
  32794. getReflectionTextureMatrix(): Matrix;
  32795. setReflectionTextureMatrix(value: Matrix): void;
  32796. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  32797. serialize(): any;
  32798. }
  32799. }
  32800. declare module BABYLON {
  32801. /**
  32802. * Class used to store data associated with WebGL texture data for the engine
  32803. * This class should not be used directly
  32804. */
  32805. class InternalTexture implements IInternalTextureTracker {
  32806. /**
  32807. * The source of the texture data is unknown
  32808. */
  32809. static DATASOURCE_UNKNOWN: number;
  32810. /**
  32811. * Texture data comes from an URL
  32812. */
  32813. static DATASOURCE_URL: number;
  32814. /**
  32815. * Texture data is only used for temporary storage
  32816. */
  32817. static DATASOURCE_TEMP: number;
  32818. /**
  32819. * Texture data comes from raw data (ArrayBuffer)
  32820. */
  32821. static DATASOURCE_RAW: number;
  32822. /**
  32823. * Texture content is dynamic (video or dynamic texture)
  32824. */
  32825. static DATASOURCE_DYNAMIC: number;
  32826. /**
  32827. * Texture content is generated by rendering to it
  32828. */
  32829. static DATASOURCE_RENDERTARGET: number;
  32830. /**
  32831. * Texture content is part of a multi render target process
  32832. */
  32833. static DATASOURCE_MULTIRENDERTARGET: number;
  32834. /**
  32835. * Texture data comes from a cube data file
  32836. */
  32837. static DATASOURCE_CUBE: number;
  32838. /**
  32839. * Texture data comes from a raw cube data
  32840. */
  32841. static DATASOURCE_CUBERAW: number;
  32842. /**
  32843. * Texture data come from a prefiltered cube data file
  32844. */
  32845. static DATASOURCE_CUBEPREFILTERED: number;
  32846. /**
  32847. * Texture content is raw 3D data
  32848. */
  32849. static DATASOURCE_RAW3D: number;
  32850. /**
  32851. * Texture content is a depth texture
  32852. */
  32853. static DATASOURCE_DEPTHTEXTURE: number;
  32854. /**
  32855. * Defines if the texture is ready
  32856. */
  32857. isReady: boolean;
  32858. /**
  32859. * Defines if the texture is a cube texture
  32860. */
  32861. isCube: boolean;
  32862. /**
  32863. * Defines if the texture contains 3D data
  32864. */
  32865. is3D: boolean;
  32866. /**
  32867. * Gets the URL used to load this texture
  32868. */
  32869. url: string;
  32870. /**
  32871. * Gets the sampling mode of the texture
  32872. */
  32873. samplingMode: number;
  32874. /**
  32875. * Gets a boolean indicating if the texture needs mipmaps generation
  32876. */
  32877. generateMipMaps: boolean;
  32878. /**
  32879. * Gets the number of samples used by the texture (WebGL2+ only)
  32880. */
  32881. samples: number;
  32882. /**
  32883. * Gets the type of the texture
  32884. */
  32885. type: number;
  32886. /**
  32887. * Gets the format of the texture
  32888. */
  32889. format: number;
  32890. /**
  32891. * Observable called when the texture is loaded
  32892. */
  32893. onLoadedObservable: Observable<InternalTexture>;
  32894. /**
  32895. * Gets the width of the texture
  32896. */
  32897. width: number;
  32898. /**
  32899. * Gets the height of the texture
  32900. */
  32901. height: number;
  32902. /**
  32903. * Gets the depth of the texture
  32904. */
  32905. depth: number;
  32906. /**
  32907. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32908. */
  32909. baseWidth: number;
  32910. /**
  32911. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32912. */
  32913. baseHeight: number;
  32914. /**
  32915. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32916. */
  32917. baseDepth: number;
  32918. /**
  32919. * Gets a boolean indicating if the texture is inverted on Y axis
  32920. */
  32921. invertY: boolean;
  32922. /**
  32923. * Gets or set the previous tracker in the list
  32924. */
  32925. previous: Nullable<IInternalTextureTracker>;
  32926. /**
  32927. * Gets or set the next tracker in the list
  32928. */
  32929. next: Nullable<IInternalTextureTracker>;
  32930. /** @hidden */
  32931. _initialSlot: number;
  32932. /** @hidden */
  32933. _designatedSlot: number;
  32934. /** @hidden */
  32935. _dataSource: number;
  32936. /** @hidden */
  32937. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  32938. /** @hidden */
  32939. _bufferView: Nullable<ArrayBufferView>;
  32940. /** @hidden */
  32941. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32942. /** @hidden */
  32943. _size: number;
  32944. /** @hidden */
  32945. _extension: string;
  32946. /** @hidden */
  32947. _files: Nullable<string[]>;
  32948. /** @hidden */
  32949. _workingCanvas: HTMLCanvasElement;
  32950. /** @hidden */
  32951. _workingContext: CanvasRenderingContext2D;
  32952. /** @hidden */
  32953. _framebuffer: Nullable<WebGLFramebuffer>;
  32954. /** @hidden */
  32955. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32956. /** @hidden */
  32957. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32958. /** @hidden */
  32959. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32960. /** @hidden */
  32961. _attachments: Nullable<number[]>;
  32962. /** @hidden */
  32963. _cachedCoordinatesMode: Nullable<number>;
  32964. /** @hidden */
  32965. _cachedWrapU: Nullable<number>;
  32966. /** @hidden */
  32967. _cachedWrapV: Nullable<number>;
  32968. /** @hidden */
  32969. _cachedWrapR: Nullable<number>;
  32970. /** @hidden */
  32971. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32972. /** @hidden */
  32973. _isDisabled: boolean;
  32974. /** @hidden */
  32975. _compression: Nullable<string>;
  32976. /** @hidden */
  32977. _generateStencilBuffer: boolean;
  32978. /** @hidden */
  32979. _generateDepthBuffer: boolean;
  32980. /** @hidden */
  32981. _comparisonFunction: number;
  32982. /** @hidden */
  32983. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32984. /** @hidden */
  32985. _lodGenerationScale: number;
  32986. /** @hidden */
  32987. _lodGenerationOffset: number;
  32988. /** @hidden */
  32989. _lodTextureHigh: BaseTexture;
  32990. /** @hidden */
  32991. _lodTextureMid: BaseTexture;
  32992. /** @hidden */
  32993. _lodTextureLow: BaseTexture;
  32994. /** @hidden */
  32995. _webGLTexture: Nullable<WebGLTexture>;
  32996. /** @hidden */
  32997. _references: number;
  32998. private _engine;
  32999. /**
  33000. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33001. */
  33002. readonly dataSource: number;
  33003. /**
  33004. * Creates a new InternalTexture
  33005. * @param engine defines the engine to use
  33006. * @param dataSource defines the type of data that will be used
  33007. */
  33008. constructor(engine: Engine, dataSource: number);
  33009. /**
  33010. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33011. */
  33012. incrementReferences(): void;
  33013. /**
  33014. * Change the size of the texture (not the size of the content)
  33015. * @param width defines the new width
  33016. * @param height defines the new height
  33017. * @param depth defines the new depth (1 by default)
  33018. */
  33019. updateSize(width: int, height: int, depth?: int): void;
  33020. /** @hidden */
  33021. _rebuild(): void;
  33022. private _swapAndDie(target);
  33023. /**
  33024. * Dispose the current allocated resources
  33025. */
  33026. dispose(): void;
  33027. }
  33028. }
  33029. declare module BABYLON {
  33030. /**
  33031. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33032. */
  33033. interface IInternalTextureTracker {
  33034. /**
  33035. * Gets or set the previous tracker in the list
  33036. */
  33037. previous: Nullable<IInternalTextureTracker>;
  33038. /**
  33039. * Gets or set the next tracker in the list
  33040. */
  33041. next: Nullable<IInternalTextureTracker>;
  33042. }
  33043. /**
  33044. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33045. */
  33046. class DummyInternalTextureTracker {
  33047. /**
  33048. * Gets or set the previous tracker in the list
  33049. */
  33050. previous: Nullable<IInternalTextureTracker>;
  33051. /**
  33052. * Gets or set the next tracker in the list
  33053. */
  33054. next: Nullable<IInternalTextureTracker>;
  33055. }
  33056. }
  33057. declare module BABYLON {
  33058. class MirrorTexture extends RenderTargetTexture {
  33059. private scene;
  33060. mirrorPlane: Plane;
  33061. private _transformMatrix;
  33062. private _mirrorMatrix;
  33063. private _savedViewMatrix;
  33064. private _blurX;
  33065. private _blurY;
  33066. private _adaptiveBlurKernel;
  33067. private _blurKernelX;
  33068. private _blurKernelY;
  33069. private _blurRatio;
  33070. blurRatio: number;
  33071. adaptiveBlurKernel: number;
  33072. blurKernel: number;
  33073. blurKernelX: number;
  33074. blurKernelY: number;
  33075. private _autoComputeBlurKernel();
  33076. protected _onRatioRescale(): void;
  33077. private _updateGammaSpace();
  33078. private _imageProcessingConfigChangeObserver;
  33079. constructor(name: string, size: number | {
  33080. width: number;
  33081. height: number;
  33082. } | {
  33083. ratio: number;
  33084. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33085. private _preparePostProcesses();
  33086. clone(): MirrorTexture;
  33087. serialize(): any;
  33088. dispose(): void;
  33089. }
  33090. }
  33091. declare module BABYLON {
  33092. interface IMultiRenderTargetOptions {
  33093. generateMipMaps?: boolean;
  33094. types?: number[];
  33095. samplingModes?: number[];
  33096. generateDepthBuffer?: boolean;
  33097. generateStencilBuffer?: boolean;
  33098. generateDepthTexture?: boolean;
  33099. textureCount?: number;
  33100. doNotChangeAspectRatio?: boolean;
  33101. defaultType?: number;
  33102. }
  33103. class MultiRenderTarget extends RenderTargetTexture {
  33104. private _internalTextures;
  33105. private _textures;
  33106. readonly isSupported: boolean;
  33107. private _multiRenderTargetOptions;
  33108. readonly textures: Texture[];
  33109. readonly depthTexture: Texture;
  33110. wrapU: number;
  33111. wrapV: number;
  33112. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33113. _rebuild(): void;
  33114. private _createInternalTextures();
  33115. private _createTextures();
  33116. samples: number;
  33117. resize(size: any): void;
  33118. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33119. dispose(): void;
  33120. releaseInternalTextures(): void;
  33121. }
  33122. }
  33123. declare module BABYLON {
  33124. class RawTexture extends Texture {
  33125. format: number;
  33126. private _engine;
  33127. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33128. update(data: ArrayBufferView): void;
  33129. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33130. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33131. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33132. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33133. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33134. }
  33135. }
  33136. declare module BABYLON {
  33137. /**
  33138. * Class used to store 3D textures containing user data
  33139. */
  33140. class RawTexture3D extends Texture {
  33141. /** Gets or sets the texture format to use*/
  33142. format: number;
  33143. private _engine;
  33144. /**
  33145. * Create a new RawTexture3D
  33146. * @param data defines the data of the texture
  33147. * @param width defines the width of the texture
  33148. * @param height defines the height of the texture
  33149. * @param depth defines the depth of the texture
  33150. * @param format defines the texture format to use
  33151. * @param scene defines the hosting scene
  33152. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33153. * @param invertY defines if texture must be stored with Y axis inverted
  33154. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33155. */
  33156. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33157. /** Gets or sets the texture format to use*/
  33158. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  33159. /**
  33160. * Update the texture with new data
  33161. * @param data defines the data to store in the texture
  33162. */
  33163. update(data: ArrayBufferView): void;
  33164. }
  33165. }
  33166. declare module BABYLON {
  33167. /**
  33168. * Creates a refraction texture used by refraction channel of the standard material.
  33169. * @param name the texture name
  33170. * @param size size of the underlying texture
  33171. * @param scene root scene
  33172. */
  33173. class RefractionTexture extends RenderTargetTexture {
  33174. refractionPlane: Plane;
  33175. depth: number;
  33176. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33177. clone(): RefractionTexture;
  33178. serialize(): any;
  33179. }
  33180. }
  33181. declare module BABYLON {
  33182. class RenderTargetTexture extends Texture {
  33183. isCube: boolean;
  33184. static _REFRESHRATE_RENDER_ONCE: number;
  33185. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33186. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33187. static readonly REFRESHRATE_RENDER_ONCE: number;
  33188. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33189. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33190. /**
  33191. * Use this predicate to dynamically define the list of mesh you want to render.
  33192. * If set, the renderList property will be overwritten.
  33193. */
  33194. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33195. /**
  33196. * Use this list to define the list of mesh you want to render.
  33197. */
  33198. renderList: Nullable<Array<AbstractMesh>>;
  33199. renderParticles: boolean;
  33200. renderSprites: boolean;
  33201. coordinatesMode: number;
  33202. activeCamera: Nullable<Camera>;
  33203. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33204. useCameraPostProcesses: boolean;
  33205. ignoreCameraViewport: boolean;
  33206. private _postProcessManager;
  33207. private _postProcesses;
  33208. private _resizeObserver;
  33209. /**
  33210. * An event triggered when the texture is unbind.
  33211. */
  33212. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33213. /**
  33214. * An event triggered when the texture is unbind.
  33215. */
  33216. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33217. private _onAfterUnbindObserver;
  33218. onAfterUnbind: () => void;
  33219. /**
  33220. * An event triggered before rendering the texture
  33221. */
  33222. onBeforeRenderObservable: Observable<number>;
  33223. private _onBeforeRenderObserver;
  33224. onBeforeRender: (faceIndex: number) => void;
  33225. /**
  33226. * An event triggered after rendering the texture
  33227. */
  33228. onAfterRenderObservable: Observable<number>;
  33229. private _onAfterRenderObserver;
  33230. onAfterRender: (faceIndex: number) => void;
  33231. /**
  33232. * An event triggered after the texture clear
  33233. */
  33234. onClearObservable: Observable<Engine>;
  33235. private _onClearObserver;
  33236. onClear: (Engine: Engine) => void;
  33237. clearColor: Color4;
  33238. protected _size: number | {
  33239. width: number;
  33240. height: number;
  33241. };
  33242. protected _initialSizeParameter: number | {
  33243. width: number;
  33244. height: number;
  33245. } | {
  33246. ratio: number;
  33247. };
  33248. protected _sizeRatio: Nullable<number>;
  33249. _generateMipMaps: boolean;
  33250. protected _renderingManager: RenderingManager;
  33251. _waitingRenderList: string[];
  33252. protected _doNotChangeAspectRatio: boolean;
  33253. protected _currentRefreshId: number;
  33254. protected _refreshRate: number;
  33255. protected _textureMatrix: Matrix;
  33256. protected _samples: number;
  33257. protected _renderTargetOptions: RenderTargetCreationOptions;
  33258. readonly renderTargetOptions: RenderTargetCreationOptions;
  33259. protected _engine: Engine;
  33260. protected _onRatioRescale(): void;
  33261. /**
  33262. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33263. * It must define where the camera used to render the texture is set
  33264. */
  33265. boundingBoxPosition: Vector3;
  33266. private _boundingBoxSize;
  33267. /**
  33268. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33269. * When defined, the cubemap will switch to local mode
  33270. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33271. * @example https://www.babylonjs-playground.com/#RNASML
  33272. */
  33273. boundingBoxSize: Vector3;
  33274. /**
  33275. * In case the RTT has been created with a depth texture, get the associated
  33276. * depth texture.
  33277. * Otherwise, return null.
  33278. */
  33279. depthStencilTexture: Nullable<InternalTexture>;
  33280. /**
  33281. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33282. * or used a shadow, depth texture...
  33283. * @param name The friendly name of the texture
  33284. * @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)
  33285. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33286. * @param generateMipMaps True if mip maps need to be generated after render.
  33287. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33288. * @param type The type of the buffer in the RTT (int, half float, float...)
  33289. * @param isCube True if a cube texture needs to be created
  33290. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33291. * @param generateDepthBuffer True to generate a depth buffer
  33292. * @param generateStencilBuffer True to generate a stencil buffer
  33293. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33294. */
  33295. constructor(name: string, size: number | {
  33296. width: number;
  33297. height: number;
  33298. } | {
  33299. ratio: number;
  33300. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33301. /**
  33302. * Creates a depth stencil texture.
  33303. * This is only available in WebGL 2 or with the depth texture extension available.
  33304. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33305. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33306. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33307. */
  33308. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33309. private _processSizeParameter(size);
  33310. samples: number;
  33311. resetRefreshCounter(): void;
  33312. refreshRate: number;
  33313. addPostProcess(postProcess: PostProcess): void;
  33314. clearPostProcesses(dispose?: boolean): void;
  33315. removePostProcess(postProcess: PostProcess): void;
  33316. _shouldRender(): boolean;
  33317. getRenderSize(): number;
  33318. getRenderWidth(): number;
  33319. getRenderHeight(): number;
  33320. readonly canRescale: boolean;
  33321. scale(ratio: number): void;
  33322. getReflectionTextureMatrix(): Matrix;
  33323. resize(size: number | {
  33324. width: number;
  33325. height: number;
  33326. } | {
  33327. ratio: number;
  33328. }): void;
  33329. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33330. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33331. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33332. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33333. /**
  33334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33335. * This allowed control for front to back rendering or reversly depending of the special needs.
  33336. *
  33337. * @param renderingGroupId The rendering group id corresponding to its index
  33338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33341. */
  33342. 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;
  33343. /**
  33344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33345. *
  33346. * @param renderingGroupId The rendering group id corresponding to its index
  33347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33348. */
  33349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33350. clone(): RenderTargetTexture;
  33351. serialize(): any;
  33352. disposeFramebufferObjects(): void;
  33353. dispose(): void;
  33354. _rebuild(): void;
  33355. /**
  33356. * Clear the info related to rendering groups preventing retention point in material dispose.
  33357. */
  33358. freeRenderingGroups(): void;
  33359. }
  33360. }
  33361. declare module BABYLON {
  33362. class Texture extends BaseTexture {
  33363. static NEAREST_SAMPLINGMODE: number;
  33364. static NEAREST_NEAREST_MIPLINEAR: number;
  33365. static BILINEAR_SAMPLINGMODE: number;
  33366. static LINEAR_LINEAR_MIPNEAREST: number;
  33367. static TRILINEAR_SAMPLINGMODE: number;
  33368. static LINEAR_LINEAR_MIPLINEAR: number;
  33369. static NEAREST_NEAREST_MIPNEAREST: number;
  33370. static NEAREST_LINEAR_MIPNEAREST: number;
  33371. static NEAREST_LINEAR_MIPLINEAR: number;
  33372. static NEAREST_LINEAR: number;
  33373. static NEAREST_NEAREST: number;
  33374. static LINEAR_NEAREST_MIPNEAREST: number;
  33375. static LINEAR_NEAREST_MIPLINEAR: number;
  33376. static LINEAR_LINEAR: number;
  33377. static LINEAR_NEAREST: number;
  33378. static EXPLICIT_MODE: number;
  33379. static SPHERICAL_MODE: number;
  33380. static PLANAR_MODE: number;
  33381. static CUBIC_MODE: number;
  33382. static PROJECTION_MODE: number;
  33383. static SKYBOX_MODE: number;
  33384. static INVCUBIC_MODE: number;
  33385. static EQUIRECTANGULAR_MODE: number;
  33386. static FIXED_EQUIRECTANGULAR_MODE: number;
  33387. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33388. static CLAMP_ADDRESSMODE: number;
  33389. static WRAP_ADDRESSMODE: number;
  33390. static MIRROR_ADDRESSMODE: number;
  33391. /**
  33392. * 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
  33393. */
  33394. static UseSerializedUrlIfAny: boolean;
  33395. url: Nullable<string>;
  33396. uOffset: number;
  33397. vOffset: number;
  33398. uScale: number;
  33399. vScale: number;
  33400. uAng: number;
  33401. vAng: number;
  33402. wAng: number;
  33403. readonly noMipmap: boolean;
  33404. private _noMipmap;
  33405. _invertY: boolean;
  33406. private _rowGenerationMatrix;
  33407. private _cachedTextureMatrix;
  33408. private _projectionModeMatrix;
  33409. private _t0;
  33410. private _t1;
  33411. private _t2;
  33412. private _cachedUOffset;
  33413. private _cachedVOffset;
  33414. private _cachedUScale;
  33415. private _cachedVScale;
  33416. private _cachedUAng;
  33417. private _cachedVAng;
  33418. private _cachedWAng;
  33419. private _cachedProjectionMatrixId;
  33420. private _cachedCoordinatesMode;
  33421. _samplingMode: number;
  33422. private _buffer;
  33423. private _deleteBuffer;
  33424. protected _format: Nullable<number>;
  33425. private _delayedOnLoad;
  33426. private _delayedOnError;
  33427. protected _onLoadObservable: Nullable<Observable<Texture>>;
  33428. protected _isBlocking: boolean;
  33429. isBlocking: boolean;
  33430. readonly samplingMode: number;
  33431. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  33432. updateURL(url: string): void;
  33433. delayLoad(): void;
  33434. updateSamplingMode(samplingMode: number): void;
  33435. private _prepareRowForTextureGeneration(x, y, z, t);
  33436. getTextureMatrix(): Matrix;
  33437. getReflectionTextureMatrix(): Matrix;
  33438. clone(): Texture;
  33439. readonly onLoadObservable: Observable<Texture>;
  33440. serialize(): any;
  33441. getClassName(): string;
  33442. dispose(): void;
  33443. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  33444. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  33445. 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;
  33446. }
  33447. }
  33448. declare module BABYLON {
  33449. /**
  33450. * Settings for finer control over video usage
  33451. */
  33452. interface VideoTextureSettings {
  33453. /**
  33454. * Applies `autoplay` to video, if specified
  33455. */
  33456. autoPlay?: boolean;
  33457. /**
  33458. * Applies `loop` to video, if specified
  33459. */
  33460. loop?: boolean;
  33461. /**
  33462. * Automatically updates internal texture from video at every frame in the render loop
  33463. */
  33464. autoUpdateTexture: boolean;
  33465. }
  33466. class VideoTexture extends Texture {
  33467. /**
  33468. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33469. */
  33470. readonly autoUpdateTexture: boolean;
  33471. /**
  33472. * The video instance used by the texture internally
  33473. */
  33474. readonly video: HTMLVideoElement;
  33475. private _generateMipMaps;
  33476. private _engine;
  33477. private _stillImageCaptured;
  33478. /**
  33479. * Creates a video texture.
  33480. * Sample : https://doc.babylonjs.com/how_to/video_texture
  33481. * @param {string | null} name optional name, will detect from video source, if not defined
  33482. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  33483. * @param {BABYLON.Scene} scene is obviously the current scene.
  33484. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33485. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  33486. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33487. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  33488. */
  33489. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33490. private _getName(src);
  33491. private _getVideo(src);
  33492. private _createInternalTexture;
  33493. private reset;
  33494. /**
  33495. * Internal method to initiate `update`.
  33496. */
  33497. _rebuild(): void;
  33498. /**
  33499. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33500. */
  33501. update(): void;
  33502. /**
  33503. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33504. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33505. */
  33506. updateTexture(isVisible: boolean): void;
  33507. protected _updateInternalTexture: (e?: Event | undefined) => void;
  33508. /**
  33509. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33510. * @param url New url.
  33511. */
  33512. updateURL(url: string): void;
  33513. dispose(): void;
  33514. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33515. minWidth: number;
  33516. maxWidth: number;
  33517. minHeight: number;
  33518. maxHeight: number;
  33519. deviceId: string;
  33520. }): void;
  33521. }
  33522. }
  33523. declare module BABYLON {
  33524. /**
  33525. * Particle emitter emitting particles from the inside of a box.
  33526. * It emits the particles randomly between 2 given directions.
  33527. */
  33528. class BoxParticleEmitter implements IParticleEmitterType {
  33529. /**
  33530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33531. */
  33532. direction1: Vector3;
  33533. /**
  33534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33535. */
  33536. direction2: Vector3;
  33537. /**
  33538. * 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.
  33539. */
  33540. minEmitBox: Vector3;
  33541. /**
  33542. * 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.
  33543. */
  33544. maxEmitBox: Vector3;
  33545. /**
  33546. * Creates a new instance BoxParticleEmitter
  33547. */
  33548. constructor();
  33549. /**
  33550. * Called by the particle System when the direction is computed for the created particle.
  33551. * @param emitPower is the power of the particle (speed)
  33552. * @param worldMatrix is the world matrix of the particle system
  33553. * @param directionToUpdate is the direction vector to update with the result
  33554. * @param particle is the particle we are computed the direction for
  33555. */
  33556. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33557. /**
  33558. * Called by the particle System when the position is computed for the created particle.
  33559. * @param worldMatrix is the world matrix of the particle system
  33560. * @param positionToUpdate is the position vector to update with the result
  33561. * @param particle is the particle we are computed the position for
  33562. */
  33563. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33564. /**
  33565. * Clones the current emitter and returns a copy of it
  33566. * @returns the new emitter
  33567. */
  33568. clone(): BoxParticleEmitter;
  33569. /**
  33570. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33571. * @param effect defines the update shader
  33572. */
  33573. applyToShader(effect: Effect): void;
  33574. /**
  33575. * Returns a string to use to update the GPU particles update shader
  33576. * @returns a string containng the defines string
  33577. */
  33578. getEffectDefines(): string;
  33579. /**
  33580. * Returns the string "BoxEmitter"
  33581. * @returns a string containing the class name
  33582. */
  33583. getClassName(): string;
  33584. /**
  33585. * Serializes the particle system to a JSON object.
  33586. * @returns the JSON object
  33587. */
  33588. serialize(): any;
  33589. /**
  33590. * Parse properties from a JSON object
  33591. * @param serializationObject defines the JSON object
  33592. */
  33593. parse(serializationObject: any): void;
  33594. }
  33595. }
  33596. declare module BABYLON {
  33597. /**
  33598. * Particle emitter emitting particles from the inside of a cone.
  33599. * It emits the particles alongside the cone volume from the base to the particle.
  33600. * The emission direction might be randomized.
  33601. */
  33602. class ConeParticleEmitter implements IParticleEmitterType {
  33603. /**
  33604. * The radius of the emission cone.
  33605. */
  33606. angle: number;
  33607. /**
  33608. * The cone base angle.
  33609. */
  33610. directionRandomizer: number;
  33611. private _radius;
  33612. private _height;
  33613. /**
  33614. * Gets the radius of the emission cone.
  33615. */
  33616. /**
  33617. * Sets the radius of the emission cone.
  33618. */
  33619. radius: number;
  33620. /**
  33621. * Creates a new instance ConeParticleEmitter
  33622. * @param radius the radius of the emission cone (1 by default)
  33623. * @param angles the cone base angle (PI by default)
  33624. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33625. */
  33626. constructor(radius?: number,
  33627. /**
  33628. * The radius of the emission cone.
  33629. */
  33630. angle?: number,
  33631. /**
  33632. * The cone base angle.
  33633. */
  33634. directionRandomizer?: number);
  33635. /**
  33636. * Called by the particle System when the direction is computed for the created particle.
  33637. * @param emitPower is the power of the particle (speed)
  33638. * @param worldMatrix is the world matrix of the particle system
  33639. * @param directionToUpdate is the direction vector to update with the result
  33640. * @param particle is the particle we are computed the direction for
  33641. */
  33642. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33643. /**
  33644. * Called by the particle System when the position is computed for the created particle.
  33645. * @param worldMatrix is the world matrix of the particle system
  33646. * @param positionToUpdate is the position vector to update with the result
  33647. * @param particle is the particle we are computed the position for
  33648. */
  33649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33650. /**
  33651. * Clones the current emitter and returns a copy of it
  33652. * @returns the new emitter
  33653. */
  33654. clone(): ConeParticleEmitter;
  33655. /**
  33656. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33657. * @param effect defines the update shader
  33658. */
  33659. applyToShader(effect: Effect): void;
  33660. /**
  33661. * Returns a string to use to update the GPU particles update shader
  33662. * @returns a string containng the defines string
  33663. */
  33664. getEffectDefines(): string;
  33665. /**
  33666. * Returns the string "BoxEmitter"
  33667. * @returns a string containing the class name
  33668. */
  33669. getClassName(): string;
  33670. /**
  33671. * Serializes the particle system to a JSON object.
  33672. * @returns the JSON object
  33673. */
  33674. serialize(): any;
  33675. /**
  33676. * Parse properties from a JSON object
  33677. * @param serializationObject defines the JSON object
  33678. */
  33679. parse(serializationObject: any): void;
  33680. }
  33681. }
  33682. declare module BABYLON {
  33683. /**
  33684. * Particle emitter represents a volume emitting particles.
  33685. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  33686. */
  33687. interface IParticleEmitterType {
  33688. /**
  33689. * Called by the particle System when the direction is computed for the created particle.
  33690. * @param emitPower is the power of the particle (speed)
  33691. * @param worldMatrix is the world matrix of the particle system
  33692. * @param directionToUpdate is the direction vector to update with the result
  33693. * @param particle is the particle we are computed the direction for
  33694. */
  33695. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33696. /**
  33697. * Called by the particle System when the position is computed for the created particle.
  33698. * @param worldMatrix is the world matrix of the particle system
  33699. * @param positionToUpdate is the position vector to update with the result
  33700. * @param particle is the particle we are computed the position for
  33701. */
  33702. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33703. /**
  33704. * Clones the current emitter and returns a copy of it
  33705. * @returns the new emitter
  33706. */
  33707. clone(): IParticleEmitterType;
  33708. /**
  33709. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33710. * @param effect defines the update shader
  33711. */
  33712. applyToShader(effect: Effect): void;
  33713. /**
  33714. * Returns a string to use to update the GPU particles update shader
  33715. * @returns the effect defines string
  33716. */
  33717. getEffectDefines(): string;
  33718. /**
  33719. * Returns a string representing the class name
  33720. * @returns a string containing the class name
  33721. */
  33722. getClassName(): string;
  33723. /**
  33724. * Serializes the particle system to a JSON object.
  33725. * @returns the JSON object
  33726. */
  33727. serialize(): any;
  33728. /**
  33729. * Parse properties from a JSON object
  33730. * @param serializationObject defines the JSON object
  33731. */
  33732. parse(serializationObject: any): void;
  33733. }
  33734. }
  33735. declare module BABYLON {
  33736. /**
  33737. * Particle emitter emitting particles from the inside of a sphere.
  33738. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  33739. */
  33740. class SphereParticleEmitter implements IParticleEmitterType {
  33741. /**
  33742. * The radius of the emission sphere.
  33743. */
  33744. radius: number;
  33745. /**
  33746. * How much to randomize the particle direction [0-1].
  33747. */
  33748. directionRandomizer: number;
  33749. /**
  33750. * Creates a new instance SphereParticleEmitter
  33751. * @param radius the radius of the emission sphere (1 by default)
  33752. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33753. */
  33754. constructor(
  33755. /**
  33756. * The radius of the emission sphere.
  33757. */
  33758. radius?: number,
  33759. /**
  33760. * How much to randomize the particle direction [0-1].
  33761. */
  33762. directionRandomizer?: number);
  33763. /**
  33764. * Called by the particle System when the direction is computed for the created particle.
  33765. * @param emitPower is the power of the particle (speed)
  33766. * @param worldMatrix is the world matrix of the particle system
  33767. * @param directionToUpdate is the direction vector to update with the result
  33768. * @param particle is the particle we are computed the direction for
  33769. */
  33770. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33771. /**
  33772. * Called by the particle System when the position is computed for the created particle.
  33773. * @param worldMatrix is the world matrix of the particle system
  33774. * @param positionToUpdate is the position vector to update with the result
  33775. * @param particle is the particle we are computed the position for
  33776. */
  33777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33778. /**
  33779. * Clones the current emitter and returns a copy of it
  33780. * @returns the new emitter
  33781. */
  33782. clone(): SphereParticleEmitter;
  33783. /**
  33784. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33785. * @param effect defines the update shader
  33786. */
  33787. applyToShader(effect: Effect): void;
  33788. /**
  33789. * Returns a string to use to update the GPU particles update shader
  33790. * @returns a string containng the defines string
  33791. */
  33792. getEffectDefines(): string;
  33793. /**
  33794. * Returns the string "SphereParticleEmitter"
  33795. * @returns a string containing the class name
  33796. */
  33797. getClassName(): string;
  33798. /**
  33799. * Serializes the particle system to a JSON object.
  33800. * @returns the JSON object
  33801. */
  33802. serialize(): any;
  33803. /**
  33804. * Parse properties from a JSON object
  33805. * @param serializationObject defines the JSON object
  33806. */
  33807. parse(serializationObject: any): void;
  33808. }
  33809. /**
  33810. * Particle emitter emitting particles from the inside of a sphere.
  33811. * It emits the particles randomly between two vectors.
  33812. */
  33813. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  33814. /**
  33815. * The min limit of the emission direction.
  33816. */
  33817. direction1: Vector3;
  33818. /**
  33819. * The max limit of the emission direction.
  33820. */
  33821. direction2: Vector3;
  33822. /**
  33823. * Creates a new instance SphereDirectedParticleEmitter
  33824. * @param radius the radius of the emission sphere (1 by default)
  33825. * @param direction1 the min limit of the emission direction (up vector by default)
  33826. * @param direction2 the max limit of the emission direction (up vector by default)
  33827. */
  33828. constructor(radius?: number,
  33829. /**
  33830. * The min limit of the emission direction.
  33831. */
  33832. direction1?: Vector3,
  33833. /**
  33834. * The max limit of the emission direction.
  33835. */
  33836. direction2?: Vector3);
  33837. /**
  33838. * Called by the particle System when the direction is computed for the created particle.
  33839. * @param emitPower is the power of the particle (speed)
  33840. * @param worldMatrix is the world matrix of the particle system
  33841. * @param directionToUpdate is the direction vector to update with the result
  33842. * @param particle is the particle we are computed the direction for
  33843. */
  33844. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33845. /**
  33846. * Clones the current emitter and returns a copy of it
  33847. * @returns the new emitter
  33848. */
  33849. clone(): SphereDirectedParticleEmitter;
  33850. /**
  33851. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33852. * @param effect defines the update shader
  33853. */
  33854. applyToShader(effect: Effect): void;
  33855. /**
  33856. * Returns a string to use to update the GPU particles update shader
  33857. * @returns a string containng the defines string
  33858. */
  33859. getEffectDefines(): string;
  33860. /**
  33861. * Returns the string "SphereDirectedParticleEmitter"
  33862. * @returns a string containing the class name
  33863. */
  33864. getClassName(): string;
  33865. /**
  33866. * Serializes the particle system to a JSON object.
  33867. * @returns the JSON object
  33868. */
  33869. serialize(): any;
  33870. /**
  33871. * Parse properties from a JSON object
  33872. * @param serializationObject defines the JSON object
  33873. */
  33874. parse(serializationObject: any): void;
  33875. }
  33876. }
  33877. declare var DracoDecoderModule: any;
  33878. declare var WebAssembly: any;
  33879. declare module BABYLON {
  33880. /**
  33881. * Configuration for Draco compression
  33882. */
  33883. interface IDracoCompressionConfiguration {
  33884. /**
  33885. * Configuration for the decoder.
  33886. */
  33887. decoder?: {
  33888. /**
  33889. * The url to the WebAssembly module.
  33890. */
  33891. wasmUrl?: string;
  33892. /**
  33893. * The url to the WebAssembly binary.
  33894. */
  33895. wasmBinaryUrl?: string;
  33896. /**
  33897. * The url to the fallback JavaScript module.
  33898. */
  33899. fallbackUrl?: string;
  33900. };
  33901. }
  33902. /**
  33903. * Draco compression (https://google.github.io/draco/)
  33904. */
  33905. class DracoCompression implements IDisposable {
  33906. private static _DecoderModulePromise;
  33907. /**
  33908. * The configuration.
  33909. */
  33910. static Configuration: IDracoCompressionConfiguration;
  33911. /**
  33912. * Returns true if the decoder is available.
  33913. */
  33914. static readonly DecoderAvailable: boolean;
  33915. /**
  33916. * Constructor
  33917. */
  33918. constructor();
  33919. /**
  33920. * Stop all async operations and release resources.
  33921. */
  33922. dispose(): void;
  33923. /**
  33924. * Decode Draco compressed mesh data to vertex data.
  33925. * @param data The array buffer view for the Draco compression data
  33926. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  33927. * @returns A promise that resolves with the decoded vertex data
  33928. */
  33929. decodeMeshAsync(data: ArrayBufferView, attributes: {
  33930. [kind: string]: number;
  33931. }): Promise<VertexData>;
  33932. private static _GetDecoderModule();
  33933. private static _LoadScriptAsync(url);
  33934. private static _LoadFileAsync(url);
  33935. }
  33936. }
  33937. declare module BABYLON {
  33938. class CannonJSPlugin implements IPhysicsEnginePlugin {
  33939. private _useDeltaForWorldStep;
  33940. world: any;
  33941. name: string;
  33942. private _physicsMaterials;
  33943. private _fixedTimeStep;
  33944. BJSCANNON: any;
  33945. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  33946. setGravity(gravity: Vector3): void;
  33947. setTimeStep(timeStep: number): void;
  33948. getTimeStep(): number;
  33949. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33950. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33951. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33952. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33953. private _processChildMeshes(mainImpostor);
  33954. removePhysicsBody(impostor: PhysicsImpostor): void;
  33955. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  33956. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  33957. private _addMaterial(name, friction, restitution);
  33958. private _checkWithEpsilon(value);
  33959. private _createShape(impostor);
  33960. private _createHeightmap(object, pointDepth?);
  33961. private _minus90X;
  33962. private _plus90X;
  33963. private _tmpPosition;
  33964. private _tmpDeltaPosition;
  33965. private _tmpUnityRotation;
  33966. private _updatePhysicsBodyTransformation(impostor);
  33967. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33968. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33969. isSupported(): boolean;
  33970. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33971. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33972. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33973. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33974. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33975. getBodyMass(impostor: PhysicsImpostor): number;
  33976. getBodyFriction(impostor: PhysicsImpostor): number;
  33977. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33978. getBodyRestitution(impostor: PhysicsImpostor): number;
  33979. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33980. sleepBody(impostor: PhysicsImpostor): void;
  33981. wakeUpBody(impostor: PhysicsImpostor): void;
  33982. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33983. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  33984. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  33985. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33986. getRadius(impostor: PhysicsImpostor): number;
  33987. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33988. dispose(): void;
  33989. private _extendNamespace();
  33990. }
  33991. }
  33992. declare module BABYLON {
  33993. class OimoJSPlugin implements IPhysicsEnginePlugin {
  33994. world: any;
  33995. name: string;
  33996. BJSOIMO: any;
  33997. constructor(iterations?: number);
  33998. setGravity(gravity: Vector3): void;
  33999. setTimeStep(timeStep: number): void;
  34000. getTimeStep(): number;
  34001. private _tmpImpostorsArray;
  34002. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34003. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34004. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34005. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34006. private _tmpPositionVector;
  34007. removePhysicsBody(impostor: PhysicsImpostor): void;
  34008. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34009. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34010. isSupported(): boolean;
  34011. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34012. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34013. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34014. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34015. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34016. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34017. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34018. getBodyMass(impostor: PhysicsImpostor): number;
  34019. getBodyFriction(impostor: PhysicsImpostor): number;
  34020. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34021. getBodyRestitution(impostor: PhysicsImpostor): number;
  34022. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34023. sleepBody(impostor: PhysicsImpostor): void;
  34024. wakeUpBody(impostor: PhysicsImpostor): void;
  34025. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34026. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34027. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34028. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34029. getRadius(impostor: PhysicsImpostor): number;
  34030. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34031. dispose(): void;
  34032. }
  34033. }
  34034. declare module BABYLON {
  34035. /**
  34036. * This represents a set of one or more post processes in Babylon.
  34037. * A post process can be used to apply a shader to a texture after it is rendered.
  34038. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34039. */
  34040. class PostProcessRenderEffect {
  34041. private _postProcesses;
  34042. private _getPostProcesses;
  34043. private _singleInstance;
  34044. private _cameras;
  34045. private _indicesForCamera;
  34046. /**
  34047. * Name of the effect
  34048. */
  34049. _name: string;
  34050. /**
  34051. * Instantiates a post process render effect.
  34052. * A post process can be used to apply a shader to a texture after it is rendered.
  34053. * @param engine The engine the effect is tied to
  34054. * @param name The name of the effect
  34055. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34056. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34057. */
  34058. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34059. /**
  34060. * Checks if all the post processes in the effect are supported.
  34061. */
  34062. readonly isSupported: boolean;
  34063. /**
  34064. * Updates the current state of the effect
  34065. */
  34066. _update(): void;
  34067. /**
  34068. * Attaches the effect on cameras
  34069. * @param cameras The camera to attach to.
  34070. */
  34071. _attachCameras(cameras: Camera): void;
  34072. /**
  34073. * Attaches the effect on cameras
  34074. * @param cameras The camera to attach to.
  34075. */
  34076. _attachCameras(cameras: Camera[]): void;
  34077. /**
  34078. * Detatches the effect on cameras
  34079. * @param cameras The camera to detatch from.
  34080. */
  34081. _detachCameras(cameras: Camera): void;
  34082. /**
  34083. * Detatches the effect on cameras
  34084. * @param cameras The camera to detatch from.
  34085. */
  34086. _detachCameras(cameras: Camera[]): void;
  34087. /**
  34088. * Enables the effect on given cameras
  34089. * @param cameras The camera to enable.
  34090. */
  34091. _enable(cameras: Camera): void;
  34092. /**
  34093. * Enables the effect on given cameras
  34094. * @param cameras The camera to enable.
  34095. */
  34096. _enable(cameras: Nullable<Camera[]>): void;
  34097. /**
  34098. * Disables the effect on the given cameras
  34099. * @param cameras The camera to disable.
  34100. */
  34101. _disable(cameras: Camera): void;
  34102. /**
  34103. * Disables the effect on the given cameras
  34104. * @param cameras The camera to disable.
  34105. */
  34106. _disable(cameras: Nullable<Camera[]>): void;
  34107. /**
  34108. * Gets a list of the post processes contained in the effect.
  34109. * @param camera The camera to get the post processes on.
  34110. * @returns The list of the post processes in the effect.
  34111. */
  34112. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34113. }
  34114. }
  34115. declare module BABYLON {
  34116. class PostProcessRenderPipeline {
  34117. private engine;
  34118. private _renderEffects;
  34119. private _renderEffectsForIsolatedPass;
  34120. protected _cameras: Camera[];
  34121. _name: string;
  34122. constructor(engine: Engine, name: string);
  34123. getClassName(): string;
  34124. readonly isSupported: boolean;
  34125. addEffect(renderEffect: PostProcessRenderEffect): void;
  34126. _rebuild(): void;
  34127. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34128. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34129. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34130. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34131. _attachCameras(cameras: Camera, unique: boolean): void;
  34132. _attachCameras(cameras: Camera[], unique: boolean): void;
  34133. _detachCameras(cameras: Camera): void;
  34134. _detachCameras(cameras: Nullable<Camera[]>): void;
  34135. _update(): void;
  34136. _reset(): void;
  34137. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34138. dispose(): void;
  34139. }
  34140. }
  34141. declare module BABYLON {
  34142. class PostProcessRenderPipelineManager {
  34143. private _renderPipelines;
  34144. constructor();
  34145. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34146. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34147. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34148. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34149. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34150. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34151. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34152. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34153. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34154. update(): void;
  34155. _rebuild(): void;
  34156. dispose(): void;
  34157. }
  34158. }
  34159. declare module BABYLON {
  34160. /**
  34161. * Helper class dealing with the extraction of spherical polynomial dataArray
  34162. * from a cube map.
  34163. */
  34164. class CubeMapToSphericalPolynomialTools {
  34165. private static FileFaces;
  34166. /**
  34167. * Converts a texture to the according Spherical Polynomial data.
  34168. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34169. *
  34170. * @param texture The texture to extract the information from.
  34171. * @return The Spherical Polynomial data.
  34172. */
  34173. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34174. /**
  34175. * Converts a cubemap to the according Spherical Polynomial data.
  34176. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34177. *
  34178. * @param cubeInfo The Cube map to extract the information from.
  34179. * @return The Spherical Polynomial data.
  34180. */
  34181. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34182. }
  34183. }
  34184. declare module BABYLON {
  34185. /**
  34186. * Header information of HDR texture files.
  34187. */
  34188. interface HDRInfo {
  34189. /**
  34190. * The height of the texture in pixels.
  34191. */
  34192. height: number;
  34193. /**
  34194. * The width of the texture in pixels.
  34195. */
  34196. width: number;
  34197. /**
  34198. * The index of the beginning of the data in the binary file.
  34199. */
  34200. dataPosition: number;
  34201. }
  34202. /**
  34203. * This groups tools to convert HDR texture to native colors array.
  34204. */
  34205. class HDRTools {
  34206. private static Ldexp(mantissa, exponent);
  34207. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34208. private static readStringLine(uint8array, startIndex);
  34209. /**
  34210. * Reads header information from an RGBE texture stored in a native array.
  34211. * More information on this format are available here:
  34212. * https://en.wikipedia.org/wiki/RGBE_image_format
  34213. *
  34214. * @param uint8array The binary file stored in native array.
  34215. * @return The header information.
  34216. */
  34217. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34218. /**
  34219. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34220. * This RGBE texture needs to store the information as a panorama.
  34221. *
  34222. * More information on this format are available here:
  34223. * https://en.wikipedia.org/wiki/RGBE_image_format
  34224. *
  34225. * @param buffer The binary file stored in an array buffer.
  34226. * @param size The expected size of the extracted cubemap.
  34227. * @return The Cube Map information.
  34228. */
  34229. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34230. /**
  34231. * Returns the pixels data extracted from an RGBE texture.
  34232. * This pixels will be stored left to right up to down in the R G B order in one array.
  34233. *
  34234. * More information on this format are available here:
  34235. * https://en.wikipedia.org/wiki/RGBE_image_format
  34236. *
  34237. * @param uint8array The binary file stored in an array buffer.
  34238. * @param hdrInfo The header information of the file.
  34239. * @return The pixels data in RGB right to left up to down order.
  34240. */
  34241. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34242. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34243. }
  34244. }
  34245. declare module BABYLON {
  34246. /**
  34247. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34248. */
  34249. interface CubeMapInfo {
  34250. /**
  34251. * The pixel array for the front face.
  34252. * This is stored in format, left to right, up to down format.
  34253. */
  34254. front: Nullable<ArrayBufferView>;
  34255. /**
  34256. * The pixel array for the back face.
  34257. * This is stored in format, left to right, up to down format.
  34258. */
  34259. back: Nullable<ArrayBufferView>;
  34260. /**
  34261. * The pixel array for the left face.
  34262. * This is stored in format, left to right, up to down format.
  34263. */
  34264. left: Nullable<ArrayBufferView>;
  34265. /**
  34266. * The pixel array for the right face.
  34267. * This is stored in format, left to right, up to down format.
  34268. */
  34269. right: Nullable<ArrayBufferView>;
  34270. /**
  34271. * The pixel array for the up face.
  34272. * This is stored in format, left to right, up to down format.
  34273. */
  34274. up: Nullable<ArrayBufferView>;
  34275. /**
  34276. * The pixel array for the down face.
  34277. * This is stored in format, left to right, up to down format.
  34278. */
  34279. down: Nullable<ArrayBufferView>;
  34280. /**
  34281. * The size of the cubemap stored.
  34282. *
  34283. * Each faces will be size * size pixels.
  34284. */
  34285. size: number;
  34286. /**
  34287. * The format of the texture.
  34288. *
  34289. * RGBA, RGB.
  34290. */
  34291. format: number;
  34292. /**
  34293. * The type of the texture data.
  34294. *
  34295. * UNSIGNED_INT, FLOAT.
  34296. */
  34297. type: number;
  34298. /**
  34299. * Specifies whether the texture is in gamma space.
  34300. */
  34301. gammaSpace: boolean;
  34302. }
  34303. /**
  34304. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34305. */
  34306. class PanoramaToCubeMapTools {
  34307. private static FACE_FRONT;
  34308. private static FACE_BACK;
  34309. private static FACE_RIGHT;
  34310. private static FACE_LEFT;
  34311. private static FACE_DOWN;
  34312. private static FACE_UP;
  34313. /**
  34314. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34315. *
  34316. * @param float32Array The source data.
  34317. * @param inputWidth The width of the input panorama.
  34318. * @param inputhHeight The height of the input panorama.
  34319. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34320. * @return The cubemap data
  34321. */
  34322. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34323. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34324. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34325. }
  34326. }
  34327. declare module BABYLON {
  34328. class CustomProceduralTexture extends ProceduralTexture {
  34329. private _animate;
  34330. private _time;
  34331. private _config;
  34332. private _texturePath;
  34333. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34334. private loadJson(jsonUrl);
  34335. isReady(): boolean;
  34336. render(useCameraPostProcess?: boolean): void;
  34337. updateTextures(): void;
  34338. updateShaderUniforms(): void;
  34339. animate: boolean;
  34340. }
  34341. }
  34342. declare module BABYLON {
  34343. class ProceduralTexture extends Texture {
  34344. isCube: boolean;
  34345. private _size;
  34346. _generateMipMaps: boolean;
  34347. isEnabled: boolean;
  34348. private _currentRefreshId;
  34349. private _refreshRate;
  34350. onGenerated: () => void;
  34351. private _vertexBuffers;
  34352. private _indexBuffer;
  34353. private _effect;
  34354. private _uniforms;
  34355. private _samplers;
  34356. private _fragment;
  34357. _textures: {
  34358. [key: string]: Texture;
  34359. };
  34360. private _floats;
  34361. private _floatsArrays;
  34362. private _colors3;
  34363. private _colors4;
  34364. private _vectors2;
  34365. private _vectors3;
  34366. private _matrices;
  34367. private _fallbackTexture;
  34368. private _fallbackTextureUsed;
  34369. private _engine;
  34370. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  34371. private _createIndexBuffer();
  34372. _rebuild(): void;
  34373. reset(): void;
  34374. isReady(): boolean;
  34375. resetRefreshCounter(): void;
  34376. setFragment(fragment: any): void;
  34377. refreshRate: number;
  34378. _shouldRender(): boolean;
  34379. getRenderSize(): number;
  34380. resize(size: number, generateMipMaps: boolean): void;
  34381. private _checkUniform(uniformName);
  34382. setTexture(name: string, texture: Texture): ProceduralTexture;
  34383. setFloat(name: string, value: number): ProceduralTexture;
  34384. setFloats(name: string, value: number[]): ProceduralTexture;
  34385. setColor3(name: string, value: Color3): ProceduralTexture;
  34386. setColor4(name: string, value: Color4): ProceduralTexture;
  34387. setVector2(name: string, value: Vector2): ProceduralTexture;
  34388. setVector3(name: string, value: Vector3): ProceduralTexture;
  34389. setMatrix(name: string, value: Matrix): ProceduralTexture;
  34390. render(useCameraPostProcess?: boolean): void;
  34391. clone(): ProceduralTexture;
  34392. dispose(): void;
  34393. }
  34394. }
  34395. declare module BABYLON {
  34396. /**
  34397. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  34398. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  34399. */
  34400. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34401. private _scene;
  34402. private _originalCameras;
  34403. /**
  34404. * ID of the sharpen post process,
  34405. */
  34406. private readonly SharpenPostProcessId;
  34407. /**
  34408. * ID of the image processing post process;
  34409. */
  34410. readonly ImageProcessingPostProcessId: string;
  34411. /**
  34412. * ID of the Fast Approximate Anti-Aliasing post process;
  34413. */
  34414. readonly FxaaPostProcessId: string;
  34415. /**
  34416. * ID of the chromatic aberration post process,
  34417. */
  34418. private readonly ChromaticAberrationPostProcessId;
  34419. /**
  34420. * ID of the grain post process
  34421. */
  34422. private readonly GrainPostProcessId;
  34423. /**
  34424. * Sharpen post process which will apply a sharpen convolution to enhance edges
  34425. */
  34426. sharpen: SharpenPostProcess;
  34427. private _sharpenEffect;
  34428. private bloom;
  34429. /**
  34430. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  34431. */
  34432. depthOfField: DepthOfFieldEffect;
  34433. /**
  34434. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  34435. */
  34436. fxaa: FxaaPostProcess;
  34437. /**
  34438. * Image post processing pass used to perform operations such as tone mapping or color grading.
  34439. */
  34440. imageProcessing: ImageProcessingPostProcess;
  34441. /**
  34442. * Chromatic aberration post process which will shift rgb colors in the image
  34443. */
  34444. chromaticAberration: ChromaticAberrationPostProcess;
  34445. private _chromaticAberrationEffect;
  34446. /**
  34447. * Grain post process which add noise to the image
  34448. */
  34449. grain: GrainPostProcess;
  34450. private _grainEffect;
  34451. /**
  34452. * Animations which can be used to tweak settings over a period of time
  34453. */
  34454. animations: Animation[];
  34455. private _imageProcessingConfigurationObserver;
  34456. private _sharpenEnabled;
  34457. private _bloomEnabled;
  34458. private _depthOfFieldEnabled;
  34459. private _depthOfFieldBlurLevel;
  34460. private _fxaaEnabled;
  34461. private _imageProcessingEnabled;
  34462. private _defaultPipelineTextureType;
  34463. private _bloomScale;
  34464. private _chromaticAberrationEnabled;
  34465. private _grainEnabled;
  34466. private _buildAllowed;
  34467. /**
  34468. * Enable or disable the sharpen process from the pipeline
  34469. */
  34470. sharpenEnabled: boolean;
  34471. private _resizeObserver;
  34472. private _hardwareScaleLevel;
  34473. private _bloomKernel;
  34474. /**
  34475. * Specifies the size of the bloom blur kernel, relative to the final output size
  34476. */
  34477. bloomKernel: number;
  34478. /**
  34479. * Specifies the weight of the bloom in the final rendering
  34480. */
  34481. private _bloomWeight;
  34482. /**
  34483. * Specifies the luma threshold for the area that will be blurred by the bloom
  34484. */
  34485. private _bloomThreshold;
  34486. private _hdr;
  34487. /**
  34488. * The strength of the bloom.
  34489. */
  34490. bloomWeight: number;
  34491. /**
  34492. * The strength of the bloom.
  34493. */
  34494. bloomThreshold: number;
  34495. /**
  34496. * The scale of the bloom, lower value will provide better performance.
  34497. */
  34498. bloomScale: number;
  34499. /**
  34500. * Enable or disable the bloom from the pipeline
  34501. */
  34502. bloomEnabled: boolean;
  34503. private _rebuildBloom();
  34504. /**
  34505. * If the depth of field is enabled.
  34506. */
  34507. depthOfFieldEnabled: boolean;
  34508. /**
  34509. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34510. */
  34511. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34512. /**
  34513. * If the anti aliasing is enabled.
  34514. */
  34515. fxaaEnabled: boolean;
  34516. private _samples;
  34517. /**
  34518. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34519. */
  34520. samples: number;
  34521. /**
  34522. * If image processing is enabled.
  34523. */
  34524. imageProcessingEnabled: boolean;
  34525. /**
  34526. * Enable or disable the chromaticAberration process from the pipeline
  34527. */
  34528. chromaticAberrationEnabled: boolean;
  34529. /**
  34530. * Enable or disable the grain process from the pipeline
  34531. */
  34532. grainEnabled: boolean;
  34533. /**
  34534. * @constructor
  34535. * @param {string} name - The rendering pipeline name
  34536. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34537. * @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)
  34538. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34539. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  34540. */
  34541. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34542. /**
  34543. * Force the compilation of the entire pipeline.
  34544. */
  34545. prepare(): void;
  34546. private _hasCleared;
  34547. private _prevPostProcess;
  34548. private _prevPrevPostProcess;
  34549. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34550. private _buildPipeline();
  34551. private _disposePostProcesses(disposeNonRecreated?);
  34552. /**
  34553. * Dispose of the pipeline and stop all post processes
  34554. */
  34555. dispose(): void;
  34556. /**
  34557. * Serialize the rendering pipeline (Used when exporting)
  34558. * @returns the serialized object
  34559. */
  34560. serialize(): any;
  34561. /**
  34562. * Parse the serialized pipeline
  34563. * @param source Source pipeline.
  34564. * @param scene The scene to load the pipeline to.
  34565. * @param rootUrl The URL of the serialized pipeline.
  34566. * @returns An instantiated pipeline from the serialized object.
  34567. */
  34568. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34569. }
  34570. }
  34571. declare module BABYLON {
  34572. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34573. /**
  34574. * The chromatic aberration PostProcess id in the pipeline
  34575. */
  34576. LensChromaticAberrationEffect: string;
  34577. /**
  34578. * The highlights enhancing PostProcess id in the pipeline
  34579. */
  34580. HighlightsEnhancingEffect: string;
  34581. /**
  34582. * The depth-of-field PostProcess id in the pipeline
  34583. */
  34584. LensDepthOfFieldEffect: string;
  34585. private _scene;
  34586. private _depthTexture;
  34587. private _grainTexture;
  34588. private _chromaticAberrationPostProcess;
  34589. private _highlightsPostProcess;
  34590. private _depthOfFieldPostProcess;
  34591. private _edgeBlur;
  34592. private _grainAmount;
  34593. private _chromaticAberration;
  34594. private _distortion;
  34595. private _highlightsGain;
  34596. private _highlightsThreshold;
  34597. private _dofDistance;
  34598. private _dofAperture;
  34599. private _dofDarken;
  34600. private _dofPentagon;
  34601. private _blurNoise;
  34602. /**
  34603. * @constructor
  34604. *
  34605. * Effect parameters are as follow:
  34606. * {
  34607. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34608. * edge_blur: number; // from 0 to x (1 for realism)
  34609. * distortion: number; // from 0 to x (1 for realism)
  34610. * grain_amount: number; // from 0 to 1
  34611. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34612. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34613. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34614. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34615. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34616. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34617. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34618. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34619. * }
  34620. * Note: if an effect parameter is unset, effect is disabled
  34621. *
  34622. * @param {string} name - The rendering pipeline name
  34623. * @param {object} parameters - An object containing all parameters (see above)
  34624. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34625. * @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)
  34626. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34627. */
  34628. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  34629. setEdgeBlur(amount: number): void;
  34630. disableEdgeBlur(): void;
  34631. setGrainAmount(amount: number): void;
  34632. disableGrain(): void;
  34633. setChromaticAberration(amount: number): void;
  34634. disableChromaticAberration(): void;
  34635. setEdgeDistortion(amount: number): void;
  34636. disableEdgeDistortion(): void;
  34637. setFocusDistance(amount: number): void;
  34638. disableDepthOfField(): void;
  34639. setAperture(amount: number): void;
  34640. setDarkenOutOfFocus(amount: number): void;
  34641. enablePentagonBokeh(): void;
  34642. disablePentagonBokeh(): void;
  34643. enableNoiseBlur(): void;
  34644. disableNoiseBlur(): void;
  34645. setHighlightsGain(amount: number): void;
  34646. setHighlightsThreshold(amount: number): void;
  34647. disableHighlights(): void;
  34648. /**
  34649. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  34650. */
  34651. dispose(disableDepthRender?: boolean): void;
  34652. private _createChromaticAberrationPostProcess(ratio);
  34653. private _createHighlightsPostProcess(ratio);
  34654. private _createDepthOfFieldPostProcess(ratio);
  34655. private _createGrainTexture();
  34656. }
  34657. }
  34658. declare module BABYLON {
  34659. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  34660. /**
  34661. * The PassPostProcess id in the pipeline that contains the original scene color
  34662. */
  34663. SSAOOriginalSceneColorEffect: string;
  34664. /**
  34665. * The SSAO PostProcess id in the pipeline
  34666. */
  34667. SSAORenderEffect: string;
  34668. /**
  34669. * The horizontal blur PostProcess id in the pipeline
  34670. */
  34671. SSAOBlurHRenderEffect: string;
  34672. /**
  34673. * The vertical blur PostProcess id in the pipeline
  34674. */
  34675. SSAOBlurVRenderEffect: string;
  34676. /**
  34677. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34678. */
  34679. SSAOCombineRenderEffect: string;
  34680. /**
  34681. * The output strength of the SSAO post-process. Default value is 1.0.
  34682. */
  34683. totalStrength: number;
  34684. /**
  34685. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  34686. */
  34687. maxZ: number;
  34688. /**
  34689. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  34690. */
  34691. minZAspect: number;
  34692. /**
  34693. * Number of samples used for the SSAO calculations. Default value is 8
  34694. */
  34695. private _samples;
  34696. /**
  34697. * Ratio object used for SSAO ratio and blur ratio
  34698. */
  34699. private _ratio;
  34700. /**
  34701. * Dynamically generated sphere sampler.
  34702. */
  34703. private _sampleSphere;
  34704. /**
  34705. * Blur filter offsets
  34706. */
  34707. private _samplerOffsets;
  34708. samples: number;
  34709. /**
  34710. * Are we using bilateral blur ?
  34711. */
  34712. private _expensiveBlur;
  34713. expensiveBlur: boolean;
  34714. /**
  34715. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  34716. */
  34717. radius: number;
  34718. /**
  34719. * The base color of the SSAO post-process
  34720. * The final result is "base + ssao" between [0, 1]
  34721. */
  34722. base: number;
  34723. /**
  34724. * Support test.
  34725. */
  34726. static readonly IsSupported: boolean;
  34727. private _scene;
  34728. private _depthTexture;
  34729. private _normalTexture;
  34730. private _randomTexture;
  34731. private _originalColorPostProcess;
  34732. private _ssaoPostProcess;
  34733. private _blurHPostProcess;
  34734. private _blurVPostProcess;
  34735. private _ssaoCombinePostProcess;
  34736. private _firstUpdate;
  34737. /**
  34738. * @constructor
  34739. * @param {string} name - The rendering pipeline name
  34740. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34741. * @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 }
  34742. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34743. */
  34744. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34745. /**
  34746. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34747. */
  34748. dispose(disableGeometryBufferRenderer?: boolean): void;
  34749. private _createBlurPostProcess(ssaoRatio, blurRatio);
  34750. _rebuild(): void;
  34751. private _generateHemisphere();
  34752. private _createSSAOPostProcess(ratio);
  34753. private _createSSAOCombinePostProcess(ratio);
  34754. private _createRandomTexture();
  34755. /**
  34756. * Serialize the rendering pipeline (Used when exporting)
  34757. * @returns the serialized object
  34758. */
  34759. serialize(): any;
  34760. /**
  34761. * Parse the serialized pipeline
  34762. * @param source Source pipeline.
  34763. * @param scene The scene to load the pipeline to.
  34764. * @param rootUrl The URL of the serialized pipeline.
  34765. * @returns An instantiated pipeline from the serialized object.
  34766. */
  34767. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  34768. }
  34769. }
  34770. declare module BABYLON {
  34771. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  34772. /**
  34773. * The PassPostProcess id in the pipeline that contains the original scene color
  34774. */
  34775. SSAOOriginalSceneColorEffect: string;
  34776. /**
  34777. * The SSAO PostProcess id in the pipeline
  34778. */
  34779. SSAORenderEffect: string;
  34780. /**
  34781. * The horizontal blur PostProcess id in the pipeline
  34782. */
  34783. SSAOBlurHRenderEffect: string;
  34784. /**
  34785. * The vertical blur PostProcess id in the pipeline
  34786. */
  34787. SSAOBlurVRenderEffect: string;
  34788. /**
  34789. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34790. */
  34791. SSAOCombineRenderEffect: string;
  34792. /**
  34793. * The output strength of the SSAO post-process. Default value is 1.0.
  34794. */
  34795. totalStrength: number;
  34796. /**
  34797. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  34798. */
  34799. radius: number;
  34800. /**
  34801. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  34802. * Must not be equal to fallOff and superior to fallOff.
  34803. * Default value is 0.975
  34804. */
  34805. area: number;
  34806. /**
  34807. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  34808. * Must not be equal to area and inferior to area.
  34809. * Default value is 0.0
  34810. */
  34811. fallOff: number;
  34812. /**
  34813. * The base color of the SSAO post-process
  34814. * The final result is "base + ssao" between [0, 1]
  34815. */
  34816. base: number;
  34817. private _scene;
  34818. private _depthTexture;
  34819. private _randomTexture;
  34820. private _originalColorPostProcess;
  34821. private _ssaoPostProcess;
  34822. private _blurHPostProcess;
  34823. private _blurVPostProcess;
  34824. private _ssaoCombinePostProcess;
  34825. private _firstUpdate;
  34826. /**
  34827. * @constructor
  34828. * @param {string} name - The rendering pipeline name
  34829. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34830. * @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 }
  34831. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34832. */
  34833. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34834. /**
  34835. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34836. */
  34837. dispose(disableDepthRender?: boolean): void;
  34838. private _createBlurPostProcess(ratio);
  34839. _rebuild(): void;
  34840. private _createSSAOPostProcess(ratio);
  34841. private _createSSAOCombinePostProcess(ratio);
  34842. private _createRandomTexture();
  34843. }
  34844. }
  34845. declare module BABYLON {
  34846. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34847. /**
  34848. * Public members
  34849. */
  34850. originalPostProcess: Nullable<PostProcess>;
  34851. downSampleX4PostProcess: Nullable<PostProcess>;
  34852. brightPassPostProcess: Nullable<PostProcess>;
  34853. blurHPostProcesses: PostProcess[];
  34854. blurVPostProcesses: PostProcess[];
  34855. textureAdderPostProcess: Nullable<PostProcess>;
  34856. volumetricLightPostProcess: Nullable<PostProcess>;
  34857. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  34858. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  34859. volumetricLightMergePostProces: Nullable<PostProcess>;
  34860. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  34861. luminancePostProcess: Nullable<PostProcess>;
  34862. luminanceDownSamplePostProcesses: PostProcess[];
  34863. hdrPostProcess: Nullable<PostProcess>;
  34864. textureAdderFinalPostProcess: Nullable<PostProcess>;
  34865. lensFlareFinalPostProcess: Nullable<PostProcess>;
  34866. hdrFinalPostProcess: Nullable<PostProcess>;
  34867. lensFlarePostProcess: Nullable<PostProcess>;
  34868. lensFlareComposePostProcess: Nullable<PostProcess>;
  34869. motionBlurPostProcess: Nullable<PostProcess>;
  34870. depthOfFieldPostProcess: Nullable<PostProcess>;
  34871. brightThreshold: number;
  34872. blurWidth: number;
  34873. horizontalBlur: boolean;
  34874. exposure: number;
  34875. lensTexture: Nullable<Texture>;
  34876. volumetricLightCoefficient: number;
  34877. volumetricLightPower: number;
  34878. volumetricLightBlurScale: number;
  34879. sourceLight: Nullable<SpotLight | DirectionalLight>;
  34880. hdrMinimumLuminance: number;
  34881. hdrDecreaseRate: number;
  34882. hdrIncreaseRate: number;
  34883. lensColorTexture: Nullable<Texture>;
  34884. lensFlareStrength: number;
  34885. lensFlareGhostDispersal: number;
  34886. lensFlareHaloWidth: number;
  34887. lensFlareDistortionStrength: number;
  34888. lensStarTexture: Nullable<Texture>;
  34889. lensFlareDirtTexture: Nullable<Texture>;
  34890. depthOfFieldDistance: number;
  34891. depthOfFieldBlurWidth: number;
  34892. motionStrength: number;
  34893. animations: Animation[];
  34894. /**
  34895. * Private members
  34896. */
  34897. private _scene;
  34898. private _currentDepthOfFieldSource;
  34899. private _basePostProcess;
  34900. private _hdrCurrentLuminance;
  34901. private _floatTextureType;
  34902. private _ratio;
  34903. private _bloomEnabled;
  34904. private _depthOfFieldEnabled;
  34905. private _vlsEnabled;
  34906. private _lensFlareEnabled;
  34907. private _hdrEnabled;
  34908. private _motionBlurEnabled;
  34909. private _motionBlurSamples;
  34910. private _volumetricLightStepsCount;
  34911. BloomEnabled: boolean;
  34912. DepthOfFieldEnabled: boolean;
  34913. LensFlareEnabled: boolean;
  34914. HDREnabled: boolean;
  34915. VLSEnabled: boolean;
  34916. MotionBlurEnabled: boolean;
  34917. volumetricLightStepsCount: number;
  34918. motionBlurSamples: number;
  34919. /**
  34920. * @constructor
  34921. * @param {string} name - The rendering pipeline name
  34922. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34923. * @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)
  34924. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  34925. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34926. */
  34927. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  34928. private _buildPipeline();
  34929. private _createDownSampleX4PostProcess(scene, ratio);
  34930. private _createBrightPassPostProcess(scene, ratio);
  34931. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  34932. private _createTextureAdderPostProcess(scene, ratio);
  34933. private _createVolumetricLightPostProcess(scene, ratio);
  34934. private _createLuminancePostProcesses(scene, textureType);
  34935. private _createHdrPostProcess(scene, ratio);
  34936. private _createLensFlarePostProcess(scene, ratio);
  34937. private _createDepthOfFieldPostProcess(scene, ratio);
  34938. private _createMotionBlurPostProcess(scene, ratio);
  34939. private _getDepthTexture();
  34940. private _disposePostProcesses();
  34941. /**
  34942. * Dispose of the pipeline and stop all post processes
  34943. */
  34944. dispose(): void;
  34945. /**
  34946. * Serialize the rendering pipeline (Used when exporting)
  34947. * @returns the serialized object
  34948. */
  34949. serialize(): any;
  34950. /**
  34951. * Parse the serialized pipeline
  34952. * @param source Source pipeline.
  34953. * @param scene The scene to load the pipeline to.
  34954. * @param rootUrl The URL of the serialized pipeline.
  34955. * @returns An instantiated pipeline from the serialized object.
  34956. */
  34957. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  34958. static LuminanceSteps: number;
  34959. }
  34960. }