babylon.d.ts 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239
  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 _pointerCaptures;
  1018. private _timeAccumulator;
  1019. private _currentStepId;
  1020. private _currentInternalStep;
  1021. /** @hidden */
  1022. _mirroredCameraPosition: Nullable<Vector3>;
  1023. /**
  1024. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1025. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1026. */
  1027. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1028. /**
  1029. * Observable event triggered each time an keyboard event is received from the hosting window
  1030. */
  1031. onKeyboardObservable: Observable<KeyboardInfo>;
  1032. private _onKeyDown;
  1033. private _onKeyUp;
  1034. private _onCanvasFocusObserver;
  1035. private _onCanvasBlurObserver;
  1036. private _useRightHandedSystem;
  1037. /**
  1038. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1039. */
  1040. useRightHandedSystem: boolean;
  1041. /**
  1042. * Sets the step Id used by deterministic lock step
  1043. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1044. * @param newStepId defines the step Id
  1045. */
  1046. setStepId(newStepId: number): void;
  1047. /**
  1048. * Gets the step Id used by deterministic lock step
  1049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1050. * @returns the step Id
  1051. */
  1052. getStepId(): number;
  1053. /**
  1054. * Gets the internal step used by deterministic lock step
  1055. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1056. * @returns the internal step
  1057. */
  1058. getInternalStep(): number;
  1059. private _fogEnabled;
  1060. /**
  1061. * Gets or sets a boolean indicating if fog is enabled on this scene
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. */
  1064. fogEnabled: boolean;
  1065. private _fogMode;
  1066. /**
  1067. * Gets or sets the fog mode to use
  1068. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1069. */
  1070. fogMode: number;
  1071. /**
  1072. * Gets or sets the fog color to use
  1073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1074. */
  1075. fogColor: Color3;
  1076. /**
  1077. * Gets or sets the fog density to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogDensity: number;
  1081. /**
  1082. * Gets or sets the fog start distance to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogStart: number;
  1086. /**
  1087. * Gets or sets the fog end distance to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogEnd: number;
  1091. private _shadowsEnabled;
  1092. /**
  1093. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1094. */
  1095. shadowsEnabled: boolean;
  1096. private _lightsEnabled;
  1097. /**
  1098. * Gets or sets a boolean indicating if lights are enabled on this scene
  1099. */
  1100. lightsEnabled: boolean;
  1101. /**
  1102. * All of the lights added to this scene
  1103. * @see http://doc.babylonjs.com/babylon101/lights
  1104. */
  1105. lights: Light[];
  1106. /** All of the cameras added to this scene.
  1107. * @see http://doc.babylonjs.com/babylon101/cameras
  1108. */
  1109. cameras: Camera[];
  1110. /** All of the active cameras added to this scene. */
  1111. activeCameras: Camera[];
  1112. /** The current active camera */
  1113. activeCamera: Nullable<Camera>;
  1114. /**
  1115. * All of the tranform nodes added to this scene
  1116. * @see http://doc.babylonjs.com/how_to/transformnode
  1117. */
  1118. transformNodes: TransformNode[];
  1119. /**
  1120. * All of the (abstract) meshes added to this scene
  1121. */
  1122. meshes: AbstractMesh[];
  1123. /**
  1124. * All of the animation groups added to this scene
  1125. * @see http://doc.babylonjs.com/how_to/group
  1126. */
  1127. animationGroups: AnimationGroup[];
  1128. private _geometries;
  1129. /**
  1130. * All of the materials added to this scene
  1131. * @see http://doc.babylonjs.com/babylon101/materials
  1132. */
  1133. materials: Material[];
  1134. /**
  1135. * All of the multi-materials added to this scene
  1136. * @see http://doc.babylonjs.com/how_to/multi_materials
  1137. */
  1138. multiMaterials: MultiMaterial[];
  1139. private _defaultMaterial;
  1140. /** The default material used on meshes when no material is affected */
  1141. /** The default material used on meshes when no material is affected */
  1142. defaultMaterial: Material;
  1143. private _texturesEnabled;
  1144. /**
  1145. * Gets or sets a boolean indicating if textures are enabled on this scene
  1146. */
  1147. texturesEnabled: boolean;
  1148. /**
  1149. * All of the textures added to this scene
  1150. */
  1151. textures: BaseTexture[];
  1152. /**
  1153. * Gets or sets a boolean indicating if particles are enabled on this scene
  1154. */
  1155. particlesEnabled: boolean;
  1156. /**
  1157. * All of the particle systems added to this scene
  1158. * @see http://doc.babylonjs.com/babylon101/particles
  1159. */
  1160. particleSystems: IParticleSystem[];
  1161. /**
  1162. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1163. */
  1164. spritesEnabled: boolean;
  1165. /**
  1166. * All of the sprite managers added to this scene
  1167. * @see http://doc.babylonjs.com/babylon101/sprites
  1168. */
  1169. spriteManagers: SpriteManager[];
  1170. /**
  1171. * The list of layers (background and foreground) of the scene
  1172. */
  1173. layers: Layer[];
  1174. /**
  1175. * The list of effect layers (highlights/glow) added to the scene
  1176. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1177. * @see http://doc.babylonjs.com/how_to/glow_layer
  1178. */
  1179. effectLayers: EffectLayer[];
  1180. private _skeletonsEnabled;
  1181. /**
  1182. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1183. */
  1184. skeletonsEnabled: boolean;
  1185. /**
  1186. * The list of skeletons added to the scene
  1187. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1188. */
  1189. skeletons: Skeleton[];
  1190. /**
  1191. * The list of morph target managers added to the scene
  1192. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1193. */
  1194. morphTargetManagers: MorphTargetManager[];
  1195. /**
  1196. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1197. */
  1198. lensFlaresEnabled: boolean;
  1199. /**
  1200. * The list of lens flare system added to the scene
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1202. */
  1203. lensFlareSystems: LensFlareSystem[];
  1204. /**
  1205. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1207. */
  1208. collisionsEnabled: boolean;
  1209. private _workerCollisions;
  1210. /** @hidden */
  1211. collisionCoordinator: ICollisionCoordinator;
  1212. /**
  1213. * Defines the gravity applied to this scene (used only for collisions)
  1214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1215. */
  1216. gravity: Vector3;
  1217. /**
  1218. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1219. */
  1220. postProcessesEnabled: boolean;
  1221. /**
  1222. * The list of postprocesses added to the scene
  1223. */
  1224. postProcesses: PostProcess[];
  1225. /**
  1226. * Gets the current postprocess manager
  1227. */
  1228. postProcessManager: PostProcessManager;
  1229. private _postProcessRenderPipelineManager;
  1230. /**
  1231. * Gets the postprocess render pipeline manager
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1233. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1234. */
  1235. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1236. /**
  1237. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1238. */
  1239. renderTargetsEnabled: boolean;
  1240. /**
  1241. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1242. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1243. */
  1244. dumpNextRenderTargets: boolean;
  1245. /**
  1246. * The list of user defined render targets added to the scene
  1247. */
  1248. customRenderTargets: RenderTargetTexture[];
  1249. /**
  1250. * Defines if texture loading must be delayed
  1251. * If true, textures will only be loaded when they need to be rendered
  1252. */
  1253. useDelayedTextureLoading: boolean;
  1254. /**
  1255. * Gets the list of meshes imported to the scene through SceneLoader
  1256. */
  1257. importedMeshesFiles: String[];
  1258. /**
  1259. * Gets or sets a boolean indicating if probes are enabled on this scene
  1260. */
  1261. probesEnabled: boolean;
  1262. /**
  1263. * The list of reflection probes added to the scene
  1264. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1265. */
  1266. reflectionProbes: ReflectionProbe[];
  1267. /**
  1268. * @hidden
  1269. */
  1270. database: Database;
  1271. /**
  1272. * Gets or sets the action manager associated with the scene
  1273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1274. */
  1275. actionManager: ActionManager;
  1276. /** @hidden */
  1277. _actionManagers: ActionManager[];
  1278. private _meshesForIntersections;
  1279. /**
  1280. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1281. */
  1282. proceduralTexturesEnabled: boolean;
  1283. /**
  1284. * The list of procedural textures added to the scene
  1285. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1286. */
  1287. proceduralTextures: ProceduralTexture[];
  1288. private _mainSoundTrack;
  1289. /**
  1290. * The list of sound tracks added to the scene
  1291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1292. */
  1293. soundTracks: SoundTrack[];
  1294. private _audioEnabled;
  1295. private _headphone;
  1296. /**
  1297. * Gets the main soundtrack associated with the scene
  1298. */
  1299. readonly mainSoundTrack: SoundTrack;
  1300. /**
  1301. * Gets or sets the VRExperienceHelper attached to the scene
  1302. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1303. * @ignorenaming
  1304. */
  1305. VRHelper: VRExperienceHelper;
  1306. /**
  1307. * Gets or sets the simplification queue attached to the scene
  1308. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1309. */
  1310. simplificationQueue: SimplificationQueue;
  1311. private _engine;
  1312. private _totalVertices;
  1313. /** @hidden */
  1314. _activeIndices: PerfCounter;
  1315. /** @hidden */
  1316. _activeParticles: PerfCounter;
  1317. /** @hidden */
  1318. _activeBones: PerfCounter;
  1319. private _animationRatio;
  1320. private _animationTimeLast;
  1321. private _animationTime;
  1322. /**
  1323. * Gets or sets a general scale for animation speed
  1324. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1325. */
  1326. animationTimeScale: number;
  1327. /** @hidden */
  1328. _cachedMaterial: Nullable<Material>;
  1329. /** @hidden */
  1330. _cachedEffect: Nullable<Effect>;
  1331. /** @hidden */
  1332. _cachedVisibility: Nullable<number>;
  1333. private _renderId;
  1334. private _executeWhenReadyTimeoutId;
  1335. private _intermediateRendering;
  1336. private _viewUpdateFlag;
  1337. private _projectionUpdateFlag;
  1338. private _alternateViewUpdateFlag;
  1339. private _alternateProjectionUpdateFlag;
  1340. /** @hidden */
  1341. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1342. private _activeRequests;
  1343. private _pendingData;
  1344. private _isDisposed;
  1345. /**
  1346. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1347. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1348. */
  1349. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1350. private _activeMeshes;
  1351. private _processedMaterials;
  1352. private _renderTargets;
  1353. /** @hidden */
  1354. _activeParticleSystems: SmartArray<IParticleSystem>;
  1355. private _activeSkeletons;
  1356. private _softwareSkinnedMeshes;
  1357. private _renderingManager;
  1358. private _physicsEngine;
  1359. /** @hidden */
  1360. _activeAnimatables: Animatable[];
  1361. private _transformMatrix;
  1362. private _sceneUbo;
  1363. private _alternateSceneUbo;
  1364. private _pickWithRayInverseMatrix;
  1365. private _boundingBoxRenderer;
  1366. private _outlineRenderer;
  1367. private _viewMatrix;
  1368. private _projectionMatrix;
  1369. private _alternateViewMatrix;
  1370. private _alternateProjectionMatrix;
  1371. private _alternateTransformMatrix;
  1372. private _useAlternateCameraConfiguration;
  1373. private _alternateRendering;
  1374. /** @hidden */
  1375. _forcedViewPosition: Nullable<Vector3>;
  1376. /** @hidden */
  1377. readonly _isAlternateRenderingEnabled: boolean;
  1378. private _frustumPlanes;
  1379. /**
  1380. * Gets the list of frustum planes (built from the active camera)
  1381. */
  1382. readonly frustumPlanes: Plane[];
  1383. /**
  1384. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1385. * This is useful if there are more lights that the maximum simulteanous authorized
  1386. */
  1387. requireLightSorting: boolean;
  1388. private _selectionOctree;
  1389. private _pointerOverMesh;
  1390. private _pointerOverSprite;
  1391. private _debugLayer;
  1392. private _depthRenderer;
  1393. private _geometryBufferRenderer;
  1394. /**
  1395. * Gets the current geometry buffer associated to the scene.
  1396. */
  1397. /**
  1398. * Sets the current geometry buffer for the scene.
  1399. */
  1400. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1401. private _pickedDownMesh;
  1402. private _pickedUpMesh;
  1403. private _pickedDownSprite;
  1404. private _externalData;
  1405. private _uid;
  1406. /**
  1407. * Creates a new Scene
  1408. * @param engine defines the engine to use to render this scene
  1409. */
  1410. constructor(engine: Engine);
  1411. /**
  1412. * Gets the debug layer associated with the scene
  1413. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1414. */
  1415. readonly debugLayer: DebugLayer;
  1416. /**
  1417. * Gets a boolean indicating if collisions are processed on a web worker
  1418. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1419. */
  1420. workerCollisions: boolean;
  1421. /**
  1422. * Gets the octree used to boost mesh selection (picking)
  1423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1424. */
  1425. readonly selectionOctree: Octree<AbstractMesh>;
  1426. /**
  1427. * Gets the mesh that is currently under the pointer
  1428. */
  1429. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1430. /**
  1431. * Gets the current on-screen X position of the pointer
  1432. */
  1433. readonly pointerX: number;
  1434. /**
  1435. * Gets the current on-screen Y position of the pointer
  1436. */
  1437. readonly pointerY: number;
  1438. /**
  1439. * Gets the cached material (ie. the latest rendered one)
  1440. * @returns the cached material
  1441. */
  1442. getCachedMaterial(): Nullable<Material>;
  1443. /**
  1444. * Gets the cached effect (ie. the latest rendered one)
  1445. * @returns the cached effect
  1446. */
  1447. getCachedEffect(): Nullable<Effect>;
  1448. /**
  1449. * Gets the cached visibility state (ie. the latest rendered one)
  1450. * @returns the cached visibility state
  1451. */
  1452. getCachedVisibility(): Nullable<number>;
  1453. /**
  1454. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1455. * @param material defines the current material
  1456. * @param effect defines the current effect
  1457. * @param visibility defines the current visibility state
  1458. * @returns true if one parameter is not cached
  1459. */
  1460. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1461. /**
  1462. * Gets the bounding box renderer associated with the scene
  1463. * @returns a BoundingBoxRenderer
  1464. */
  1465. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1466. /**
  1467. * Gets the outline renderer associated with the scene
  1468. * @returns a OutlineRenderer
  1469. */
  1470. getOutlineRenderer(): OutlineRenderer;
  1471. /**
  1472. * Gets the engine associated with the scene
  1473. * @returns an Engine
  1474. */
  1475. getEngine(): Engine;
  1476. /**
  1477. * Gets the total number of vertices rendered per frame
  1478. * @returns the total number of vertices rendered per frame
  1479. */
  1480. getTotalVertices(): number;
  1481. /**
  1482. * Gets the performance counter for total vertices
  1483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1484. */
  1485. readonly totalVerticesPerfCounter: PerfCounter;
  1486. /**
  1487. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1488. * @returns the total number of active indices rendered per frame
  1489. */
  1490. getActiveIndices(): number;
  1491. /**
  1492. * Gets the performance counter for active indices
  1493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1494. */
  1495. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1496. /**
  1497. * Gets the total number of active particles rendered per frame
  1498. * @returns the total number of active particles rendered per frame
  1499. */
  1500. getActiveParticles(): number;
  1501. /**
  1502. * Gets the performance counter for active particles
  1503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1504. */
  1505. readonly activeParticlesPerfCounter: PerfCounter;
  1506. /**
  1507. * Gets the total number of active bones rendered per frame
  1508. * @returns the total number of active bones rendered per frame
  1509. */
  1510. getActiveBones(): number;
  1511. /**
  1512. * Gets the performance counter for active bones
  1513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1514. */
  1515. readonly activeBonesPerfCounter: PerfCounter;
  1516. /** @hidden */
  1517. getInterFramePerfCounter(): number;
  1518. /** @hidden */
  1519. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1520. /** @hidden */
  1521. getLastFrameDuration(): number;
  1522. /** @hidden */
  1523. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1524. /** @hidden */
  1525. getEvaluateActiveMeshesDuration(): number;
  1526. /** @hidden */
  1527. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1528. /**
  1529. * Gets the array of active meshes
  1530. * @returns an array of AbstractMesh
  1531. */
  1532. getActiveMeshes(): SmartArray<AbstractMesh>;
  1533. /** @hidden */
  1534. getRenderTargetsDuration(): number;
  1535. /** @hidden */
  1536. getRenderDuration(): number;
  1537. /** @hidden */
  1538. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1539. /** @hidden */
  1540. getParticlesDuration(): number;
  1541. /** @hidden */
  1542. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1543. /** @hidden */
  1544. getSpritesDuration(): number;
  1545. /** @hidden */
  1546. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1547. /**
  1548. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1549. * @returns a number
  1550. */
  1551. getAnimationRatio(): number;
  1552. /**
  1553. * Gets an unique Id for the current frame
  1554. * @returns a number
  1555. */
  1556. getRenderId(): number;
  1557. /** Call this function if you want to manually increment the render Id*/
  1558. incrementRenderId(): void;
  1559. private _updatePointerPosition(evt);
  1560. private _createUbo();
  1561. private _createAlternateUbo();
  1562. /**
  1563. * Use this method to simulate a pointer move on a mesh
  1564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1567. * @returns the current scene
  1568. */
  1569. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1570. private _processPointerMove(pickResult, evt);
  1571. /**
  1572. * Use this method to simulate a pointer down on a mesh
  1573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1576. * @returns the current scene
  1577. */
  1578. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1579. private _processPointerDown(pickResult, evt);
  1580. /**
  1581. * Use this method to simulate a pointer up on a mesh
  1582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1585. * @returns the current scene
  1586. */
  1587. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1588. private _processPointerUp(pickResult, evt, clickInfo);
  1589. /**
  1590. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1591. * @param attachUp defines if you want to attach events to pointerup
  1592. * @param attachDown defines if you want to attach events to pointerdown
  1593. * @param attachMove defines if you want to attach events to pointermove
  1594. */
  1595. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1596. /** Detaches all event handlers*/
  1597. detachControl(): void;
  1598. /**
  1599. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1600. * Delay loaded resources are not taking in account
  1601. * @return true if all required resources are ready
  1602. */
  1603. isReady(): boolean;
  1604. /** Resets all cached information relative to material (including effect and visibility) */
  1605. resetCachedMaterial(): void;
  1606. /**
  1607. * Registers a function to be called before every frame render
  1608. * @param func defines the function to register
  1609. */
  1610. registerBeforeRender(func: () => void): void;
  1611. /**
  1612. * Unregisters a function called before every frame render
  1613. * @param func defines the function to unregister
  1614. */
  1615. unregisterBeforeRender(func: () => void): void;
  1616. /**
  1617. * Registers a function to be called after every frame render
  1618. * @param func defines the function to register
  1619. */
  1620. registerAfterRender(func: () => void): void;
  1621. /**
  1622. * Unregisters a function called after every frame render
  1623. * @param func defines the function to unregister
  1624. */
  1625. unregisterAfterRender(func: () => void): void;
  1626. private _executeOnceBeforeRender(func);
  1627. /**
  1628. * The provided function will run before render once and will be disposed afterwards.
  1629. * A timeout delay can be provided so that the function will be executed in N ms.
  1630. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1631. * @param func The function to be executed.
  1632. * @param timeout optional delay in ms
  1633. */
  1634. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1635. /** @hidden */
  1636. _addPendingData(data: any): void;
  1637. /** @hidden */
  1638. _removePendingData(data: any): void;
  1639. /**
  1640. * Returns the number of items waiting to be loaded
  1641. * @returns the number of items waiting to be loaded
  1642. */
  1643. getWaitingItemsCount(): number;
  1644. /**
  1645. * Returns a boolean indicating if the scene is still loading data
  1646. */
  1647. readonly isLoading: boolean;
  1648. /**
  1649. * Registers a function to be executed when the scene is ready
  1650. * @param {Function} func - the function to be executed
  1651. */
  1652. executeWhenReady(func: () => void): void;
  1653. /**
  1654. * Returns a promise that resolves when the scene is ready
  1655. * @returns A promise that resolves when the scene is ready
  1656. */
  1657. whenReadyAsync(): Promise<void>;
  1658. /** @hidden */
  1659. _checkIsReady(): void;
  1660. /**
  1661. * Will start the animation sequence of a given target
  1662. * @param target defines the target
  1663. * @param from defines from which frame should animation start
  1664. * @param to defines until which frame should animation run.
  1665. * @param weight defines the weight to apply to the animation (1.0 by default)
  1666. * @param loop defines if the animation loops
  1667. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1668. * @param onAnimationEnd defines the function to be executed when the animation ends
  1669. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1670. * @returns the animatable object created for this animation
  1671. */
  1672. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1673. /**
  1674. * Will start the animation sequence of a given target
  1675. * @param target defines the target
  1676. * @param from defines from which frame should animation start
  1677. * @param to defines until which frame should animation run.
  1678. * @param loop defines if the animation loops
  1679. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1680. * @param onAnimationEnd defines the function to be executed when the animation ends
  1681. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1682. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1683. * @returns the animatable object created for this animation
  1684. */
  1685. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1686. /**
  1687. * Begin a new animation on a given node
  1688. * @param target defines the target where the animation will take place
  1689. * @param animations defines the list of animations to start
  1690. * @param from defines the initial value
  1691. * @param to defines the final value
  1692. * @param loop defines if you want animation to loop (off by default)
  1693. * @param speedRatio defines the speed ratio to apply to all animations
  1694. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1695. * @returns the list of created animatables
  1696. */
  1697. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1698. /**
  1699. * Begin a new animation on a given node and its hierarchy
  1700. * @param target defines the root node where the animation will take place
  1701. * @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.
  1702. * @param animations defines the list of animations to start
  1703. * @param from defines the initial value
  1704. * @param to defines the final value
  1705. * @param loop defines if you want animation to loop (off by default)
  1706. * @param speedRatio defines the speed ratio to apply to all animations
  1707. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1708. * @returns the list of animatables created for all nodes
  1709. */
  1710. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1711. /**
  1712. * Gets the animatable associated with a specific target
  1713. * @param target defines the target of the animatable
  1714. * @returns the required animatable if found
  1715. */
  1716. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1717. /**
  1718. * Gets all animatables associated with a given target
  1719. * @param target defines the target to look animatables for
  1720. * @returns an array of Animatables
  1721. */
  1722. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1723. /**
  1724. * Gets all animatable attached to the scene
  1725. */
  1726. readonly animatables: Animatable[];
  1727. /**
  1728. * Will stop the animation of the given target
  1729. * @param target - the target
  1730. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1731. */
  1732. stopAnimation(target: any, animationName?: string): void;
  1733. /**
  1734. * Stops and removes all animations that have been applied to the scene
  1735. */
  1736. stopAllAnimations(): void;
  1737. private _animate();
  1738. /** @hidden */
  1739. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1740. private _processLateAnimationBindingsForMatrices(holder);
  1741. private _processLateAnimationBindingsForQuaternions(holder);
  1742. private _processLateAnimationBindings();
  1743. /** @hidden */
  1744. _switchToAlternateCameraConfiguration(active: boolean): void;
  1745. /**
  1746. * Gets the current view matrix
  1747. * @returns a Matrix
  1748. */
  1749. getViewMatrix(): Matrix;
  1750. /**
  1751. * Gets the current projection matrix
  1752. * @returns a Matrix
  1753. */
  1754. getProjectionMatrix(): Matrix;
  1755. /**
  1756. * Gets the current transform matrix
  1757. * @returns a Matrix made of View * Projection
  1758. */
  1759. getTransformMatrix(): Matrix;
  1760. /**
  1761. * Sets the current transform matrix
  1762. * @param view defines the View matrix to use
  1763. * @param projection defines the Projection matrix to use
  1764. */
  1765. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1766. /** @hidden */
  1767. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1768. /**
  1769. * Gets the uniform buffer used to store scene data
  1770. * @returns a UniformBuffer
  1771. */
  1772. getSceneUniformBuffer(): UniformBuffer;
  1773. /**
  1774. * Gets an unique (relatively to the current scene) Id
  1775. * @returns an unique number for the scene
  1776. */
  1777. getUniqueId(): number;
  1778. /**
  1779. * Add a mesh to the list of scene's meshes
  1780. * @param newMesh defines the mesh to add
  1781. */
  1782. addMesh(newMesh: AbstractMesh): void;
  1783. /**
  1784. * Remove a mesh for the list of scene's meshes
  1785. * @param toRemove defines the mesh to remove
  1786. * @param recursive if all child meshes should also be removed from the scene
  1787. * @returns the index where the mesh was in the mesh list
  1788. */
  1789. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1790. /**
  1791. * Add a transform node to the list of scene's transform nodes
  1792. * @param newTransformNode defines the transform node to add
  1793. */
  1794. addTransformNode(newTransformNode: TransformNode): void;
  1795. /**
  1796. * Remove a transform node for the list of scene's transform nodes
  1797. * @param toRemove defines the transform node to remove
  1798. * @returns the index where the transform node was in the transform node list
  1799. */
  1800. removeTransformNode(toRemove: TransformNode): number;
  1801. /**
  1802. * Remove a skeleton for the list of scene's skeletons
  1803. * @param toRemove defines the skeleton to remove
  1804. * @returns the index where the skeleton was in the skeleton list
  1805. */
  1806. removeSkeleton(toRemove: Skeleton): number;
  1807. /**
  1808. * Remove a morph target for the list of scene's morph targets
  1809. * @param toRemove defines the morph target to remove
  1810. * @returns the index where the morph target was in the morph target list
  1811. */
  1812. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1813. /**
  1814. * Remove a light for the list of scene's lights
  1815. * @param toRemove defines the light to remove
  1816. * @returns the index where the light was in the light list
  1817. */
  1818. removeLight(toRemove: Light): number;
  1819. /**
  1820. * Remove a camera for the list of scene's cameras
  1821. * @param toRemove defines the camera to remove
  1822. * @returns the index where the camera was in the camera list
  1823. */
  1824. removeCamera(toRemove: Camera): number;
  1825. /**
  1826. * Remove a particle system for the list of scene's particle systems
  1827. * @param toRemove defines the particle system to remove
  1828. * @returns the index where the particle system was in the particle system list
  1829. */
  1830. removeParticleSystem(toRemove: IParticleSystem): number;
  1831. /**
  1832. * Remove a animation for the list of scene's animations
  1833. * @param toRemove defines the animation to remove
  1834. * @returns the index where the animation was in the animation list
  1835. */
  1836. removeAnimation(toRemove: Animation): number;
  1837. /**
  1838. * Removes the given animation group from this scene.
  1839. * @param toRemove The animation group to remove
  1840. * @returns The index of the removed animation group
  1841. */
  1842. removeAnimationGroup(toRemove: AnimationGroup): number;
  1843. /**
  1844. * Removes the given multi-material from this scene.
  1845. * @param toRemove The multi-material to remove
  1846. * @returns The index of the removed multi-material
  1847. */
  1848. removeMultiMaterial(toRemove: MultiMaterial): number;
  1849. /**
  1850. * Removes the given material from this scene.
  1851. * @param toRemove The material to remove
  1852. * @returns The index of the removed material
  1853. */
  1854. removeMaterial(toRemove: Material): number;
  1855. /**
  1856. * Removes the given lens flare system from this scene.
  1857. * @param toRemove The lens flare system to remove
  1858. * @returns The index of the removed lens flare system
  1859. */
  1860. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1861. /**
  1862. * Removes the given action manager from this scene.
  1863. * @param toRemove The action manager to remove
  1864. * @returns The index of the removed action manager
  1865. */
  1866. removeActionManager(toRemove: ActionManager): number;
  1867. /**
  1868. * Removes the given effect layer from this scene.
  1869. * @param toRemove defines the effect layer to remove
  1870. * @returns the index of the removed effect layer
  1871. */
  1872. removeEffectLayer(toRemove: EffectLayer): number;
  1873. /**
  1874. * Removes the given texture from this scene.
  1875. * @param toRemove The texture to remove
  1876. * @returns The index of the removed texture
  1877. */
  1878. removeTexture(toRemove: BaseTexture): number;
  1879. /**
  1880. * Adds the given light to this scene
  1881. * @param newLight The light to add
  1882. */
  1883. addLight(newLight: Light): void;
  1884. /**
  1885. * Sorts the list list based on light priorities
  1886. */
  1887. sortLightsByPriority(): void;
  1888. /**
  1889. * Adds the given camera to this scene
  1890. * @param newCamera The camera to add
  1891. */
  1892. addCamera(newCamera: Camera): void;
  1893. /**
  1894. * Adds the given skeleton to this scene
  1895. * @param newSkeleton The skeleton to add
  1896. */
  1897. addSkeleton(newSkeleton: Skeleton): void;
  1898. /**
  1899. * Adds the given particle system to this scene
  1900. * @param newParticleSystem The particle system to add
  1901. */
  1902. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1903. /**
  1904. * Adds the given animation to this scene
  1905. * @param newAnimation The animation to add
  1906. */
  1907. addAnimation(newAnimation: Animation): void;
  1908. /**
  1909. * Adds the given animation group to this scene.
  1910. * @param newAnimationGroup The animation group to add
  1911. */
  1912. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1913. /**
  1914. * Adds the given multi-material to this scene
  1915. * @param newMultiMaterial The multi-material to add
  1916. */
  1917. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1918. /**
  1919. * Adds the given material to this scene
  1920. * @param newMaterial The material to add
  1921. */
  1922. addMaterial(newMaterial: Material): void;
  1923. /**
  1924. * Adds the given morph target to this scene
  1925. * @param newMorphTargetManager The morph target to add
  1926. */
  1927. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1928. /**
  1929. * Adds the given geometry to this scene
  1930. * @param newGeometry The geometry to add
  1931. */
  1932. addGeometry(newGeometry: Geometry): void;
  1933. /**
  1934. * Adds the given lens flare system to this scene
  1935. * @param newLensFlareSystem The lens flare system to add
  1936. */
  1937. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1938. /**
  1939. * Adds the given effect layer to this scene
  1940. * @param newEffectLayer defines the effect layer to add
  1941. */
  1942. addEffectLayer(newEffectLayer: EffectLayer): void;
  1943. /**
  1944. * Adds the given action manager to this scene
  1945. * @param newActionManager The action manager to add
  1946. */
  1947. addActionManager(newActionManager: ActionManager): void;
  1948. /**
  1949. * Adds the given texture to this scene.
  1950. * @param newTexture The texture to add
  1951. */
  1952. addTexture(newTexture: BaseTexture): void;
  1953. /**
  1954. * Switch active camera
  1955. * @param newCamera defines the new active camera
  1956. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1957. */
  1958. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1959. /**
  1960. * sets the active camera of the scene using its ID
  1961. * @param id defines the camera's ID
  1962. * @return the new active camera or null if none found.
  1963. */
  1964. setActiveCameraByID(id: string): Nullable<Camera>;
  1965. /**
  1966. * sets the active camera of the scene using its name
  1967. * @param name defines the camera's name
  1968. * @returns the new active camera or null if none found.
  1969. */
  1970. setActiveCameraByName(name: string): Nullable<Camera>;
  1971. /**
  1972. * get an animation group using its name
  1973. * @param name defines the material's name
  1974. * @return the animation group or null if none found.
  1975. */
  1976. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1977. /**
  1978. * get a material using its id
  1979. * @param id defines the material's ID
  1980. * @return the material or null if none found.
  1981. */
  1982. getMaterialByID(id: string): Nullable<Material>;
  1983. /**
  1984. * Gets a material using its name
  1985. * @param name defines the material's name
  1986. * @return the material or null if none found.
  1987. */
  1988. getMaterialByName(name: string): Nullable<Material>;
  1989. /**
  1990. * Gets a lens flare system using its name
  1991. * @param name defines the name to look for
  1992. * @returns the lens flare system or null if not found
  1993. */
  1994. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1995. /**
  1996. * Gets a lens flare system using its id
  1997. * @param id defines the id to look for
  1998. * @returns the lens flare system or null if not found
  1999. */
  2000. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2001. /**
  2002. * Gets a camera using its id
  2003. * @param id defines the id to look for
  2004. * @returns the camera or null if not found
  2005. */
  2006. getCameraByID(id: string): Nullable<Camera>;
  2007. /**
  2008. * Gets a camera using its unique id
  2009. * @param uniqueId defines the unique id to look for
  2010. * @returns the camera or null if not found
  2011. */
  2012. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2013. /**
  2014. * Gets a camera using its name
  2015. * @param name defines the camera's name
  2016. * @return the camera or null if none found.
  2017. */
  2018. getCameraByName(name: string): Nullable<Camera>;
  2019. /**
  2020. * Gets a bone using its id
  2021. * @param id defines the bone's id
  2022. * @return the bone or null if not found
  2023. */
  2024. getBoneByID(id: string): Nullable<Bone>;
  2025. /**
  2026. * Gets a bone using its id
  2027. * @param name defines the bone's name
  2028. * @return the bone or null if not found
  2029. */
  2030. getBoneByName(name: string): Nullable<Bone>;
  2031. /**
  2032. * Gets a light node using its name
  2033. * @param name defines the the light's name
  2034. * @return the light or null if none found.
  2035. */
  2036. getLightByName(name: string): Nullable<Light>;
  2037. /**
  2038. * Gets a light node using its id
  2039. * @param id defines the light's id
  2040. * @return the light or null if none found.
  2041. */
  2042. getLightByID(id: string): Nullable<Light>;
  2043. /**
  2044. * Gets a light node using its scene-generated unique ID
  2045. * @param uniqueId defines the light's unique id
  2046. * @return the light or null if none found.
  2047. */
  2048. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2049. /**
  2050. * Gets a particle system by id
  2051. * @param id defines the particle system id
  2052. * @return the corresponding system or null if none found
  2053. */
  2054. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2055. /**
  2056. * Gets a geometry using its ID
  2057. * @param id defines the geometry's id
  2058. * @return the geometry or null if none found.
  2059. */
  2060. getGeometryByID(id: string): Nullable<Geometry>;
  2061. /**
  2062. * Add a new geometry to this scene
  2063. * @param geometry defines the geometry to be added to the scene.
  2064. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2065. * @return a boolean defining if the geometry was added or not
  2066. */
  2067. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2068. /**
  2069. * Removes an existing geometry
  2070. * @param geometry defines the geometry to be removed from the scene
  2071. * @return a boolean defining if the geometry was removed or not
  2072. */
  2073. removeGeometry(geometry: Geometry): boolean;
  2074. /**
  2075. * Gets the list of geometries attached to the scene
  2076. * @returns an array of Geometry
  2077. */
  2078. getGeometries(): Geometry[];
  2079. /**
  2080. * Gets the first added mesh found of a given ID
  2081. * @param id defines the id to search for
  2082. * @return the mesh found or null if not found at all
  2083. */
  2084. getMeshByID(id: string): Nullable<AbstractMesh>;
  2085. /**
  2086. * Gets a list of meshes using their id
  2087. * @param id defines the id to search for
  2088. * @returns a list of meshes
  2089. */
  2090. getMeshesByID(id: string): Array<AbstractMesh>;
  2091. /**
  2092. * Gets the first added transform node found of a given ID
  2093. * @param id defines the id to search for
  2094. * @return the found transform node or null if not found at all.
  2095. */
  2096. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2097. /**
  2098. * Gets a list of transform nodes using their id
  2099. * @param id defines the id to search for
  2100. * @returns a list of transform nodes
  2101. */
  2102. getTransformNodesByID(id: string): Array<TransformNode>;
  2103. /**
  2104. * Gets a mesh with its auto-generated unique id
  2105. * @param uniqueId defines the unique id to search for
  2106. * @return the found mesh or null if not found at all.
  2107. */
  2108. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2109. /**
  2110. * Gets a the last added mesh using a given id
  2111. * @param id defines the id to search for
  2112. * @return the found mesh or null if not found at all.
  2113. */
  2114. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2115. /**
  2116. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2117. * @param id defines the id to search for
  2118. * @return the found node or null if not found at all
  2119. */
  2120. getLastEntryByID(id: string): Nullable<Node>;
  2121. /**
  2122. * Gets a node (Mesh, Camera, Light) using a given id
  2123. * @param id defines the id to search for
  2124. * @return the found node or null if not found at all
  2125. */
  2126. getNodeByID(id: string): Nullable<Node>;
  2127. /**
  2128. * Gets a node (Mesh, Camera, Light) using a given name
  2129. * @param name defines the name to search for
  2130. * @return the found node or null if not found at all.
  2131. */
  2132. getNodeByName(name: string): Nullable<Node>;
  2133. /**
  2134. * Gets a mesh using a given name
  2135. * @param name defines the name to search for
  2136. * @return the found mesh or null if not found at all.
  2137. */
  2138. getMeshByName(name: string): Nullable<AbstractMesh>;
  2139. /**
  2140. * Gets a transform node using a given name
  2141. * @param name defines the name to search for
  2142. * @return the found transform node or null if not found at all.
  2143. */
  2144. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2145. /**
  2146. * Gets a sound using a given name
  2147. * @param name defines the name to search for
  2148. * @return the found sound or null if not found at all.
  2149. */
  2150. getSoundByName(name: string): Nullable<Sound>;
  2151. /**
  2152. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2153. * @param id defines the id to search for
  2154. * @return the found skeleton or null if not found at all.
  2155. */
  2156. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2157. /**
  2158. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2159. * @param id defines the id to search for
  2160. * @return the found skeleton or null if not found at all.
  2161. */
  2162. getSkeletonById(id: string): Nullable<Skeleton>;
  2163. /**
  2164. * Gets a skeleton using a given name
  2165. * @param name defines the name to search for
  2166. * @return the found skeleton or null if not found at all.
  2167. */
  2168. getSkeletonByName(name: string): Nullable<Skeleton>;
  2169. /**
  2170. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2171. * @param id defines the id to search for
  2172. * @return the found morph target manager or null if not found at all.
  2173. */
  2174. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2175. /**
  2176. * Gets a boolean indicating if the given mesh is active
  2177. * @param mesh defines the mesh to look for
  2178. * @returns true if the mesh is in the active list
  2179. */
  2180. isActiveMesh(mesh: AbstractMesh): boolean;
  2181. /**
  2182. * Return a the first highlight layer of the scene with a given name.
  2183. * @param name The name of the highlight layer to look for.
  2184. * @return The highlight layer if found otherwise null.
  2185. */
  2186. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2187. /**
  2188. * Return a the first highlight layer of the scene with a given name.
  2189. * @param name The name of the highlight layer to look for.
  2190. * @return The highlight layer if found otherwise null.
  2191. */
  2192. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2193. /**
  2194. * Return a unique id as a string which can serve as an identifier for the scene
  2195. */
  2196. readonly uid: string;
  2197. /**
  2198. * Add an externaly attached data from its key.
  2199. * This method call will fail and return false, if such key already exists.
  2200. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2201. * @param key the unique key that identifies the data
  2202. * @param data the data object to associate to the key for this Engine instance
  2203. * @return true if no such key were already present and the data was added successfully, false otherwise
  2204. */
  2205. addExternalData<T>(key: string, data: T): boolean;
  2206. /**
  2207. * Get an externaly attached data from its key
  2208. * @param key the unique key that identifies the data
  2209. * @return the associated data, if present (can be null), or undefined if not present
  2210. */
  2211. getExternalData<T>(key: string): Nullable<T>;
  2212. /**
  2213. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2214. * @param key the unique key that identifies the data
  2215. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2216. * @return the associated data, can be null if the factory returned null.
  2217. */
  2218. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2219. /**
  2220. * Remove an externaly attached data from the Engine instance
  2221. * @param key the unique key that identifies the data
  2222. * @return true if the data was successfully removed, false if it doesn't exist
  2223. */
  2224. removeExternalData(key: string): boolean;
  2225. private _evaluateSubMesh(subMesh, mesh);
  2226. /**
  2227. * Clear the processed materials smart array preventing retention point in material dispose.
  2228. */
  2229. freeProcessedMaterials(): void;
  2230. /**
  2231. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2232. */
  2233. freeActiveMeshes(): void;
  2234. /**
  2235. * Clear the info related to rendering groups preventing retention points during dispose.
  2236. */
  2237. freeRenderingGroups(): void;
  2238. /** @hidden */
  2239. _isInIntermediateRendering(): boolean;
  2240. private _activeMeshCandidateProvider;
  2241. /**
  2242. * Defines the current active mesh candidate provider
  2243. * @param provider defines the provider to use
  2244. */
  2245. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2246. /**
  2247. * Gets the current active mesh candidate provider
  2248. * @returns the current active mesh candidate provider
  2249. */
  2250. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2251. private _activeMeshesFrozen;
  2252. /**
  2253. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2254. * @returns the current scene
  2255. */
  2256. freezeActiveMeshes(): Scene;
  2257. /**
  2258. * Use this function to restart evaluating active meshes on every frame
  2259. * @returns the current scene
  2260. */
  2261. unfreezeActiveMeshes(): Scene;
  2262. private _evaluateActiveMeshes();
  2263. private _activeMesh(sourceMesh, mesh);
  2264. /**
  2265. * Update the transform matrix to update from the current active camera
  2266. * @param force defines a boolean used to force the update even if cache is up to date
  2267. */
  2268. updateTransformMatrix(force?: boolean): void;
  2269. /**
  2270. * 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)
  2271. * @param alternateCamera defines the camera to use
  2272. */
  2273. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2274. private _renderForCamera(camera, rigParent?);
  2275. private _processSubCameras(camera);
  2276. private _checkIntersections();
  2277. /**
  2278. * Render the scene
  2279. */
  2280. render(): void;
  2281. private _updateAudioParameters();
  2282. /**
  2283. * Gets or sets if audio support is enabled
  2284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2285. */
  2286. audioEnabled: boolean;
  2287. private _disableAudio();
  2288. private _enableAudio();
  2289. /**
  2290. * Gets or sets if audio will be output to headphones
  2291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2292. */
  2293. headphone: boolean;
  2294. private _switchAudioModeForHeadphones();
  2295. private _switchAudioModeForNormalSpeakers();
  2296. /**
  2297. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2298. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2299. * @returns the created depth renderer
  2300. */
  2301. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2302. /**
  2303. * Disables a depth renderer for a given camera
  2304. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2305. */
  2306. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2307. /**
  2308. * Enables a GeometryBufferRender and associates it with the scene
  2309. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2310. * @returns the GeometryBufferRenderer
  2311. */
  2312. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2313. /**
  2314. * Disables the GeometryBufferRender associated with the scene
  2315. */
  2316. disableGeometryBufferRenderer(): void;
  2317. /**
  2318. * Freeze all materials
  2319. * A frozen material will not be updatable but should be faster to render
  2320. */
  2321. freezeMaterials(): void;
  2322. /**
  2323. * Unfreeze all materials
  2324. * A frozen material will not be updatable but should be faster to render
  2325. */
  2326. unfreezeMaterials(): void;
  2327. /**
  2328. * Releases all held ressources
  2329. */
  2330. dispose(): void;
  2331. /**
  2332. * Gets if the scene is already disposed
  2333. */
  2334. readonly isDisposed: boolean;
  2335. /**
  2336. * Releases sounds & soundtracks
  2337. */
  2338. disposeSounds(): void;
  2339. /**
  2340. * Get the world extend vectors with an optional filter
  2341. *
  2342. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2343. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2344. */
  2345. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2346. min: Vector3;
  2347. max: Vector3;
  2348. };
  2349. /**
  2350. * Creates or updates the octree used to boost selection (picking)
  2351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2352. * @param maxCapacity defines the maximum capacity per leaf
  2353. * @param maxDepth defines the maximum depth of the octree
  2354. * @returns an octree of AbstractMesh
  2355. */
  2356. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2357. /**
  2358. * Creates a ray that can be used to pick in the scene
  2359. * @param x defines the x coordinate of the origin (on-screen)
  2360. * @param y defines the y coordinate of the origin (on-screen)
  2361. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2362. * @param camera defines the camera to use for the picking
  2363. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2364. * @returns a Ray
  2365. */
  2366. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2367. /**
  2368. * Creates a ray that can be used to pick in the scene
  2369. * @param x defines the x coordinate of the origin (on-screen)
  2370. * @param y defines the y coordinate of the origin (on-screen)
  2371. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2372. * @param result defines the ray where to store the picking ray
  2373. * @param camera defines the camera to use for the picking
  2374. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2375. * @returns the current scene
  2376. */
  2377. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2378. /**
  2379. * Creates a ray that can be used to pick in the scene
  2380. * @param x defines the x coordinate of the origin (on-screen)
  2381. * @param y defines the y coordinate of the origin (on-screen)
  2382. * @param camera defines the camera to use for the picking
  2383. * @returns a Ray
  2384. */
  2385. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2386. /**
  2387. * Creates a ray that can be used to pick in the scene
  2388. * @param x defines the x coordinate of the origin (on-screen)
  2389. * @param y defines the y coordinate of the origin (on-screen)
  2390. * @param result defines the ray where to store the picking ray
  2391. * @param camera defines the camera to use for the picking
  2392. * @returns the current scene
  2393. */
  2394. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2395. private _internalPick(rayFunction, predicate?, fastCheck?);
  2396. private _internalMultiPick(rayFunction, predicate?);
  2397. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2398. private _tempPickingRay;
  2399. /** Launch a ray to try to pick a mesh in the scene
  2400. * @param x position on screen
  2401. * @param y position on screen
  2402. * @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
  2403. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2404. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2405. * @returns a PickingInfo
  2406. */
  2407. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2408. /** Launch a ray to try to pick a sprite in the scene
  2409. * @param x position on screen
  2410. * @param y position on screen
  2411. * @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
  2412. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2413. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2414. * @returns a PickingInfo
  2415. */
  2416. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2417. private _cachedRayForTransform;
  2418. /** Use the given ray to pick a mesh in the scene
  2419. * @param ray The ray to use to pick meshes
  2420. * @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
  2421. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2422. * @returns a PickingInfo
  2423. */
  2424. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2425. /**
  2426. * Launch a ray to try to pick a mesh in the scene
  2427. * @param x X position on screen
  2428. * @param y Y position on screen
  2429. * @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
  2430. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2431. * @returns an array of PickingInfo
  2432. */
  2433. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2434. /**
  2435. * Launch a ray to try to pick a mesh in the scene
  2436. * @param ray Ray to use
  2437. * @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
  2438. * @returns an array of PickingInfo
  2439. */
  2440. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2441. /**
  2442. * Force the value of meshUnderPointer
  2443. * @param mesh defines the mesh to use
  2444. */
  2445. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2446. /**
  2447. * Gets the mesh under the pointer
  2448. * @returns a Mesh or null if no mesh is under the pointer
  2449. */
  2450. getPointerOverMesh(): Nullable<AbstractMesh>;
  2451. /**
  2452. * Force the sprite under the pointer
  2453. * @param sprite defines the sprite to use
  2454. */
  2455. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2456. /**
  2457. * Gets the sprite under the pointer
  2458. * @returns a Sprite or null if no sprite is under the pointer
  2459. */
  2460. getPointerOverSprite(): Nullable<Sprite>;
  2461. /**
  2462. * Gets the current physics engine
  2463. * @returns a PhysicsEngine or null if none attached
  2464. */
  2465. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2466. /**
  2467. * Enables physics to the current scene
  2468. * @param gravity defines the scene's gravity for the physics engine
  2469. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2470. * @return a boolean indicating if the physics engine was initialized
  2471. */
  2472. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2473. /**
  2474. * Disables and disposes the physics engine associated with the scene
  2475. */
  2476. disablePhysicsEngine(): void;
  2477. /**
  2478. * Gets a boolean indicating if there is an active physics engine
  2479. * @returns a boolean indicating if there is an active physics engine
  2480. */
  2481. isPhysicsEnabled(): boolean;
  2482. /**
  2483. * Deletes a physics compound impostor
  2484. * @param compound defines the compound to delete
  2485. */
  2486. deleteCompoundImpostor(compound: any): void;
  2487. /** @hidden */
  2488. _rebuildGeometries(): void;
  2489. /** @hidden */
  2490. _rebuildTextures(): void;
  2491. /**
  2492. * Creates a default light for the scene.
  2493. * @param replace Whether to replace the existing lights in the scene.
  2494. */
  2495. createDefaultLight(replace?: boolean): void;
  2496. /**
  2497. * Creates a default camera for the scene.
  2498. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2499. * @param replace Whether to replace the existing active camera in the scene.
  2500. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2501. */
  2502. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2503. /**
  2504. * Creates a default camera and a default light
  2505. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2506. * @param replace defines if the camera and/or light will replace the existing ones
  2507. * @param attachCameraControls defines if attachControl will be called on the new camera
  2508. */
  2509. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2510. /**
  2511. * Creates a new sky box
  2512. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2513. * @param environmentTexture defines the texture to use as environment texture
  2514. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2515. * @param scale defines the overall scale of the skybox
  2516. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2517. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2518. * @returns a new mesh holding the sky box
  2519. */
  2520. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2521. /**
  2522. * Creates a new environment
  2523. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2524. * @param options defines the options you can use to configure the environment
  2525. * @returns the new EnvironmentHelper
  2526. */
  2527. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2528. /**
  2529. * Creates a new VREXperienceHelper
  2530. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2531. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2532. * @returns a new VREXperienceHelper
  2533. */
  2534. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2535. private _getByTags(list, tagsQuery, forEach?);
  2536. /**
  2537. * Get a list of meshes by tags
  2538. * @param tagsQuery defines the tags query to use
  2539. * @param forEach defines a predicate used to filter results
  2540. * @returns an array of Mesh
  2541. */
  2542. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2543. /**
  2544. * Get a list of cameras by tags
  2545. * @param tagsQuery defines the tags query to use
  2546. * @param forEach defines a predicate used to filter results
  2547. * @returns an array of Camera
  2548. */
  2549. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2550. /**
  2551. * Get a list of lights by tags
  2552. * @param tagsQuery defines the tags query to use
  2553. * @param forEach defines a predicate used to filter results
  2554. * @returns an array of Light
  2555. */
  2556. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2557. /**
  2558. * Get a list of materials by tags
  2559. * @param tagsQuery defines the tags query to use
  2560. * @param forEach defines a predicate used to filter results
  2561. * @returns an array of Material
  2562. */
  2563. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2564. /**
  2565. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2566. * This allowed control for front to back rendering or reversly depending of the special needs.
  2567. *
  2568. * @param renderingGroupId The rendering group id corresponding to its index
  2569. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2570. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2571. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2572. */
  2573. 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;
  2574. /**
  2575. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2576. *
  2577. * @param renderingGroupId The rendering group id corresponding to its index
  2578. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2579. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2580. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2581. */
  2582. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2583. /**
  2584. * Will flag all materials as dirty to trigger new shader compilation
  2585. * @param flag defines the flag used to specify which material part must be marked as dirty
  2586. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2587. */
  2588. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2589. /** @hidden */
  2590. _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;
  2591. /** @hidden */
  2592. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2593. }
  2594. }
  2595. declare module BABYLON {
  2596. type Nullable<T> = T | null;
  2597. type float = number;
  2598. type double = number;
  2599. type int = number;
  2600. type FloatArray = number[] | Float32Array;
  2601. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2602. /**
  2603. * Alias for types that can be used by a Buffer or VertexBuffer.
  2604. */
  2605. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2606. }
  2607. declare module BABYLON {
  2608. /**
  2609. * The action to be carried out following a trigger
  2610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2611. */
  2612. class Action {
  2613. /** the trigger, with or without parameters, for the action */
  2614. triggerOptions: any;
  2615. /**
  2616. * Trigger for the action
  2617. */
  2618. trigger: number;
  2619. /**
  2620. * Internal only - manager for action
  2621. * @hidden
  2622. */
  2623. _actionManager: ActionManager;
  2624. private _nextActiveAction;
  2625. private _child;
  2626. private _condition?;
  2627. private _triggerParameter;
  2628. /**
  2629. * An event triggered prior to action being executed.
  2630. */
  2631. onBeforeExecuteObservable: Observable<Action>;
  2632. /**
  2633. * Creates a new Action
  2634. * @param triggerOptions the trigger, with or without parameters, for the action
  2635. * @param condition an optional determinant of action
  2636. */
  2637. constructor(
  2638. /** the trigger, with or without parameters, for the action */
  2639. triggerOptions: any, condition?: Condition);
  2640. /**
  2641. * Internal only
  2642. * @hidden
  2643. */
  2644. _prepare(): void;
  2645. /**
  2646. * Gets the trigger parameters
  2647. * @returns the trigger parameters
  2648. */
  2649. getTriggerParameter(): any;
  2650. /**
  2651. * Internal only - executes current action event
  2652. * @hidden
  2653. */
  2654. _executeCurrent(evt?: ActionEvent): void;
  2655. /**
  2656. * Execute placeholder for child classes
  2657. * @param evt optional action event
  2658. */
  2659. execute(evt?: ActionEvent): void;
  2660. /**
  2661. * Skips to next active action
  2662. */
  2663. skipToNextActiveAction(): void;
  2664. /**
  2665. * Adds action to chain of actions, may be a DoNothingAction
  2666. * @param action defines the next action to execute
  2667. * @returns The action passed in
  2668. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2669. */
  2670. then(action: Action): Action;
  2671. /**
  2672. * Internal only
  2673. * @hidden
  2674. */
  2675. _getProperty(propertyPath: string): string;
  2676. /**
  2677. * Internal only
  2678. * @hidden
  2679. */
  2680. _getEffectiveTarget(target: any, propertyPath: string): any;
  2681. /**
  2682. * Serialize placeholder for child classes
  2683. * @param parent of child
  2684. * @returns the serialized object
  2685. */
  2686. serialize(parent: any): any;
  2687. /**
  2688. * Internal only called by serialize
  2689. * @hidden
  2690. */
  2691. protected _serialize(serializedAction: any, parent?: any): any;
  2692. /**
  2693. * Internal only
  2694. * @hidden
  2695. */
  2696. static _SerializeValueAsString: (value: any) => string;
  2697. /**
  2698. * Internal only
  2699. * @hidden
  2700. */
  2701. static _GetTargetProperty: (target: Scene | Node) => {
  2702. name: string;
  2703. targetType: string;
  2704. value: string;
  2705. };
  2706. }
  2707. }
  2708. declare module BABYLON {
  2709. /**
  2710. * ActionEvent is the event being sent when an action is triggered.
  2711. */
  2712. class ActionEvent {
  2713. /** The mesh or sprite that triggered the action */
  2714. source: any;
  2715. /** The X mouse cursor position at the time of the event */
  2716. pointerX: number;
  2717. /** The Y mouse cursor position at the time of the event */
  2718. pointerY: number;
  2719. /** The mesh that is currently pointed at (can be null) */
  2720. meshUnderPointer: Nullable<AbstractMesh>;
  2721. /** the original (browser) event that triggered the ActionEvent */
  2722. sourceEvent: any;
  2723. /** additional data for the event */
  2724. additionalData: any;
  2725. /**
  2726. * Creates a new ActionEvent
  2727. * @param source The mesh or sprite that triggered the action
  2728. * @param pointerX The X mouse cursor position at the time of the event
  2729. * @param pointerY The Y mouse cursor position at the time of the event
  2730. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2731. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2732. * @param additionalData additional data for the event
  2733. */
  2734. constructor(
  2735. /** The mesh or sprite that triggered the action */
  2736. source: any,
  2737. /** The X mouse cursor position at the time of the event */
  2738. pointerX: number,
  2739. /** The Y mouse cursor position at the time of the event */
  2740. pointerY: number,
  2741. /** The mesh that is currently pointed at (can be null) */
  2742. meshUnderPointer: Nullable<AbstractMesh>,
  2743. /** the original (browser) event that triggered the ActionEvent */
  2744. sourceEvent?: any,
  2745. /** additional data for the event */
  2746. additionalData?: any);
  2747. /**
  2748. * Helper function to auto-create an ActionEvent from a source mesh.
  2749. * @param source The source mesh that triggered the event
  2750. * @param evt The original (browser) event
  2751. * @param additionalData additional data for the event
  2752. * @returns the new ActionEvent
  2753. */
  2754. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2755. /**
  2756. * Helper function to auto-create an ActionEvent from a source sprite
  2757. * @param source The source sprite that triggered the event
  2758. * @param scene Scene associated with the sprite
  2759. * @param evt The original (browser) event
  2760. * @param additionalData additional data for the event
  2761. * @returns the new ActionEvent
  2762. */
  2763. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2764. /**
  2765. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2766. * @param scene the scene where the event occurred
  2767. * @param evt The original (browser) event
  2768. * @returns the new ActionEvent
  2769. */
  2770. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2771. /**
  2772. * Helper function to auto-create an ActionEvent from a primitive
  2773. * @param prim defines the target primitive
  2774. * @param pointerPos defines the pointer position
  2775. * @param evt The original (browser) event
  2776. * @param additionalData additional data for the event
  2777. * @returns the new ActionEvent
  2778. */
  2779. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2780. }
  2781. /**
  2782. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2783. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2785. */
  2786. class ActionManager {
  2787. private static _NothingTrigger;
  2788. private static _OnPickTrigger;
  2789. private static _OnLeftPickTrigger;
  2790. private static _OnRightPickTrigger;
  2791. private static _OnCenterPickTrigger;
  2792. private static _OnPickDownTrigger;
  2793. private static _OnDoublePickTrigger;
  2794. private static _OnPickUpTrigger;
  2795. private static _OnLongPressTrigger;
  2796. private static _OnPointerOverTrigger;
  2797. private static _OnPointerOutTrigger;
  2798. private static _OnEveryFrameTrigger;
  2799. private static _OnIntersectionEnterTrigger;
  2800. private static _OnIntersectionExitTrigger;
  2801. private static _OnKeyDownTrigger;
  2802. private static _OnKeyUpTrigger;
  2803. private static _OnPickOutTrigger;
  2804. /**
  2805. * Nothing
  2806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2807. */
  2808. static readonly NothingTrigger: number;
  2809. /**
  2810. * On pick
  2811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2812. */
  2813. static readonly OnPickTrigger: number;
  2814. /**
  2815. * On left pick
  2816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2817. */
  2818. static readonly OnLeftPickTrigger: number;
  2819. /**
  2820. * On right pick
  2821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2822. */
  2823. static readonly OnRightPickTrigger: number;
  2824. /**
  2825. * On center pick
  2826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2827. */
  2828. static readonly OnCenterPickTrigger: number;
  2829. /**
  2830. * On pick down
  2831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2832. */
  2833. static readonly OnPickDownTrigger: number;
  2834. /**
  2835. * On double pick
  2836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2837. */
  2838. static readonly OnDoublePickTrigger: number;
  2839. /**
  2840. * On pick up
  2841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2842. */
  2843. static readonly OnPickUpTrigger: number;
  2844. /**
  2845. * On pick out.
  2846. * This trigger will only be raised if you also declared a OnPickDown
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnPickOutTrigger: number;
  2850. /**
  2851. * On long press
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnLongPressTrigger: number;
  2855. /**
  2856. * On pointer over
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnPointerOverTrigger: number;
  2860. /**
  2861. * On pointer out
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnPointerOutTrigger: number;
  2865. /**
  2866. * On every frame
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnEveryFrameTrigger: number;
  2870. /**
  2871. * On intersection enter
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnIntersectionEnterTrigger: number;
  2875. /**
  2876. * On intersection exit
  2877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2878. */
  2879. static readonly OnIntersectionExitTrigger: number;
  2880. /**
  2881. * On key down
  2882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2883. */
  2884. static readonly OnKeyDownTrigger: number;
  2885. /**
  2886. * On key up
  2887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2888. */
  2889. static readonly OnKeyUpTrigger: number;
  2890. /** Gets the list of active triggers */
  2891. static Triggers: {
  2892. [key: string]: number;
  2893. };
  2894. /** Gets the list of actions */
  2895. actions: Action[];
  2896. /** Gets the cursor to use when hovering items */
  2897. hoverCursor: string;
  2898. private _scene;
  2899. /**
  2900. * Creates a new action manager
  2901. * @param scene defines the hosting scene
  2902. */
  2903. constructor(scene: Scene);
  2904. /**
  2905. * Releases all associated resources
  2906. */
  2907. dispose(): void;
  2908. /**
  2909. * Gets hosting scene
  2910. * @returns the hosting scene
  2911. */
  2912. getScene(): Scene;
  2913. /**
  2914. * Does this action manager handles actions of any of the given triggers
  2915. * @param triggers defines the triggers to be tested
  2916. * @return a boolean indicating whether one (or more) of the triggers is handled
  2917. */
  2918. hasSpecificTriggers(triggers: number[]): boolean;
  2919. /**
  2920. * Does this action manager handles actions of a given trigger
  2921. * @param trigger defines the trigger to be tested
  2922. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2923. * @return whether the trigger is handled
  2924. */
  2925. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2926. /**
  2927. * Does this action manager has pointer triggers
  2928. */
  2929. readonly hasPointerTriggers: boolean;
  2930. /**
  2931. * Does this action manager has pick triggers
  2932. */
  2933. readonly hasPickTriggers: boolean;
  2934. /**
  2935. * Does exist one action manager with at least one trigger
  2936. **/
  2937. static readonly HasTriggers: boolean;
  2938. /**
  2939. * Does exist one action manager with at least one pick trigger
  2940. **/
  2941. static readonly HasPickTriggers: boolean;
  2942. /**
  2943. * Does exist one action manager that handles actions of a given trigger
  2944. * @param trigger defines the trigger to be tested
  2945. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2946. **/
  2947. static HasSpecificTrigger(trigger: number): boolean;
  2948. /**
  2949. * Registers an action to this action manager
  2950. * @param action defines the action to be registered
  2951. * @return the action amended (prepared) after registration
  2952. */
  2953. registerAction(action: Action): Nullable<Action>;
  2954. /**
  2955. * Unregisters an action to this action manager
  2956. * @param action defines the action to be unregistered
  2957. * @return a boolean indicating whether the action has been unregistered
  2958. */
  2959. unregisterAction(action: Action): Boolean;
  2960. /**
  2961. * Process a specific trigger
  2962. * @param trigger defines the trigger to process
  2963. * @param evt defines the event details to be processed
  2964. */
  2965. processTrigger(trigger: number, evt?: ActionEvent): void;
  2966. /** @hidden */
  2967. _getEffectiveTarget(target: any, propertyPath: string): any;
  2968. /** @hidden */
  2969. _getProperty(propertyPath: string): string;
  2970. /**
  2971. * Serialize this manager to a JSON object
  2972. * @param name defines the property name to store this manager
  2973. * @returns a JSON representation of this manager
  2974. */
  2975. serialize(name: string): any;
  2976. /**
  2977. * Creates a new ActionManager from a JSON data
  2978. * @param parsedActions defines the JSON data to read from
  2979. * @param object defines the hosting mesh
  2980. * @param scene defines the hosting scene
  2981. */
  2982. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2983. /**
  2984. * Get a trigger name by index
  2985. * @param trigger defines the trigger index
  2986. * @returns a trigger name
  2987. */
  2988. static GetTriggerName(trigger: number): string;
  2989. }
  2990. }
  2991. declare module BABYLON {
  2992. /**
  2993. * A Condition applied to an Action
  2994. */
  2995. class Condition {
  2996. /**
  2997. * Internal only - manager for action
  2998. * @hidden
  2999. */
  3000. _actionManager: ActionManager;
  3001. /**
  3002. * Internal only
  3003. * @hidden
  3004. */
  3005. _evaluationId: number;
  3006. /**
  3007. * Internal only
  3008. * @hidden
  3009. */
  3010. _currentResult: boolean;
  3011. /**
  3012. * Creates a new Condition
  3013. * @param actionManager the manager of the action the condition is applied to
  3014. */
  3015. constructor(actionManager: ActionManager);
  3016. /**
  3017. * Check if the current condition is valid
  3018. * @returns a boolean
  3019. */
  3020. isValid(): boolean;
  3021. /**
  3022. * Internal only
  3023. * @hidden
  3024. */
  3025. _getProperty(propertyPath: string): string;
  3026. /**
  3027. * Internal only
  3028. * @hidden
  3029. */
  3030. _getEffectiveTarget(target: any, propertyPath: string): any;
  3031. /**
  3032. * Serialize placeholder for child classes
  3033. * @returns the serialized object
  3034. */
  3035. serialize(): any;
  3036. /**
  3037. * Internal only
  3038. * @hidden
  3039. */
  3040. protected _serialize(serializedCondition: any): any;
  3041. }
  3042. /**
  3043. * Defines specific conditional operators as extensions of Condition
  3044. */
  3045. class ValueCondition extends Condition {
  3046. /** path to specify the property of the target the conditional operator uses */
  3047. propertyPath: string;
  3048. /** the value compared by the conditional operator against the current value of the property */
  3049. value: any;
  3050. /** the conditional operator, default ValueCondition.IsEqual */
  3051. operator: number;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. private static _IsEqual;
  3057. /**
  3058. * Internal only
  3059. * @hidden
  3060. */
  3061. private static _IsDifferent;
  3062. /**
  3063. * Internal only
  3064. * @hidden
  3065. */
  3066. private static _IsGreater;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. private static _IsLesser;
  3072. /**
  3073. * returns the number for IsEqual
  3074. */
  3075. static readonly IsEqual: number;
  3076. /**
  3077. * Returns the number for IsDifferent
  3078. */
  3079. static readonly IsDifferent: number;
  3080. /**
  3081. * Returns the number for IsGreater
  3082. */
  3083. static readonly IsGreater: number;
  3084. /**
  3085. * Returns the number for IsLesser
  3086. */
  3087. static readonly IsLesser: number;
  3088. /**
  3089. * Internal only The action manager for the condition
  3090. * @hidden
  3091. */
  3092. _actionManager: ActionManager;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private _target;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private _effectiveTarget;
  3103. /**
  3104. * Internal only
  3105. * @hidden
  3106. */
  3107. private _property;
  3108. /**
  3109. * Creates a new ValueCondition
  3110. * @param actionManager manager for the action the condition applies to
  3111. * @param target for the action
  3112. * @param propertyPath path to specify the property of the target the conditional operator uses
  3113. * @param value the value compared by the conditional operator against the current value of the property
  3114. * @param operator the conditional operator, default ValueCondition.IsEqual
  3115. */
  3116. constructor(actionManager: ActionManager, target: any,
  3117. /** path to specify the property of the target the conditional operator uses */
  3118. propertyPath: string,
  3119. /** the value compared by the conditional operator against the current value of the property */
  3120. value: any,
  3121. /** the conditional operator, default ValueCondition.IsEqual */
  3122. operator?: number);
  3123. /**
  3124. * Compares the given value with the property value for the specified conditional operator
  3125. * @returns the result of the comparison
  3126. */
  3127. isValid(): boolean;
  3128. /**
  3129. * Serialize the ValueCondition into a JSON compatible object
  3130. * @returns serialization object
  3131. */
  3132. serialize(): any;
  3133. /**
  3134. * Gets the name of the conditional operator for the ValueCondition
  3135. * @param operator the conditional operator
  3136. * @returns the name
  3137. */
  3138. static GetOperatorName(operator: number): string;
  3139. }
  3140. /**
  3141. * Defines a predicate condition as an extension of Condition
  3142. */
  3143. class PredicateCondition extends Condition {
  3144. /** defines the predicate function used to validate the condition */
  3145. predicate: () => boolean;
  3146. /**
  3147. * Internal only - manager for action
  3148. * @hidden
  3149. */
  3150. _actionManager: ActionManager;
  3151. /**
  3152. * Creates a new PredicateCondition
  3153. * @param actionManager manager for the action the condition applies to
  3154. * @param predicate defines the predicate function used to validate the condition
  3155. */
  3156. constructor(actionManager: ActionManager,
  3157. /** defines the predicate function used to validate the condition */
  3158. predicate: () => boolean);
  3159. /**
  3160. * @returns the validity of the predicate condition
  3161. */
  3162. isValid(): boolean;
  3163. }
  3164. /**
  3165. * Defines a state condition as an extension of Condition
  3166. */
  3167. class StateCondition extends Condition {
  3168. value: string;
  3169. /**
  3170. * Internal only - manager for action
  3171. * @hidden
  3172. */
  3173. _actionManager: ActionManager;
  3174. /**
  3175. * Internal only
  3176. * @hidden
  3177. */
  3178. private _target;
  3179. /**
  3180. * Creates a new StateCondition
  3181. * @param actionManager manager for the action the condition applies to
  3182. * @param target of the condition
  3183. * @param value to compare with target state
  3184. */
  3185. constructor(actionManager: ActionManager, target: any, value: string);
  3186. /**
  3187. * @returns the validity of the state
  3188. */
  3189. isValid(): boolean;
  3190. /**
  3191. * Serialize the StateCondition into a JSON compatible object
  3192. * @returns serialization object
  3193. */
  3194. serialize(): any;
  3195. }
  3196. }
  3197. declare module BABYLON {
  3198. class SwitchBooleanAction extends Action {
  3199. propertyPath: string;
  3200. private _target;
  3201. private _effectiveTarget;
  3202. private _property;
  3203. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3204. _prepare(): void;
  3205. execute(): void;
  3206. serialize(parent: any): any;
  3207. }
  3208. class SetStateAction extends Action {
  3209. value: string;
  3210. private _target;
  3211. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3212. execute(): void;
  3213. serialize(parent: any): any;
  3214. }
  3215. class SetValueAction extends Action {
  3216. propertyPath: string;
  3217. value: any;
  3218. private _target;
  3219. private _effectiveTarget;
  3220. private _property;
  3221. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3222. _prepare(): void;
  3223. execute(): void;
  3224. serialize(parent: any): any;
  3225. }
  3226. class IncrementValueAction extends Action {
  3227. propertyPath: string;
  3228. value: any;
  3229. private _target;
  3230. private _effectiveTarget;
  3231. private _property;
  3232. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3233. _prepare(): void;
  3234. execute(): void;
  3235. serialize(parent: any): any;
  3236. }
  3237. class PlayAnimationAction extends Action {
  3238. from: number;
  3239. to: number;
  3240. loop: boolean | undefined;
  3241. private _target;
  3242. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3243. _prepare(): void;
  3244. execute(): void;
  3245. serialize(parent: any): any;
  3246. }
  3247. class StopAnimationAction extends Action {
  3248. private _target;
  3249. constructor(triggerOptions: any, target: any, condition?: Condition);
  3250. _prepare(): void;
  3251. execute(): void;
  3252. serialize(parent: any): any;
  3253. }
  3254. class DoNothingAction extends Action {
  3255. constructor(triggerOptions?: any, condition?: Condition);
  3256. execute(): void;
  3257. serialize(parent: any): any;
  3258. }
  3259. class CombineAction extends Action {
  3260. children: Action[];
  3261. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3262. _prepare(): void;
  3263. execute(evt: ActionEvent): void;
  3264. serialize(parent: any): any;
  3265. }
  3266. class ExecuteCodeAction extends Action {
  3267. func: (evt: ActionEvent) => void;
  3268. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3269. execute(evt: ActionEvent): void;
  3270. }
  3271. class SetParentAction extends Action {
  3272. private _parent;
  3273. private _target;
  3274. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3275. _prepare(): void;
  3276. execute(): void;
  3277. serialize(parent: any): any;
  3278. }
  3279. class PlaySoundAction extends Action {
  3280. private _sound;
  3281. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3282. _prepare(): void;
  3283. execute(): void;
  3284. serialize(parent: any): any;
  3285. }
  3286. class StopSoundAction extends Action {
  3287. private _sound;
  3288. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3289. _prepare(): void;
  3290. execute(): void;
  3291. serialize(parent: any): any;
  3292. }
  3293. }
  3294. declare module BABYLON {
  3295. class InterpolateValueAction extends Action {
  3296. propertyPath: string;
  3297. value: any;
  3298. duration: number;
  3299. stopOtherAnimations: boolean | undefined;
  3300. onInterpolationDone: (() => void) | undefined;
  3301. private _target;
  3302. private _effectiveTarget;
  3303. private _property;
  3304. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3305. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3306. _prepare(): void;
  3307. execute(): void;
  3308. serialize(parent: any): any;
  3309. }
  3310. }
  3311. declare module BABYLON {
  3312. class Animatable {
  3313. target: any;
  3314. fromFrame: number;
  3315. toFrame: number;
  3316. loopAnimation: boolean;
  3317. onAnimationEnd: (() => void) | null | undefined;
  3318. private _localDelayOffset;
  3319. private _pausedDelay;
  3320. private _runtimeAnimations;
  3321. private _paused;
  3322. private _scene;
  3323. private _speedRatio;
  3324. private _weight;
  3325. private _syncRoot;
  3326. animationStarted: boolean;
  3327. /**
  3328. * Gets the root Animatable used to synchronize and normalize animations
  3329. */
  3330. readonly syncRoot: Animatable;
  3331. /**
  3332. * Gets the current frame of the first RuntimeAnimation
  3333. * Used to synchronize Animatables
  3334. */
  3335. readonly masterFrame: number;
  3336. /**
  3337. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3338. */
  3339. weight: number;
  3340. /**
  3341. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3342. */
  3343. speedRatio: number;
  3344. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3345. /**
  3346. * Synchronize and normalize current Animatable with a source Animatable
  3347. * This is useful when using animation weights and when animations are not of the same length
  3348. * @param root defines the root Animatable to synchronize with
  3349. * @returns the current Animatable
  3350. */
  3351. syncWith(root: Animatable): Animatable;
  3352. getAnimations(): RuntimeAnimation[];
  3353. appendAnimations(target: any, animations: Animation[]): void;
  3354. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3355. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3356. reset(): void;
  3357. enableBlending(blendingSpeed: number): void;
  3358. disableBlending(): void;
  3359. goToFrame(frame: number): void;
  3360. pause(): void;
  3361. restart(): void;
  3362. stop(animationName?: string): void;
  3363. _animate(delay: number): boolean;
  3364. }
  3365. }
  3366. declare module BABYLON {
  3367. /**
  3368. * Represents the range of an animation
  3369. */
  3370. class AnimationRange {
  3371. /**The name of the animation range**/
  3372. name: string;
  3373. /**The starting frame of the animation */
  3374. from: number;
  3375. /**The ending frame of the animation*/
  3376. to: number;
  3377. /**
  3378. * Initializes the range of an animation
  3379. * @param name The name of the animation range
  3380. * @param from The starting frame of the animation
  3381. * @param to The ending frame of the animation
  3382. */
  3383. constructor(
  3384. /**The name of the animation range**/
  3385. name: string,
  3386. /**The starting frame of the animation */
  3387. from: number,
  3388. /**The ending frame of the animation*/
  3389. to: number);
  3390. /**
  3391. * Makes a copy of the animation range
  3392. * @returns A copy of the animation range
  3393. */
  3394. clone(): AnimationRange;
  3395. }
  3396. /**
  3397. * Composed of a frame, and an action function
  3398. */
  3399. class AnimationEvent {
  3400. /** The frame for which the event is triggered **/
  3401. frame: number;
  3402. /** The event to perform when triggered **/
  3403. action: () => void;
  3404. /** Specifies if the event should be triggered only once**/
  3405. onlyOnce: boolean | undefined;
  3406. /**
  3407. * Specifies if the animation event is done
  3408. */
  3409. isDone: boolean;
  3410. /**
  3411. * Initializes the animation event
  3412. * @param frame The frame for which the event is triggered
  3413. * @param action The event to perform when triggered
  3414. * @param onlyOnce Specifies if the event should be triggered only once
  3415. */
  3416. constructor(
  3417. /** The frame for which the event is triggered **/
  3418. frame: number,
  3419. /** The event to perform when triggered **/
  3420. action: () => void,
  3421. /** Specifies if the event should be triggered only once**/
  3422. onlyOnce?: boolean | undefined);
  3423. }
  3424. /**
  3425. * A cursor which tracks a point on a path
  3426. */
  3427. class PathCursor {
  3428. private path;
  3429. /**
  3430. * Stores path cursor callbacks for when an onchange event is triggered
  3431. */
  3432. private _onchange;
  3433. /**
  3434. * The value of the path cursor
  3435. */
  3436. value: number;
  3437. /**
  3438. * The animation array of the path cursor
  3439. */
  3440. animations: Animation[];
  3441. /**
  3442. * Initializes the path cursor
  3443. * @param path The path to track
  3444. */
  3445. constructor(path: Path2);
  3446. /**
  3447. * Gets the cursor point on the path
  3448. * @returns A point on the path cursor at the cursor location
  3449. */
  3450. getPoint(): Vector3;
  3451. /**
  3452. * Moves the cursor ahead by the step amount
  3453. * @param step The amount to move the cursor forward
  3454. * @returns This path cursor
  3455. */
  3456. moveAhead(step?: number): PathCursor;
  3457. /**
  3458. * Moves the cursor behind by the step amount
  3459. * @param step The amount to move the cursor back
  3460. * @returns This path cursor
  3461. */
  3462. moveBack(step?: number): PathCursor;
  3463. /**
  3464. * Moves the cursor by the step amount
  3465. * If the step amount is greater than one, an exception is thrown
  3466. * @param step The amount to move the cursor
  3467. * @returns This path cursor
  3468. */
  3469. move(step: number): PathCursor;
  3470. /**
  3471. * Ensures that the value is limited between zero and one
  3472. * @returns This path cursor
  3473. */
  3474. private ensureLimits();
  3475. /**
  3476. * Runs onchange callbacks on change (used by the animation engine)
  3477. * @returns This path cursor
  3478. */
  3479. private raiseOnChange();
  3480. /**
  3481. * Executes a function on change
  3482. * @param f A path cursor onchange callback
  3483. * @returns This path cursor
  3484. */
  3485. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3486. }
  3487. /**
  3488. * Defines an interface which represents an animation key frame
  3489. */
  3490. interface IAnimationKey {
  3491. /**
  3492. * Frame of the key frame
  3493. */
  3494. frame: number;
  3495. /**
  3496. * Value at the specifies key frame
  3497. */
  3498. value: any;
  3499. /**
  3500. * The input tangent for the cubic hermite spline
  3501. */
  3502. inTangent?: any;
  3503. /**
  3504. * The output tangent for the cubic hermite spline
  3505. */
  3506. outTangent?: any;
  3507. /**
  3508. * The animation interpolation type
  3509. */
  3510. interpolation?: AnimationKeyInterpolation;
  3511. }
  3512. /**
  3513. * Enum for the animation key frame interpolation type
  3514. */
  3515. enum AnimationKeyInterpolation {
  3516. /**
  3517. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3518. */
  3519. STEP = 1,
  3520. }
  3521. /**
  3522. * Class used to store any kind of animation
  3523. */
  3524. class Animation {
  3525. /**Name of the animation */
  3526. name: string;
  3527. /**Property to animate */
  3528. targetProperty: string;
  3529. /**The frames per second of the animation */
  3530. framePerSecond: number;
  3531. /**The data type of the animation */
  3532. dataType: number;
  3533. /**The loop mode of the animation */
  3534. loopMode: number | undefined;
  3535. /**Specifies if blending should be enabled */
  3536. enableBlending: boolean | undefined;
  3537. /**
  3538. * Use matrix interpolation instead of using direct key value when animating matrices
  3539. */
  3540. static AllowMatricesInterpolation: boolean;
  3541. /**
  3542. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3543. */
  3544. static AllowMatrixDecomposeForInterpolation: boolean;
  3545. /**
  3546. * Stores the key frames of the animation
  3547. */
  3548. private _keys;
  3549. /**
  3550. * Stores the easing function of the animation
  3551. */
  3552. private _easingFunction;
  3553. /**
  3554. * @hidden Internal use only
  3555. */
  3556. _runtimeAnimations: RuntimeAnimation[];
  3557. /**
  3558. * The set of event that will be linked to this animation
  3559. */
  3560. private _events;
  3561. /**
  3562. * Stores an array of target property paths
  3563. */
  3564. targetPropertyPath: string[];
  3565. /**
  3566. * Stores the blending speed of the animation
  3567. */
  3568. blendingSpeed: number;
  3569. /**
  3570. * Stores the animation ranges for the animation
  3571. */
  3572. private _ranges;
  3573. /**
  3574. * @hidden Internal use
  3575. */
  3576. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3577. /**
  3578. * Sets up an animation
  3579. * @param property The property to animate
  3580. * @param animationType The animation type to apply
  3581. * @param framePerSecond The frames per second of the animation
  3582. * @param easingFunction The easing function used in the animation
  3583. * @returns The created animation
  3584. */
  3585. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3586. /**
  3587. * Create and start an animation on a node
  3588. * @param name defines the name of the global animation that will be run on all nodes
  3589. * @param node defines the root node where the animation will take place
  3590. * @param targetProperty defines property to animate
  3591. * @param framePerSecond defines the number of frame per second yo use
  3592. * @param totalFrame defines the number of frames in total
  3593. * @param from defines the initial value
  3594. * @param to defines the final value
  3595. * @param loopMode defines which loop mode you want to use (off by default)
  3596. * @param easingFunction defines the easing function to use (linear by default)
  3597. * @param onAnimationEnd defines the callback to call when animation end
  3598. * @returns the animatable created for this animation
  3599. */
  3600. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3601. /**
  3602. * Create and start an animation on a node and its descendants
  3603. * @param name defines the name of the global animation that will be run on all nodes
  3604. * @param node defines the root node where the animation will take place
  3605. * @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
  3606. * @param targetProperty defines property to animate
  3607. * @param framePerSecond defines the number of frame per second to use
  3608. * @param totalFrame defines the number of frames in total
  3609. * @param from defines the initial value
  3610. * @param to defines the final value
  3611. * @param loopMode defines which loop mode you want to use (off by default)
  3612. * @param easingFunction defines the easing function to use (linear by default)
  3613. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3614. * @returns the list of animatables created for all nodes
  3615. * @example https://www.babylonjs-playground.com/#MH0VLI
  3616. */
  3617. 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[]>;
  3618. /**
  3619. * Creates a new animation, merges it with the existing animations and starts it
  3620. * @param name Name of the animation
  3621. * @param node Node which contains the scene that begins the animations
  3622. * @param targetProperty Specifies which property to animate
  3623. * @param framePerSecond The frames per second of the animation
  3624. * @param totalFrame The total number of frames
  3625. * @param from The frame at the beginning of the animation
  3626. * @param to The frame at the end of the animation
  3627. * @param loopMode Specifies the loop mode of the animation
  3628. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3629. * @param onAnimationEnd Callback to run once the animation is complete
  3630. * @returns Nullable animation
  3631. */
  3632. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3633. /**
  3634. * Transition property of the Camera to the target Value
  3635. * @param property The property to transition
  3636. * @param targetValue The target Value of the property
  3637. * @param host The object where the property to animate belongs
  3638. * @param scene Scene used to run the animation
  3639. * @param frameRate Framerate (in frame/s) to use
  3640. * @param transition The transition type we want to use
  3641. * @param duration The duration of the animation, in milliseconds
  3642. * @param onAnimationEnd Callback trigger at the end of the animation
  3643. * @returns Nullable animation
  3644. */
  3645. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3646. /**
  3647. * Return the array of runtime animations currently using this animation
  3648. */
  3649. readonly runtimeAnimations: RuntimeAnimation[];
  3650. /**
  3651. * Specifies if any of the runtime animations are currently running
  3652. */
  3653. readonly hasRunningRuntimeAnimations: boolean;
  3654. /**
  3655. * Initializes the animation
  3656. * @param name Name of the animation
  3657. * @param targetProperty Property to animate
  3658. * @param framePerSecond The frames per second of the animation
  3659. * @param dataType The data type of the animation
  3660. * @param loopMode The loop mode of the animation
  3661. * @param enableBlendings Specifies if blending should be enabled
  3662. */
  3663. constructor(
  3664. /**Name of the animation */
  3665. name: string,
  3666. /**Property to animate */
  3667. targetProperty: string,
  3668. /**The frames per second of the animation */
  3669. framePerSecond: number,
  3670. /**The data type of the animation */
  3671. dataType: number,
  3672. /**The loop mode of the animation */
  3673. loopMode?: number | undefined,
  3674. /**Specifies if blending should be enabled */
  3675. enableBlending?: boolean | undefined);
  3676. /**
  3677. * Converts the animation to a string
  3678. * @param fullDetails support for multiple levels of logging within scene loading
  3679. * @returns String form of the animation
  3680. */
  3681. toString(fullDetails?: boolean): string;
  3682. /**
  3683. * Add an event to this animation
  3684. * @param event Event to add
  3685. */
  3686. addEvent(event: AnimationEvent): void;
  3687. /**
  3688. * Remove all events found at the given frame
  3689. * @param frame The frame to remove events from
  3690. */
  3691. removeEvents(frame: number): void;
  3692. /**
  3693. * Retrieves all the events from the animation
  3694. * @returns Events from the animation
  3695. */
  3696. getEvents(): AnimationEvent[];
  3697. /**
  3698. * Creates an animation range
  3699. * @param name Name of the animation range
  3700. * @param from Starting frame of the animation range
  3701. * @param to Ending frame of the animation
  3702. */
  3703. createRange(name: string, from: number, to: number): void;
  3704. /**
  3705. * Deletes an animation range by name
  3706. * @param name Name of the animation range to delete
  3707. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3708. */
  3709. deleteRange(name: string, deleteFrames?: boolean): void;
  3710. /**
  3711. * Gets the animation range by name, or null if not defined
  3712. * @param name Name of the animation range
  3713. * @returns Nullable animation range
  3714. */
  3715. getRange(name: string): Nullable<AnimationRange>;
  3716. /**
  3717. * Gets the key frames from the animation
  3718. * @returns The key frames of the animation
  3719. */
  3720. getKeys(): Array<IAnimationKey>;
  3721. /**
  3722. * Gets the highest frame rate of the animation
  3723. * @returns Highest frame rate of the animation
  3724. */
  3725. getHighestFrame(): number;
  3726. /**
  3727. * Gets the easing function of the animation
  3728. * @returns Easing function of the animation
  3729. */
  3730. getEasingFunction(): IEasingFunction;
  3731. /**
  3732. * Sets the easing function of the animation
  3733. * @param easingFunction A custom mathematical formula for animation
  3734. */
  3735. setEasingFunction(easingFunction: EasingFunction): void;
  3736. /**
  3737. * Interpolates a scalar linearly
  3738. * @param startValue Start value of the animation curve
  3739. * @param endValue End value of the animation curve
  3740. * @param gradient Scalar amount to interpolate
  3741. * @returns Interpolated scalar value
  3742. */
  3743. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3744. /**
  3745. * Interpolates a scalar cubically
  3746. * @param startValue Start value of the animation curve
  3747. * @param outTangent End tangent of the animation
  3748. * @param endValue End value of the animation curve
  3749. * @param inTangent Start tangent of the animation curve
  3750. * @param gradient Scalar amount to interpolate
  3751. * @returns Interpolated scalar value
  3752. */
  3753. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3754. /**
  3755. * Interpolates a quaternion using a spherical linear interpolation
  3756. * @param startValue Start value of the animation curve
  3757. * @param endValue End value of the animation curve
  3758. * @param gradient Scalar amount to interpolate
  3759. * @returns Interpolated quaternion value
  3760. */
  3761. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3762. /**
  3763. * Interpolates a quaternion cubically
  3764. * @param startValue Start value of the animation curve
  3765. * @param outTangent End tangent of the animation curve
  3766. * @param endValue End value of the animation curve
  3767. * @param inTangent Start tangent of the animation curve
  3768. * @param gradient Scalar amount to interpolate
  3769. * @returns Interpolated quaternion value
  3770. */
  3771. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3772. /**
  3773. * Interpolates a Vector3 linearl
  3774. * @param startValue Start value of the animation curve
  3775. * @param endValue End value of the animation curve
  3776. * @param gradient Scalar amount to interpolate
  3777. * @returns Interpolated scalar value
  3778. */
  3779. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3780. /**
  3781. * Interpolates a Vector3 cubically
  3782. * @param startValue Start value of the animation curve
  3783. * @param outTangent End tangent of the animation
  3784. * @param endValue End value of the animation curve
  3785. * @param inTangent Start tangent of the animation curve
  3786. * @param gradient Scalar amount to interpolate
  3787. * @returns InterpolatedVector3 value
  3788. */
  3789. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3790. /**
  3791. * Interpolates a Vector2 linearly
  3792. * @param startValue Start value of the animation curve
  3793. * @param endValue End value of the animation curve
  3794. * @param gradient Scalar amount to interpolate
  3795. * @returns Interpolated Vector2 value
  3796. */
  3797. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3798. /**
  3799. * Interpolates a Vector2 cubically
  3800. * @param startValue Start value of the animation curve
  3801. * @param outTangent End tangent of the animation
  3802. * @param endValue End value of the animation curve
  3803. * @param inTangent Start tangent of the animation curve
  3804. * @param gradient Scalar amount to interpolate
  3805. * @returns Interpolated Vector2 value
  3806. */
  3807. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3808. /**
  3809. * Interpolates a size linearly
  3810. * @param startValue Start value of the animation curve
  3811. * @param endValue End value of the animation curve
  3812. * @param gradient Scalar amount to interpolate
  3813. * @returns Interpolated Size value
  3814. */
  3815. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3816. /**
  3817. * Interpolates a Color3 linearly
  3818. * @param startValue Start value of the animation curve
  3819. * @param endValue End value of the animation curve
  3820. * @param gradient Scalar amount to interpolate
  3821. * @returns Interpolated Color3 value
  3822. */
  3823. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3824. /**
  3825. * @hidden Internal use only
  3826. */
  3827. _getKeyValue(value: any): any;
  3828. /**
  3829. * @hidden Internal use only
  3830. */
  3831. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3832. /**
  3833. * Defines the function to use to interpolate matrices
  3834. * @param startValue defines the start matrix
  3835. * @param endValue defines the end matrix
  3836. * @param gradient defines the gradient between both matrices
  3837. * @param result defines an optional target matrix where to store the interpolation
  3838. * @returns the interpolated matrix
  3839. */
  3840. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3841. /**
  3842. * Makes a copy of the animation
  3843. * @returns Cloned animation
  3844. */
  3845. clone(): Animation;
  3846. /**
  3847. * Sets the key frames of the animation
  3848. * @param values The animation key frames to set
  3849. */
  3850. setKeys(values: Array<IAnimationKey>): void;
  3851. /**
  3852. * Serializes the animation to an object
  3853. * @returns Serialized object
  3854. */
  3855. serialize(): any;
  3856. /**
  3857. * Float animation type
  3858. */
  3859. private static _ANIMATIONTYPE_FLOAT;
  3860. /**
  3861. * Vector3 animation type
  3862. */
  3863. private static _ANIMATIONTYPE_VECTOR3;
  3864. /**
  3865. * Quaternion animation type
  3866. */
  3867. private static _ANIMATIONTYPE_QUATERNION;
  3868. /**
  3869. * Matrix animation type
  3870. */
  3871. private static _ANIMATIONTYPE_MATRIX;
  3872. /**
  3873. * Color3 animation type
  3874. */
  3875. private static _ANIMATIONTYPE_COLOR3;
  3876. /**
  3877. * Vector2 animation type
  3878. */
  3879. private static _ANIMATIONTYPE_VECTOR2;
  3880. /**
  3881. * Size animation type
  3882. */
  3883. private static _ANIMATIONTYPE_SIZE;
  3884. /**
  3885. * Relative Loop Mode
  3886. */
  3887. private static _ANIMATIONLOOPMODE_RELATIVE;
  3888. /**
  3889. * Cycle Loop Mode
  3890. */
  3891. private static _ANIMATIONLOOPMODE_CYCLE;
  3892. /**
  3893. * Constant Loop Mode
  3894. */
  3895. private static _ANIMATIONLOOPMODE_CONSTANT;
  3896. /**
  3897. * Get the float animation type
  3898. */
  3899. static readonly ANIMATIONTYPE_FLOAT: number;
  3900. /**
  3901. * Get the Vector3 animation type
  3902. */
  3903. static readonly ANIMATIONTYPE_VECTOR3: number;
  3904. /**
  3905. * Get the Vectpr2 animation type
  3906. */
  3907. static readonly ANIMATIONTYPE_VECTOR2: number;
  3908. /**
  3909. * Get the Size animation type
  3910. */
  3911. static readonly ANIMATIONTYPE_SIZE: number;
  3912. /**
  3913. * Get the Quaternion animation type
  3914. */
  3915. static readonly ANIMATIONTYPE_QUATERNION: number;
  3916. /**
  3917. * Get the Matrix animation type
  3918. */
  3919. static readonly ANIMATIONTYPE_MATRIX: number;
  3920. /**
  3921. * Get the Color3 animation type
  3922. */
  3923. static readonly ANIMATIONTYPE_COLOR3: number;
  3924. /**
  3925. * Get the Relative Loop Mode
  3926. */
  3927. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3928. /**
  3929. * Get the Cycle Loop Mode
  3930. */
  3931. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3932. /**
  3933. * Get the Constant Loop Mode
  3934. */
  3935. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3936. /** @hidden */
  3937. static _UniversalLerp(left: any, right: any, amount: number): any;
  3938. /**
  3939. * Parses an animation object and creates an animation
  3940. * @param parsedAnimation Parsed animation object
  3941. * @returns Animation object
  3942. */
  3943. static Parse(parsedAnimation: any): Animation;
  3944. /**
  3945. * Appends the serialized animations from the source animations
  3946. * @param source Source containing the animations
  3947. * @param destination Target to store the animations
  3948. */
  3949. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3950. }
  3951. }
  3952. declare module BABYLON {
  3953. /**
  3954. * This class defines the direct association between an animation and a target
  3955. */
  3956. class TargetedAnimation {
  3957. animation: Animation;
  3958. target: any;
  3959. }
  3960. /**
  3961. * Use this class to create coordinated animations on multiple targets
  3962. */
  3963. class AnimationGroup implements IDisposable {
  3964. name: string;
  3965. private _scene;
  3966. private _targetedAnimations;
  3967. private _animatables;
  3968. private _from;
  3969. private _to;
  3970. private _isStarted;
  3971. private _speedRatio;
  3972. onAnimationEndObservable: Observable<TargetedAnimation>;
  3973. /**
  3974. * Gets the first frame
  3975. */
  3976. readonly from: number;
  3977. /**
  3978. * Gets the last frame
  3979. */
  3980. readonly to: number;
  3981. /**
  3982. * Define if the animations are started
  3983. */
  3984. readonly isStarted: boolean;
  3985. /**
  3986. * Gets or sets the speed ratio to use for all animations
  3987. */
  3988. /**
  3989. * Gets or sets the speed ratio to use for all animations
  3990. */
  3991. speedRatio: number;
  3992. /**
  3993. * Gets the targeted animations for this animation group
  3994. */
  3995. readonly targetedAnimations: Array<TargetedAnimation>;
  3996. /**
  3997. * returning the list of animatables controlled by this animation group.
  3998. */
  3999. readonly animatables: Array<Animatable>;
  4000. constructor(name: string, scene?: Nullable<Scene>);
  4001. /**
  4002. * Add an animation (with its target) in the group
  4003. * @param animation defines the animation we want to add
  4004. * @param target defines the target of the animation
  4005. * @returns the {BABYLON.TargetedAnimation} object
  4006. */
  4007. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4008. /**
  4009. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4010. * It can add constant keys at begin or end
  4011. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4012. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4013. */
  4014. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4015. /**
  4016. * Start all animations on given targets
  4017. * @param loop defines if animations must loop
  4018. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4019. * @param from defines the from key (optional)
  4020. * @param to defines the to key (optional)
  4021. * @returns the current animation group
  4022. */
  4023. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4024. /**
  4025. * Pause all animations
  4026. */
  4027. pause(): AnimationGroup;
  4028. /**
  4029. * Play all animations to initial state
  4030. * This function will start() the animations if they were not started or will restart() them if they were paused
  4031. * @param loop defines if animations must loop
  4032. */
  4033. play(loop?: boolean): AnimationGroup;
  4034. /**
  4035. * Reset all animations to initial state
  4036. */
  4037. reset(): AnimationGroup;
  4038. /**
  4039. * Restart animations from key 0
  4040. */
  4041. restart(): AnimationGroup;
  4042. /**
  4043. * Stop all animations
  4044. */
  4045. stop(): AnimationGroup;
  4046. /**
  4047. * Set animation weight for all animatables
  4048. * @param weight defines the weight to use
  4049. * @return the animationGroup
  4050. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4051. */
  4052. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4053. /**
  4054. * Synchronize and normalize all animatables with a source animatable
  4055. * @param root defines the root animatable to synchronize with
  4056. * @return the animationGroup
  4057. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4058. */
  4059. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4060. /**
  4061. * Goes to a specific frame in this animation group
  4062. * @param frame the frame number to go to
  4063. * @return the animationGroup
  4064. */
  4065. goToFrame(frame: number): AnimationGroup;
  4066. /**
  4067. * Dispose all associated resources
  4068. */
  4069. dispose(): void;
  4070. }
  4071. }
  4072. declare module BABYLON {
  4073. /**
  4074. * Class used to override all child animations of a given target
  4075. */
  4076. class AnimationPropertiesOverride {
  4077. /**
  4078. * Gets or sets a value indicating if animation blending must be used
  4079. */
  4080. enableBlending: boolean;
  4081. /**
  4082. * Gets or sets the blending speed to use when enableBlending is true
  4083. */
  4084. blendingSpeed: number;
  4085. /**
  4086. * Gets or sets the default loop mode to use
  4087. */
  4088. loopMode: number;
  4089. }
  4090. }
  4091. declare module BABYLON {
  4092. interface IEasingFunction {
  4093. ease(gradient: number): number;
  4094. }
  4095. class EasingFunction implements IEasingFunction {
  4096. private static _EASINGMODE_EASEIN;
  4097. private static _EASINGMODE_EASEOUT;
  4098. private static _EASINGMODE_EASEINOUT;
  4099. static readonly EASINGMODE_EASEIN: number;
  4100. static readonly EASINGMODE_EASEOUT: number;
  4101. static readonly EASINGMODE_EASEINOUT: number;
  4102. private _easingMode;
  4103. setEasingMode(easingMode: number): void;
  4104. getEasingMode(): number;
  4105. easeInCore(gradient: number): number;
  4106. ease(gradient: number): number;
  4107. }
  4108. class CircleEase extends EasingFunction implements IEasingFunction {
  4109. easeInCore(gradient: number): number;
  4110. }
  4111. class BackEase extends EasingFunction implements IEasingFunction {
  4112. amplitude: number;
  4113. constructor(amplitude?: number);
  4114. easeInCore(gradient: number): number;
  4115. }
  4116. class BounceEase extends EasingFunction implements IEasingFunction {
  4117. bounces: number;
  4118. bounciness: number;
  4119. constructor(bounces?: number, bounciness?: number);
  4120. easeInCore(gradient: number): number;
  4121. }
  4122. class CubicEase extends EasingFunction implements IEasingFunction {
  4123. easeInCore(gradient: number): number;
  4124. }
  4125. class ElasticEase extends EasingFunction implements IEasingFunction {
  4126. oscillations: number;
  4127. springiness: number;
  4128. constructor(oscillations?: number, springiness?: number);
  4129. easeInCore(gradient: number): number;
  4130. }
  4131. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4132. exponent: number;
  4133. constructor(exponent?: number);
  4134. easeInCore(gradient: number): number;
  4135. }
  4136. class PowerEase extends EasingFunction implements IEasingFunction {
  4137. power: number;
  4138. constructor(power?: number);
  4139. easeInCore(gradient: number): number;
  4140. }
  4141. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4142. easeInCore(gradient: number): number;
  4143. }
  4144. class QuarticEase extends EasingFunction implements IEasingFunction {
  4145. easeInCore(gradient: number): number;
  4146. }
  4147. class QuinticEase extends EasingFunction implements IEasingFunction {
  4148. easeInCore(gradient: number): number;
  4149. }
  4150. class SineEase extends EasingFunction implements IEasingFunction {
  4151. easeInCore(gradient: number): number;
  4152. }
  4153. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4154. x1: number;
  4155. y1: number;
  4156. x2: number;
  4157. y2: number;
  4158. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4159. easeInCore(gradient: number): number;
  4160. }
  4161. }
  4162. declare module BABYLON {
  4163. /**
  4164. * Defines a runtime animation
  4165. */
  4166. class RuntimeAnimation {
  4167. /**
  4168. * The current frame of the runtime animation
  4169. */
  4170. private _currentFrame;
  4171. /**
  4172. * The animation used by the runtime animation
  4173. */
  4174. private _animation;
  4175. /**
  4176. * The target of the runtime animation
  4177. */
  4178. private _target;
  4179. /**
  4180. * The initiating animatable
  4181. */
  4182. private _host;
  4183. /**
  4184. * The original value of the runtime animation
  4185. */
  4186. private _originalValue;
  4187. /**
  4188. * The original blend value of the runtime animation
  4189. */
  4190. private _originalBlendValue;
  4191. /**
  4192. * The offsets cache of the runtime animation
  4193. */
  4194. private _offsetsCache;
  4195. /**
  4196. * The high limits cache of the runtime animation
  4197. */
  4198. private _highLimitsCache;
  4199. /**
  4200. * Specifies if the runtime animation has been stopped
  4201. */
  4202. private _stopped;
  4203. /**
  4204. * The blending factor of the runtime animation
  4205. */
  4206. private _blendingFactor;
  4207. /**
  4208. * The BabylonJS scene
  4209. */
  4210. private _scene;
  4211. /**
  4212. * The current value of the runtime animation
  4213. */
  4214. private _currentValue;
  4215. /** @hidden */
  4216. _workValue: any;
  4217. /**
  4218. * The active target of the runtime animation
  4219. */
  4220. private _activeTarget;
  4221. /**
  4222. * The target path of the runtime animation
  4223. */
  4224. private _targetPath;
  4225. /**
  4226. * The weight of the runtime animation
  4227. */
  4228. private _weight;
  4229. /**
  4230. * The ratio offset of the runtime animation
  4231. */
  4232. private _ratioOffset;
  4233. /**
  4234. * The previous delay of the runtime animation
  4235. */
  4236. private _previousDelay;
  4237. /**
  4238. * The previous ratio of the runtime animation
  4239. */
  4240. private _previousRatio;
  4241. /**
  4242. * Gets the current frame of the runtime animation
  4243. */
  4244. readonly currentFrame: number;
  4245. /**
  4246. * Gets the weight of the runtime animation
  4247. */
  4248. readonly weight: number;
  4249. /**
  4250. * Gets the current value of the runtime animation
  4251. */
  4252. readonly currentValue: any;
  4253. /**
  4254. * Gets the target path of the runtime animation
  4255. */
  4256. readonly targetPath: string;
  4257. /**
  4258. * Gets the actual target of the runtime animation
  4259. */
  4260. readonly target: any;
  4261. /**
  4262. * Create a new RuntimeAnimation object
  4263. * @param target defines the target of the animation
  4264. * @param animation defines the source animation object
  4265. * @param scene defines the hosting scene
  4266. * @param host defines the initiating Animatable
  4267. */
  4268. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4269. /**
  4270. * Gets the animation from the runtime animation
  4271. */
  4272. readonly animation: Animation;
  4273. /**
  4274. * Resets the runtime animation to the beginning
  4275. * @param restoreOriginal defines whether to restore the target property to the original value
  4276. */
  4277. reset(restoreOriginal?: boolean): void;
  4278. /**
  4279. * Specifies if the runtime animation is stopped
  4280. * @returns Boolean specifying if the runtime animation is stopped
  4281. */
  4282. isStopped(): boolean;
  4283. /**
  4284. * Disposes of the runtime animation
  4285. */
  4286. dispose(): void;
  4287. /**
  4288. * Interpolates the animation from the current frame
  4289. * @param currentFrame The frame to interpolate the animation to
  4290. * @param repeatCount The number of times that the animation should loop
  4291. * @param loopMode The type of looping mode to use
  4292. * @param offsetValue Animation offset value
  4293. * @param highLimitValue The high limit value
  4294. * @returns The interpolated value
  4295. */
  4296. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4297. /**
  4298. * Apply the interpolated value to the target
  4299. * @param currentValue defines the value computed by the animation
  4300. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4301. */
  4302. setValue(currentValue: any, weight?: number): void;
  4303. private _setValue(target, currentValue, weight, targetIndex?);
  4304. /**
  4305. * Gets the loop pmode of the runtime animation
  4306. * @returns Loop Mode
  4307. */
  4308. private _getCorrectLoopMode();
  4309. /**
  4310. * Move the current animation to a given frame
  4311. * @param frame defines the frame to move to
  4312. */
  4313. goToFrame(frame: number): void;
  4314. /**
  4315. * @hidden Internal use only
  4316. */
  4317. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4318. /**
  4319. * Execute the current animation
  4320. * @param delay defines the delay to add to the current frame
  4321. * @param from defines the lower bound of the animation range
  4322. * @param to defines the upper bound of the animation range
  4323. * @param loop defines if the current animation must loop
  4324. * @param speedRatio defines the current speed ratio
  4325. * @param weight defines the weight of the animation (default is -1 so no weight)
  4326. * @returns a boolean indicating if the animation has ended
  4327. */
  4328. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4329. }
  4330. }
  4331. declare module BABYLON {
  4332. /**
  4333. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4335. */
  4336. class Analyser {
  4337. /**
  4338. * Gets or sets the smoothing
  4339. * @ignorenaming
  4340. */
  4341. SMOOTHING: number;
  4342. /**
  4343. * Gets or sets the FFT table size
  4344. * @ignorenaming
  4345. */
  4346. FFT_SIZE: number;
  4347. /**
  4348. * Gets or sets the bar graph amplitude
  4349. * @ignorenaming
  4350. */
  4351. BARGRAPHAMPLITUDE: number;
  4352. /**
  4353. * Gets or sets the position of the debug canvas
  4354. * @ignorenaming
  4355. */
  4356. DEBUGCANVASPOS: {
  4357. x: number;
  4358. y: number;
  4359. };
  4360. /**
  4361. * Gets or sets the debug canvas size
  4362. * @ignorenaming
  4363. */
  4364. DEBUGCANVASSIZE: {
  4365. width: number;
  4366. height: number;
  4367. };
  4368. private _byteFreqs;
  4369. private _byteTime;
  4370. private _floatFreqs;
  4371. private _webAudioAnalyser;
  4372. private _debugCanvas;
  4373. private _debugCanvasContext;
  4374. private _scene;
  4375. private _registerFunc;
  4376. private _audioEngine;
  4377. /**
  4378. * Creates a new analyser
  4379. * @param scene defines hosting scene
  4380. */
  4381. constructor(scene: Scene);
  4382. /**
  4383. * Get the number of data values you will have to play with for the visualization
  4384. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4385. * @returns a number
  4386. */
  4387. getFrequencyBinCount(): number;
  4388. /**
  4389. * Gets the current frequency data as a byte array
  4390. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4391. * @returns a Uint8Array
  4392. */
  4393. getByteFrequencyData(): Uint8Array;
  4394. /**
  4395. * Gets the current waveform as a byte array
  4396. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4397. * @returns a Uint8Array
  4398. */
  4399. getByteTimeDomainData(): Uint8Array;
  4400. /**
  4401. * Gets the current frequency data as a float array
  4402. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4403. * @returns a Float32Array
  4404. */
  4405. getFloatFrequencyData(): Float32Array;
  4406. /**
  4407. * Renders the debug canvas
  4408. */
  4409. drawDebugCanvas(): void;
  4410. /**
  4411. * Stops rendering the debug canvas and removes it
  4412. */
  4413. stopDebugCanvas(): void;
  4414. /**
  4415. * Connects two audio nodes
  4416. * @param inputAudioNode defines first node to connect
  4417. * @param outputAudioNode defines second node to connect
  4418. */
  4419. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4420. /**
  4421. * Releases all associated resources
  4422. */
  4423. dispose(): void;
  4424. }
  4425. }
  4426. declare module BABYLON {
  4427. class AudioEngine {
  4428. private _audioContext;
  4429. private _audioContextInitialized;
  4430. canUseWebAudio: boolean;
  4431. masterGain: GainNode;
  4432. private _connectedAnalyser;
  4433. WarnedWebAudioUnsupported: boolean;
  4434. unlocked: boolean;
  4435. onAudioUnlocked: () => any;
  4436. isMP3supported: boolean;
  4437. isOGGsupported: boolean;
  4438. readonly audioContext: Nullable<AudioContext>;
  4439. constructor();
  4440. private _unlockiOSaudio();
  4441. private _initializeAudioContext();
  4442. dispose(): void;
  4443. getGlobalVolume(): number;
  4444. setGlobalVolume(newVolume: number): void;
  4445. connectToAnalyser(analyser: Analyser): void;
  4446. }
  4447. }
  4448. declare module BABYLON {
  4449. class Sound {
  4450. name: string;
  4451. autoplay: boolean;
  4452. loop: boolean;
  4453. useCustomAttenuation: boolean;
  4454. soundTrackId: number;
  4455. spatialSound: boolean;
  4456. refDistance: number;
  4457. rolloffFactor: number;
  4458. maxDistance: number;
  4459. distanceModel: string;
  4460. private _panningModel;
  4461. onended: () => any;
  4462. private _playbackRate;
  4463. private _streaming;
  4464. private _startTime;
  4465. private _startOffset;
  4466. private _position;
  4467. private _localDirection;
  4468. private _volume;
  4469. private _isReadyToPlay;
  4470. isPlaying: boolean;
  4471. isPaused: boolean;
  4472. private _isDirectional;
  4473. private _readyToPlayCallback;
  4474. private _audioBuffer;
  4475. private _soundSource;
  4476. private _streamingSource;
  4477. private _soundPanner;
  4478. private _soundGain;
  4479. private _inputAudioNode;
  4480. private _ouputAudioNode;
  4481. private _coneInnerAngle;
  4482. private _coneOuterAngle;
  4483. private _coneOuterGain;
  4484. private _scene;
  4485. private _connectedMesh;
  4486. private _customAttenuationFunction;
  4487. private _registerFunc;
  4488. private _isOutputConnected;
  4489. private _htmlAudioElement;
  4490. private _urlType;
  4491. /**
  4492. * Create a sound and attach it to a scene
  4493. * @param name Name of your sound
  4494. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4495. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4496. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4497. */
  4498. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4499. dispose(): void;
  4500. isReady(): boolean;
  4501. private _soundLoaded(audioData);
  4502. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4503. updateOptions(options: any): void;
  4504. private _createSpatialParameters();
  4505. private _updateSpatialParameters();
  4506. switchPanningModelToHRTF(): void;
  4507. switchPanningModelToEqualPower(): void;
  4508. private _switchPanningModel();
  4509. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4510. /**
  4511. * Transform this sound into a directional source
  4512. * @param coneInnerAngle Size of the inner cone in degree
  4513. * @param coneOuterAngle Size of the outer cone in degree
  4514. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4515. */
  4516. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4517. setPosition(newPosition: Vector3): void;
  4518. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4519. private _updateDirection();
  4520. updateDistanceFromListener(): void;
  4521. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4522. /**
  4523. * Play the sound
  4524. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4525. * @param offset (optional) Start the sound setting it at a specific time
  4526. */
  4527. play(time?: number, offset?: number): void;
  4528. private _onended();
  4529. /**
  4530. * Stop the sound
  4531. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4532. */
  4533. stop(time?: number): void;
  4534. pause(): void;
  4535. setVolume(newVolume: number, time?: number): void;
  4536. setPlaybackRate(newPlaybackRate: number): void;
  4537. getVolume(): number;
  4538. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4539. detachFromMesh(): void;
  4540. private _onRegisterAfterWorldMatrixUpdate(node);
  4541. clone(): Nullable<Sound>;
  4542. getAudioBuffer(): AudioBuffer | null;
  4543. serialize(): any;
  4544. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4545. }
  4546. }
  4547. declare module BABYLON {
  4548. class SoundTrack {
  4549. private _outputAudioNode;
  4550. private _scene;
  4551. id: number;
  4552. soundCollection: Array<Sound>;
  4553. private _isMainTrack;
  4554. private _connectedAnalyser;
  4555. private _options;
  4556. private _isInitialized;
  4557. constructor(scene: Scene, options?: any);
  4558. private _initializeSoundTrackAudioGraph();
  4559. dispose(): void;
  4560. AddSound(sound: Sound): void;
  4561. RemoveSound(sound: Sound): void;
  4562. setVolume(newVolume: number): void;
  4563. switchPanningModelToHRTF(): void;
  4564. switchPanningModelToEqualPower(): void;
  4565. connectToAnalyser(analyser: Analyser): void;
  4566. }
  4567. }
  4568. declare module BABYLON {
  4569. interface Behavior<T extends Node> {
  4570. name: string;
  4571. init(): void;
  4572. attach(node: T): void;
  4573. detach(): void;
  4574. }
  4575. }
  4576. declare module BABYLON {
  4577. /**
  4578. * Class used to store bone information
  4579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4580. */
  4581. class Bone extends Node {
  4582. /**
  4583. * defines the bone name
  4584. */
  4585. name: string;
  4586. private static _tmpVecs;
  4587. private static _tmpQuat;
  4588. private static _tmpMats;
  4589. /**
  4590. * Gets the list of child bones
  4591. */
  4592. children: Bone[];
  4593. /** Gets the animations associated with this bone */
  4594. animations: Animation[];
  4595. /**
  4596. * Gets or sets bone length
  4597. */
  4598. length: number;
  4599. /**
  4600. * @hidden Internal only
  4601. * Set this value to map this bone to a different index in the transform matrices
  4602. * Set this value to -1 to exclude the bone from the transform matrices
  4603. */
  4604. _index: Nullable<number>;
  4605. private _skeleton;
  4606. private _localMatrix;
  4607. private _restPose;
  4608. private _baseMatrix;
  4609. private _absoluteTransform;
  4610. private _invertedAbsoluteTransform;
  4611. private _parent;
  4612. private _scalingDeterminant;
  4613. private _worldTransform;
  4614. private _localScaling;
  4615. private _localRotation;
  4616. private _localPosition;
  4617. private _needToDecompose;
  4618. private _needToCompose;
  4619. /** @hidden */
  4620. /** @hidden */
  4621. _matrix: Matrix;
  4622. /**
  4623. * Create a new bone
  4624. * @param name defines the bone name
  4625. * @param skeleton defines the parent skeleton
  4626. * @param parentBone defines the parent (can be null if the bone is the root)
  4627. * @param localMatrix defines the local matrix
  4628. * @param restPose defines the rest pose matrix
  4629. * @param baseMatrix defines the base matrix
  4630. * @param index defines index of the bone in the hiearchy
  4631. */
  4632. constructor(
  4633. /**
  4634. * defines the bone name
  4635. */
  4636. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4637. /**
  4638. * Gets the parent skeleton
  4639. * @returns a skeleton
  4640. */
  4641. getSkeleton(): Skeleton;
  4642. /**
  4643. * Gets parent bone
  4644. * @returns a bone or null if the bone is the root of the bone hierarchy
  4645. */
  4646. getParent(): Nullable<Bone>;
  4647. /**
  4648. * Sets the parent bone
  4649. * @param parent defines the parent (can be null if the bone is the root)
  4650. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4651. */
  4652. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4653. /**
  4654. * Gets the local matrix
  4655. * @returns a matrix
  4656. */
  4657. getLocalMatrix(): Matrix;
  4658. /**
  4659. * Gets the base matrix (initial matrix which remains unchanged)
  4660. * @returns a matrix
  4661. */
  4662. getBaseMatrix(): Matrix;
  4663. /**
  4664. * Gets the rest pose matrix
  4665. * @returns a matrix
  4666. */
  4667. getRestPose(): Matrix;
  4668. /**
  4669. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4670. */
  4671. getWorldMatrix(): Matrix;
  4672. /**
  4673. * Sets the local matrix to rest pose matrix
  4674. */
  4675. returnToRest(): void;
  4676. /**
  4677. * Gets the inverse of the absolute transform matrix.
  4678. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4679. * @returns a matrix
  4680. */
  4681. getInvertedAbsoluteTransform(): Matrix;
  4682. /**
  4683. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4684. * @returns a matrix
  4685. */
  4686. getAbsoluteTransform(): Matrix;
  4687. /** Gets or sets current position (in local space) */
  4688. position: Vector3;
  4689. /** Gets or sets current rotation (in local space) */
  4690. rotation: Vector3;
  4691. /** Gets or sets current rotation quaternion (in local space) */
  4692. rotationQuaternion: Quaternion;
  4693. /** Gets or sets current scaling (in local space) */
  4694. scaling: Vector3;
  4695. /**
  4696. * Gets the animation properties override
  4697. */
  4698. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4699. private _decompose();
  4700. private _compose();
  4701. /**
  4702. * Update the base and local matrices
  4703. * @param matrix defines the new base or local matrix
  4704. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4705. * @param updateLocalMatrix defines if the local matrix should be updated
  4706. */
  4707. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4708. /** @hidden */
  4709. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4710. /**
  4711. * Flag the bone as dirty (Forcing it to update everything)
  4712. */
  4713. markAsDirty(): void;
  4714. private _markAsDirtyAndCompose();
  4715. private _markAsDirtyAndDecompose();
  4716. /**
  4717. * Copy an animation range from another bone
  4718. * @param source defines the source bone
  4719. * @param rangeName defines the range name to copy
  4720. * @param frameOffset defines the frame offset
  4721. * @param rescaleAsRequired defines if rescaling must be applied if required
  4722. * @param skelDimensionsRatio defines the scaling ratio
  4723. * @returns true if operation was successful
  4724. */
  4725. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4726. /**
  4727. * Translate the bone in local or world space
  4728. * @param vec The amount to translate the bone
  4729. * @param space The space that the translation is in
  4730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4731. */
  4732. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4733. /**
  4734. * Set the postion of the bone in local or world space
  4735. * @param position The position to set the bone
  4736. * @param space The space that the position is in
  4737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4738. */
  4739. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4740. /**
  4741. * Set the absolute position of the bone (world space)
  4742. * @param position The position to set the bone
  4743. * @param mesh The mesh that this bone is attached to
  4744. */
  4745. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4746. /**
  4747. * Scale the bone on the x, y and z axes (in local space)
  4748. * @param x The amount to scale the bone on the x axis
  4749. * @param y The amount to scale the bone on the y axis
  4750. * @param z The amount to scale the bone on the z axis
  4751. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4752. */
  4753. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4754. /**
  4755. * Set the bone scaling in local space
  4756. * @param scale defines the scaling vector
  4757. */
  4758. setScale(scale: Vector3): void;
  4759. /**
  4760. * Gets the current scaling in local space
  4761. * @returns the current scaling vector
  4762. */
  4763. getScale(): Vector3;
  4764. /**
  4765. * Gets the current scaling in local space and stores it in a target vector
  4766. * @param result defines the target vector
  4767. */
  4768. getScaleToRef(result: Vector3): void;
  4769. /**
  4770. * Set the yaw, pitch, and roll of the bone in local or world space
  4771. * @param yaw The rotation of the bone on the y axis
  4772. * @param pitch The rotation of the bone on the x axis
  4773. * @param roll The rotation of the bone on the z axis
  4774. * @param space The space that the axes of rotation are in
  4775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4776. */
  4777. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4778. /**
  4779. * Add a rotation to the bone on an axis in local or world space
  4780. * @param axis The axis to rotate the bone on
  4781. * @param amount The amount to rotate the bone
  4782. * @param space The space that the axis is in
  4783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4784. */
  4785. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4786. /**
  4787. * Set the rotation of the bone to a particular axis angle in local or world space
  4788. * @param axis The axis to rotate the bone on
  4789. * @param angle The angle that the bone should be rotated to
  4790. * @param space The space that the axis is in
  4791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4792. */
  4793. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4794. /**
  4795. * Set the euler rotation of the bone in local of world space
  4796. * @param rotation The euler rotation that the bone should be set to
  4797. * @param space The space that the rotation is in
  4798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4799. */
  4800. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4801. /**
  4802. * Set the quaternion rotation of the bone in local of world space
  4803. * @param quat The quaternion rotation that the bone should be set to
  4804. * @param space The space that the rotation is in
  4805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4806. */
  4807. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4808. /**
  4809. * Set the rotation matrix of the bone in local of world space
  4810. * @param rotMat The rotation matrix that the bone should be set to
  4811. * @param space The space that the rotation is in
  4812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4813. */
  4814. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4815. private _rotateWithMatrix(rmat, space?, mesh?);
  4816. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4817. /**
  4818. * Get the position of the bone in local or world space
  4819. * @param space The space that the returned position is in
  4820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4821. * @returns The position of the bone
  4822. */
  4823. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4824. /**
  4825. * Copy the position of the bone to a vector3 in local or world space
  4826. * @param space The space that the returned position is in
  4827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4828. * @param result The vector3 to copy the position to
  4829. */
  4830. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4831. /**
  4832. * Get the absolute position of the bone (world space)
  4833. * @param mesh The mesh that this bone is attached to
  4834. * @returns The absolute position of the bone
  4835. */
  4836. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4837. /**
  4838. * Copy the absolute position of the bone (world space) to the result param
  4839. * @param mesh The mesh that this bone is attached to
  4840. * @param result The vector3 to copy the absolute position to
  4841. */
  4842. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4843. /**
  4844. * Compute the absolute transforms of this bone and its children
  4845. */
  4846. computeAbsoluteTransforms(): void;
  4847. /**
  4848. * Get the world direction from an axis that is in the local space of the bone
  4849. * @param localAxis The local direction that is used to compute the world direction
  4850. * @param mesh The mesh that this bone is attached to
  4851. * @returns The world direction
  4852. */
  4853. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4854. /**
  4855. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4856. * @param localAxis The local direction that is used to compute the world direction
  4857. * @param mesh The mesh that this bone is attached to
  4858. * @param result The vector3 that the world direction will be copied to
  4859. */
  4860. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4861. /**
  4862. * Get the euler rotation of the bone in local or world space
  4863. * @param space The space that the rotation should be in
  4864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4865. * @returns The euler rotation
  4866. */
  4867. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4868. /**
  4869. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4870. * @param space The space that the rotation should be in
  4871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4872. * @param result The vector3 that the rotation should be copied to
  4873. */
  4874. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4875. /**
  4876. * Get the quaternion rotation of the bone in either local or world space
  4877. * @param space The space that the rotation should be in
  4878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4879. * @returns The quaternion rotation
  4880. */
  4881. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4882. /**
  4883. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4884. * @param space The space that the rotation should be in
  4885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4886. * @param result The quaternion that the rotation should be copied to
  4887. */
  4888. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4889. /**
  4890. * Get the rotation matrix of the bone in local or world space
  4891. * @param space The space that the rotation should be in
  4892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4893. * @returns The rotation matrix
  4894. */
  4895. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4896. /**
  4897. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4898. * @param space The space that the rotation should be in
  4899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4900. * @param result The quaternion that the rotation should be copied to
  4901. */
  4902. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4903. /**
  4904. * Get the world position of a point that is in the local space of the bone
  4905. * @param position The local position
  4906. * @param mesh The mesh that this bone is attached to
  4907. * @returns The world position
  4908. */
  4909. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4910. /**
  4911. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4912. * @param position The local position
  4913. * @param mesh The mesh that this bone is attached to
  4914. * @param result The vector3 that the world position should be copied to
  4915. */
  4916. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4917. /**
  4918. * Get the local position of a point that is in world space
  4919. * @param position The world position
  4920. * @param mesh The mesh that this bone is attached to
  4921. * @returns The local position
  4922. */
  4923. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4924. /**
  4925. * Get the local position of a point that is in world space and copy it to the result param
  4926. * @param position The world position
  4927. * @param mesh The mesh that this bone is attached to
  4928. * @param result The vector3 that the local position should be copied to
  4929. */
  4930. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4931. }
  4932. }
  4933. declare module BABYLON {
  4934. /**
  4935. * Class used to apply inverse kinematics to bones
  4936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4937. */
  4938. class BoneIKController {
  4939. private static _tmpVecs;
  4940. private static _tmpQuat;
  4941. private static _tmpMats;
  4942. /**
  4943. * Gets or sets the target mesh
  4944. */
  4945. targetMesh: AbstractMesh;
  4946. /** Gets or sets the mesh used as pole */
  4947. poleTargetMesh: AbstractMesh;
  4948. /**
  4949. * Gets or sets the bone used as pole
  4950. */
  4951. poleTargetBone: Nullable<Bone>;
  4952. /**
  4953. * Gets or sets the target position
  4954. */
  4955. targetPosition: Vector3;
  4956. /**
  4957. * Gets or sets the pole target position
  4958. */
  4959. poleTargetPosition: Vector3;
  4960. /**
  4961. * Gets or sets the pole target local offset
  4962. */
  4963. poleTargetLocalOffset: Vector3;
  4964. /**
  4965. * Gets or sets the pole angle
  4966. */
  4967. poleAngle: number;
  4968. /**
  4969. * Gets or sets the mesh associated with the controller
  4970. */
  4971. mesh: AbstractMesh;
  4972. /**
  4973. * 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)
  4974. */
  4975. slerpAmount: number;
  4976. private _bone1Quat;
  4977. private _bone1Mat;
  4978. private _bone2Ang;
  4979. private _bone1;
  4980. private _bone2;
  4981. private _bone1Length;
  4982. private _bone2Length;
  4983. private _maxAngle;
  4984. private _maxReach;
  4985. private _rightHandedSystem;
  4986. private _bendAxis;
  4987. private _slerping;
  4988. private _adjustRoll;
  4989. /**
  4990. * Gets or sets maximum allowed angle
  4991. */
  4992. maxAngle: number;
  4993. /**
  4994. * Creates a new BoneIKController
  4995. * @param mesh defines the mesh to control
  4996. * @param bone defines the bone to control
  4997. * @param options defines options to set up the controller
  4998. */
  4999. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5000. targetMesh?: AbstractMesh;
  5001. poleTargetMesh?: AbstractMesh;
  5002. poleTargetBone?: Bone;
  5003. poleTargetLocalOffset?: Vector3;
  5004. poleAngle?: number;
  5005. bendAxis?: Vector3;
  5006. maxAngle?: number;
  5007. slerpAmount?: number;
  5008. });
  5009. private _setMaxAngle(ang);
  5010. /**
  5011. * Force the controller to update the bones
  5012. */
  5013. update(): void;
  5014. }
  5015. }
  5016. declare module BABYLON {
  5017. /**
  5018. * Class used to make a bone look toward a point in space
  5019. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5020. */
  5021. class BoneLookController {
  5022. private static _tmpVecs;
  5023. private static _tmpQuat;
  5024. private static _tmpMats;
  5025. /**
  5026. * The target Vector3 that the bone will look at
  5027. */
  5028. target: Vector3;
  5029. /**
  5030. * The mesh that the bone is attached to
  5031. */
  5032. mesh: AbstractMesh;
  5033. /**
  5034. * The bone that will be looking to the target
  5035. */
  5036. bone: Bone;
  5037. /**
  5038. * The up axis of the coordinate system that is used when the bone is rotated
  5039. */
  5040. upAxis: Vector3;
  5041. /**
  5042. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5043. */
  5044. upAxisSpace: Space;
  5045. /**
  5046. * Used to make an adjustment to the yaw of the bone
  5047. */
  5048. adjustYaw: number;
  5049. /**
  5050. * Used to make an adjustment to the pitch of the bone
  5051. */
  5052. adjustPitch: number;
  5053. /**
  5054. * Used to make an adjustment to the roll of the bone
  5055. */
  5056. adjustRoll: number;
  5057. /**
  5058. * 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)
  5059. */
  5060. slerpAmount: number;
  5061. private _minYaw;
  5062. private _maxYaw;
  5063. private _minPitch;
  5064. private _maxPitch;
  5065. private _minYawSin;
  5066. private _minYawCos;
  5067. private _maxYawSin;
  5068. private _maxYawCos;
  5069. private _midYawConstraint;
  5070. private _minPitchTan;
  5071. private _maxPitchTan;
  5072. private _boneQuat;
  5073. private _slerping;
  5074. private _transformYawPitch;
  5075. private _transformYawPitchInv;
  5076. private _firstFrameSkipped;
  5077. private _yawRange;
  5078. private _fowardAxis;
  5079. /**
  5080. * Gets or sets the minimum yaw angle that the bone can look to
  5081. */
  5082. minYaw: number;
  5083. /**
  5084. * Gets or sets the maximum yaw angle that the bone can look to
  5085. */
  5086. maxYaw: number;
  5087. /**
  5088. * Gets or sets the minimum pitch angle that the bone can look to
  5089. */
  5090. minPitch: number;
  5091. /**
  5092. * Gets or sets the maximum pitch angle that the bone can look to
  5093. */
  5094. maxPitch: number;
  5095. /**
  5096. * Create a BoneLookController
  5097. * @param mesh the mesh that the bone belongs to
  5098. * @param bone the bone that will be looking to the target
  5099. * @param target the target Vector3 to look at
  5100. * @param settings optional settings:
  5101. * * maxYaw: the maximum angle the bone will yaw to
  5102. * * minYaw: the minimum angle the bone will yaw to
  5103. * * maxPitch: the maximum angle the bone will pitch to
  5104. * * minPitch: the minimum angle the bone will yaw to
  5105. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5106. * * upAxis: the up axis of the coordinate system
  5107. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5108. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5109. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5110. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5111. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5112. * * adjustRoll: used to make an adjustment to the roll of the bone
  5113. **/
  5114. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5115. maxYaw?: number;
  5116. minYaw?: number;
  5117. maxPitch?: number;
  5118. minPitch?: number;
  5119. slerpAmount?: number;
  5120. upAxis?: Vector3;
  5121. upAxisSpace?: Space;
  5122. yawAxis?: Vector3;
  5123. pitchAxis?: Vector3;
  5124. adjustYaw?: number;
  5125. adjustPitch?: number;
  5126. adjustRoll?: number;
  5127. });
  5128. /**
  5129. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5130. */
  5131. update(): void;
  5132. private _getAngleDiff(ang1, ang2);
  5133. private _getAngleBetween(ang1, ang2);
  5134. private _isAngleBetween(ang, ang1, ang2);
  5135. }
  5136. }
  5137. declare module BABYLON {
  5138. /**
  5139. * Class used to handle skinning animations
  5140. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5141. */
  5142. class Skeleton implements IAnimatable {
  5143. /** defines the skeleton name */
  5144. name: string;
  5145. /** defines the skeleton Id */
  5146. id: string;
  5147. /**
  5148. * Gets the list of child bones
  5149. */
  5150. bones: Bone[];
  5151. /**
  5152. * Gets an estimate of the dimension of the skeleton at rest
  5153. */
  5154. dimensionsAtRest: Vector3;
  5155. /**
  5156. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5157. */
  5158. needInitialSkinMatrix: boolean;
  5159. /**
  5160. * Gets the list of animations attached to this skeleton
  5161. */
  5162. animations: Array<Animation>;
  5163. private _scene;
  5164. private _isDirty;
  5165. private _transformMatrices;
  5166. private _meshesWithPoseMatrix;
  5167. private _animatables;
  5168. private _identity;
  5169. private _synchronizedWithMesh;
  5170. private _ranges;
  5171. private _lastAbsoluteTransformsUpdateId;
  5172. /**
  5173. * Specifies if the skeleton should be serialized
  5174. */
  5175. doNotSerialize: boolean;
  5176. private _animationPropertiesOverride;
  5177. /**
  5178. * Gets or sets the animation properties override
  5179. */
  5180. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5181. /**
  5182. * An observable triggered before computing the skeleton's matrices
  5183. */
  5184. onBeforeComputeObservable: Observable<Skeleton>;
  5185. /**
  5186. * Creates a new skeleton
  5187. * @param name defines the skeleton name
  5188. * @param id defines the skeleton Id
  5189. * @param scene defines the hosting scene
  5190. */
  5191. constructor(
  5192. /** defines the skeleton name */
  5193. name: string,
  5194. /** defines the skeleton Id */
  5195. id: string, scene: Scene);
  5196. /**
  5197. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5198. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5199. * @returns a Float32Array containing matrices data
  5200. */
  5201. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5202. /**
  5203. * Gets the current hosting scene
  5204. * @returns a scene object
  5205. */
  5206. getScene(): Scene;
  5207. /**
  5208. * Gets a string representing the current skeleton data
  5209. * @param fullDetails defines a boolean indicating if we want a verbose version
  5210. * @returns a string representing the current skeleton data
  5211. */
  5212. toString(fullDetails?: boolean): string;
  5213. /**
  5214. * Get bone's index searching by name
  5215. * @param name defines bone's name to search for
  5216. * @return the indice of the bone. Returns -1 if not found
  5217. */
  5218. getBoneIndexByName(name: string): number;
  5219. /**
  5220. * Creater a new animation range
  5221. * @param name defines the name of the range
  5222. * @param from defines the start key
  5223. * @param to defines the end key
  5224. */
  5225. createAnimationRange(name: string, from: number, to: number): void;
  5226. /**
  5227. * Delete a specific animation range
  5228. * @param name defines the name of the range
  5229. * @param deleteFrames defines if frames must be removed as well
  5230. */
  5231. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5232. /**
  5233. * Gets a specific animation range
  5234. * @param name defines the name of the range to look for
  5235. * @returns the requested animation range or null if not found
  5236. */
  5237. getAnimationRange(name: string): Nullable<AnimationRange>;
  5238. /**
  5239. * Gets the list of all animation ranges defined on this skeleton
  5240. * @returns an array
  5241. */
  5242. getAnimationRanges(): Nullable<AnimationRange>[];
  5243. /**
  5244. * Copy animation range from a source skeleton.
  5245. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5246. * @param source defines the source skeleton
  5247. * @param name defines the name of the range to copy
  5248. * @param rescaleAsRequired defines if rescaling must be applied if required
  5249. * @returns true if operation was successful
  5250. */
  5251. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5252. /**
  5253. * Forces the skeleton to go to rest pose
  5254. */
  5255. returnToRest(): void;
  5256. private _getHighestAnimationFrame();
  5257. /**
  5258. * Begin a specific animation range
  5259. * @param name defines the name of the range to start
  5260. * @param loop defines if looping must be turned on (false by default)
  5261. * @param speedRatio defines the speed ratio to apply (1 by default)
  5262. * @param onAnimationEnd defines a callback which will be called when animation will end
  5263. * @returns a new animatable
  5264. */
  5265. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5266. /** @hidden */
  5267. _markAsDirty(): void;
  5268. /** @hidden */
  5269. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5270. /** @hidden */
  5271. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5272. /** @hidden */
  5273. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5274. /**
  5275. * Build all resources required to render a skeleton
  5276. */
  5277. prepare(): void;
  5278. /**
  5279. * Gets the list of animatables currently running for this skeleton
  5280. * @returns an array of animatables
  5281. */
  5282. getAnimatables(): IAnimatable[];
  5283. /**
  5284. * Clone the current skeleton
  5285. * @param name defines the name of the new skeleton
  5286. * @param id defines the id of the enw skeleton
  5287. * @returns the new skeleton
  5288. */
  5289. clone(name: string, id: string): Skeleton;
  5290. /**
  5291. * Enable animation blending for this skeleton
  5292. * @param blendingSpeed defines the blending speed to apply
  5293. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5294. */
  5295. enableBlending(blendingSpeed?: number): void;
  5296. /**
  5297. * Releases all resources associated with the current skeleton
  5298. */
  5299. dispose(): void;
  5300. /**
  5301. * Serialize the skeleton in a JSON object
  5302. * @returns a JSON object
  5303. */
  5304. serialize(): any;
  5305. /**
  5306. * Creates a new skeleton from serialized data
  5307. * @param parsedSkeleton defines the serialized data
  5308. * @param scene defines the hosting scene
  5309. * @returns a new skeleton
  5310. */
  5311. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5312. /**
  5313. * Compute all node absolute transforms
  5314. * @param forceUpdate defines if computation must be done even if cache is up to date
  5315. */
  5316. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5317. /**
  5318. * Gets the root pose matrix
  5319. * @returns a matrix
  5320. */
  5321. getPoseMatrix(): Nullable<Matrix>;
  5322. /**
  5323. * Sorts bones per internal index
  5324. */
  5325. sortBones(): void;
  5326. private _sortBones(index, bones, visited);
  5327. }
  5328. }
  5329. declare module BABYLON {
  5330. class Collider {
  5331. /** Define if a collision was found */
  5332. collisionFound: boolean;
  5333. /**
  5334. * Define last intersection point in local space
  5335. */
  5336. intersectionPoint: Vector3;
  5337. /**
  5338. * Define last collided mesh
  5339. */
  5340. collidedMesh: Nullable<AbstractMesh>;
  5341. private _collisionPoint;
  5342. private _planeIntersectionPoint;
  5343. private _tempVector;
  5344. private _tempVector2;
  5345. private _tempVector3;
  5346. private _tempVector4;
  5347. private _edge;
  5348. private _baseToVertex;
  5349. private _destinationPoint;
  5350. private _slidePlaneNormal;
  5351. private _displacementVector;
  5352. _radius: Vector3;
  5353. _retry: number;
  5354. private _velocity;
  5355. private _basePoint;
  5356. private _epsilon;
  5357. _velocityWorldLength: number;
  5358. _basePointWorld: Vector3;
  5359. private _velocityWorld;
  5360. private _normalizedVelocity;
  5361. _initialVelocity: Vector3;
  5362. _initialPosition: Vector3;
  5363. private _nearestDistance;
  5364. private _collisionMask;
  5365. collisionMask: number;
  5366. /**
  5367. * Gets the plane normal used to compute the sliding response (in local space)
  5368. */
  5369. readonly slidePlaneNormal: Vector3;
  5370. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5371. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5372. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5373. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5374. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5375. _getResponse(pos: Vector3, vel: Vector3): void;
  5376. }
  5377. }
  5378. declare module BABYLON {
  5379. var CollisionWorker: string;
  5380. interface ICollisionCoordinator {
  5381. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5382. init(scene: Scene): void;
  5383. destroy(): void;
  5384. onMeshAdded(mesh: AbstractMesh): void;
  5385. onMeshUpdated(mesh: AbstractMesh): void;
  5386. onMeshRemoved(mesh: AbstractMesh): void;
  5387. onGeometryAdded(geometry: Geometry): void;
  5388. onGeometryUpdated(geometry: Geometry): void;
  5389. onGeometryDeleted(geometry: Geometry): void;
  5390. }
  5391. interface SerializedMesh {
  5392. id: string;
  5393. name: string;
  5394. uniqueId: number;
  5395. geometryId: Nullable<string>;
  5396. sphereCenter: Array<number>;
  5397. sphereRadius: number;
  5398. boxMinimum: Array<number>;
  5399. boxMaximum: Array<number>;
  5400. worldMatrixFromCache: any;
  5401. subMeshes: Array<SerializedSubMesh>;
  5402. checkCollisions: boolean;
  5403. }
  5404. interface SerializedSubMesh {
  5405. position: number;
  5406. verticesStart: number;
  5407. verticesCount: number;
  5408. indexStart: number;
  5409. indexCount: number;
  5410. hasMaterial: boolean;
  5411. sphereCenter: Array<number>;
  5412. sphereRadius: number;
  5413. boxMinimum: Array<number>;
  5414. boxMaximum: Array<number>;
  5415. }
  5416. /**
  5417. * Interface describing the value associated with a geometry
  5418. */
  5419. interface SerializedGeometry {
  5420. /**
  5421. * Defines the unique ID of the geometry
  5422. */
  5423. id: string;
  5424. /**
  5425. * Defines the array containing the positions
  5426. */
  5427. positions: Float32Array;
  5428. /**
  5429. * Defines the array containing the indices
  5430. */
  5431. indices: Uint32Array;
  5432. /**
  5433. * Defines the array containing the normals
  5434. */
  5435. normals: Float32Array;
  5436. }
  5437. interface BabylonMessage {
  5438. taskType: WorkerTaskType;
  5439. payload: InitPayload | CollidePayload | UpdatePayload;
  5440. }
  5441. interface SerializedColliderToWorker {
  5442. position: Array<number>;
  5443. velocity: Array<number>;
  5444. radius: Array<number>;
  5445. }
  5446. /** Defines supported task for worker process */
  5447. enum WorkerTaskType {
  5448. /** Initialization */
  5449. INIT = 0,
  5450. /** Update of geometry */
  5451. UPDATE = 1,
  5452. /** Evaluate collision */
  5453. COLLIDE = 2,
  5454. }
  5455. interface WorkerReply {
  5456. error: WorkerReplyType;
  5457. taskType: WorkerTaskType;
  5458. payload?: any;
  5459. }
  5460. interface CollisionReplyPayload {
  5461. newPosition: Array<number>;
  5462. collisionId: number;
  5463. collidedMeshUniqueId: number;
  5464. }
  5465. interface InitPayload {
  5466. }
  5467. interface CollidePayload {
  5468. collisionId: number;
  5469. collider: SerializedColliderToWorker;
  5470. maximumRetry: number;
  5471. excludedMeshUniqueId: Nullable<number>;
  5472. }
  5473. interface UpdatePayload {
  5474. updatedMeshes: {
  5475. [n: number]: SerializedMesh;
  5476. };
  5477. updatedGeometries: {
  5478. [s: string]: SerializedGeometry;
  5479. };
  5480. removedMeshes: Array<number>;
  5481. removedGeometries: Array<string>;
  5482. }
  5483. /** Defines kind of replies returned by worker */
  5484. enum WorkerReplyType {
  5485. /** Success */
  5486. SUCCESS = 0,
  5487. /** Unkown error */
  5488. UNKNOWN_ERROR = 1,
  5489. }
  5490. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5491. private _scene;
  5492. private _scaledPosition;
  5493. private _scaledVelocity;
  5494. private _collisionsCallbackArray;
  5495. private _init;
  5496. private _runningUpdated;
  5497. private _worker;
  5498. private _addUpdateMeshesList;
  5499. private _addUpdateGeometriesList;
  5500. private _toRemoveMeshesArray;
  5501. private _toRemoveGeometryArray;
  5502. constructor();
  5503. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5504. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5505. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5506. init(scene: Scene): void;
  5507. destroy(): void;
  5508. onMeshAdded(mesh: AbstractMesh): void;
  5509. onMeshUpdated: (transformNode: TransformNode) => void;
  5510. onMeshRemoved(mesh: AbstractMesh): void;
  5511. onGeometryAdded(geometry: Geometry): void;
  5512. onGeometryUpdated: (geometry: Geometry) => void;
  5513. onGeometryDeleted(geometry: Geometry): void;
  5514. private _afterRender;
  5515. private _onMessageFromWorker;
  5516. }
  5517. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5518. private _scene;
  5519. private _scaledPosition;
  5520. private _scaledVelocity;
  5521. private _finalPosition;
  5522. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5523. init(scene: Scene): void;
  5524. destroy(): void;
  5525. onMeshAdded(mesh: AbstractMesh): void;
  5526. onMeshUpdated(mesh: AbstractMesh): void;
  5527. onMeshRemoved(mesh: AbstractMesh): void;
  5528. onGeometryAdded(geometry: Geometry): void;
  5529. onGeometryUpdated(geometry: Geometry): void;
  5530. onGeometryDeleted(geometry: Geometry): void;
  5531. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5532. }
  5533. }
  5534. declare function importScripts(...urls: string[]): void;
  5535. declare const safePostMessage: any;
  5536. declare module BABYLON {
  5537. var WorkerIncluded: boolean;
  5538. class CollisionCache {
  5539. private _meshes;
  5540. private _geometries;
  5541. getMeshes(): {
  5542. [n: number]: SerializedMesh;
  5543. };
  5544. getGeometries(): {
  5545. [s: number]: SerializedGeometry;
  5546. };
  5547. getMesh(id: any): SerializedMesh;
  5548. addMesh(mesh: SerializedMesh): void;
  5549. removeMesh(uniqueId: number): void;
  5550. getGeometry(id: string): SerializedGeometry;
  5551. addGeometry(geometry: SerializedGeometry): void;
  5552. removeGeometry(id: string): void;
  5553. }
  5554. class CollideWorker {
  5555. collider: Collider;
  5556. private _collisionCache;
  5557. private finalPosition;
  5558. private collisionsScalingMatrix;
  5559. private collisionTranformationMatrix;
  5560. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5561. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5562. private checkCollision(mesh);
  5563. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5564. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5565. private checkSubmeshCollision(subMesh);
  5566. }
  5567. interface ICollisionDetector {
  5568. onInit(payload: InitPayload): void;
  5569. onUpdate(payload: UpdatePayload): void;
  5570. onCollision(payload: CollidePayload): void;
  5571. }
  5572. class CollisionDetectorTransferable implements ICollisionDetector {
  5573. private _collisionCache;
  5574. onInit(payload: InitPayload): void;
  5575. onUpdate(payload: UpdatePayload): void;
  5576. onCollision(payload: CollidePayload): void;
  5577. }
  5578. }
  5579. declare module BABYLON {
  5580. class IntersectionInfo {
  5581. bu: Nullable<number>;
  5582. bv: Nullable<number>;
  5583. distance: number;
  5584. faceId: number;
  5585. subMeshId: number;
  5586. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5587. }
  5588. class PickingInfo {
  5589. hit: boolean;
  5590. distance: number;
  5591. pickedPoint: Nullable<Vector3>;
  5592. pickedMesh: Nullable<AbstractMesh>;
  5593. bu: number;
  5594. bv: number;
  5595. faceId: number;
  5596. subMeshId: number;
  5597. pickedSprite: Nullable<Sprite>;
  5598. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5599. getTextureCoordinates(): Nullable<Vector2>;
  5600. }
  5601. }
  5602. declare module BABYLON {
  5603. class ArcRotateCamera extends TargetCamera {
  5604. alpha: number;
  5605. beta: number;
  5606. radius: number;
  5607. protected _target: Vector3;
  5608. protected _targetHost: Nullable<AbstractMesh>;
  5609. target: Vector3;
  5610. inertialAlphaOffset: number;
  5611. inertialBetaOffset: number;
  5612. inertialRadiusOffset: number;
  5613. lowerAlphaLimit: Nullable<number>;
  5614. upperAlphaLimit: Nullable<number>;
  5615. lowerBetaLimit: number;
  5616. upperBetaLimit: number;
  5617. lowerRadiusLimit: Nullable<number>;
  5618. upperRadiusLimit: Nullable<number>;
  5619. inertialPanningX: number;
  5620. inertialPanningY: number;
  5621. pinchToPanMaxDistance: number;
  5622. panningDistanceLimit: Nullable<number>;
  5623. panningOriginTarget: Vector3;
  5624. panningInertia: number;
  5625. angularSensibilityX: number;
  5626. angularSensibilityY: number;
  5627. pinchPrecision: number;
  5628. pinchDeltaPercentage: number;
  5629. panningSensibility: number;
  5630. keysUp: number[];
  5631. keysDown: number[];
  5632. keysLeft: number[];
  5633. keysRight: number[];
  5634. wheelPrecision: number;
  5635. wheelDeltaPercentage: number;
  5636. zoomOnFactor: number;
  5637. targetScreenOffset: Vector2;
  5638. allowUpsideDown: boolean;
  5639. _viewMatrix: Matrix;
  5640. _useCtrlForPanning: boolean;
  5641. _panningMouseButton: number;
  5642. inputs: ArcRotateCameraInputsManager;
  5643. _reset: () => void;
  5644. panningAxis: Vector3;
  5645. protected _localDirection: Vector3;
  5646. protected _transformedDirection: Vector3;
  5647. private _bouncingBehavior;
  5648. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5649. useBouncingBehavior: boolean;
  5650. private _framingBehavior;
  5651. readonly framingBehavior: Nullable<FramingBehavior>;
  5652. useFramingBehavior: boolean;
  5653. private _autoRotationBehavior;
  5654. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5655. useAutoRotationBehavior: boolean;
  5656. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5657. onCollide: (collidedMesh: AbstractMesh) => void;
  5658. checkCollisions: boolean;
  5659. collisionRadius: Vector3;
  5660. protected _collider: Collider;
  5661. protected _previousPosition: Vector3;
  5662. protected _collisionVelocity: Vector3;
  5663. protected _newPosition: Vector3;
  5664. protected _previousAlpha: number;
  5665. protected _previousBeta: number;
  5666. protected _previousRadius: number;
  5667. protected _collisionTriggered: boolean;
  5668. protected _targetBoundingCenter: Nullable<Vector3>;
  5669. private _computationVector;
  5670. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5671. _initCache(): void;
  5672. _updateCache(ignoreParentClass?: boolean): void;
  5673. protected _getTargetPosition(): Vector3;
  5674. /**
  5675. * Store current camera state (fov, position, etc..)
  5676. */
  5677. private _storedAlpha;
  5678. private _storedBeta;
  5679. private _storedRadius;
  5680. private _storedTarget;
  5681. storeState(): Camera;
  5682. /**
  5683. * Restored camera state. You must call storeState() first
  5684. */
  5685. _restoreStateValues(): boolean;
  5686. _isSynchronizedViewMatrix(): boolean;
  5687. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5688. detachControl(element: HTMLElement): void;
  5689. _checkInputs(): void;
  5690. protected _checkLimits(): void;
  5691. rebuildAnglesAndRadius(): void;
  5692. setPosition(position: Vector3): void;
  5693. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5694. _getViewMatrix(): Matrix;
  5695. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5696. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5697. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5698. min: Vector3;
  5699. max: Vector3;
  5700. distance: number;
  5701. }, doNotUpdateMaxZ?: boolean): void;
  5702. /**
  5703. * @override
  5704. * Override Camera.createRigCamera
  5705. */
  5706. createRigCamera(name: string, cameraIndex: number): Camera;
  5707. /**
  5708. * @override
  5709. * Override Camera._updateRigCameras
  5710. */
  5711. _updateRigCameras(): void;
  5712. dispose(): void;
  5713. getClassName(): string;
  5714. }
  5715. }
  5716. declare module BABYLON {
  5717. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5718. constructor(camera: ArcRotateCamera);
  5719. addMouseWheel(): ArcRotateCameraInputsManager;
  5720. addPointers(): ArcRotateCameraInputsManager;
  5721. addKeyboard(): ArcRotateCameraInputsManager;
  5722. addGamepad(): ArcRotateCameraInputsManager;
  5723. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5724. }
  5725. }
  5726. declare module BABYLON {
  5727. class Camera extends Node {
  5728. inputs: CameraInputsManager<Camera>;
  5729. private static _PERSPECTIVE_CAMERA;
  5730. private static _ORTHOGRAPHIC_CAMERA;
  5731. private static _FOVMODE_VERTICAL_FIXED;
  5732. private static _FOVMODE_HORIZONTAL_FIXED;
  5733. private static _RIG_MODE_NONE;
  5734. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5735. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5736. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5737. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5738. private static _RIG_MODE_VR;
  5739. private static _RIG_MODE_WEBVR;
  5740. static readonly PERSPECTIVE_CAMERA: number;
  5741. static readonly ORTHOGRAPHIC_CAMERA: number;
  5742. /**
  5743. * This is the default FOV mode for perspective cameras.
  5744. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5745. *
  5746. */
  5747. static readonly FOVMODE_VERTICAL_FIXED: number;
  5748. /**
  5749. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5750. *
  5751. */
  5752. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5753. static readonly RIG_MODE_NONE: number;
  5754. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5755. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5756. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5757. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5758. static readonly RIG_MODE_VR: number;
  5759. static readonly RIG_MODE_WEBVR: number;
  5760. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5761. static UseAlternateWebVRRendering: boolean;
  5762. position: Vector3;
  5763. /**
  5764. * The vector the camera should consider as up.
  5765. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5766. */
  5767. upVector: Vector3;
  5768. orthoLeft: Nullable<number>;
  5769. orthoRight: Nullable<number>;
  5770. orthoBottom: Nullable<number>;
  5771. orthoTop: Nullable<number>;
  5772. /**
  5773. * FOV is set in Radians. (default is 0.8)
  5774. */
  5775. fov: number;
  5776. minZ: number;
  5777. maxZ: number;
  5778. inertia: number;
  5779. mode: number;
  5780. isIntermediate: boolean;
  5781. viewport: Viewport;
  5782. /**
  5783. * Restricts the camera to viewing objects with the same layerMask.
  5784. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5785. */
  5786. layerMask: number;
  5787. /**
  5788. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5789. */
  5790. fovMode: number;
  5791. cameraRigMode: number;
  5792. interaxialDistance: number;
  5793. isStereoscopicSideBySide: boolean;
  5794. _cameraRigParams: any;
  5795. _rigCameras: Camera[];
  5796. _rigPostProcess: Nullable<PostProcess>;
  5797. protected _webvrViewMatrix: Matrix;
  5798. _skipRendering: boolean;
  5799. _alternateCamera: Camera;
  5800. customRenderTargets: RenderTargetTexture[];
  5801. onViewMatrixChangedObservable: Observable<Camera>;
  5802. onProjectionMatrixChangedObservable: Observable<Camera>;
  5803. onAfterCheckInputsObservable: Observable<Camera>;
  5804. onRestoreStateObservable: Observable<Camera>;
  5805. private _computedViewMatrix;
  5806. _projectionMatrix: Matrix;
  5807. private _doNotComputeProjectionMatrix;
  5808. private _worldMatrix;
  5809. _postProcesses: Nullable<PostProcess>[];
  5810. private _transformMatrix;
  5811. _activeMeshes: SmartArray<AbstractMesh>;
  5812. protected _globalPosition: Vector3;
  5813. private _frustumPlanes;
  5814. private _refreshFrustumPlanes;
  5815. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5816. private _storedFov;
  5817. private _stateStored;
  5818. /**
  5819. * Store current camera state (fov, position, etc..)
  5820. */
  5821. storeState(): Camera;
  5822. /**
  5823. * Restores the camera state values if it has been stored. You must call storeState() first
  5824. */
  5825. protected _restoreStateValues(): boolean;
  5826. /**
  5827. * Restored camera state. You must call storeState() first
  5828. */
  5829. restoreState(): boolean;
  5830. getClassName(): string;
  5831. /**
  5832. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5833. */
  5834. toString(fullDetails?: boolean): string;
  5835. readonly globalPosition: Vector3;
  5836. getActiveMeshes(): SmartArray<AbstractMesh>;
  5837. isActiveMesh(mesh: Mesh): boolean;
  5838. /**
  5839. * Is this camera ready to be used/rendered
  5840. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5841. * @return true if the camera is ready
  5842. */
  5843. isReady(completeCheck?: boolean): boolean;
  5844. _initCache(): void;
  5845. _updateCache(ignoreParentClass?: boolean): void;
  5846. _isSynchronized(): boolean;
  5847. _isSynchronizedViewMatrix(): boolean;
  5848. _isSynchronizedProjectionMatrix(): boolean;
  5849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5850. detachControl(element: HTMLElement): void;
  5851. update(): void;
  5852. _checkInputs(): void;
  5853. readonly rigCameras: Camera[];
  5854. readonly rigPostProcess: Nullable<PostProcess>;
  5855. /**
  5856. * Internal, gets the first post proces.
  5857. * @returns the first post process to be run on this camera.
  5858. */
  5859. _getFirstPostProcess(): Nullable<PostProcess>;
  5860. private _cascadePostProcessesToRigCams();
  5861. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5862. detachPostProcess(postProcess: PostProcess): void;
  5863. getWorldMatrix(): Matrix;
  5864. _getViewMatrix(): Matrix;
  5865. getViewMatrix(force?: boolean): Matrix;
  5866. freezeProjectionMatrix(projection?: Matrix): void;
  5867. unfreezeProjectionMatrix(): void;
  5868. getProjectionMatrix(force?: boolean): Matrix;
  5869. getTranformationMatrix(): Matrix;
  5870. private updateFrustumPlanes();
  5871. isInFrustum(target: ICullable): boolean;
  5872. isCompletelyInFrustum(target: ICullable): boolean;
  5873. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5874. /**
  5875. * Releases resources associated with this node.
  5876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5878. */
  5879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5880. readonly leftCamera: Nullable<FreeCamera>;
  5881. readonly rightCamera: Nullable<FreeCamera>;
  5882. getLeftTarget(): Nullable<Vector3>;
  5883. getRightTarget(): Nullable<Vector3>;
  5884. setCameraRigMode(mode: number, rigParams: any): void;
  5885. private _getVRProjectionMatrix();
  5886. protected _updateCameraRotationMatrix(): void;
  5887. protected _updateWebVRCameraRotationMatrix(): void;
  5888. /**
  5889. * This function MUST be overwritten by the different WebVR cameras available.
  5890. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5891. */
  5892. protected _getWebVRProjectionMatrix(): Matrix;
  5893. /**
  5894. * This function MUST be overwritten by the different WebVR cameras available.
  5895. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5896. */
  5897. protected _getWebVRViewMatrix(): Matrix;
  5898. setCameraRigParameter(name: string, value: any): void;
  5899. /**
  5900. * needs to be overridden by children so sub has required properties to be copied
  5901. */
  5902. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5903. /**
  5904. * May need to be overridden by children
  5905. */
  5906. _updateRigCameras(): void;
  5907. _setupInputs(): void;
  5908. serialize(): any;
  5909. clone(name: string): Camera;
  5910. getDirection(localAxis: Vector3): Vector3;
  5911. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5912. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5913. computeWorldMatrix(): Matrix;
  5914. static Parse(parsedCamera: any, scene: Scene): Camera;
  5915. }
  5916. }
  5917. declare module BABYLON {
  5918. var CameraInputTypes: {};
  5919. interface ICameraInput<TCamera extends Camera> {
  5920. camera: Nullable<TCamera>;
  5921. getClassName(): string;
  5922. getSimpleName(): string;
  5923. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5924. detachControl: (element: Nullable<HTMLElement>) => void;
  5925. checkInputs?: () => void;
  5926. }
  5927. interface CameraInputsMap<TCamera extends Camera> {
  5928. [name: string]: ICameraInput<TCamera>;
  5929. [idx: number]: ICameraInput<TCamera>;
  5930. }
  5931. class CameraInputsManager<TCamera extends Camera> {
  5932. attached: CameraInputsMap<TCamera>;
  5933. attachedElement: Nullable<HTMLElement>;
  5934. noPreventDefault: boolean;
  5935. camera: TCamera;
  5936. checkInputs: () => void;
  5937. constructor(camera: TCamera);
  5938. /**
  5939. * Add an input method to a camera.
  5940. * builtin inputs example: camera.inputs.addGamepad();
  5941. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5942. * @param input camera input method
  5943. */
  5944. add(input: ICameraInput<TCamera>): void;
  5945. /**
  5946. * Remove a specific input method from a camera
  5947. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5948. * @param inputToRemove camera input method
  5949. */
  5950. remove(inputToRemove: ICameraInput<TCamera>): void;
  5951. removeByType(inputType: string): void;
  5952. private _addCheckInputs(fn);
  5953. attachInput(input: ICameraInput<TCamera>): void;
  5954. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5955. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5956. rebuildInputCheck(): void;
  5957. /**
  5958. * Remove all attached input methods from a camera
  5959. */
  5960. clear(): void;
  5961. serialize(serializedCamera: any): void;
  5962. parse(parsedCamera: any): void;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5968. * being tilted forward or back and left or right.
  5969. */
  5970. class DeviceOrientationCamera extends FreeCamera {
  5971. private _initialQuaternion;
  5972. private _quaternionCache;
  5973. /**
  5974. * Creates a new device orientation camera
  5975. * @param name The name of the camera
  5976. * @param position The start position camera
  5977. * @param scene The scene the camera belongs to
  5978. */
  5979. constructor(name: string, position: Vector3, scene: Scene);
  5980. /**
  5981. * Gets the current instance class name ("DeviceOrientationCamera").
  5982. * This helps avoiding instanceof at run time.
  5983. * @returns the class name
  5984. */
  5985. getClassName(): string;
  5986. /**
  5987. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5988. */
  5989. _checkInputs(): void;
  5990. /**
  5991. * Reset the camera to its default orientation on the specified axis only.
  5992. * @param axis The axis to reset
  5993. */
  5994. resetToCurrentRotation(axis?: Axis): void;
  5995. }
  5996. }
  5997. declare module BABYLON {
  5998. class FollowCamera extends TargetCamera {
  5999. radius: number;
  6000. rotationOffset: number;
  6001. heightOffset: number;
  6002. cameraAcceleration: number;
  6003. maxCameraSpeed: number;
  6004. lockedTarget: Nullable<AbstractMesh>;
  6005. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6006. private getRadians(degrees);
  6007. private follow(cameraTarget);
  6008. _checkInputs(): void;
  6009. getClassName(): string;
  6010. }
  6011. class ArcFollowCamera extends TargetCamera {
  6012. alpha: number;
  6013. beta: number;
  6014. radius: number;
  6015. target: Nullable<AbstractMesh>;
  6016. private _cartesianCoordinates;
  6017. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6018. private follow();
  6019. _checkInputs(): void;
  6020. getClassName(): string;
  6021. }
  6022. }
  6023. declare module BABYLON {
  6024. class FreeCamera extends TargetCamera {
  6025. ellipsoid: Vector3;
  6026. ellipsoidOffset: Vector3;
  6027. checkCollisions: boolean;
  6028. applyGravity: boolean;
  6029. inputs: FreeCameraInputsManager;
  6030. /**
  6031. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6032. * Higher values reduce sensitivity.
  6033. */
  6034. /**
  6035. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6036. * Higher values reduce sensitivity.
  6037. */
  6038. angularSensibility: number;
  6039. keysUp: number[];
  6040. keysDown: number[];
  6041. keysLeft: number[];
  6042. keysRight: number[];
  6043. onCollide: (collidedMesh: AbstractMesh) => void;
  6044. private _collider;
  6045. private _needMoveForGravity;
  6046. private _oldPosition;
  6047. private _diffPosition;
  6048. private _newPosition;
  6049. _localDirection: Vector3;
  6050. _transformedDirection: Vector3;
  6051. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6053. detachControl(element: HTMLElement): void;
  6054. private _collisionMask;
  6055. collisionMask: number;
  6056. _collideWithWorld(displacement: Vector3): void;
  6057. private _onCollisionPositionChange;
  6058. _checkInputs(): void;
  6059. _decideIfNeedsToMove(): boolean;
  6060. _updatePosition(): void;
  6061. dispose(): void;
  6062. getClassName(): string;
  6063. }
  6064. }
  6065. declare module BABYLON {
  6066. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6067. constructor(camera: FreeCamera);
  6068. addKeyboard(): FreeCameraInputsManager;
  6069. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6070. addGamepad(): FreeCameraInputsManager;
  6071. addDeviceOrientation(): FreeCameraInputsManager;
  6072. addTouch(): FreeCameraInputsManager;
  6073. addVirtualJoystick(): FreeCameraInputsManager;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. class GamepadCamera extends UniversalCamera {
  6078. gamepadAngularSensibility: number;
  6079. gamepadMoveSensibility: number;
  6080. constructor(name: string, position: Vector3, scene: Scene);
  6081. getClassName(): string;
  6082. }
  6083. }
  6084. declare module BABYLON {
  6085. /**
  6086. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6087. */
  6088. class AnaglyphFreeCamera extends FreeCamera {
  6089. /**
  6090. * Creates a new AnaglyphFreeCamera
  6091. * @param name defines camera name
  6092. * @param position defines initial position
  6093. * @param interaxialDistance defines distance between each color axis
  6094. * @param scene defines the hosting scene
  6095. */
  6096. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6097. /**
  6098. * Gets camera class name
  6099. * @returns AnaglyphFreeCamera
  6100. */
  6101. getClassName(): string;
  6102. }
  6103. /**
  6104. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6105. */
  6106. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6107. /**
  6108. * Creates a new AnaglyphArcRotateCamera
  6109. * @param name defines camera name
  6110. * @param alpha defines alpha angle (in radians)
  6111. * @param beta defines beta angle (in radians)
  6112. * @param radius defines radius
  6113. * @param target defines camera target
  6114. * @param interaxialDistance defines distance between each color axis
  6115. * @param scene defines the hosting scene
  6116. */
  6117. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6118. /**
  6119. * Gets camera class name
  6120. * @returns AnaglyphArcRotateCamera
  6121. */
  6122. getClassName(): string;
  6123. }
  6124. /**
  6125. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6126. */
  6127. class AnaglyphGamepadCamera extends GamepadCamera {
  6128. /**
  6129. * Creates a new AnaglyphGamepadCamera
  6130. * @param name defines camera name
  6131. * @param position defines initial position
  6132. * @param interaxialDistance defines distance between each color axis
  6133. * @param scene defines the hosting scene
  6134. */
  6135. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6136. /**
  6137. * Gets camera class name
  6138. * @returns AnaglyphGamepadCamera
  6139. */
  6140. getClassName(): string;
  6141. }
  6142. /**
  6143. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6144. */
  6145. class AnaglyphUniversalCamera extends UniversalCamera {
  6146. /**
  6147. * Creates a new AnaglyphUniversalCamera
  6148. * @param name defines camera name
  6149. * @param position defines initial position
  6150. * @param interaxialDistance defines distance between each color axis
  6151. * @param scene defines the hosting scene
  6152. */
  6153. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6154. /**
  6155. * Gets camera class name
  6156. * @returns AnaglyphUniversalCamera
  6157. */
  6158. getClassName(): string;
  6159. }
  6160. /**
  6161. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6162. */
  6163. class StereoscopicFreeCamera extends FreeCamera {
  6164. /**
  6165. * Creates a new StereoscopicFreeCamera
  6166. * @param name defines camera name
  6167. * @param position defines initial position
  6168. * @param interaxialDistance defines distance between each color axis
  6169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6170. * @param scene defines the hosting scene
  6171. */
  6172. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6173. /**
  6174. * Gets camera class name
  6175. * @returns StereoscopicFreeCamera
  6176. */
  6177. getClassName(): string;
  6178. }
  6179. /**
  6180. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6181. */
  6182. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6183. /**
  6184. * Creates a new StereoscopicArcRotateCamera
  6185. * @param name defines camera name
  6186. * @param alpha defines alpha angle (in radians)
  6187. * @param beta defines beta angle (in radians)
  6188. * @param radius defines radius
  6189. * @param target defines camera target
  6190. * @param interaxialDistance defines distance between each color axis
  6191. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6192. * @param scene defines the hosting scene
  6193. */
  6194. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6195. /**
  6196. * Gets camera class name
  6197. * @returns StereoscopicArcRotateCamera
  6198. */
  6199. getClassName(): string;
  6200. }
  6201. /**
  6202. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6203. */
  6204. class StereoscopicGamepadCamera extends GamepadCamera {
  6205. /**
  6206. * Creates a new StereoscopicGamepadCamera
  6207. * @param name defines camera name
  6208. * @param position defines initial position
  6209. * @param interaxialDistance defines distance between each color axis
  6210. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6211. * @param scene defines the hosting scene
  6212. */
  6213. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6214. /**
  6215. * Gets camera class name
  6216. * @returns StereoscopicGamepadCamera
  6217. */
  6218. getClassName(): string;
  6219. }
  6220. /**
  6221. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6222. */
  6223. class StereoscopicUniversalCamera extends UniversalCamera {
  6224. /**
  6225. * Creates a new StereoscopicUniversalCamera
  6226. * @param name defines camera name
  6227. * @param position defines initial position
  6228. * @param interaxialDistance defines distance between each color axis
  6229. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6230. * @param scene defines the hosting scene
  6231. */
  6232. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6233. /**
  6234. * Gets camera class name
  6235. * @returns StereoscopicUniversalCamera
  6236. */
  6237. getClassName(): string;
  6238. }
  6239. }
  6240. declare module BABYLON {
  6241. class TargetCamera extends Camera {
  6242. cameraDirection: Vector3;
  6243. cameraRotation: Vector2;
  6244. rotation: Vector3;
  6245. rotationQuaternion: Quaternion;
  6246. speed: number;
  6247. noRotationConstraint: boolean;
  6248. lockedTarget: any;
  6249. _currentTarget: Vector3;
  6250. _viewMatrix: Matrix;
  6251. _camMatrix: Matrix;
  6252. _cameraTransformMatrix: Matrix;
  6253. _cameraRotationMatrix: Matrix;
  6254. private _rigCamTransformMatrix;
  6255. _referencePoint: Vector3;
  6256. private _currentUpVector;
  6257. _transformedReferencePoint: Vector3;
  6258. protected _globalCurrentTarget: Vector3;
  6259. protected _globalCurrentUpVector: Vector3;
  6260. _reset: () => void;
  6261. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6262. getFrontPosition(distance: number): Vector3;
  6263. _getLockedTargetPosition(): Nullable<Vector3>;
  6264. /**
  6265. * Store current camera state (fov, position, etc..)
  6266. */
  6267. private _storedPosition;
  6268. private _storedRotation;
  6269. private _storedRotationQuaternion;
  6270. storeState(): Camera;
  6271. /**
  6272. * Restored camera state. You must call storeState() first
  6273. */
  6274. _restoreStateValues(): boolean;
  6275. _initCache(): void;
  6276. _updateCache(ignoreParentClass?: boolean): void;
  6277. _isSynchronizedViewMatrix(): boolean;
  6278. _computeLocalCameraSpeed(): number;
  6279. setTarget(target: Vector3): void;
  6280. /**
  6281. * Return the current target position of the camera. This value is expressed in local space.
  6282. */
  6283. getTarget(): Vector3;
  6284. _decideIfNeedsToMove(): boolean;
  6285. _updatePosition(): void;
  6286. _checkInputs(): void;
  6287. protected _updateCameraRotationMatrix(): void;
  6288. _getViewMatrix(): Matrix;
  6289. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6290. /**
  6291. * @override
  6292. * Override Camera.createRigCamera
  6293. */
  6294. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6295. /**
  6296. * @override
  6297. * Override Camera._updateRigCameras
  6298. */
  6299. _updateRigCameras(): void;
  6300. private _getRigCamPosition(halfSpace, result);
  6301. getClassName(): string;
  6302. }
  6303. }
  6304. declare module BABYLON {
  6305. class TouchCamera extends FreeCamera {
  6306. touchAngularSensibility: number;
  6307. touchMoveSensibility: number;
  6308. constructor(name: string, position: Vector3, scene: Scene);
  6309. getClassName(): string;
  6310. _setupInputs(): void;
  6311. }
  6312. }
  6313. declare module BABYLON {
  6314. class UniversalCamera extends TouchCamera {
  6315. gamepadAngularSensibility: number;
  6316. gamepadMoveSensibility: number;
  6317. constructor(name: string, position: Vector3, scene: Scene);
  6318. getClassName(): string;
  6319. }
  6320. }
  6321. declare module BABYLON {
  6322. class VirtualJoysticksCamera extends FreeCamera {
  6323. constructor(name: string, position: Vector3, scene: Scene);
  6324. getClassName(): string;
  6325. }
  6326. }
  6327. interface VRDisplay extends EventTarget {
  6328. /**
  6329. * Dictionary of capabilities describing the VRDisplay.
  6330. */
  6331. readonly capabilities: VRDisplayCapabilities;
  6332. /**
  6333. * z-depth defining the far plane of the eye view frustum
  6334. * enables mapping of values in the render target depth
  6335. * attachment to scene coordinates. Initially set to 10000.0.
  6336. */
  6337. depthFar: number;
  6338. /**
  6339. * z-depth defining the near plane of the eye view frustum
  6340. * enables mapping of values in the render target depth
  6341. * attachment to scene coordinates. Initially set to 0.01.
  6342. */
  6343. depthNear: number;
  6344. /**
  6345. * An identifier for this distinct VRDisplay. Used as an
  6346. * association point in the Gamepad API.
  6347. */
  6348. readonly displayId: number;
  6349. /**
  6350. * A display name, a user-readable name identifying it.
  6351. */
  6352. readonly displayName: string;
  6353. readonly isConnected: boolean;
  6354. readonly isPresenting: boolean;
  6355. /**
  6356. * If this VRDisplay supports room-scale experiences, the optional
  6357. * stage attribute contains details on the room-scale parameters.
  6358. */
  6359. readonly stageParameters: VRStageParameters | null;
  6360. /**
  6361. * Passing the value returned by `requestAnimationFrame` to
  6362. * `cancelAnimationFrame` will unregister the callback.
  6363. */
  6364. cancelAnimationFrame(handle: number): void;
  6365. /**
  6366. * Stops presenting to the VRDisplay.
  6367. */
  6368. exitPresent(): Promise<void>;
  6369. getEyeParameters(whichEye: string): VREyeParameters;
  6370. /**
  6371. * Populates the passed VRFrameData with the information required to render
  6372. * the current frame.
  6373. */
  6374. getFrameData(frameData: VRFrameData): boolean;
  6375. /**
  6376. * Get the layers currently being presented.
  6377. */
  6378. getLayers(): VRLayer[];
  6379. /**
  6380. * Return a VRPose containing the future predicted pose of the VRDisplay
  6381. * when the current frame will be presented. The value returned will not
  6382. * change until JavaScript has returned control to the browser.
  6383. *
  6384. * The VRPose will contain the position, orientation, velocity,
  6385. * and acceleration of each of these properties.
  6386. */
  6387. getPose(): VRPose;
  6388. /**
  6389. * Return the current instantaneous pose of the VRDisplay, with no
  6390. * prediction applied.
  6391. */
  6392. getImmediatePose(): VRPose;
  6393. /**
  6394. * The callback passed to `requestAnimationFrame` will be called
  6395. * any time a new frame should be rendered. When the VRDisplay is
  6396. * presenting the callback will be called at the native refresh
  6397. * rate of the HMD. When not presenting this function acts
  6398. * identically to how window.requestAnimationFrame acts. Content should
  6399. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6400. * asynchronously from other displays and at differing refresh rates.
  6401. */
  6402. requestAnimationFrame(callback: FrameRequestCallback): number;
  6403. /**
  6404. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6405. * Repeat calls while already presenting will update the VRLayers being displayed.
  6406. */
  6407. requestPresent(layers: VRLayer[]): Promise<void>;
  6408. /**
  6409. * Reset the pose for this display, treating its current position and
  6410. * orientation as the "origin/zero" values. VRPose.position,
  6411. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6412. * updated when calling resetPose(). This should be called in only
  6413. * sitting-space experiences.
  6414. */
  6415. resetPose(): void;
  6416. /**
  6417. * The VRLayer provided to the VRDisplay will be captured and presented
  6418. * in the HMD. Calling this function has the same effect on the source
  6419. * canvas as any other operation that uses its source image, and canvases
  6420. * created without preserveDrawingBuffer set to true will be cleared.
  6421. */
  6422. submitFrame(pose?: VRPose): void;
  6423. }
  6424. declare var VRDisplay: {
  6425. prototype: VRDisplay;
  6426. new (): VRDisplay;
  6427. };
  6428. interface VRLayer {
  6429. leftBounds?: number[] | null;
  6430. rightBounds?: number[] | null;
  6431. source?: HTMLCanvasElement | null;
  6432. }
  6433. interface VRDisplayCapabilities {
  6434. readonly canPresent: boolean;
  6435. readonly hasExternalDisplay: boolean;
  6436. readonly hasOrientation: boolean;
  6437. readonly hasPosition: boolean;
  6438. readonly maxLayers: number;
  6439. }
  6440. interface VREyeParameters {
  6441. /** @deprecated */
  6442. readonly fieldOfView: VRFieldOfView;
  6443. readonly offset: Float32Array;
  6444. readonly renderHeight: number;
  6445. readonly renderWidth: number;
  6446. }
  6447. interface VRFieldOfView {
  6448. readonly downDegrees: number;
  6449. readonly leftDegrees: number;
  6450. readonly rightDegrees: number;
  6451. readonly upDegrees: number;
  6452. }
  6453. interface VRFrameData {
  6454. readonly leftProjectionMatrix: Float32Array;
  6455. readonly leftViewMatrix: Float32Array;
  6456. readonly pose: VRPose;
  6457. readonly rightProjectionMatrix: Float32Array;
  6458. readonly rightViewMatrix: Float32Array;
  6459. readonly timestamp: number;
  6460. }
  6461. interface VRPose {
  6462. readonly angularAcceleration: Float32Array | null;
  6463. readonly angularVelocity: Float32Array | null;
  6464. readonly linearAcceleration: Float32Array | null;
  6465. readonly linearVelocity: Float32Array | null;
  6466. readonly orientation: Float32Array | null;
  6467. readonly position: Float32Array | null;
  6468. readonly timestamp: number;
  6469. }
  6470. interface VRStageParameters {
  6471. sittingToStandingTransform?: Float32Array;
  6472. sizeX?: number;
  6473. sizeY?: number;
  6474. }
  6475. interface Navigator {
  6476. getVRDisplays(): Promise<VRDisplay[]>;
  6477. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6478. }
  6479. interface Window {
  6480. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6481. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6482. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6483. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6484. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6485. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6486. }
  6487. interface Gamepad {
  6488. readonly displayId: number;
  6489. }
  6490. /**
  6491. * Module Debug contains the (visual) components to debug a scene correctly
  6492. */
  6493. declare module BABYLON.Debug {
  6494. /**
  6495. * The Axes viewer will show 3 axes in a specific point in space
  6496. */
  6497. class AxesViewer {
  6498. private _xline;
  6499. private _yline;
  6500. private _zline;
  6501. private _xmesh;
  6502. private _ymesh;
  6503. private _zmesh;
  6504. scene: Nullable<Scene>;
  6505. scaleLines: number;
  6506. constructor(scene: Scene, scaleLines?: number);
  6507. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6508. dispose(): void;
  6509. }
  6510. }
  6511. declare module BABYLON.Debug {
  6512. /**
  6513. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6514. */
  6515. class BoneAxesViewer extends AxesViewer {
  6516. mesh: Nullable<Mesh>;
  6517. bone: Nullable<Bone>;
  6518. pos: Vector3;
  6519. xaxis: Vector3;
  6520. yaxis: Vector3;
  6521. zaxis: Vector3;
  6522. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6523. update(): void;
  6524. dispose(): void;
  6525. }
  6526. }
  6527. declare module BABYLON {
  6528. class DebugLayer {
  6529. private _scene;
  6530. static InspectorURL: string;
  6531. private _inspector;
  6532. private BJSINSPECTOR;
  6533. constructor(scene: Scene);
  6534. /** Creates the inspector window. */
  6535. private _createInspector(config?);
  6536. isVisible(): boolean;
  6537. hide(): void;
  6538. show(config?: {
  6539. popup?: boolean;
  6540. initialTab?: number;
  6541. parentElement?: HTMLElement;
  6542. newColors?: {
  6543. backgroundColor?: string;
  6544. backgroundColorLighter?: string;
  6545. backgroundColorLighter2?: string;
  6546. backgroundColorLighter3?: string;
  6547. color?: string;
  6548. colorTop?: string;
  6549. colorBot?: string;
  6550. };
  6551. }): void;
  6552. }
  6553. }
  6554. declare module BABYLON.Debug {
  6555. /**
  6556. * Used to show the physics impostor around the specific mesh.
  6557. */
  6558. class PhysicsViewer {
  6559. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6560. protected _meshes: Array<Nullable<AbstractMesh>>;
  6561. protected _scene: Nullable<Scene>;
  6562. protected _numMeshes: number;
  6563. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6564. private _renderFunction;
  6565. private _debugBoxMesh;
  6566. private _debugSphereMesh;
  6567. private _debugMaterial;
  6568. constructor(scene: Scene);
  6569. protected _updateDebugMeshes(): void;
  6570. showImpostor(impostor: PhysicsImpostor): void;
  6571. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6572. private _getDebugMaterial(scene);
  6573. private _getDebugBoxMesh(scene);
  6574. private _getDebugSphereMesh(scene);
  6575. private _getDebugMesh(impostor, scene);
  6576. dispose(): void;
  6577. }
  6578. }
  6579. declare module BABYLON {
  6580. class RayHelper {
  6581. ray: Nullable<Ray>;
  6582. private _renderPoints;
  6583. private _renderLine;
  6584. private _renderFunction;
  6585. private _scene;
  6586. private _updateToMeshFunction;
  6587. private _attachedToMesh;
  6588. private _meshSpaceDirection;
  6589. private _meshSpaceOrigin;
  6590. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6591. constructor(ray: Ray);
  6592. show(scene: Scene, color: Color3): void;
  6593. hide(): void;
  6594. private _render();
  6595. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6596. detachFromMesh(): void;
  6597. private _updateToMesh();
  6598. dispose(): void;
  6599. }
  6600. }
  6601. declare module BABYLON.Debug {
  6602. /**
  6603. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  6604. */
  6605. class SkeletonViewer {
  6606. skeleton: Skeleton;
  6607. mesh: AbstractMesh;
  6608. autoUpdateBonesMatrices: boolean;
  6609. renderingGroupId: number;
  6610. color: Color3;
  6611. private _scene;
  6612. private _debugLines;
  6613. private _debugMesh;
  6614. private _isEnabled;
  6615. private _renderFunction;
  6616. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  6617. isEnabled: boolean;
  6618. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  6619. private _getLinesForBonesWithLength(bones, meshMat);
  6620. private _getLinesForBonesNoLength(bones, meshMat);
  6621. update(): void;
  6622. dispose(): void;
  6623. }
  6624. }
  6625. declare module BABYLON {
  6626. /**
  6627. * Interface for attribute information associated with buffer instanciation
  6628. */
  6629. class InstancingAttributeInfo {
  6630. /**
  6631. * Index/offset of the attribute in the vertex shader
  6632. */
  6633. index: number;
  6634. /**
  6635. * size of the attribute, 1, 2, 3 or 4
  6636. */
  6637. attributeSize: number;
  6638. /**
  6639. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6640. * default is FLOAT
  6641. */
  6642. attribyteType: number;
  6643. /**
  6644. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6645. */
  6646. normalized: boolean;
  6647. /**
  6648. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6649. */
  6650. offset: number;
  6651. /**
  6652. * Name of the GLSL attribute, for debugging purpose only
  6653. */
  6654. attributeName: string;
  6655. }
  6656. /**
  6657. * Define options used to create a render target texture
  6658. */
  6659. class RenderTargetCreationOptions {
  6660. /**
  6661. * Specifies is mipmaps must be generated
  6662. */
  6663. generateMipMaps?: boolean;
  6664. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6665. generateDepthBuffer?: boolean;
  6666. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6667. generateStencilBuffer?: boolean;
  6668. /** Defines texture type (int by default) */
  6669. type?: number;
  6670. /** Defines sampling mode (trilinear by default) */
  6671. samplingMode?: number;
  6672. /** Defines format (RGBA by default) */
  6673. format?: number;
  6674. }
  6675. /**
  6676. * Define options used to create a depth texture
  6677. */
  6678. class DepthTextureCreationOptions {
  6679. /** Specifies whether or not a stencil should be allocated in the texture */
  6680. generateStencil?: boolean;
  6681. /** Specifies whether or not bilinear filtering is enable on the texture */
  6682. bilinearFiltering?: boolean;
  6683. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6684. comparisonFunction?: number;
  6685. /** Specifies if the created texture is a cube texture */
  6686. isCube?: boolean;
  6687. }
  6688. /**
  6689. * Class used to describe the capabilities of the engine relatively to the current browser
  6690. */
  6691. class EngineCapabilities {
  6692. /** Maximum textures units per fragment shader */
  6693. maxTexturesImageUnits: number;
  6694. /** Maximum texture units per vertex shader */
  6695. maxVertexTextureImageUnits: number;
  6696. /** Maximum textures units in the entire pipeline */
  6697. maxCombinedTexturesImageUnits: number;
  6698. /** Maximum texture size */
  6699. maxTextureSize: number;
  6700. /** Maximum cube texture size */
  6701. maxCubemapTextureSize: number;
  6702. /** Maximum render texture size */
  6703. maxRenderTextureSize: number;
  6704. /** Maximum number of vertex attributes */
  6705. maxVertexAttribs: number;
  6706. /** Maximum number of varyings */
  6707. maxVaryingVectors: number;
  6708. /** Maximum number of uniforms per vertex shader */
  6709. maxVertexUniformVectors: number;
  6710. /** Maximum number of uniforms per fragment shader */
  6711. maxFragmentUniformVectors: number;
  6712. /** Defines if standard derivates (dx/dy) are supported */
  6713. standardDerivatives: boolean;
  6714. /** Defines if s3tc texture compression is supported */
  6715. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6716. /** Defines if pvrtc texture compression is supported */
  6717. pvrtc: any;
  6718. /** Defines if etc1 texture compression is supported */
  6719. etc1: any;
  6720. /** Defines if etc2 texture compression is supported */
  6721. etc2: any;
  6722. /** Defines if astc texture compression is supported */
  6723. astc: any;
  6724. /** Defines if float textures are supported */
  6725. textureFloat: boolean;
  6726. /** Defines if vertex array objects are supported */
  6727. vertexArrayObject: boolean;
  6728. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6729. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6730. /** Gets the maximum level of anisotropy supported */
  6731. maxAnisotropy: number;
  6732. /** Defines if instancing is supported */
  6733. instancedArrays: boolean;
  6734. /** Defines if 32 bits indices are supported */
  6735. uintIndices: boolean;
  6736. /** Defines if high precision shaders are supported */
  6737. highPrecisionShaderSupported: boolean;
  6738. /** Defines if depth reading in the fragment shader is supported */
  6739. fragmentDepthSupported: boolean;
  6740. /** Defines if float texture linear filtering is supported*/
  6741. textureFloatLinearFiltering: boolean;
  6742. /** Defines if rendering to float textures is supported */
  6743. textureFloatRender: boolean;
  6744. /** Defines if half float textures are supported*/
  6745. textureHalfFloat: boolean;
  6746. /** Defines if half float texture linear filtering is supported*/
  6747. textureHalfFloatLinearFiltering: boolean;
  6748. /** Defines if rendering to half float textures is supported */
  6749. textureHalfFloatRender: boolean;
  6750. /** Defines if textureLOD shader command is supported */
  6751. textureLOD: boolean;
  6752. /** Defines if draw buffers extension is supported */
  6753. drawBuffersExtension: boolean;
  6754. /** Defines if depth textures are supported */
  6755. depthTextureExtension: boolean;
  6756. /** Defines if float color buffer are supported */
  6757. colorBufferFloat: boolean;
  6758. /** Gets disjoint timer query extension (null if not supported) */
  6759. timerQuery: EXT_disjoint_timer_query;
  6760. /** Defines if timestamp can be used with timer query */
  6761. canUseTimestampForTimerQuery: boolean;
  6762. }
  6763. /** Interface defining initialization parameters for Engine class */
  6764. interface EngineOptions extends WebGLContextAttributes {
  6765. /**
  6766. * Defines if the engine should no exceed a specified device ratio
  6767. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6768. */
  6769. limitDeviceRatio?: number;
  6770. /**
  6771. * Defines if webvr should be enabled automatically
  6772. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6773. */
  6774. autoEnableWebVR?: boolean;
  6775. /**
  6776. * Defines if webgl2 should be turned off even if supported
  6777. * @see http://doc.babylonjs.com/features/webgl2
  6778. */
  6779. disableWebGL2Support?: boolean;
  6780. /**
  6781. * Defines if webaudio should be initialized as well
  6782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6783. */
  6784. audioEngine?: boolean;
  6785. /**
  6786. * Defines if animations should run using a deterministic lock step
  6787. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6788. */
  6789. deterministicLockstep?: boolean;
  6790. /** Defines the maximum steps to use with deterministic lock step mode */
  6791. lockstepMaxSteps?: number;
  6792. /**
  6793. * Defines that engine should ignore context lost events
  6794. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6795. */
  6796. doNotHandleContextLost?: boolean;
  6797. }
  6798. /**
  6799. * Defines the interface used by display changed events
  6800. */
  6801. interface IDisplayChangedEventArgs {
  6802. /** Gets the vrDisplay object (if any) */
  6803. vrDisplay: Nullable<any>;
  6804. /** Gets a boolean indicating if webVR is supported */
  6805. vrSupported: boolean;
  6806. }
  6807. /**
  6808. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6809. */
  6810. class Engine {
  6811. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6812. static ExceptionList: ({
  6813. key: string;
  6814. capture: string;
  6815. captureConstraint: number;
  6816. targets: string[];
  6817. } | {
  6818. key: string;
  6819. capture: null;
  6820. captureConstraint: null;
  6821. targets: string[];
  6822. })[];
  6823. /** Gets the list of created engines */
  6824. static Instances: Engine[];
  6825. /**
  6826. * Gets the latest created engine
  6827. */
  6828. static readonly LastCreatedEngine: Nullable<Engine>;
  6829. /**
  6830. * Gets the latest created scene
  6831. */
  6832. static readonly LastCreatedScene: Nullable<Scene>;
  6833. /**
  6834. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6835. * @param flag defines which part of the materials must be marked as dirty
  6836. * @param predicate defines a predicate used to filter which materials should be affected
  6837. */
  6838. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6839. private static _ALPHA_DISABLE;
  6840. private static _ALPHA_ADD;
  6841. private static _ALPHA_COMBINE;
  6842. private static _ALPHA_SUBTRACT;
  6843. private static _ALPHA_MULTIPLY;
  6844. private static _ALPHA_MAXIMIZED;
  6845. private static _ALPHA_ONEONE;
  6846. private static _ALPHA_PREMULTIPLIED;
  6847. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6848. private static _ALPHA_INTERPOLATE;
  6849. private static _ALPHA_SCREENMODE;
  6850. private static _DELAYLOADSTATE_NONE;
  6851. private static _DELAYLOADSTATE_LOADED;
  6852. private static _DELAYLOADSTATE_LOADING;
  6853. private static _DELAYLOADSTATE_NOTLOADED;
  6854. private static _TEXTUREFORMAT_ALPHA;
  6855. private static _TEXTUREFORMAT_LUMINANCE;
  6856. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6857. private static _TEXTUREFORMAT_RGB;
  6858. private static _TEXTUREFORMAT_RGBA;
  6859. private static _TEXTUREFORMAT_R32F;
  6860. private static _TEXTUREFORMAT_RG32F;
  6861. private static _TEXTUREFORMAT_RGB32F;
  6862. private static _TEXTUREFORMAT_RGBA32F;
  6863. private static _TEXTURETYPE_UNSIGNED_INT;
  6864. private static _TEXTURETYPE_FLOAT;
  6865. private static _TEXTURETYPE_HALF_FLOAT;
  6866. private static _NEVER;
  6867. private static _ALWAYS;
  6868. private static _LESS;
  6869. private static _EQUAL;
  6870. private static _LEQUAL;
  6871. private static _GREATER;
  6872. private static _GEQUAL;
  6873. private static _NOTEQUAL;
  6874. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6875. static readonly NEVER: number;
  6876. /** 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 */
  6877. static readonly ALWAYS: number;
  6878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6879. static readonly LESS: number;
  6880. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6881. static readonly EQUAL: number;
  6882. /** 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 */
  6883. static readonly LEQUAL: number;
  6884. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6885. static readonly GREATER: number;
  6886. /** 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 */
  6887. static readonly GEQUAL: number;
  6888. /** 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 */
  6889. static readonly NOTEQUAL: number;
  6890. private static _KEEP;
  6891. private static _REPLACE;
  6892. private static _INCR;
  6893. private static _DECR;
  6894. private static _INVERT;
  6895. private static _INCR_WRAP;
  6896. private static _DECR_WRAP;
  6897. /** Passed to stencilOperation to specify that stencil value must be kept */
  6898. static readonly KEEP: number;
  6899. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6900. static readonly REPLACE: number;
  6901. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6902. static readonly INCR: number;
  6903. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6904. static readonly DECR: number;
  6905. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6906. static readonly INVERT: number;
  6907. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6908. static readonly INCR_WRAP: number;
  6909. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6910. static readonly DECR_WRAP: number;
  6911. /** Defines that alpha blending is disabled */
  6912. static readonly ALPHA_DISABLE: number;
  6913. /** Defines that alpha blending to SRC + DEST */
  6914. static readonly ALPHA_ONEONE: number;
  6915. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6916. static readonly ALPHA_ADD: number;
  6917. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6918. static readonly ALPHA_COMBINE: number;
  6919. /** Defines that alpha blending to DEST - SRC * DEST */
  6920. static readonly ALPHA_SUBTRACT: number;
  6921. /** Defines that alpha blending to SRC * DEST */
  6922. static readonly ALPHA_MULTIPLY: number;
  6923. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6924. static readonly ALPHA_MAXIMIZED: number;
  6925. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6926. static readonly ALPHA_PREMULTIPLIED: number;
  6927. /**
  6928. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6929. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6930. */
  6931. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6932. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6933. static readonly ALPHA_INTERPOLATE: number;
  6934. /**
  6935. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6936. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6937. */
  6938. static readonly ALPHA_SCREENMODE: number;
  6939. /** Defines that the ressource is not delayed*/
  6940. static readonly DELAYLOADSTATE_NONE: number;
  6941. /** Defines that the ressource was successfully delay loaded */
  6942. static readonly DELAYLOADSTATE_LOADED: number;
  6943. /** Defines that the ressource is currently delay loading */
  6944. static readonly DELAYLOADSTATE_LOADING: number;
  6945. /** Defines that the ressource is delayed and has not started loading */
  6946. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6947. /** ALPHA */
  6948. static readonly TEXTUREFORMAT_ALPHA: number;
  6949. /** LUMINANCE */
  6950. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6951. /**
  6952. * R32F
  6953. */
  6954. static readonly TEXTUREFORMAT_R32F: number;
  6955. /**
  6956. * RG32F
  6957. */
  6958. static readonly TEXTUREFORMAT_RG32F: number;
  6959. /**
  6960. * RGB32F
  6961. */
  6962. static readonly TEXTUREFORMAT_RGB32F: number;
  6963. /**
  6964. * RGBA32F
  6965. */
  6966. static readonly TEXTUREFORMAT_RGBA32F: number;
  6967. /** LUMINANCE_ALPHA */
  6968. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6969. /** RGB */
  6970. static readonly TEXTUREFORMAT_RGB: number;
  6971. /** RGBA */
  6972. static readonly TEXTUREFORMAT_RGBA: number;
  6973. /** UNSIGNED_INT */
  6974. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6975. /** FLOAT */
  6976. static readonly TEXTURETYPE_FLOAT: number;
  6977. /** HALF_FLOAT */
  6978. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6979. private static _SCALEMODE_FLOOR;
  6980. private static _SCALEMODE_NEAREST;
  6981. private static _SCALEMODE_CEILING;
  6982. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6983. static readonly SCALEMODE_FLOOR: number;
  6984. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6985. static readonly SCALEMODE_NEAREST: number;
  6986. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6987. static readonly SCALEMODE_CEILING: number;
  6988. /**
  6989. * Returns the current version of the framework
  6990. */
  6991. static readonly Version: string;
  6992. /**
  6993. * Gets or sets the epsilon value used by collision engine
  6994. */
  6995. static CollisionsEpsilon: number;
  6996. /**
  6997. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6998. */
  6999. static CodeRepository: string;
  7000. /**
  7001. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7002. */
  7003. static ShadersRepository: string;
  7004. /**
  7005. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7006. */
  7007. forcePOTTextures: boolean;
  7008. /**
  7009. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7010. */
  7011. isFullscreen: boolean;
  7012. /**
  7013. * Gets a boolean indicating if the pointer is currently locked
  7014. */
  7015. isPointerLock: boolean;
  7016. /**
  7017. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7018. */
  7019. cullBackFaces: boolean;
  7020. /**
  7021. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7022. */
  7023. renderEvenInBackground: boolean;
  7024. /**
  7025. * Gets or sets a boolean indicating that cache can be kept between frames
  7026. */
  7027. preventCacheWipeBetweenFrames: boolean;
  7028. /**
  7029. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7030. **/
  7031. enableOfflineSupport: boolean;
  7032. /**
  7033. * 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)
  7034. **/
  7035. disableManifestCheck: boolean;
  7036. /**
  7037. * Gets the list of created scenes
  7038. */
  7039. scenes: Scene[];
  7040. /**
  7041. * Gets the list of created postprocesses
  7042. */
  7043. postProcesses: PostProcess[];
  7044. /**
  7045. * Observable event triggered each time the rendering canvas is resized
  7046. */
  7047. onResizeObservable: Observable<Engine>;
  7048. /**
  7049. * Observable event triggered each time the canvas loses focus
  7050. */
  7051. onCanvasBlurObservable: Observable<Engine>;
  7052. /**
  7053. * Observable event triggered each time the canvas gains focus
  7054. */
  7055. onCanvasFocusObservable: Observable<Engine>;
  7056. /**
  7057. * Observable event triggered each time the canvas receives pointerout event
  7058. */
  7059. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7060. /**
  7061. * Observable event triggered before each texture is initialized
  7062. */
  7063. onBeforeTextureInitObservable: Observable<Texture>;
  7064. private _vrDisplay;
  7065. private _vrSupported;
  7066. private _oldSize;
  7067. private _oldHardwareScaleFactor;
  7068. private _vrExclusivePointerMode;
  7069. private _webVRInitPromise;
  7070. /**
  7071. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7072. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7073. */
  7074. readonly isInVRExclusivePointerMode: boolean;
  7075. /**
  7076. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7077. */
  7078. disableUniformBuffers: boolean;
  7079. /** @hidden */
  7080. _uniformBuffers: UniformBuffer[];
  7081. /**
  7082. * Gets a boolean indicating that the engine supports uniform buffers
  7083. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7084. */
  7085. readonly supportsUniformBuffers: boolean;
  7086. /**
  7087. * Observable raised when the engine begins a new frame
  7088. */
  7089. onBeginFrameObservable: Observable<Engine>;
  7090. /**
  7091. * Observable raised when the engine ends the current frame
  7092. */
  7093. onEndFrameObservable: Observable<Engine>;
  7094. /**
  7095. * Observable raised when the engine is about to compile a shader
  7096. */
  7097. onBeforeShaderCompilationObservable: Observable<Engine>;
  7098. /**
  7099. * Observable raised when the engine has jsut compiled a shader
  7100. */
  7101. onAfterShaderCompilationObservable: Observable<Engine>;
  7102. private _gl;
  7103. private _renderingCanvas;
  7104. private _windowIsBackground;
  7105. private _webGLVersion;
  7106. /**
  7107. * Gets a boolean indicating that only power of 2 textures are supported
  7108. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7109. */
  7110. readonly needPOTTextures: boolean;
  7111. /** @hidden */
  7112. _badOS: boolean;
  7113. /** @hidden */
  7114. _badDesktopOS: boolean;
  7115. /**
  7116. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7117. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7118. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7119. */
  7120. disableTextureBindingOptimization: boolean;
  7121. /**
  7122. * Gets the audio engine
  7123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7124. * @ignorenaming
  7125. */
  7126. static audioEngine: AudioEngine;
  7127. private _onFocus;
  7128. private _onBlur;
  7129. private _onCanvasPointerOut;
  7130. private _onCanvasBlur;
  7131. private _onCanvasFocus;
  7132. private _onFullscreenChange;
  7133. private _onPointerLockChange;
  7134. private _onVRDisplayPointerRestricted;
  7135. private _onVRDisplayPointerUnrestricted;
  7136. private _onVrDisplayConnect;
  7137. private _onVrDisplayDisconnect;
  7138. private _onVrDisplayPresentChange;
  7139. /**
  7140. * Observable signaled when VR display mode changes
  7141. */
  7142. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7143. /**
  7144. * Observable signaled when VR request present is complete
  7145. */
  7146. onVRRequestPresentComplete: Observable<boolean>;
  7147. /**
  7148. * Observable signaled when VR request present starts
  7149. */
  7150. onVRRequestPresentStart: Observable<Engine>;
  7151. private _hardwareScalingLevel;
  7152. /** @hidden */
  7153. protected _caps: EngineCapabilities;
  7154. private _pointerLockRequested;
  7155. private _isStencilEnable;
  7156. private _colorWrite;
  7157. private _loadingScreen;
  7158. /** @hidden */
  7159. _drawCalls: PerfCounter;
  7160. /** @hidden */
  7161. _textureCollisions: PerfCounter;
  7162. private _glVersion;
  7163. private _glRenderer;
  7164. private _glVendor;
  7165. private _videoTextureSupported;
  7166. private _renderingQueueLaunched;
  7167. private _activeRenderLoops;
  7168. private _deterministicLockstep;
  7169. private _lockstepMaxSteps;
  7170. /**
  7171. * Observable signaled when a context lost event is raised
  7172. */
  7173. onContextLostObservable: Observable<Engine>;
  7174. /**
  7175. * Observable signaled when a context restored event is raised
  7176. */
  7177. onContextRestoredObservable: Observable<Engine>;
  7178. private _onContextLost;
  7179. private _onContextRestored;
  7180. private _contextWasLost;
  7181. private _doNotHandleContextLost;
  7182. private _performanceMonitor;
  7183. private _fps;
  7184. private _deltaTime;
  7185. /**
  7186. * Turn this value on if you want to pause FPS computation when in background
  7187. */
  7188. disablePerformanceMonitorInBackground: boolean;
  7189. /**
  7190. * Gets the performance monitor attached to this engine
  7191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7192. */
  7193. readonly performanceMonitor: PerformanceMonitor;
  7194. /** @hidden */
  7195. protected _depthCullingState: _DepthCullingState;
  7196. /** @hidden */
  7197. protected _stencilState: _StencilState;
  7198. /** @hidden */
  7199. protected _alphaState: _AlphaState;
  7200. /** @hidden */
  7201. protected _alphaMode: number;
  7202. private _internalTexturesCache;
  7203. /** @hidden */
  7204. protected _activeChannel: number;
  7205. private _currentTextureChannel;
  7206. /** @hidden */
  7207. protected _boundTexturesCache: {
  7208. [key: string]: Nullable<InternalTexture>;
  7209. };
  7210. /** @hidden */
  7211. protected _currentEffect: Nullable<Effect>;
  7212. /** @hidden */
  7213. protected _currentProgram: Nullable<WebGLProgram>;
  7214. private _compiledEffects;
  7215. private _vertexAttribArraysEnabled;
  7216. /** @hidden */
  7217. protected _cachedViewport: Nullable<Viewport>;
  7218. private _cachedVertexArrayObject;
  7219. /** @hidden */
  7220. protected _cachedVertexBuffers: any;
  7221. /** @hidden */
  7222. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7223. /** @hidden */
  7224. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7225. /** @hidden */
  7226. protected _currentRenderTarget: Nullable<InternalTexture>;
  7227. private _uintIndicesCurrentlySet;
  7228. private _currentBoundBuffer;
  7229. /** @hidden */
  7230. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7231. private _currentBufferPointers;
  7232. private _currentInstanceLocations;
  7233. private _currentInstanceBuffers;
  7234. private _textureUnits;
  7235. private _firstBoundInternalTextureTracker;
  7236. private _lastBoundInternalTextureTracker;
  7237. private _workingCanvas;
  7238. private _workingContext;
  7239. private _rescalePostProcess;
  7240. private _dummyFramebuffer;
  7241. private _externalData;
  7242. private _bindedRenderFunction;
  7243. private _vaoRecordInProgress;
  7244. private _mustWipeVertexAttributes;
  7245. private _emptyTexture;
  7246. private _emptyCubeTexture;
  7247. private _emptyTexture3D;
  7248. private _frameHandler;
  7249. private _nextFreeTextureSlots;
  7250. private _maxSimultaneousTextures;
  7251. private _activeRequests;
  7252. private _texturesSupported;
  7253. private _textureFormatInUse;
  7254. /**
  7255. * Gets the list of texture formats supported
  7256. */
  7257. readonly texturesSupported: Array<string>;
  7258. /**
  7259. * Gets the list of texture formats in use
  7260. */
  7261. readonly textureFormatInUse: Nullable<string>;
  7262. /**
  7263. * Gets the current viewport
  7264. */
  7265. readonly currentViewport: Nullable<Viewport>;
  7266. /**
  7267. * Gets the default empty texture
  7268. */
  7269. readonly emptyTexture: InternalTexture;
  7270. /**
  7271. * Gets the default empty 3D texture
  7272. */
  7273. readonly emptyTexture3D: InternalTexture;
  7274. /**
  7275. * Gets the default empty cube texture
  7276. */
  7277. readonly emptyCubeTexture: InternalTexture;
  7278. /**
  7279. * Creates a new engine
  7280. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7281. * @param antialias defines enable antialiasing (default: false)
  7282. * @param options defines further options to be sent to the getContext() function
  7283. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7284. */
  7285. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7286. private _rebuildInternalTextures();
  7287. private _rebuildEffects();
  7288. private _rebuildBuffers();
  7289. private _initGLContext();
  7290. /**
  7291. * Gets version of the current webGL context
  7292. */
  7293. readonly webGLVersion: number;
  7294. /**
  7295. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7296. */
  7297. readonly isStencilEnable: boolean;
  7298. private _prepareWorkingCanvas();
  7299. /**
  7300. * Reset the texture cache to empty state
  7301. */
  7302. resetTextureCache(): void;
  7303. /**
  7304. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7306. * @returns true if engine is in deterministic lock step mode
  7307. */
  7308. isDeterministicLockStep(): boolean;
  7309. /**
  7310. * Gets the max steps when engine is running in deterministic lock step
  7311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7312. * @returns the max steps
  7313. */
  7314. getLockstepMaxSteps(): number;
  7315. /**
  7316. * Gets an object containing information about the current webGL context
  7317. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7318. */
  7319. getGlInfo(): {
  7320. vendor: string;
  7321. renderer: string;
  7322. version: string;
  7323. };
  7324. /**
  7325. * Gets current aspect ratio
  7326. * @param camera defines the camera to use to get the aspect ratio
  7327. * @param useScreen defines if screen size must be used (or the current render target if any)
  7328. * @returns a number defining the aspect ratio
  7329. */
  7330. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7331. /**
  7332. * Gets the current render width
  7333. * @param useScreen defines if screen size must be used (or the current render target if any)
  7334. * @returns a number defining the current render width
  7335. */
  7336. getRenderWidth(useScreen?: boolean): number;
  7337. /**
  7338. * Gets the current render height
  7339. * @param useScreen defines if screen size must be used (or the current render target if any)
  7340. * @returns a number defining the current render height
  7341. */
  7342. getRenderHeight(useScreen?: boolean): number;
  7343. /**
  7344. * Gets the HTML canvas attached with the current webGL context
  7345. * @returns a HTML canvas
  7346. */
  7347. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7348. /**
  7349. * Gets the client rect of the HTML canvas attached with the current webGL context
  7350. * @returns a client rectanglee
  7351. */
  7352. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7353. /**
  7354. * Defines the hardware scaling level.
  7355. * By default the hardware scaling level is computed from the window device ratio.
  7356. * 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.
  7357. * @param level defines the level to use
  7358. */
  7359. setHardwareScalingLevel(level: number): void;
  7360. /**
  7361. * Gets the current hardware scaling level.
  7362. * By default the hardware scaling level is computed from the window device ratio.
  7363. * 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.
  7364. * @returns a number indicating the current hardware scaling level
  7365. */
  7366. getHardwareScalingLevel(): number;
  7367. /**
  7368. * Gets the list of loaded textures
  7369. * @returns an array containing all loaded textures
  7370. */
  7371. getLoadedTexturesCache(): InternalTexture[];
  7372. /**
  7373. * Gets the object containing all engine capabilities
  7374. * @returns the EngineCapabilities object
  7375. */
  7376. getCaps(): EngineCapabilities;
  7377. /** @hidden */
  7378. readonly drawCalls: number;
  7379. /** @hidden */
  7380. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7381. /**
  7382. * Gets the current depth function
  7383. * @returns a number defining the depth function
  7384. */
  7385. getDepthFunction(): Nullable<number>;
  7386. /**
  7387. * Sets the current depth function
  7388. * @param depthFunc defines the function to use
  7389. */
  7390. setDepthFunction(depthFunc: number): void;
  7391. /**
  7392. * Sets the current depth function to GREATER
  7393. */
  7394. setDepthFunctionToGreater(): void;
  7395. /**
  7396. * Sets the current depth function to GEQUAL
  7397. */
  7398. setDepthFunctionToGreaterOrEqual(): void;
  7399. /**
  7400. * Sets the current depth function to LESS
  7401. */
  7402. setDepthFunctionToLess(): void;
  7403. /**
  7404. * Sets the current depth function to LEQUAL
  7405. */
  7406. setDepthFunctionToLessOrEqual(): void;
  7407. /**
  7408. * Gets a boolean indicating if stencil buffer is enabled
  7409. * @returns the current stencil buffer state
  7410. */
  7411. getStencilBuffer(): boolean;
  7412. /**
  7413. * Enable or disable the stencil buffer
  7414. * @param enable defines if the stencil buffer must be enabled or disabled
  7415. */
  7416. setStencilBuffer(enable: boolean): void;
  7417. /**
  7418. * Gets the current stencil mask
  7419. * @returns a number defining the new stencil mask to use
  7420. */
  7421. getStencilMask(): number;
  7422. /**
  7423. * Sets the current stencil mask
  7424. * @param mask defines the new stencil mask to use
  7425. */
  7426. setStencilMask(mask: number): void;
  7427. /**
  7428. * Gets the current stencil function
  7429. * @returns a number defining the stencil function to use
  7430. */
  7431. getStencilFunction(): number;
  7432. /**
  7433. * Gets the current stencil reference value
  7434. * @returns a number defining the stencil reference value to use
  7435. */
  7436. getStencilFunctionReference(): number;
  7437. /**
  7438. * Gets the current stencil mask
  7439. * @returns a number defining the stencil mask to use
  7440. */
  7441. getStencilFunctionMask(): number;
  7442. /**
  7443. * Sets the current stencil function
  7444. * @param stencilFunc defines the new stencil function to use
  7445. */
  7446. setStencilFunction(stencilFunc: number): void;
  7447. /**
  7448. * Sets the current stencil reference
  7449. * @param reference defines the new stencil reference to use
  7450. */
  7451. setStencilFunctionReference(reference: number): void;
  7452. /**
  7453. * Sets the current stencil mask
  7454. * @param mask defines the new stencil mask to use
  7455. */
  7456. setStencilFunctionMask(mask: number): void;
  7457. /**
  7458. * Gets the current stencil operation when stencil fails
  7459. * @returns a number defining stencil operation to use when stencil fails
  7460. */
  7461. getStencilOperationFail(): number;
  7462. /**
  7463. * Gets the current stencil operation when depth fails
  7464. * @returns a number defining stencil operation to use when depth fails
  7465. */
  7466. getStencilOperationDepthFail(): number;
  7467. /**
  7468. * Gets the current stencil operation when stencil passes
  7469. * @returns a number defining stencil operation to use when stencil passes
  7470. */
  7471. getStencilOperationPass(): number;
  7472. /**
  7473. * Sets the stencil operation to use when stencil fails
  7474. * @param operation defines the stencil operation to use when stencil fails
  7475. */
  7476. setStencilOperationFail(operation: number): void;
  7477. /**
  7478. * Sets the stencil operation to use when depth fails
  7479. * @param operation defines the stencil operation to use when depth fails
  7480. */
  7481. setStencilOperationDepthFail(operation: number): void;
  7482. /**
  7483. * Sets the stencil operation to use when stencil passes
  7484. * @param operation defines the stencil operation to use when stencil passes
  7485. */
  7486. setStencilOperationPass(operation: number): void;
  7487. /**
  7488. * Sets a boolean indicating if the dithering state is enabled or disabled
  7489. * @param value defines the dithering state
  7490. */
  7491. setDitheringState(value: boolean): void;
  7492. /**
  7493. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7494. * @param value defines the rasterizer state
  7495. */
  7496. setRasterizerState(value: boolean): void;
  7497. /**
  7498. * stop executing a render loop function and remove it from the execution array
  7499. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7500. */
  7501. stopRenderLoop(renderFunction?: () => void): void;
  7502. /** @hidden */
  7503. _renderLoop(): void;
  7504. /**
  7505. * Register and execute a render loop. The engine can have more than one render function
  7506. * @param renderFunction defines the function to continuously execute
  7507. */
  7508. runRenderLoop(renderFunction: () => void): void;
  7509. /**
  7510. * Toggle full screen mode
  7511. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7512. * @param options defines an option object to be sent to the requestFullscreen function
  7513. */
  7514. switchFullscreen(requestPointerLock: boolean): void;
  7515. /**
  7516. * Clear the current render buffer or the current render target (if any is set up)
  7517. * @param color defines the color to use
  7518. * @param backBuffer defines if the back buffer must be cleared
  7519. * @param depth defines if the depth buffer must be cleared
  7520. * @param stencil defines if the stencil buffer must be cleared
  7521. */
  7522. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7523. /**
  7524. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7525. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7526. * @param y defines the y-coordinate of the corner of the clear rectangle
  7527. * @param width defines the width of the clear rectangle
  7528. * @param height defines the height of the clear rectangle
  7529. * @param clearColor defines the clear color
  7530. */
  7531. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7532. /**
  7533. * Set the WebGL's viewport
  7534. * @param viewport defines the viewport element to be used
  7535. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7536. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7537. */
  7538. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7539. /**
  7540. * Directly set the WebGL Viewport
  7541. * @param x defines the x coordinate of the viewport (in screen space)
  7542. * @param y defines the y coordinate of the viewport (in screen space)
  7543. * @param width defines the width of the viewport (in screen space)
  7544. * @param height defines the height of the viewport (in screen space)
  7545. * @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
  7546. */
  7547. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7548. /**
  7549. * Begin a new frame
  7550. */
  7551. beginFrame(): void;
  7552. /**
  7553. * Enf the current frame
  7554. */
  7555. endFrame(): void;
  7556. /**
  7557. * Resize the view according to the canvas' size
  7558. */
  7559. resize(): void;
  7560. /**
  7561. * Force a specific size of the canvas
  7562. * @param width defines the new canvas' width
  7563. * @param height defines the new canvas' height
  7564. */
  7565. setSize(width: number, height: number): void;
  7566. /**
  7567. * Gets a boolean indicating if a webVR device was detected
  7568. * @returns true if a webVR device was detected
  7569. */
  7570. isVRDevicePresent(): boolean;
  7571. /**
  7572. * Gets the current webVR device
  7573. * @returns the current webVR device (or null)
  7574. */
  7575. getVRDevice(): any;
  7576. /**
  7577. * Initializes a webVR display and starts listening to display change events
  7578. * The onVRDisplayChangedObservable will be notified upon these changes
  7579. * @returns The onVRDisplayChangedObservable
  7580. */
  7581. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7582. /**
  7583. * Initializes a webVR display and starts listening to display change events
  7584. * The onVRDisplayChangedObservable will be notified upon these changes
  7585. * @returns A promise containing a VRDisplay and if vr is supported
  7586. */
  7587. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7588. /**
  7589. * Call this function to switch to webVR mode
  7590. * Will do nothing if webVR is not supported or if there is no webVR device
  7591. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7592. */
  7593. enableVR(): void;
  7594. /**
  7595. * Call this function to leave webVR mode
  7596. * Will do nothing if webVR is not supported or if there is no webVR device
  7597. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7598. */
  7599. disableVR(): void;
  7600. private _onVRFullScreenTriggered;
  7601. private _getVRDisplaysAsync();
  7602. /**
  7603. * Binds the frame buffer to the specified texture.
  7604. * @param texture The texture to render to or null for the default canvas
  7605. * @param faceIndex The face of the texture to render to in case of cube texture
  7606. * @param requiredWidth The width of the target to render to
  7607. * @param requiredHeight The height of the target to render to
  7608. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7609. * @param depthStencilTexture The depth stencil texture to use to render
  7610. */
  7611. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  7612. private bindUnboundFramebuffer(framebuffer);
  7613. /**
  7614. * Unbind the current render target texture from the webGL context
  7615. * @param texture defines the render target texture to unbind
  7616. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7617. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7618. */
  7619. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7620. /**
  7621. * Unbind a list of render target textures from the webGL context
  7622. * This is used only when drawBuffer extension or webGL2 are active
  7623. * @param textures defines the render target textures to unbind
  7624. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7625. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7626. */
  7627. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7628. /**
  7629. * Force the mipmap generation for the given render target texture
  7630. * @param texture defines the render target texture to use
  7631. */
  7632. generateMipMapsForCubemap(texture: InternalTexture): void;
  7633. /**
  7634. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7635. */
  7636. flushFramebuffer(): void;
  7637. /**
  7638. * Unbind the current render target and bind the default framebuffer
  7639. */
  7640. restoreDefaultFramebuffer(): void;
  7641. /**
  7642. * Create an uniform buffer
  7643. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7644. * @param elements defines the content of the uniform buffer
  7645. * @returns the webGL uniform buffer
  7646. */
  7647. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7648. /**
  7649. * Create a dynamic uniform buffer
  7650. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7651. * @param elements defines the content of the uniform buffer
  7652. * @returns the webGL uniform buffer
  7653. */
  7654. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7655. /**
  7656. * Update an existing uniform buffer
  7657. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7658. * @param uniformBuffer defines the target uniform buffer
  7659. * @param elements defines the content to update
  7660. * @param offset defines the offset in the uniform buffer where update should start
  7661. * @param count defines the size of the data to update
  7662. */
  7663. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7664. private _resetVertexBufferBinding();
  7665. /**
  7666. * Creates a vertex buffer
  7667. * @param data the data for the vertex buffer
  7668. * @returns the new WebGL static buffer
  7669. */
  7670. createVertexBuffer(data: DataArray): WebGLBuffer;
  7671. /**
  7672. * Creates a dynamic vertex buffer
  7673. * @param data the data for the dynamic vertex buffer
  7674. * @returns the new WebGL dynamic buffer
  7675. */
  7676. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7677. /**
  7678. * Update a dynamic index buffer
  7679. * @param indexBuffer defines the target index buffer
  7680. * @param indices defines the data to update
  7681. * @param offset defines the offset in the target index buffer where update should start
  7682. */
  7683. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7684. /**
  7685. * Updates a dynamic vertex buffer.
  7686. * @param vertexBuffer the vertex buffer to update
  7687. * @param data the data used to update the vertex buffer
  7688. * @param byteOffset the byte offset of the data
  7689. * @param byteLength the byte length of the data
  7690. */
  7691. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7692. private _resetIndexBufferBinding();
  7693. /**
  7694. * Creates a new index buffer
  7695. * @param indices defines the content of the index buffer
  7696. * @param updatable defines if the index buffer must be updatable
  7697. * @returns a new webGL buffer
  7698. */
  7699. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7700. /**
  7701. * Bind a webGL buffer to the webGL context
  7702. * @param buffer defines the buffer to bind
  7703. */
  7704. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7705. /**
  7706. * Bind an uniform buffer to the current webGL context
  7707. * @param buffer defines the buffer to bind
  7708. */
  7709. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7710. /**
  7711. * Bind a buffer to the current webGL context at a given location
  7712. * @param buffer defines the buffer to bind
  7713. * @param location defines the index where to bind the buffer
  7714. */
  7715. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7716. /**
  7717. * Bind a specific block at a given index in a specific shader program
  7718. * @param shaderProgram defines the shader program
  7719. * @param blockName defines the block name
  7720. * @param index defines the index where to bind the block
  7721. */
  7722. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7723. private bindIndexBuffer(buffer);
  7724. private bindBuffer(buffer, target);
  7725. /**
  7726. * update the bound buffer with the given data
  7727. * @param data defines the data to update
  7728. */
  7729. updateArrayBuffer(data: Float32Array): void;
  7730. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7731. private _bindIndexBufferWithCache(indexBuffer);
  7732. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7733. /**
  7734. * Records a vertex array object
  7735. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7736. * @param vertexBuffers defines the list of vertex buffers to store
  7737. * @param indexBuffer defines the index buffer to store
  7738. * @param effect defines the effect to store
  7739. * @returns the new vertex array object
  7740. */
  7741. recordVertexArrayObject(vertexBuffers: {
  7742. [key: string]: VertexBuffer;
  7743. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7744. /**
  7745. * Bind a specific vertex array object
  7746. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7747. * @param vertexArrayObject defines the vertex array object to bind
  7748. * @param indexBuffer defines the index buffer to bind
  7749. */
  7750. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7751. /**
  7752. * Bind webGl buffers directly to the webGL context
  7753. * @param vertexBuffer defines the vertex buffer to bind
  7754. * @param indexBuffer defines the index buffer to bind
  7755. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7756. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7757. * @param effect defines the effect associated with the vertex buffer
  7758. */
  7759. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7760. private _unbindVertexArrayObject();
  7761. /**
  7762. * Bind a list of vertex buffers to the webGL context
  7763. * @param vertexBuffers defines the list of vertex buffers to bind
  7764. * @param indexBuffer defines the index buffer to bind
  7765. * @param effect defines the effect associated with the vertex buffers
  7766. */
  7767. bindBuffers(vertexBuffers: {
  7768. [key: string]: Nullable<VertexBuffer>;
  7769. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7770. /**
  7771. * Unbind all instance attributes
  7772. */
  7773. unbindInstanceAttributes(): void;
  7774. /**
  7775. * Release and free the memory of a vertex array object
  7776. * @param vao defines the vertex array object to delete
  7777. */
  7778. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7779. /** @hidden */
  7780. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7781. /**
  7782. * Creates a webGL buffer to use with instanciation
  7783. * @param capacity defines the size of the buffer
  7784. * @returns the webGL buffer
  7785. */
  7786. createInstancesBuffer(capacity: number): WebGLBuffer;
  7787. /**
  7788. * Delete a webGL buffer used with instanciation
  7789. * @param buffer defines the webGL buffer to delete
  7790. */
  7791. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7792. /**
  7793. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7794. * @param instancesBuffer defines the webGL buffer to update and bind
  7795. * @param data defines the data to store in the buffer
  7796. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7797. */
  7798. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7799. /**
  7800. * Apply all cached states (depth, culling, stencil and alpha)
  7801. */
  7802. applyStates(): void;
  7803. /**
  7804. * Send a draw order
  7805. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7806. * @param indexStart defines the starting index
  7807. * @param indexCount defines the number of index to draw
  7808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7809. */
  7810. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7811. /**
  7812. * Draw a list of points
  7813. * @param verticesStart defines the index of first vertex to draw
  7814. * @param verticesCount defines the count of vertices to draw
  7815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7816. */
  7817. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7818. /**
  7819. * Draw a list of unindexed primitives
  7820. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7821. * @param verticesStart defines the index of first vertex to draw
  7822. * @param verticesCount defines the count of vertices to draw
  7823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7824. */
  7825. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7826. /**
  7827. * Draw a list of indexed primitives
  7828. * @param fillMode defines the primitive to use
  7829. * @param indexStart defines the starting index
  7830. * @param indexCount defines the number of index to draw
  7831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7832. */
  7833. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7834. /**
  7835. * Draw a list of unindexed primitives
  7836. * @param fillMode defines the primitive to use
  7837. * @param verticesStart defines the index of first vertex to draw
  7838. * @param verticesCount defines the count of vertices to draw
  7839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7840. */
  7841. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7842. private _drawMode(fillMode);
  7843. /** @hidden */
  7844. _releaseEffect(effect: Effect): void;
  7845. /** @hidden */
  7846. _deleteProgram(program: WebGLProgram): void;
  7847. /**
  7848. * Create a new effect (used to store vertex/fragment shaders)
  7849. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7850. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7851. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7852. * @param samplers defines an array of string used to represent textures
  7853. * @param defines defines the string containing the defines to use to compile the shaders
  7854. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7855. * @param onCompiled defines a function to call when the effect creation is successful
  7856. * @param onError defines a function to call when the effect creation has failed
  7857. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7858. * @returns the new Effect
  7859. */
  7860. 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;
  7861. /**
  7862. * Create an effect to use with particle systems
  7863. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7864. * @param uniformsNames defines a list of attribute names
  7865. * @param samplers defines an array of string used to represent textures
  7866. * @param defines defines the string containing the defines to use to compile the shaders
  7867. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7868. * @param onCompiled defines a function to call when the effect creation is successful
  7869. * @param onError defines a function to call when the effect creation has failed
  7870. * @returns the new Effect
  7871. */
  7872. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7873. /**
  7874. * Directly creates a webGL program
  7875. * @param vertexCode defines the vertex shader code to use
  7876. * @param fragmentCode defines the fragment shader code to use
  7877. * @param context defines the webGL context to use (if not set, the current one will be used)
  7878. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7879. * @returns the new webGL program
  7880. */
  7881. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7882. /**
  7883. * Creates a webGL program
  7884. * @param vertexCode defines the vertex shader code to use
  7885. * @param fragmentCode defines the fragment shader code to use
  7886. * @param defines defines the string containing the defines to use to compile the shaders
  7887. * @param context defines the webGL context to use (if not set, the current one will be used)
  7888. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7889. * @returns the new webGL program
  7890. */
  7891. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7892. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7893. /**
  7894. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7895. * @param shaderProgram defines the webGL program to use
  7896. * @param uniformsNames defines the list of uniform names
  7897. * @returns an array of webGL uniform locations
  7898. */
  7899. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7900. /**
  7901. * Gets the lsit of active attributes for a given webGL program
  7902. * @param shaderProgram defines the webGL program to use
  7903. * @param attributesNames defines the list of attribute names to get
  7904. * @returns an array of indices indicating the offset of each attribute
  7905. */
  7906. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7907. /**
  7908. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7909. * @param effect defines the effect to activate
  7910. */
  7911. enableEffect(effect: Nullable<Effect>): void;
  7912. /**
  7913. * Set the value of an uniform to an array of int32
  7914. * @param uniform defines the webGL uniform location where to store the value
  7915. * @param array defines the array of int32 to store
  7916. */
  7917. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7918. /**
  7919. * Set the value of an uniform to an array of int32 (stored as vec2)
  7920. * @param uniform defines the webGL uniform location where to store the value
  7921. * @param array defines the array of int32 to store
  7922. */
  7923. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7924. /**
  7925. * Set the value of an uniform to an array of int32 (stored as vec3)
  7926. * @param uniform defines the webGL uniform location where to store the value
  7927. * @param array defines the array of int32 to store
  7928. */
  7929. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7930. /**
  7931. * Set the value of an uniform to an array of int32 (stored as vec4)
  7932. * @param uniform defines the webGL uniform location where to store the value
  7933. * @param array defines the array of int32 to store
  7934. */
  7935. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7936. /**
  7937. * Set the value of an uniform to an array of float32
  7938. * @param uniform defines the webGL uniform location where to store the value
  7939. * @param array defines the array of float32 to store
  7940. */
  7941. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7942. /**
  7943. * Set the value of an uniform to an array of float32 (stored as vec2)
  7944. * @param uniform defines the webGL uniform location where to store the value
  7945. * @param array defines the array of float32 to store
  7946. */
  7947. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7948. /**
  7949. * Set the value of an uniform to an array of float32 (stored as vec3)
  7950. * @param uniform defines the webGL uniform location where to store the value
  7951. * @param array defines the array of float32 to store
  7952. */
  7953. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7954. /**
  7955. * Set the value of an uniform to an array of float32 (stored as vec4)
  7956. * @param uniform defines the webGL uniform location where to store the value
  7957. * @param array defines the array of float32 to store
  7958. */
  7959. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7960. /**
  7961. * Set the value of an uniform to an array of number
  7962. * @param uniform defines the webGL uniform location where to store the value
  7963. * @param array defines the array of number to store
  7964. */
  7965. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7966. /**
  7967. * Set the value of an uniform to an array of number (stored as vec2)
  7968. * @param uniform defines the webGL uniform location where to store the value
  7969. * @param array defines the array of number to store
  7970. */
  7971. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7972. /**
  7973. * Set the value of an uniform to an array of number (stored as vec3)
  7974. * @param uniform defines the webGL uniform location where to store the value
  7975. * @param array defines the array of number to store
  7976. */
  7977. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7978. /**
  7979. * Set the value of an uniform to an array of number (stored as vec4)
  7980. * @param uniform defines the webGL uniform location where to store the value
  7981. * @param array defines the array of number to store
  7982. */
  7983. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7984. /**
  7985. * Set the value of an uniform to an array of float32 (stored as matrices)
  7986. * @param uniform defines the webGL uniform location where to store the value
  7987. * @param matrices defines the array of float32 to store
  7988. */
  7989. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7990. /**
  7991. * Set the value of an uniform to a matrix
  7992. * @param uniform defines the webGL uniform location where to store the value
  7993. * @param matrix defines the matrix to store
  7994. */
  7995. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7996. /**
  7997. * Set the value of an uniform to a matrix (3x3)
  7998. * @param uniform defines the webGL uniform location where to store the value
  7999. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8000. */
  8001. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8002. /**
  8003. * Set the value of an uniform to a matrix (2x2)
  8004. * @param uniform defines the webGL uniform location where to store the value
  8005. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8006. */
  8007. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8008. /**
  8009. * Set the value of an uniform to a number (int)
  8010. * @param uniform defines the webGL uniform location where to store the value
  8011. * @param value defines the int number to store
  8012. */
  8013. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8014. /**
  8015. * Set the value of an uniform to a number (float)
  8016. * @param uniform defines the webGL uniform location where to store the value
  8017. * @param value defines the float number to store
  8018. */
  8019. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8020. /**
  8021. * Set the value of an uniform to a vec2
  8022. * @param uniform defines the webGL uniform location where to store the value
  8023. * @param x defines the 1st component of the value
  8024. * @param y defines the 2nd component of the value
  8025. */
  8026. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8027. /**
  8028. * Set the value of an uniform to a vec3
  8029. * @param uniform defines the webGL uniform location where to store the value
  8030. * @param x defines the 1st component of the value
  8031. * @param y defines the 2nd component of the value
  8032. * @param z defines the 3rd component of the value
  8033. */
  8034. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8035. /**
  8036. * Set the value of an uniform to a boolean
  8037. * @param uniform defines the webGL uniform location where to store the value
  8038. * @param bool defines the boolean to store
  8039. */
  8040. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8041. /**
  8042. * Set the value of an uniform to a vec4
  8043. * @param uniform defines the webGL uniform location where to store the value
  8044. * @param x defines the 1st component of the value
  8045. * @param y defines the 2nd component of the value
  8046. * @param z defines the 3rd component of the value
  8047. * @param w defines the 4th component of the value
  8048. */
  8049. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8050. /**
  8051. * Set the value of an uniform to a Color3
  8052. * @param uniform defines the webGL uniform location where to store the value
  8053. * @param color3 defines the color to store
  8054. */
  8055. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8056. /**
  8057. * Set the value of an uniform to a Color3 and an alpha value
  8058. * @param uniform defines the webGL uniform location where to store the value
  8059. * @param color3 defines the color to store
  8060. * @param alpha defines the alpha component to store
  8061. */
  8062. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8063. /**
  8064. * Sets a Color4 on a uniform variable
  8065. * @param uniform defines the uniform location
  8066. * @param color4 defines the value to be set
  8067. */
  8068. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8069. /**
  8070. * Set various states to the webGL context
  8071. * @param culling defines backface culling state
  8072. * @param zOffset defines the value to apply to zOffset (0 by default)
  8073. * @param force defines if states must be applied even if cache is up to date
  8074. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8075. */
  8076. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8077. /**
  8078. * Set the z offset to apply to current rendering
  8079. * @param value defines the offset to apply
  8080. */
  8081. setZOffset(value: number): void;
  8082. /**
  8083. * Gets the current value of the zOffset
  8084. * @returns the current zOffset state
  8085. */
  8086. getZOffset(): number;
  8087. /**
  8088. * Enable or disable depth buffering
  8089. * @param enable defines the state to set
  8090. */
  8091. setDepthBuffer(enable: boolean): void;
  8092. /**
  8093. * Gets a boolean indicating if depth writing is enabled
  8094. * @returns the current depth writing state
  8095. */
  8096. getDepthWrite(): boolean;
  8097. /**
  8098. * Enable or disable depth writing
  8099. * @param enable defines the state to set
  8100. */
  8101. setDepthWrite(enable: boolean): void;
  8102. /**
  8103. * Enable or disable color writing
  8104. * @param enable defines the state to set
  8105. */
  8106. setColorWrite(enable: boolean): void;
  8107. /**
  8108. * Gets a boolean indicating if color writing is enabled
  8109. * @returns the current color writing state
  8110. */
  8111. getColorWrite(): boolean;
  8112. /**
  8113. * Sets alpha constants used by some alpha blending modes
  8114. * @param r defines the red component
  8115. * @param g defines the green component
  8116. * @param b defines the blue component
  8117. * @param a defines the alpha component
  8118. */
  8119. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8120. /**
  8121. * Sets the current alpha mode
  8122. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8123. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8124. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8125. */
  8126. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8127. /**
  8128. * Gets the current alpha mode
  8129. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8130. * @returns the current alpha mode
  8131. */
  8132. getAlphaMode(): number;
  8133. /**
  8134. * Force the entire cache to be cleared
  8135. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8136. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8137. */
  8138. wipeCaches(bruteForce?: boolean): void;
  8139. /**
  8140. * Set the compressed texture format to use, based on the formats you have, and the formats
  8141. * supported by the hardware / browser.
  8142. *
  8143. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8144. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8145. * to API arguments needed to compressed textures. This puts the burden on the container
  8146. * generator to house the arcane code for determining these for current & future formats.
  8147. *
  8148. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8149. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8150. *
  8151. * Note: The result of this call is not taken into account when a texture is base64.
  8152. *
  8153. * @param formatsAvailable defines the list of those format families you have created
  8154. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8155. *
  8156. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8157. * @returns The extension selected.
  8158. */
  8159. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8160. /** @hidden */
  8161. _createTexture(): WebGLTexture;
  8162. /**
  8163. * Usually called from BABYLON.Texture.ts.
  8164. * Passed information to create a WebGLTexture
  8165. * @param urlArg defines a value which contains one of the following:
  8166. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8167. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8168. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8169. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8170. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8171. * @param scene needed for loading to the correct scene
  8172. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8173. * @param onLoad optional callback to be called upon successful completion
  8174. * @param onError optional callback to be called upon failure
  8175. * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  8176. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8177. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8178. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8179. */
  8180. 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;
  8181. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8182. /**
  8183. * Update a raw texture
  8184. * @param texture defines the texture to update
  8185. * @param data defines the data to store in the texture
  8186. * @param format defines the format of the data
  8187. * @param invertY defines if data must be stored with Y axis inverted
  8188. * @param compression defines the compression used (null by default)
  8189. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8190. */
  8191. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8192. /**
  8193. * Creates a raw texture
  8194. * @param data defines the data to store in the texture
  8195. * @param width defines the width of the texture
  8196. * @param height defines the height of the texture
  8197. * @param format defines the format of the data
  8198. * @param generateMipMaps defines if the engine should generate the mip levels
  8199. * @param invertY defines if data must be stored with Y axis inverted
  8200. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8201. * @param compression defines the compression used (null by default)
  8202. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8203. * @returns the raw texture inside an InternalTexture
  8204. */
  8205. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8206. /**
  8207. * Creates a dynamic texture
  8208. * @param width defines the width of the texture
  8209. * @param height defines the height of the texture
  8210. * @param generateMipMaps defines if the engine should generate the mip levels
  8211. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8212. * @returns the dynamic texture inside an InternalTexture
  8213. */
  8214. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8215. /**
  8216. * Update the sampling mode of a given texture
  8217. * @param samplingMode defines the required sampling mode
  8218. * @param texture defines the texture to update
  8219. */
  8220. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8221. /**
  8222. * Update the content of a dynamic texture
  8223. * @param texture defines the texture to update
  8224. * @param canvas defines the canvas containing the source
  8225. * @param invertY defines if data must be stored with Y axis inverted
  8226. * @param premulAlpha defines if alpha is stored as premultiplied
  8227. * @param format defines the format of the data
  8228. */
  8229. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8230. /**
  8231. * Update a video texture
  8232. * @param texture defines the texture to update
  8233. * @param video defines the video element to use
  8234. * @param invertY defines if data must be stored with Y axis inverted
  8235. */
  8236. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8237. /**
  8238. * Updates a depth texture Comparison Mode and Function.
  8239. * If the comparison Function is equal to 0, the mode will be set to none.
  8240. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8241. * @param texture The texture to set the comparison function for
  8242. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8243. */
  8244. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8245. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8246. /**
  8247. * Creates a depth stencil texture.
  8248. * This is only available in WebGL 2 or with the depth texture extension available.
  8249. * @param size The size of face edge in the texture.
  8250. * @param options The options defining the texture.
  8251. * @returns The texture
  8252. */
  8253. createDepthStencilTexture(size: number | {
  8254. width: number;
  8255. height: number;
  8256. }, options: DepthTextureCreationOptions): InternalTexture;
  8257. /**
  8258. * Creates a depth stencil texture.
  8259. * This is only available in WebGL 2 or with the depth texture extension available.
  8260. * @param size The size of face edge in the texture.
  8261. * @param options The options defining the texture.
  8262. * @returns The texture
  8263. */
  8264. private _createDepthStencilTexture(size, options);
  8265. /**
  8266. * Creates a depth stencil cube texture.
  8267. * This is only available in WebGL 2.
  8268. * @param size The size of face edge in the cube texture.
  8269. * @param options The options defining the cube texture.
  8270. * @returns The cube texture
  8271. */
  8272. private _createDepthStencilCubeTexture(size, options);
  8273. /**
  8274. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8275. * @param renderTarget The render target to set the frame buffer for
  8276. */
  8277. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8278. /**
  8279. * Creates a new render target texture
  8280. * @param size defines the size of the texture
  8281. * @param options defines the options used to create the texture
  8282. * @returns a new render target texture stored in an InternalTexture
  8283. */
  8284. createRenderTargetTexture(size: number | {
  8285. width: number;
  8286. height: number;
  8287. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8288. /**
  8289. * Create a multi render target texture
  8290. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8291. * @param size defines the size of the texture
  8292. * @param options defines the creation options
  8293. * @returns the cube texture as an InternalTexture
  8294. */
  8295. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8296. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8297. /**
  8298. * Updates the sample count of a render target texture
  8299. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8300. * @param texture defines the texture to update
  8301. * @param samples defines the sample count to set
  8302. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8303. */
  8304. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8305. /**
  8306. * Update the sample count for a given multiple render target texture
  8307. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8308. * @param textures defines the textures to update
  8309. * @param samples defines the sample count to set
  8310. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8311. */
  8312. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8313. /** @hidden */
  8314. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8315. /** @hidden */
  8316. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8317. /**
  8318. * Creates a new render target cube texture
  8319. * @param size defines the size of the texture
  8320. * @param options defines the options used to create the texture
  8321. * @returns a new render target cube texture stored in an InternalTexture
  8322. */
  8323. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8324. /**
  8325. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8326. * @param rootUrl defines the url where the file to load is located
  8327. * @param scene defines the current scene
  8328. * @param scale defines scale to apply to the mip map selection
  8329. * @param offset defines offset to apply to the mip map selection
  8330. * @param onLoad defines an optional callback raised when the texture is loaded
  8331. * @param onError defines an optional callback raised if there is an issue to load the texture
  8332. * @param format defines the format of the data
  8333. * @param forcedExtension defines the extension to use to pick the right loader
  8334. * @returns the cube texture as an InternalTexture
  8335. */
  8336. 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;
  8337. /**
  8338. * Creates a cube texture
  8339. * @param rootUrl defines the url where the files to load is located
  8340. * @param scene defines the current scene
  8341. * @param files defines the list of files to load (1 per face)
  8342. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8343. * @param onLoad defines an optional callback raised when the texture is loaded
  8344. * @param onError defines an optional callback raised if there is an issue to load the texture
  8345. * @param format defines the format of the data
  8346. * @param forcedExtension defines the extension to use to pick the right loader
  8347. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8348. * @returns the cube texture as an InternalTexture
  8349. */
  8350. 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;
  8351. private setCubeMapTextureParams(gl, loadMipmap);
  8352. /**
  8353. * Update a raw cube texture
  8354. * @param texture defines the texture to udpdate
  8355. * @param data defines the data to store
  8356. * @param format defines the data format
  8357. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8358. * @param invertY defines if data must be stored with Y axis inverted
  8359. * @param compression defines the compression used (null by default)
  8360. * @param level defines which level of the texture to update
  8361. */
  8362. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8363. /**
  8364. * Creates a new raw cube texture
  8365. * @param data defines the array of data to use to create each face
  8366. * @param size defines the size of the textures
  8367. * @param format defines the format of the data
  8368. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8369. * @param generateMipMaps defines if the engine should generate the mip levels
  8370. * @param invertY defines if data must be stored with Y axis inverted
  8371. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8372. * @param compression defines the compression used (null by default)
  8373. * @returns the cube texture as an InternalTexture
  8374. */
  8375. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8376. /**
  8377. * Creates a new raw cube texture from a specified url
  8378. * @param url defines the url where the data is located
  8379. * @param scene defines the current scene
  8380. * @param size defines the size of the textures
  8381. * @param format defines the format of the data
  8382. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8383. * @param noMipmap defines if the engine should avoid generating the mip levels
  8384. * @param callback defines a callback used to extract texture data from loaded data
  8385. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8386. * @param onLoad defines a callback called when texture is loaded
  8387. * @param onError defines a callback called if there is an error
  8388. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8389. * @param invertY defines if data must be stored with Y axis inverted
  8390. * @returns the cube texture as an InternalTexture
  8391. */
  8392. 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;
  8393. /**
  8394. * Update a raw 3D texture
  8395. * @param texture defines the texture to update
  8396. * @param data defines the data to store
  8397. * @param format defines the data format
  8398. * @param invertY defines if data must be stored with Y axis inverted
  8399. * @param compression defines the used compression (can be null)
  8400. */
  8401. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  8402. /**
  8403. * Creates a new raw 3D texture
  8404. * @param data defines the data used to create the texture
  8405. * @param width defines the width of the texture
  8406. * @param height defines the height of the texture
  8407. * @param depth defines the depth of the texture
  8408. * @param format defines the format of the texture
  8409. * @param generateMipMaps defines if the engine must generate mip levels
  8410. * @param invertY defines if data must be stored with Y axis inverted
  8411. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8412. * @param compression defines the compressed used (can be null)
  8413. * @returns a new raw 3D texture (stored in an InternalTexture)
  8414. */
  8415. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8416. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8417. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8418. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8419. /** @hidden */
  8420. _releaseFramebufferObjects(texture: InternalTexture): void;
  8421. /** @hidden */
  8422. _releaseTexture(texture: InternalTexture): void;
  8423. private setProgram(program);
  8424. private _boundUniforms;
  8425. /**
  8426. * Binds an effect to the webGL context
  8427. * @param effect defines the effect to bind
  8428. */
  8429. bindSamplers(effect: Effect): void;
  8430. private _moveBoundTextureOnTop(internalTexture);
  8431. private _getCorrectTextureChannel(channel, internalTexture);
  8432. private _linkTrackers(previous, next);
  8433. private _removeDesignatedSlot(internalTexture);
  8434. private _activateCurrentTexture();
  8435. /** @hidden */
  8436. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8437. /** @hidden */
  8438. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8439. /**
  8440. * Sets a texture to the webGL context from a postprocess
  8441. * @param channel defines the channel to use
  8442. * @param postProcess defines the source postprocess
  8443. */
  8444. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8445. /**
  8446. * Binds the output of the passed in post process to the texture channel specified
  8447. * @param channel The channel the texture should be bound to
  8448. * @param postProcess The post process which's output should be bound
  8449. */
  8450. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8451. /**
  8452. * Unbind all textures from the webGL context
  8453. */
  8454. unbindAllTextures(): void;
  8455. /**
  8456. * Sets a texture to the according uniform.
  8457. * @param channel The texture channel
  8458. * @param uniform The uniform to set
  8459. * @param texture The texture to apply
  8460. */
  8461. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8462. /**
  8463. * Sets a depth stencil texture from a render target to the according uniform.
  8464. * @param channel The texture channel
  8465. * @param uniform The uniform to set
  8466. * @param texture The render target texture containing the depth stencil texture to apply
  8467. */
  8468. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8469. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8470. private _getTextureWrapMode(mode);
  8471. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8472. /**
  8473. * Sets an array of texture to the webGL context
  8474. * @param channel defines the channel where the texture array must be set
  8475. * @param uniform defines the associated uniform location
  8476. * @param textures defines the array of textures to bind
  8477. */
  8478. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8479. /** @hidden */
  8480. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8481. private _setTextureParameterFloat(target, parameter, value, texture);
  8482. private _setTextureParameterInteger(target, parameter, value, texture?);
  8483. /**
  8484. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8485. * @param x defines the x coordinate of the rectangle where pixels must be read
  8486. * @param y defines the y coordinate of the rectangle where pixels must be read
  8487. * @param width defines the width of the rectangle where pixels must be read
  8488. * @param height defines the height of the rectangle where pixels must be read
  8489. * @returns a Uint8Array containing RGBA colors
  8490. */
  8491. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8492. /**
  8493. * Add an externaly attached data from its key.
  8494. * This method call will fail and return false, if such key already exists.
  8495. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8496. * @param key the unique key that identifies the data
  8497. * @param data the data object to associate to the key for this Engine instance
  8498. * @return true if no such key were already present and the data was added successfully, false otherwise
  8499. */
  8500. addExternalData<T>(key: string, data: T): boolean;
  8501. /**
  8502. * Get an externaly attached data from its key
  8503. * @param key the unique key that identifies the data
  8504. * @return the associated data, if present (can be null), or undefined if not present
  8505. */
  8506. getExternalData<T>(key: string): T;
  8507. /**
  8508. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8509. * @param key the unique key that identifies the data
  8510. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8511. * @return the associated data, can be null if the factory returned null.
  8512. */
  8513. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8514. /**
  8515. * Remove an externaly attached data from the Engine instance
  8516. * @param key the unique key that identifies the data
  8517. * @return true if the data was successfully removed, false if it doesn't exist
  8518. */
  8519. removeExternalData(key: string): boolean;
  8520. /**
  8521. * Unbind all vertex attributes from the webGL context
  8522. */
  8523. unbindAllAttributes(): void;
  8524. /**
  8525. * 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
  8526. */
  8527. releaseEffects(): void;
  8528. /**
  8529. * Dispose and release all associated resources
  8530. */
  8531. dispose(): void;
  8532. /**
  8533. * Display the loading screen
  8534. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8535. */
  8536. displayLoadingUI(): void;
  8537. /**
  8538. * Hide the loading screen
  8539. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8540. */
  8541. hideLoadingUI(): void;
  8542. /**
  8543. * Gets the current loading screen object
  8544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8545. */
  8546. /**
  8547. * Sets the current loading screen object
  8548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8549. */
  8550. loadingScreen: ILoadingScreen;
  8551. /**
  8552. * Sets the current loading screen text
  8553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8554. */
  8555. loadingUIText: string;
  8556. /**
  8557. * Sets the current loading screen background color
  8558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8559. */
  8560. loadingUIBackgroundColor: string;
  8561. /**
  8562. * Attach a new callback raised when context lost event is fired
  8563. * @param callback defines the callback to call
  8564. */
  8565. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8566. /**
  8567. * Attach a new callback raised when context restored event is fired
  8568. * @param callback defines the callback to call
  8569. */
  8570. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8571. /**
  8572. * Gets the source code of the vertex shader associated with a specific webGL program
  8573. * @param program defines the program to use
  8574. * @returns a string containing the source code of the vertex shader associated with the program
  8575. */
  8576. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8577. /**
  8578. * Gets the source code of the fragment shader associated with a specific webGL program
  8579. * @param program defines the program to use
  8580. * @returns a string containing the source code of the fragment shader associated with the program
  8581. */
  8582. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8583. /**
  8584. * Get the current error code of the webGL context
  8585. * @returns the error code
  8586. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8587. */
  8588. getError(): number;
  8589. /**
  8590. * Gets the current framerate
  8591. * @returns a number representing the framerate
  8592. */
  8593. getFps(): number;
  8594. /**
  8595. * Gets the time spent between current and previous frame
  8596. * @returns a number representing the delta time in ms
  8597. */
  8598. getDeltaTime(): number;
  8599. private _measureFps();
  8600. /** @hidden */
  8601. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  8602. private _canRenderToFloatFramebuffer();
  8603. private _canRenderToHalfFloatFramebuffer();
  8604. private _canRenderToFramebuffer(type);
  8605. /** @hidden */
  8606. _getWebGLTextureType(type: number): number;
  8607. private _getInternalFormat(format);
  8608. /** @hidden */
  8609. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8610. /** @hidden */
  8611. _getRGBAMultiSampleBufferFormat(type: number): number;
  8612. /**
  8613. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8614. * @return the new query
  8615. */
  8616. createQuery(): WebGLQuery;
  8617. /**
  8618. * Delete and release a webGL query
  8619. * @param query defines the query to delete
  8620. * @return the current engine
  8621. */
  8622. deleteQuery(query: WebGLQuery): Engine;
  8623. /**
  8624. * Check if a given query has resolved and got its value
  8625. * @param query defines the query to check
  8626. * @returns true if the query got its value
  8627. */
  8628. isQueryResultAvailable(query: WebGLQuery): boolean;
  8629. /**
  8630. * Gets the value of a given query
  8631. * @param query defines the query to check
  8632. * @returns the value of the query
  8633. */
  8634. getQueryResult(query: WebGLQuery): number;
  8635. /**
  8636. * Initiates an occlusion query
  8637. * @param algorithmType defines the algorithm to use
  8638. * @param query defines the query to use
  8639. * @returns the current engine
  8640. * @see http://doc.babylonjs.com/features/occlusionquery
  8641. */
  8642. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8643. /**
  8644. * Ends an occlusion query
  8645. * @see http://doc.babylonjs.com/features/occlusionquery
  8646. * @param algorithmType defines the algorithm to use
  8647. * @returns the current engine
  8648. */
  8649. endOcclusionQuery(algorithmType: number): Engine;
  8650. private _createTimeQuery();
  8651. private _deleteTimeQuery(query);
  8652. private _getTimeQueryResult(query);
  8653. private _getTimeQueryAvailability(query);
  8654. private _currentNonTimestampToken;
  8655. /**
  8656. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8657. * Please note that only one query can be issued at a time
  8658. * @returns a time token used to track the time span
  8659. */
  8660. startTimeQuery(): Nullable<_TimeToken>;
  8661. /**
  8662. * Ends a time query
  8663. * @param token defines the token used to measure the time span
  8664. * @returns the time spent (in ns)
  8665. */
  8666. endTimeQuery(token: _TimeToken): int;
  8667. private getGlAlgorithmType(algorithmType);
  8668. /**
  8669. * Creates a webGL transform feedback object
  8670. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8671. * @returns the webGL transform feedback object
  8672. */
  8673. createTransformFeedback(): WebGLTransformFeedback;
  8674. /**
  8675. * Delete a webGL transform feedback object
  8676. * @param value defines the webGL transform feedback object to delete
  8677. */
  8678. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8679. /**
  8680. * Bind a webGL transform feedback object to the webgl context
  8681. * @param value defines the webGL transform feedback object to bind
  8682. */
  8683. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8684. /**
  8685. * Begins a transform feedback operation
  8686. * @param usePoints defines if points or triangles must be used
  8687. */
  8688. beginTransformFeedback(usePoints?: boolean): void;
  8689. /**
  8690. * Ends a transform feedback operation
  8691. */
  8692. endTransformFeedback(): void;
  8693. /**
  8694. * Specify the varyings to use with transform feedback
  8695. * @param program defines the associated webGL program
  8696. * @param value defines the list of strings representing the varying names
  8697. */
  8698. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8699. /**
  8700. * Bind a webGL buffer for a transform feedback operation
  8701. * @param value defines the webGL buffer to bind
  8702. */
  8703. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8704. /** @hidden */
  8705. _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;
  8706. /** @hidden */
  8707. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8708. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8709. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8710. /**
  8711. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8712. * @returns true if the engine can be created
  8713. * @ignorenaming
  8714. */
  8715. static isSupported(): boolean;
  8716. }
  8717. }
  8718. declare module BABYLON {
  8719. class NullEngineOptions {
  8720. renderWidth: number;
  8721. renderHeight: number;
  8722. textureSize: number;
  8723. deterministicLockstep: boolean;
  8724. lockstepMaxSteps: number;
  8725. }
  8726. /**
  8727. * The null engine class provides support for headless version of babylon.js.
  8728. * This can be used in server side scenario or for testing purposes
  8729. */
  8730. class NullEngine extends Engine {
  8731. private _options;
  8732. isDeterministicLockStep(): boolean;
  8733. getLockstepMaxSteps(): number;
  8734. getHardwareScalingLevel(): number;
  8735. constructor(options?: NullEngineOptions);
  8736. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8737. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8738. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8739. getRenderWidth(useScreen?: boolean): number;
  8740. getRenderHeight(useScreen?: boolean): number;
  8741. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8742. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8743. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8744. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8745. bindSamplers(effect: Effect): void;
  8746. enableEffect(effect: Effect): void;
  8747. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8748. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8749. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8750. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8751. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8752. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8753. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8754. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8755. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8756. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8757. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8758. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8759. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8760. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8761. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8762. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8763. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8764. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8765. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8766. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8767. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8768. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8769. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8770. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8771. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8772. bindBuffers(vertexBuffers: {
  8773. [key: string]: VertexBuffer;
  8774. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8775. wipeCaches(bruteForce?: boolean): void;
  8776. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8777. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8778. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8779. _createTexture(): WebGLTexture;
  8780. _releaseTexture(texture: InternalTexture): void;
  8781. 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;
  8782. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8783. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8784. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8785. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8786. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8787. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8788. /**
  8789. * Updates a dynamic vertex buffer.
  8790. * @param vertexBuffer the vertex buffer to update
  8791. * @param data the data used to update the vertex buffer
  8792. * @param byteOffset the byte offset of the data (optional)
  8793. * @param byteLength the byte length of the data (optional)
  8794. */
  8795. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8796. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8797. _bindTexture(channel: number, texture: InternalTexture): void;
  8798. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8799. releaseEffects(): void;
  8800. }
  8801. }
  8802. interface WebGLRenderingContext {
  8803. readonly RASTERIZER_DISCARD: number;
  8804. readonly DEPTH_COMPONENT24: number;
  8805. readonly TEXTURE_3D: number;
  8806. readonly TEXTURE_2D_ARRAY: number;
  8807. readonly TEXTURE_COMPARE_FUNC: number;
  8808. readonly TEXTURE_COMPARE_MODE: number;
  8809. readonly COMPARE_REF_TO_TEXTURE: number;
  8810. readonly TEXTURE_WRAP_R: number;
  8811. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8812. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8813. 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;
  8814. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8815. readonly TRANSFORM_FEEDBACK: number;
  8816. readonly INTERLEAVED_ATTRIBS: number;
  8817. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8818. createTransformFeedback(): WebGLTransformFeedback;
  8819. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8820. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8821. beginTransformFeedback(primitiveMode: number): void;
  8822. endTransformFeedback(): void;
  8823. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8824. }
  8825. interface ImageBitmap {
  8826. readonly width: number;
  8827. readonly height: number;
  8828. close(): void;
  8829. }
  8830. interface WebGLQuery extends WebGLObject {
  8831. }
  8832. declare var WebGLQuery: {
  8833. prototype: WebGLQuery;
  8834. new (): WebGLQuery;
  8835. };
  8836. interface WebGLSampler extends WebGLObject {
  8837. }
  8838. declare var WebGLSampler: {
  8839. prototype: WebGLSampler;
  8840. new (): WebGLSampler;
  8841. };
  8842. interface WebGLSync extends WebGLObject {
  8843. }
  8844. declare var WebGLSync: {
  8845. prototype: WebGLSync;
  8846. new (): WebGLSync;
  8847. };
  8848. interface WebGLTransformFeedback extends WebGLObject {
  8849. }
  8850. declare var WebGLTransformFeedback: {
  8851. prototype: WebGLTransformFeedback;
  8852. new (): WebGLTransformFeedback;
  8853. };
  8854. interface WebGLVertexArrayObject extends WebGLObject {
  8855. }
  8856. declare var WebGLVertexArrayObject: {
  8857. prototype: WebGLVertexArrayObject;
  8858. new (): WebGLVertexArrayObject;
  8859. };
  8860. declare module BABYLON {
  8861. class KeyboardEventTypes {
  8862. static _KEYDOWN: number;
  8863. static _KEYUP: number;
  8864. static readonly KEYDOWN: number;
  8865. static readonly KEYUP: number;
  8866. }
  8867. class KeyboardInfo {
  8868. type: number;
  8869. event: KeyboardEvent;
  8870. constructor(type: number, event: KeyboardEvent);
  8871. }
  8872. /**
  8873. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8874. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8875. */
  8876. class KeyboardInfoPre extends KeyboardInfo {
  8877. constructor(type: number, event: KeyboardEvent);
  8878. skipOnPointerObservable: boolean;
  8879. }
  8880. }
  8881. declare module BABYLON {
  8882. class PointerEventTypes {
  8883. static _POINTERDOWN: number;
  8884. static _POINTERUP: number;
  8885. static _POINTERMOVE: number;
  8886. static _POINTERWHEEL: number;
  8887. static _POINTERPICK: number;
  8888. static _POINTERTAP: number;
  8889. static _POINTERDOUBLETAP: number;
  8890. static readonly POINTERDOWN: number;
  8891. static readonly POINTERUP: number;
  8892. static readonly POINTERMOVE: number;
  8893. static readonly POINTERWHEEL: number;
  8894. static readonly POINTERPICK: number;
  8895. static readonly POINTERTAP: number;
  8896. static readonly POINTERDOUBLETAP: number;
  8897. }
  8898. class PointerInfoBase {
  8899. type: number;
  8900. event: PointerEvent | MouseWheelEvent;
  8901. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  8902. }
  8903. /**
  8904. * This class is used to store pointer related info for the onPrePointerObservable event.
  8905. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8906. */
  8907. class PointerInfoPre extends PointerInfoBase {
  8908. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8909. localPosition: Vector2;
  8910. skipOnPointerObservable: boolean;
  8911. }
  8912. /**
  8913. * This type contains all the data related to a pointer event in Babylon.js.
  8914. * 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.
  8915. */
  8916. class PointerInfo extends PointerInfoBase {
  8917. pickInfo: Nullable<PickingInfo>;
  8918. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  8919. }
  8920. }
  8921. declare module BABYLON {
  8922. class BoundingBox implements ICullable {
  8923. vectors: Vector3[];
  8924. center: Vector3;
  8925. centerWorld: Vector3;
  8926. extendSize: Vector3;
  8927. extendSizeWorld: Vector3;
  8928. directions: Vector3[];
  8929. vectorsWorld: Vector3[];
  8930. minimumWorld: Vector3;
  8931. maximumWorld: Vector3;
  8932. minimum: Vector3;
  8933. maximum: Vector3;
  8934. private _worldMatrix;
  8935. /**
  8936. * Creates a new bounding box
  8937. * @param min defines the minimum vector (in local space)
  8938. * @param max defines the maximum vector (in local space)
  8939. */
  8940. constructor(min: Vector3, max: Vector3);
  8941. /**
  8942. * Recreates the entire bounding box from scratch
  8943. * @param min defines the new minimum vector (in local space)
  8944. * @param max defines the new maximum vector (in local space)
  8945. */
  8946. reConstruct(min: Vector3, max: Vector3): void;
  8947. getWorldMatrix(): Matrix;
  8948. setWorldMatrix(matrix: Matrix): BoundingBox;
  8949. _update(world: Matrix): void;
  8950. isInFrustum(frustumPlanes: Plane[]): boolean;
  8951. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8952. intersectsPoint(point: Vector3): boolean;
  8953. intersectsSphere(sphere: BoundingSphere): boolean;
  8954. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  8955. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  8956. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  8957. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8958. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8959. }
  8960. }
  8961. declare module BABYLON {
  8962. interface ICullable {
  8963. isInFrustum(frustumPlanes: Plane[]): boolean;
  8964. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8965. }
  8966. class BoundingInfo implements ICullable {
  8967. minimum: Vector3;
  8968. maximum: Vector3;
  8969. boundingBox: BoundingBox;
  8970. boundingSphere: BoundingSphere;
  8971. private _isLocked;
  8972. constructor(minimum: Vector3, maximum: Vector3);
  8973. isLocked: boolean;
  8974. update(world: Matrix): void;
  8975. /**
  8976. * Recreate the bounding info to be centered around a specific point given a specific extend.
  8977. * @param center New center of the bounding info
  8978. * @param extend New extend of the bounding info
  8979. */
  8980. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  8981. isInFrustum(frustumPlanes: Plane[]): boolean;
  8982. /**
  8983. * Gets the world distance between the min and max points of the bounding box
  8984. */
  8985. readonly diagonalLength: number;
  8986. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8987. _checkCollision(collider: Collider): boolean;
  8988. intersectsPoint(point: Vector3): boolean;
  8989. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  8990. }
  8991. }
  8992. declare module BABYLON {
  8993. class BoundingSphere {
  8994. center: Vector3;
  8995. radius: number;
  8996. centerWorld: Vector3;
  8997. radiusWorld: number;
  8998. minimum: Vector3;
  8999. maximum: Vector3;
  9000. private _tempRadiusVector;
  9001. /**
  9002. * Creates a new bounding sphere
  9003. * @param min defines the minimum vector (in local space)
  9004. * @param max defines the maximum vector (in local space)
  9005. */
  9006. constructor(min: Vector3, max: Vector3);
  9007. /**
  9008. * Recreates the entire bounding sphere from scratch
  9009. * @param min defines the new minimum vector (in local space)
  9010. * @param max defines the new maximum vector (in local space)
  9011. */
  9012. reConstruct(min: Vector3, max: Vector3): void;
  9013. _update(world: Matrix): void;
  9014. isInFrustum(frustumPlanes: Plane[]): boolean;
  9015. intersectsPoint(point: Vector3): boolean;
  9016. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  9017. }
  9018. }
  9019. declare module BABYLON {
  9020. class Ray {
  9021. origin: Vector3;
  9022. direction: Vector3;
  9023. length: number;
  9024. private _edge1;
  9025. private _edge2;
  9026. private _pvec;
  9027. private _tvec;
  9028. private _qvec;
  9029. private _tmpRay;
  9030. constructor(origin: Vector3, direction: Vector3, length?: number);
  9031. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  9032. intersectsBox(box: BoundingBox): boolean;
  9033. intersectsSphere(sphere: BoundingSphere): boolean;
  9034. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  9035. intersectsPlane(plane: Plane): Nullable<number>;
  9036. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  9037. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9038. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  9039. private static smallnum;
  9040. private static rayl;
  9041. /**
  9042. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9043. * @param sega the first point of the segment to test the intersection against
  9044. * @param segb the second point of the segment to test the intersection against
  9045. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9046. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9047. */
  9048. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  9049. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9050. static Zero(): Ray;
  9051. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9052. /**
  9053. * 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
  9054. * transformed to the given world matrix.
  9055. * @param origin The origin point
  9056. * @param end The end point
  9057. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9058. */
  9059. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  9060. static Transform(ray: Ray, matrix: Matrix): Ray;
  9061. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  9062. }
  9063. }
  9064. declare module BABYLON {
  9065. class StickValues {
  9066. x: number;
  9067. y: number;
  9068. constructor(x: number, y: number);
  9069. }
  9070. interface GamepadButtonChanges {
  9071. changed: boolean;
  9072. pressChanged: boolean;
  9073. touchChanged: boolean;
  9074. valueChanged: boolean;
  9075. }
  9076. class Gamepad {
  9077. id: string;
  9078. index: number;
  9079. browserGamepad: any;
  9080. type: number;
  9081. private _leftStick;
  9082. private _rightStick;
  9083. _isConnected: boolean;
  9084. private _leftStickAxisX;
  9085. private _leftStickAxisY;
  9086. private _rightStickAxisX;
  9087. private _rightStickAxisY;
  9088. private _onleftstickchanged;
  9089. private _onrightstickchanged;
  9090. static GAMEPAD: number;
  9091. static GENERIC: number;
  9092. static XBOX: number;
  9093. static POSE_ENABLED: number;
  9094. protected _invertLeftStickY: boolean;
  9095. readonly isConnected: boolean;
  9096. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9097. onleftstickchanged(callback: (values: StickValues) => void): void;
  9098. onrightstickchanged(callback: (values: StickValues) => void): void;
  9099. leftStick: StickValues;
  9100. rightStick: StickValues;
  9101. update(): void;
  9102. dispose(): void;
  9103. }
  9104. class GenericPad extends Gamepad {
  9105. private _buttons;
  9106. private _onbuttondown;
  9107. private _onbuttonup;
  9108. onButtonDownObservable: Observable<number>;
  9109. onButtonUpObservable: Observable<number>;
  9110. onbuttondown(callback: (buttonPressed: number) => void): void;
  9111. onbuttonup(callback: (buttonReleased: number) => void): void;
  9112. constructor(id: string, index: number, browserGamepad: any);
  9113. private _setButtonValue(newValue, currentValue, buttonIndex);
  9114. update(): void;
  9115. dispose(): void;
  9116. }
  9117. }
  9118. declare module BABYLON {
  9119. class GamepadManager {
  9120. private _scene;
  9121. private _babylonGamepads;
  9122. private _oneGamepadConnected;
  9123. _isMonitoring: boolean;
  9124. private _gamepadEventSupported;
  9125. private _gamepadSupport;
  9126. onGamepadConnectedObservable: Observable<Gamepad>;
  9127. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9128. private _onGamepadConnectedEvent;
  9129. private _onGamepadDisconnectedEvent;
  9130. constructor(_scene?: Scene | undefined);
  9131. readonly gamepads: Gamepad[];
  9132. getGamepadByType(type?: number): Nullable<Gamepad>;
  9133. dispose(): void;
  9134. private _addNewGamepad(gamepad);
  9135. private _startMonitoringGamepads();
  9136. private _stopMonitoringGamepads();
  9137. _checkGamepadsStatus(): void;
  9138. private _updateGamepadObjects();
  9139. }
  9140. }
  9141. declare module BABYLON {
  9142. /**
  9143. * Defines supported buttons for XBox360 compatible gamepads
  9144. */
  9145. enum Xbox360Button {
  9146. /** A */
  9147. A = 0,
  9148. /** B */
  9149. B = 1,
  9150. /** X */
  9151. X = 2,
  9152. /** Y */
  9153. Y = 3,
  9154. /** Start */
  9155. Start = 4,
  9156. /** Back */
  9157. Back = 5,
  9158. /** Left button */
  9159. LB = 6,
  9160. /** Right button */
  9161. RB = 7,
  9162. /** Left stick */
  9163. LeftStick = 8,
  9164. /** Right stick */
  9165. RightStick = 9,
  9166. }
  9167. /** Defines values for XBox360 DPad */
  9168. enum Xbox360Dpad {
  9169. /** Up */
  9170. Up = 0,
  9171. /** Down */
  9172. Down = 1,
  9173. /** Left */
  9174. Left = 2,
  9175. /** Right */
  9176. Right = 3,
  9177. }
  9178. /**
  9179. * Defines a XBox360 gamepad
  9180. */
  9181. class Xbox360Pad extends Gamepad {
  9182. private _leftTrigger;
  9183. private _rightTrigger;
  9184. private _onlefttriggerchanged;
  9185. private _onrighttriggerchanged;
  9186. private _onbuttondown;
  9187. private _onbuttonup;
  9188. private _ondpaddown;
  9189. private _ondpadup;
  9190. /** Observable raised when a button is pressed */
  9191. onButtonDownObservable: Observable<Xbox360Button>;
  9192. /** Observable raised when a button is released */
  9193. onButtonUpObservable: Observable<Xbox360Button>;
  9194. /** Observable raised when a pad is pressed */
  9195. onPadDownObservable: Observable<Xbox360Dpad>;
  9196. /** Observable raised when a pad is released */
  9197. onPadUpObservable: Observable<Xbox360Dpad>;
  9198. private _buttonA;
  9199. private _buttonB;
  9200. private _buttonX;
  9201. private _buttonY;
  9202. private _buttonBack;
  9203. private _buttonStart;
  9204. private _buttonLB;
  9205. private _buttonRB;
  9206. private _buttonLeftStick;
  9207. private _buttonRightStick;
  9208. private _dPadUp;
  9209. private _dPadDown;
  9210. private _dPadLeft;
  9211. private _dPadRight;
  9212. private _isXboxOnePad;
  9213. /**
  9214. * Creates a new XBox360 gamepad object
  9215. * @param id defines the id of this gamepad
  9216. * @param index defines its index
  9217. * @param gamepad defines the internal HTML gamepad object
  9218. * @param xboxOne defines if it is a XBox One gamepad
  9219. */
  9220. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9221. /**
  9222. * Defines the callback to call when left trigger is pressed
  9223. * @param callback defines the callback to use
  9224. */
  9225. onlefttriggerchanged(callback: (value: number) => void): void;
  9226. /**
  9227. * Defines the callback to call when right trigger is pressed
  9228. * @param callback defines the callback to use
  9229. */
  9230. onrighttriggerchanged(callback: (value: number) => void): void;
  9231. /**
  9232. * Gets or sets left trigger value
  9233. */
  9234. leftTrigger: number;
  9235. /**
  9236. * Gets or sets right trigger value
  9237. */
  9238. rightTrigger: number;
  9239. /**
  9240. * Defines the callback to call when a button is pressed
  9241. * @param callback defines the callback to use
  9242. */
  9243. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9244. /**
  9245. * Defines the callback to call when a button is released
  9246. * @param callback defines the callback to use
  9247. */
  9248. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9249. /**
  9250. * Defines the callback to call when a pad is pressed
  9251. * @param callback defines the callback to use
  9252. */
  9253. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9254. /**
  9255. * Defines the callback to call when a pad is released
  9256. * @param callback defines the callback to use
  9257. */
  9258. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9259. private _setButtonValue(newValue, currentValue, buttonType);
  9260. private _setDPadValue(newValue, currentValue, buttonType);
  9261. /** Gets or sets value of A button */
  9262. buttonA: number;
  9263. /** Gets or sets value of B button */
  9264. buttonB: number;
  9265. /** Gets or sets value of X button */
  9266. buttonX: number;
  9267. /** Gets or sets value of Y button */
  9268. buttonY: number;
  9269. /** Gets or sets value of Start button */
  9270. buttonStart: number;
  9271. /** Gets or sets value of Back button */
  9272. buttonBack: number;
  9273. /** Gets or sets value of Left button */
  9274. buttonLB: number;
  9275. /** Gets or sets value of Right button */
  9276. buttonRB: number;
  9277. /** Gets or sets value of left stick */
  9278. buttonLeftStick: number;
  9279. /** Gets or sets value of right stick */
  9280. buttonRightStick: number;
  9281. /** Gets or sets value of DPad up */
  9282. dPadUp: number;
  9283. /** Gets or sets value of DPad down */
  9284. dPadDown: number;
  9285. /** Gets or sets value of DPad left */
  9286. dPadLeft: number;
  9287. /** Gets or sets value of DPad right */
  9288. dPadRight: number;
  9289. /**
  9290. * Force the gamepad to synchronize with device values
  9291. */
  9292. update(): void;
  9293. dispose(): void;
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. /**
  9298. * Represents the different options available during the creation of
  9299. * a Environment helper.
  9300. *
  9301. * This can control the default ground, skybox and image processing setup of your scene.
  9302. */
  9303. interface IEnvironmentHelperOptions {
  9304. /**
  9305. * Specifies wether or not to create a ground.
  9306. * True by default.
  9307. */
  9308. createGround: boolean;
  9309. /**
  9310. * Specifies the ground size.
  9311. * 15 by default.
  9312. */
  9313. groundSize: number;
  9314. /**
  9315. * The texture used on the ground for the main color.
  9316. * Comes from the BabylonJS CDN by default.
  9317. *
  9318. * Remarks: Can be either a texture or a url.
  9319. */
  9320. groundTexture: string | BaseTexture;
  9321. /**
  9322. * The color mixed in the ground texture by default.
  9323. * BabylonJS clearColor by default.
  9324. */
  9325. groundColor: Color3;
  9326. /**
  9327. * Specifies the ground opacity.
  9328. * 1 by default.
  9329. */
  9330. groundOpacity: number;
  9331. /**
  9332. * Enables the ground to receive shadows.
  9333. * True by default.
  9334. */
  9335. enableGroundShadow: boolean;
  9336. /**
  9337. * Helps preventing the shadow to be fully black on the ground.
  9338. * 0.5 by default.
  9339. */
  9340. groundShadowLevel: number;
  9341. /**
  9342. * Creates a mirror texture attach to the ground.
  9343. * false by default.
  9344. */
  9345. enableGroundMirror: boolean;
  9346. /**
  9347. * Specifies the ground mirror size ratio.
  9348. * 0.3 by default as the default kernel is 64.
  9349. */
  9350. groundMirrorSizeRatio: number;
  9351. /**
  9352. * Specifies the ground mirror blur kernel size.
  9353. * 64 by default.
  9354. */
  9355. groundMirrorBlurKernel: number;
  9356. /**
  9357. * Specifies the ground mirror visibility amount.
  9358. * 1 by default
  9359. */
  9360. groundMirrorAmount: number;
  9361. /**
  9362. * Specifies the ground mirror reflectance weight.
  9363. * This uses the standard weight of the background material to setup the fresnel effect
  9364. * of the mirror.
  9365. * 1 by default.
  9366. */
  9367. groundMirrorFresnelWeight: number;
  9368. /**
  9369. * Specifies the ground mirror Falloff distance.
  9370. * This can helps reducing the size of the reflection.
  9371. * 0 by Default.
  9372. */
  9373. groundMirrorFallOffDistance: number;
  9374. /**
  9375. * Specifies the ground mirror texture type.
  9376. * Unsigned Int by Default.
  9377. */
  9378. groundMirrorTextureType: number;
  9379. /**
  9380. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9381. * the shown objects.
  9382. */
  9383. groundYBias: number;
  9384. /**
  9385. * Specifies wether or not to create a skybox.
  9386. * True by default.
  9387. */
  9388. createSkybox: boolean;
  9389. /**
  9390. * Specifies the skybox size.
  9391. * 20 by default.
  9392. */
  9393. skyboxSize: number;
  9394. /**
  9395. * The texture used on the skybox for the main color.
  9396. * Comes from the BabylonJS CDN by default.
  9397. *
  9398. * Remarks: Can be either a texture or a url.
  9399. */
  9400. skyboxTexture: string | BaseTexture;
  9401. /**
  9402. * The color mixed in the skybox texture by default.
  9403. * BabylonJS clearColor by default.
  9404. */
  9405. skyboxColor: Color3;
  9406. /**
  9407. * The background rotation around the Y axis of the scene.
  9408. * This helps aligning the key lights of your scene with the background.
  9409. * 0 by default.
  9410. */
  9411. backgroundYRotation: number;
  9412. /**
  9413. * Compute automatically the size of the elements to best fit with the scene.
  9414. */
  9415. sizeAuto: boolean;
  9416. /**
  9417. * Default position of the rootMesh if autoSize is not true.
  9418. */
  9419. rootPosition: Vector3;
  9420. /**
  9421. * Sets up the image processing in the scene.
  9422. * true by default.
  9423. */
  9424. setupImageProcessing: boolean;
  9425. /**
  9426. * The texture used as your environment texture in the scene.
  9427. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9428. *
  9429. * Remarks: Can be either a texture or a url.
  9430. */
  9431. environmentTexture: string | BaseTexture;
  9432. /**
  9433. * The value of the exposure to apply to the scene.
  9434. * 0.6 by default if setupImageProcessing is true.
  9435. */
  9436. cameraExposure: number;
  9437. /**
  9438. * The value of the contrast to apply to the scene.
  9439. * 1.6 by default if setupImageProcessing is true.
  9440. */
  9441. cameraContrast: number;
  9442. /**
  9443. * Specifies wether or not tonemapping should be enabled in the scene.
  9444. * true by default if setupImageProcessing is true.
  9445. */
  9446. toneMappingEnabled: boolean;
  9447. }
  9448. /**
  9449. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9450. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9451. * It also helps with the default setup of your imageProcessing configuration.
  9452. */
  9453. class EnvironmentHelper {
  9454. /**
  9455. * Default ground texture URL.
  9456. */
  9457. private static _groundTextureCDNUrl;
  9458. /**
  9459. * Default skybox texture URL.
  9460. */
  9461. private static _skyboxTextureCDNUrl;
  9462. /**
  9463. * Default environment texture URL.
  9464. */
  9465. private static _environmentTextureCDNUrl;
  9466. /**
  9467. * Creates the default options for the helper.
  9468. */
  9469. private static _getDefaultOptions();
  9470. private _rootMesh;
  9471. /**
  9472. * Gets the root mesh created by the helper.
  9473. */
  9474. readonly rootMesh: Mesh;
  9475. private _skybox;
  9476. /**
  9477. * Gets the skybox created by the helper.
  9478. */
  9479. readonly skybox: Nullable<Mesh>;
  9480. private _skyboxTexture;
  9481. /**
  9482. * Gets the skybox texture created by the helper.
  9483. */
  9484. readonly skyboxTexture: Nullable<BaseTexture>;
  9485. private _skyboxMaterial;
  9486. /**
  9487. * Gets the skybox material created by the helper.
  9488. */
  9489. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9490. private _ground;
  9491. /**
  9492. * Gets the ground mesh created by the helper.
  9493. */
  9494. readonly ground: Nullable<Mesh>;
  9495. private _groundTexture;
  9496. /**
  9497. * Gets the ground texture created by the helper.
  9498. */
  9499. readonly groundTexture: Nullable<BaseTexture>;
  9500. private _groundMirror;
  9501. /**
  9502. * Gets the ground mirror created by the helper.
  9503. */
  9504. readonly groundMirror: Nullable<MirrorTexture>;
  9505. /**
  9506. * Gets the ground mirror render list to helps pushing the meshes
  9507. * you wish in the ground reflection.
  9508. */
  9509. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9510. private _groundMaterial;
  9511. /**
  9512. * Gets the ground material created by the helper.
  9513. */
  9514. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9515. /**
  9516. * Stores the creation options.
  9517. */
  9518. private readonly _scene;
  9519. private _options;
  9520. /**
  9521. * This observable will be notified with any error during the creation of the environment,
  9522. * mainly texture creation errors.
  9523. */
  9524. onErrorObservable: Observable<{
  9525. message?: string;
  9526. exception?: any;
  9527. }>;
  9528. /**
  9529. * constructor
  9530. * @param options
  9531. * @param scene The scene to add the material to
  9532. */
  9533. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9534. /**
  9535. * Updates the background according to the new options
  9536. * @param options
  9537. */
  9538. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9539. /**
  9540. * Sets the primary color of all the available elements.
  9541. * @param color the main color to affect to the ground and the background
  9542. */
  9543. setMainColor(color: Color3): void;
  9544. /**
  9545. * Setup the image processing according to the specified options.
  9546. */
  9547. private _setupImageProcessing();
  9548. /**
  9549. * Setup the environment texture according to the specified options.
  9550. */
  9551. private _setupEnvironmentTexture();
  9552. /**
  9553. * Setup the background according to the specified options.
  9554. */
  9555. private _setupBackground();
  9556. /**
  9557. * Get the scene sizes according to the setup.
  9558. */
  9559. private _getSceneSize();
  9560. /**
  9561. * Setup the ground according to the specified options.
  9562. */
  9563. private _setupGround(sceneSize);
  9564. /**
  9565. * Setup the ground material according to the specified options.
  9566. */
  9567. private _setupGroundMaterial();
  9568. /**
  9569. * Setup the ground diffuse texture according to the specified options.
  9570. */
  9571. private _setupGroundDiffuseTexture();
  9572. /**
  9573. * Setup the ground mirror texture according to the specified options.
  9574. */
  9575. private _setupGroundMirrorTexture(sceneSize);
  9576. /**
  9577. * Setup the ground to receive the mirror texture.
  9578. */
  9579. private _setupMirrorInGroundMaterial();
  9580. /**
  9581. * Setup the skybox according to the specified options.
  9582. */
  9583. private _setupSkybox(sceneSize);
  9584. /**
  9585. * Setup the skybox material according to the specified options.
  9586. */
  9587. private _setupSkyboxMaterial();
  9588. /**
  9589. * Setup the skybox reflection texture according to the specified options.
  9590. */
  9591. private _setupSkyboxReflectionTexture();
  9592. private _errorHandler;
  9593. /**
  9594. * Dispose all the elements created by the Helper.
  9595. */
  9596. dispose(): void;
  9597. }
  9598. }
  9599. declare module BABYLON {
  9600. /**
  9601. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9602. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9603. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9604. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9605. */
  9606. class VideoDome extends Node {
  9607. /**
  9608. * The video texture being displayed on the sphere
  9609. */
  9610. protected _videoTexture: VideoTexture;
  9611. /**
  9612. * The skybox material
  9613. */
  9614. protected _material: BackgroundMaterial;
  9615. /**
  9616. * The surface used for the skybox
  9617. */
  9618. protected _mesh: Mesh;
  9619. /**
  9620. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9621. * Also see the options.resolution property.
  9622. */
  9623. fovMultiplier: number;
  9624. /**
  9625. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9626. * @param name Element's name, child elements will append suffixes for their own names.
  9627. * @param urlsOrVideo
  9628. * @param options An object containing optional or exposed sub element properties:
  9629. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9630. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  9631. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  9632. * @param options **loop=true** Automatically loop video on end.
  9633. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  9634. */
  9635. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  9636. resolution?: number;
  9637. clickToPlay?: boolean;
  9638. autoPlay?: boolean;
  9639. loop?: boolean;
  9640. size?: number;
  9641. }, scene: Scene);
  9642. /**
  9643. * Releases resources associated with this node.
  9644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9646. */
  9647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9648. }
  9649. }
  9650. declare module BABYLON {
  9651. /**
  9652. * This class can be used to get instrumentation data from a Babylon engine
  9653. */
  9654. class EngineInstrumentation implements IDisposable {
  9655. engine: Engine;
  9656. private _captureGPUFrameTime;
  9657. private _gpuFrameTimeToken;
  9658. private _gpuFrameTime;
  9659. private _captureShaderCompilationTime;
  9660. private _shaderCompilationTime;
  9661. private _onBeginFrameObserver;
  9662. private _onEndFrameObserver;
  9663. private _onBeforeShaderCompilationObserver;
  9664. private _onAfterShaderCompilationObserver;
  9665. /**
  9666. * Gets the perf counter used for GPU frame time
  9667. */
  9668. readonly gpuFrameTimeCounter: PerfCounter;
  9669. /**
  9670. * Gets the GPU frame time capture status
  9671. */
  9672. /**
  9673. * Enable or disable the GPU frame time capture
  9674. */
  9675. captureGPUFrameTime: boolean;
  9676. /**
  9677. * Gets the perf counter used for shader compilation time
  9678. */
  9679. readonly shaderCompilationTimeCounter: PerfCounter;
  9680. /**
  9681. * Gets the shader compilation time capture status
  9682. */
  9683. /**
  9684. * Enable or disable the shader compilation time capture
  9685. */
  9686. captureShaderCompilationTime: boolean;
  9687. constructor(engine: Engine);
  9688. dispose(): void;
  9689. }
  9690. }
  9691. declare module BABYLON {
  9692. /**
  9693. * This class can be used to get instrumentation data from a Babylon engine
  9694. */
  9695. class SceneInstrumentation implements IDisposable {
  9696. scene: Scene;
  9697. private _captureActiveMeshesEvaluationTime;
  9698. private _activeMeshesEvaluationTime;
  9699. private _captureRenderTargetsRenderTime;
  9700. private _renderTargetsRenderTime;
  9701. private _captureFrameTime;
  9702. private _frameTime;
  9703. private _captureRenderTime;
  9704. private _renderTime;
  9705. private _captureInterFrameTime;
  9706. private _interFrameTime;
  9707. private _captureParticlesRenderTime;
  9708. private _particlesRenderTime;
  9709. private _captureSpritesRenderTime;
  9710. private _spritesRenderTime;
  9711. private _capturePhysicsTime;
  9712. private _physicsTime;
  9713. private _captureAnimationsTime;
  9714. private _animationsTime;
  9715. private _onBeforeActiveMeshesEvaluationObserver;
  9716. private _onAfterActiveMeshesEvaluationObserver;
  9717. private _onBeforeRenderTargetsRenderObserver;
  9718. private _onAfterRenderTargetsRenderObserver;
  9719. private _onAfterRenderObserver;
  9720. private _onBeforeDrawPhaseObserver;
  9721. private _onAfterDrawPhaseObserver;
  9722. private _onBeforeAnimationsObserver;
  9723. private _onBeforeParticlesRenderingObserver;
  9724. private _onAfterParticlesRenderingObserver;
  9725. private _onBeforeSpritesRenderingObserver;
  9726. private _onAfterSpritesRenderingObserver;
  9727. private _onBeforePhysicsObserver;
  9728. private _onAfterPhysicsObserver;
  9729. private _onAfterAnimationsObserver;
  9730. /**
  9731. * Gets the perf counter used for active meshes evaluation time
  9732. */
  9733. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9734. /**
  9735. * Gets the active meshes evaluation time capture status
  9736. */
  9737. /**
  9738. * Enable or disable the active meshes evaluation time capture
  9739. */
  9740. captureActiveMeshesEvaluationTime: boolean;
  9741. /**
  9742. * Gets the perf counter used for render targets render time
  9743. */
  9744. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9745. /**
  9746. * Gets the render targets render time capture status
  9747. */
  9748. /**
  9749. * Enable or disable the render targets render time capture
  9750. */
  9751. captureRenderTargetsRenderTime: boolean;
  9752. /**
  9753. * Gets the perf counter used for particles render time
  9754. */
  9755. readonly particlesRenderTimeCounter: PerfCounter;
  9756. /**
  9757. * Gets the particles render time capture status
  9758. */
  9759. /**
  9760. * Enable or disable the particles render time capture
  9761. */
  9762. captureParticlesRenderTime: boolean;
  9763. /**
  9764. * Gets the perf counter used for sprites render time
  9765. */
  9766. readonly spritesRenderTimeCounter: PerfCounter;
  9767. /**
  9768. * Gets the sprites render time capture status
  9769. */
  9770. /**
  9771. * Enable or disable the sprites render time capture
  9772. */
  9773. captureSpritesRenderTime: boolean;
  9774. /**
  9775. * Gets the perf counter used for physics time
  9776. */
  9777. readonly physicsTimeCounter: PerfCounter;
  9778. /**
  9779. * Gets the physics time capture status
  9780. */
  9781. /**
  9782. * Enable or disable the physics time capture
  9783. */
  9784. capturePhysicsTime: boolean;
  9785. /**
  9786. * Gets the perf counter used for animations time
  9787. */
  9788. readonly animationsTimeCounter: PerfCounter;
  9789. /**
  9790. * Gets the animations time capture status
  9791. */
  9792. /**
  9793. * Enable or disable the animations time capture
  9794. */
  9795. captureAnimationsTime: boolean;
  9796. /**
  9797. * Gets the perf counter used for frame time capture
  9798. */
  9799. readonly frameTimeCounter: PerfCounter;
  9800. /**
  9801. * Gets the frame time capture status
  9802. */
  9803. /**
  9804. * Enable or disable the frame time capture
  9805. */
  9806. captureFrameTime: boolean;
  9807. /**
  9808. * Gets the perf counter used for inter-frames time capture
  9809. */
  9810. readonly interFrameTimeCounter: PerfCounter;
  9811. /**
  9812. * Gets the inter-frames time capture status
  9813. */
  9814. /**
  9815. * Enable or disable the inter-frames time capture
  9816. */
  9817. captureInterFrameTime: boolean;
  9818. /**
  9819. * Gets the perf counter used for render time capture
  9820. */
  9821. readonly renderTimeCounter: PerfCounter;
  9822. /**
  9823. * Gets the render time capture status
  9824. */
  9825. /**
  9826. * Enable or disable the render time capture
  9827. */
  9828. captureRenderTime: boolean;
  9829. /**
  9830. * Gets the perf counter used for draw calls
  9831. */
  9832. readonly drawCallsCounter: PerfCounter;
  9833. /**
  9834. * Gets the perf counter used for texture collisions
  9835. */
  9836. readonly textureCollisionsCounter: PerfCounter;
  9837. constructor(scene: Scene);
  9838. dispose(): void;
  9839. }
  9840. }
  9841. declare module BABYLON {
  9842. /**
  9843. * @hidden
  9844. **/
  9845. class _TimeToken {
  9846. _startTimeQuery: Nullable<WebGLQuery>;
  9847. _endTimeQuery: Nullable<WebGLQuery>;
  9848. _timeElapsedQuery: Nullable<WebGLQuery>;
  9849. _timeElapsedQueryEnded: boolean;
  9850. }
  9851. }
  9852. declare module BABYLON {
  9853. /**
  9854. * Effect layer options. This helps customizing the behaviour
  9855. * of the effect layer.
  9856. */
  9857. interface IEffectLayerOptions {
  9858. /**
  9859. * Multiplication factor apply to the canvas size to compute the render target size
  9860. * used to generated the objects (the smaller the faster).
  9861. */
  9862. mainTextureRatio: number;
  9863. /**
  9864. * Enforces a fixed size texture to ensure effect stability across devices.
  9865. */
  9866. mainTextureFixedSize?: number;
  9867. /**
  9868. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  9869. */
  9870. alphaBlendingMode: number;
  9871. /**
  9872. * The camera attached to the layer.
  9873. */
  9874. camera: Nullable<Camera>;
  9875. }
  9876. /**
  9877. * The effect layer Helps adding post process effect blended with the main pass.
  9878. *
  9879. * This can be for instance use to generate glow or higlight effects on the scene.
  9880. *
  9881. * The effect layer class can not be used directly and is intented to inherited from to be
  9882. * customized per effects.
  9883. */
  9884. abstract class EffectLayer {
  9885. private _vertexBuffers;
  9886. private _indexBuffer;
  9887. private _cachedDefines;
  9888. private _effectLayerMapGenerationEffect;
  9889. private _effectLayerOptions;
  9890. private _mergeEffect;
  9891. protected _scene: Scene;
  9892. protected _engine: Engine;
  9893. protected _maxSize: number;
  9894. protected _mainTextureDesiredSize: ISize;
  9895. protected _mainTexture: RenderTargetTexture;
  9896. protected _shouldRender: boolean;
  9897. protected _postProcesses: PostProcess[];
  9898. protected _textures: BaseTexture[];
  9899. protected _emissiveTextureAndColor: {
  9900. texture: Nullable<BaseTexture>;
  9901. color: Color4;
  9902. };
  9903. /**
  9904. * The name of the layer
  9905. */
  9906. name: string;
  9907. /**
  9908. * The clear color of the texture used to generate the glow map.
  9909. */
  9910. neutralColor: Color4;
  9911. /**
  9912. * Specifies wether the highlight layer is enabled or not.
  9913. */
  9914. isEnabled: boolean;
  9915. /**
  9916. * Gets the camera attached to the layer.
  9917. */
  9918. readonly camera: Nullable<Camera>;
  9919. /**
  9920. * An event triggered when the effect layer has been disposed.
  9921. */
  9922. onDisposeObservable: Observable<EffectLayer>;
  9923. /**
  9924. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  9925. */
  9926. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  9927. /**
  9928. * An event triggered when the generated texture is being merged in the scene.
  9929. */
  9930. onBeforeComposeObservable: Observable<EffectLayer>;
  9931. /**
  9932. * An event triggered when the generated texture has been merged in the scene.
  9933. */
  9934. onAfterComposeObservable: Observable<EffectLayer>;
  9935. /**
  9936. * An event triggered when the efffect layer changes its size.
  9937. */
  9938. onSizeChangedObservable: Observable<EffectLayer>;
  9939. /**
  9940. * Instantiates a new effect Layer and references it in the scene.
  9941. * @param name The name of the layer
  9942. * @param scene The scene to use the layer in
  9943. */
  9944. constructor(
  9945. /** The Friendly of the effect in the scene */
  9946. name: string, scene: Scene);
  9947. /**
  9948. * Get the effect name of the layer.
  9949. * @return The effect name
  9950. */
  9951. abstract getEffectName(): string;
  9952. /**
  9953. * Checks for the readiness of the element composing the layer.
  9954. * @param subMesh the mesh to check for
  9955. * @param useInstances specify wether or not to use instances to render the mesh
  9956. * @return true if ready otherwise, false
  9957. */
  9958. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9959. /**
  9960. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9961. * @returns true if the effect requires stencil during the main canvas render pass.
  9962. */
  9963. abstract needStencil(): boolean;
  9964. /**
  9965. * Create the merge effect. This is the shader use to blit the information back
  9966. * to the main canvas at the end of the scene rendering.
  9967. * @returns The effect containing the shader used to merge the effect on the main canvas
  9968. */
  9969. protected abstract _createMergeEffect(): Effect;
  9970. /**
  9971. * Creates the render target textures and post processes used in the effect layer.
  9972. */
  9973. protected abstract _createTextureAndPostProcesses(): void;
  9974. /**
  9975. * Implementation specific of rendering the generating effect on the main canvas.
  9976. * @param effect The effect used to render through
  9977. */
  9978. protected abstract _internalRender(effect: Effect): void;
  9979. /**
  9980. * Sets the required values for both the emissive texture and and the main color.
  9981. */
  9982. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9983. /**
  9984. * Free any resources and references associated to a mesh.
  9985. * Internal use
  9986. * @param mesh The mesh to free.
  9987. */
  9988. abstract _disposeMesh(mesh: Mesh): void;
  9989. /**
  9990. * Serializes this layer (Glow or Highlight for example)
  9991. * @returns a serialized layer object
  9992. */
  9993. abstract serialize?(): any;
  9994. /**
  9995. * Initializes the effect layer with the required options.
  9996. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  9997. */
  9998. protected _init(options: Partial<IEffectLayerOptions>): void;
  9999. /**
  10000. * Generates the index buffer of the full screen quad blending to the main canvas.
  10001. */
  10002. private _generateIndexBuffer();
  10003. /**
  10004. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10005. */
  10006. private _genrateVertexBuffer();
  10007. /**
  10008. * Sets the main texture desired size which is the closest power of two
  10009. * of the engine canvas size.
  10010. */
  10011. private _setMainTextureSize();
  10012. /**
  10013. * Creates the main texture for the effect layer.
  10014. */
  10015. protected _createMainTexture(): void;
  10016. /**
  10017. * Checks for the readiness of the element composing the layer.
  10018. * @param subMesh the mesh to check for
  10019. * @param useInstances specify wether or not to use instances to render the mesh
  10020. * @param emissiveTexture the associated emissive texture used to generate the glow
  10021. * @return true if ready otherwise, false
  10022. */
  10023. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10024. /**
  10025. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10026. */
  10027. render(): void;
  10028. /**
  10029. * Determine if a given mesh will be used in the current effect.
  10030. * @param mesh mesh to test
  10031. * @returns true if the mesh will be used
  10032. */
  10033. hasMesh(mesh: AbstractMesh): boolean;
  10034. /**
  10035. * Returns true if the layer contains information to display, otherwise false.
  10036. * @returns true if the glow layer should be rendered
  10037. */
  10038. shouldRender(): boolean;
  10039. /**
  10040. * Returns true if the mesh should render, otherwise false.
  10041. * @param mesh The mesh to render
  10042. * @returns true if it should render otherwise false
  10043. */
  10044. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10045. /**
  10046. * Returns true if the mesh should render, otherwise false.
  10047. * @param mesh The mesh to render
  10048. * @returns true if it should render otherwise false
  10049. */
  10050. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10051. /**
  10052. * Renders the submesh passed in parameter to the generation map.
  10053. */
  10054. protected _renderSubMesh(subMesh: SubMesh): void;
  10055. /**
  10056. * Rebuild the required buffers.
  10057. * @hidden Internal use only.
  10058. */
  10059. _rebuild(): void;
  10060. /**
  10061. * Dispose only the render target textures and post process.
  10062. */
  10063. private _disposeTextureAndPostProcesses();
  10064. /**
  10065. * Dispose the highlight layer and free resources.
  10066. */
  10067. dispose(): void;
  10068. /**
  10069. * Gets the class name of the effect layer
  10070. * @returns the string with the class name of the effect layer
  10071. */
  10072. getClassName(): string;
  10073. /**
  10074. * Creates an effect layer from parsed effect layer data
  10075. * @param parsedEffectLayer defines effect layer data
  10076. * @param scene defines the current scene
  10077. * @param rootUrl defines the root URL containing the effect layer information
  10078. * @returns a parsed effect Layer
  10079. */
  10080. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10081. }
  10082. }
  10083. declare module BABYLON {
  10084. /**
  10085. * Glow layer options. This helps customizing the behaviour
  10086. * of the glow layer.
  10087. */
  10088. interface IGlowLayerOptions {
  10089. /**
  10090. * Multiplication factor apply to the canvas size to compute the render target size
  10091. * used to generated the glowing objects (the smaller the faster).
  10092. */
  10093. mainTextureRatio: number;
  10094. /**
  10095. * Enforces a fixed size texture to ensure resize independant blur.
  10096. */
  10097. mainTextureFixedSize?: number;
  10098. /**
  10099. * How big is the kernel of the blur texture.
  10100. */
  10101. blurKernelSize: number;
  10102. /**
  10103. * The camera attached to the layer.
  10104. */
  10105. camera: Nullable<Camera>;
  10106. /**
  10107. * Enable MSAA by chosing the number of samples.
  10108. */
  10109. mainTextureSamples?: number;
  10110. }
  10111. /**
  10112. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10113. *
  10114. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10115. * glowy meshes to your scene.
  10116. *
  10117. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10118. */
  10119. class GlowLayer extends EffectLayer {
  10120. /**
  10121. * Effect Name of the layer.
  10122. */
  10123. static readonly EffectName: string;
  10124. /**
  10125. * The default blur kernel size used for the glow.
  10126. */
  10127. static DefaultBlurKernelSize: number;
  10128. /**
  10129. * The default texture size ratio used for the glow.
  10130. */
  10131. static DefaultTextureRatio: number;
  10132. /**
  10133. * Gets the kernel size of the blur.
  10134. */
  10135. /**
  10136. * Sets the kernel size of the blur.
  10137. */
  10138. blurKernelSize: number;
  10139. /**
  10140. * Gets the glow intensity.
  10141. */
  10142. /**
  10143. * Sets the glow intensity.
  10144. */
  10145. intensity: number;
  10146. private _options;
  10147. private _intensity;
  10148. private _horizontalBlurPostprocess1;
  10149. private _verticalBlurPostprocess1;
  10150. private _horizontalBlurPostprocess2;
  10151. private _verticalBlurPostprocess2;
  10152. private _blurTexture1;
  10153. private _blurTexture2;
  10154. private _postProcesses1;
  10155. private _postProcesses2;
  10156. private _includedOnlyMeshes;
  10157. private _excludedMeshes;
  10158. /**
  10159. * Callback used to let the user override the color selection on a per mesh basis
  10160. */
  10161. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10162. /**
  10163. * Callback used to let the user override the texture selection on a per mesh basis
  10164. */
  10165. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10166. /**
  10167. * Instantiates a new glow Layer and references it to the scene.
  10168. * @param name The name of the layer
  10169. * @param scene The scene to use the layer in
  10170. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10171. */
  10172. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10173. /**
  10174. * Get the effect name of the layer.
  10175. * @return The effect name
  10176. */
  10177. getEffectName(): string;
  10178. /**
  10179. * Create the merge effect. This is the shader use to blit the information back
  10180. * to the main canvas at the end of the scene rendering.
  10181. */
  10182. protected _createMergeEffect(): Effect;
  10183. /**
  10184. * Creates the render target textures and post processes used in the glow layer.
  10185. */
  10186. protected _createTextureAndPostProcesses(): void;
  10187. /**
  10188. * Checks for the readiness of the element composing the layer.
  10189. * @param subMesh the mesh to check for
  10190. * @param useInstances specify wether or not to use instances to render the mesh
  10191. * @param emissiveTexture the associated emissive texture used to generate the glow
  10192. * @return true if ready otherwise, false
  10193. */
  10194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10195. /**
  10196. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10197. */
  10198. needStencil(): boolean;
  10199. /**
  10200. * Implementation specific of rendering the generating effect on the main canvas.
  10201. * @param effect The effect used to render through
  10202. */
  10203. protected _internalRender(effect: Effect): void;
  10204. /**
  10205. * Sets the required values for both the emissive texture and and the main color.
  10206. */
  10207. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10208. /**
  10209. * Returns true if the mesh should render, otherwise false.
  10210. * @param mesh The mesh to render
  10211. * @returns true if it should render otherwise false
  10212. */
  10213. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10214. /**
  10215. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10216. * @param mesh The mesh to exclude from the glow layer
  10217. */
  10218. addExcludedMesh(mesh: Mesh): void;
  10219. /**
  10220. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10221. * @param mesh The mesh to remove
  10222. */
  10223. removeExcludedMesh(mesh: Mesh): void;
  10224. /**
  10225. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10226. * @param mesh The mesh to include in the glow layer
  10227. */
  10228. addIncludedOnlyMesh(mesh: Mesh): void;
  10229. /**
  10230. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10231. * @param mesh The mesh to remove
  10232. */
  10233. removeIncludedOnlyMesh(mesh: Mesh): void;
  10234. /**
  10235. * Determine if a given mesh will be used in the glow layer
  10236. * @param mesh The mesh to test
  10237. * @returns true if the mesh will be highlighted by the current glow layer
  10238. */
  10239. hasMesh(mesh: AbstractMesh): boolean;
  10240. /**
  10241. * Free any resources and references associated to a mesh.
  10242. * Internal use
  10243. * @param mesh The mesh to free.
  10244. */
  10245. _disposeMesh(mesh: Mesh): void;
  10246. /**
  10247. * Gets the class name of the effect layer
  10248. * @returns the string with the class name of the effect layer
  10249. */
  10250. getClassName(): string;
  10251. /**
  10252. * Serializes this glow layer
  10253. * @returns a serialized glow layer object
  10254. */
  10255. serialize(): any;
  10256. /**
  10257. * Creates a Glow Layer from parsed glow layer data
  10258. * @param parsedGlowLayer defines glow layer data
  10259. * @param scene defines the current scene
  10260. * @param rootUrl defines the root URL containing the glow layer information
  10261. * @returns a parsed Glow Layer
  10262. */
  10263. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10264. }
  10265. }
  10266. declare module BABYLON {
  10267. /**
  10268. * Highlight layer options. This helps customizing the behaviour
  10269. * of the highlight layer.
  10270. */
  10271. interface IHighlightLayerOptions {
  10272. /**
  10273. * Multiplication factor apply to the canvas size to compute the render target size
  10274. * used to generated the glowing objects (the smaller the faster).
  10275. */
  10276. mainTextureRatio: number;
  10277. /**
  10278. * Enforces a fixed size texture to ensure resize independant blur.
  10279. */
  10280. mainTextureFixedSize?: number;
  10281. /**
  10282. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10283. * of the picture to blur (the smaller the faster).
  10284. */
  10285. blurTextureSizeRatio: number;
  10286. /**
  10287. * How big in texel of the blur texture is the vertical blur.
  10288. */
  10289. blurVerticalSize: number;
  10290. /**
  10291. * How big in texel of the blur texture is the horizontal blur.
  10292. */
  10293. blurHorizontalSize: number;
  10294. /**
  10295. * Alpha blending mode used to apply the blur. Default is combine.
  10296. */
  10297. alphaBlendingMode: number;
  10298. /**
  10299. * The camera attached to the layer.
  10300. */
  10301. camera: Nullable<Camera>;
  10302. /**
  10303. * Should we display highlight as a solid stroke?
  10304. */
  10305. isStroke?: boolean;
  10306. }
  10307. /**
  10308. * The highlight layer Helps adding a glow effect around a mesh.
  10309. *
  10310. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10311. * glowy meshes to your scene.
  10312. *
  10313. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10314. */
  10315. class HighlightLayer extends EffectLayer {
  10316. name: string;
  10317. /**
  10318. * Effect Name of the highlight layer.
  10319. */
  10320. static readonly EffectName: string;
  10321. /**
  10322. * The neutral color used during the preparation of the glow effect.
  10323. * This is black by default as the blend operation is a blend operation.
  10324. */
  10325. static NeutralColor: Color4;
  10326. /**
  10327. * Stencil value used for glowing meshes.
  10328. */
  10329. static GlowingMeshStencilReference: number;
  10330. /**
  10331. * Stencil value used for the other meshes in the scene.
  10332. */
  10333. static NormalMeshStencilReference: number;
  10334. /**
  10335. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10336. */
  10337. innerGlow: boolean;
  10338. /**
  10339. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10340. */
  10341. outerGlow: boolean;
  10342. /**
  10343. * Gets the horizontal size of the blur.
  10344. */
  10345. /**
  10346. * Specifies the horizontal size of the blur.
  10347. */
  10348. blurHorizontalSize: number;
  10349. /**
  10350. * Gets the vertical size of the blur.
  10351. */
  10352. /**
  10353. * Specifies the vertical size of the blur.
  10354. */
  10355. blurVerticalSize: number;
  10356. /**
  10357. * An event triggered when the highlight layer is being blurred.
  10358. */
  10359. onBeforeBlurObservable: Observable<HighlightLayer>;
  10360. /**
  10361. * An event triggered when the highlight layer has been blurred.
  10362. */
  10363. onAfterBlurObservable: Observable<HighlightLayer>;
  10364. private _instanceGlowingMeshStencilReference;
  10365. private _options;
  10366. private _downSamplePostprocess;
  10367. private _horizontalBlurPostprocess;
  10368. private _verticalBlurPostprocess;
  10369. private _blurTexture;
  10370. private _meshes;
  10371. private _excludedMeshes;
  10372. /**
  10373. * Instantiates a new highlight Layer and references it to the scene..
  10374. * @param name The name of the layer
  10375. * @param scene The scene to use the layer in
  10376. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10377. */
  10378. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10379. /**
  10380. * Get the effect name of the layer.
  10381. * @return The effect name
  10382. */
  10383. getEffectName(): string;
  10384. /**
  10385. * Create the merge effect. This is the shader use to blit the information back
  10386. * to the main canvas at the end of the scene rendering.
  10387. */
  10388. protected _createMergeEffect(): Effect;
  10389. /**
  10390. * Creates the render target textures and post processes used in the highlight layer.
  10391. */
  10392. protected _createTextureAndPostProcesses(): void;
  10393. /**
  10394. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10395. */
  10396. needStencil(): boolean;
  10397. /**
  10398. * Checks for the readiness of the element composing the layer.
  10399. * @param subMesh the mesh to check for
  10400. * @param useInstances specify wether or not to use instances to render the mesh
  10401. * @param emissiveTexture the associated emissive texture used to generate the glow
  10402. * @return true if ready otherwise, false
  10403. */
  10404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10405. /**
  10406. * Implementation specific of rendering the generating effect on the main canvas.
  10407. * @param effect The effect used to render through
  10408. */
  10409. protected _internalRender(effect: Effect): void;
  10410. /**
  10411. * Returns true if the layer contains information to display, otherwise false.
  10412. */
  10413. shouldRender(): boolean;
  10414. /**
  10415. * Returns true if the mesh should render, otherwise false.
  10416. * @param mesh The mesh to render
  10417. * @returns true if it should render otherwise false
  10418. */
  10419. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10420. /**
  10421. * Sets the required values for both the emissive texture and and the main color.
  10422. */
  10423. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10424. /**
  10425. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10426. * @param mesh The mesh to exclude from the highlight layer
  10427. */
  10428. addExcludedMesh(mesh: Mesh): void;
  10429. /**
  10430. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10431. * @param mesh The mesh to highlight
  10432. */
  10433. removeExcludedMesh(mesh: Mesh): void;
  10434. /**
  10435. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10436. * @param mesh mesh to test
  10437. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10438. */
  10439. hasMesh(mesh: AbstractMesh): boolean;
  10440. /**
  10441. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10442. * @param mesh The mesh to highlight
  10443. * @param color The color of the highlight
  10444. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10445. */
  10446. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10447. /**
  10448. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10449. * @param mesh The mesh to highlight
  10450. */
  10451. removeMesh(mesh: Mesh): void;
  10452. /**
  10453. * Force the stencil to the normal expected value for none glowing parts
  10454. */
  10455. private _defaultStencilReference(mesh);
  10456. /**
  10457. * Free any resources and references associated to a mesh.
  10458. * Internal use
  10459. * @param mesh The mesh to free.
  10460. */
  10461. _disposeMesh(mesh: Mesh): void;
  10462. /**
  10463. * Dispose the highlight layer and free resources.
  10464. */
  10465. dispose(): void;
  10466. /**
  10467. * Gets the class name of the effect layer
  10468. * @returns the string with the class name of the effect layer
  10469. */
  10470. getClassName(): string;
  10471. /**
  10472. * Serializes this Highlight layer
  10473. * @returns a serialized Highlight layer object
  10474. */
  10475. serialize(): any;
  10476. /**
  10477. * Creates a Highlight layer from parsed Highlight layer data
  10478. * @param parsedHightlightLayer defines the Highlight layer data
  10479. * @param scene defines the current scene
  10480. * @param rootUrl defines the root URL containing the Highlight layer information
  10481. * @returns a parsed Highlight layer
  10482. */
  10483. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10484. }
  10485. }
  10486. declare module BABYLON {
  10487. class Layer {
  10488. name: string;
  10489. texture: Nullable<Texture>;
  10490. isBackground: boolean;
  10491. color: Color4;
  10492. scale: Vector2;
  10493. offset: Vector2;
  10494. alphaBlendingMode: number;
  10495. alphaTest: boolean;
  10496. layerMask: number;
  10497. private _scene;
  10498. private _vertexBuffers;
  10499. private _indexBuffer;
  10500. private _effect;
  10501. private _alphaTestEffect;
  10502. /**
  10503. * An event triggered when the layer is disposed.
  10504. */
  10505. onDisposeObservable: Observable<Layer>;
  10506. private _onDisposeObserver;
  10507. onDispose: () => void;
  10508. /**
  10509. * An event triggered before rendering the scene
  10510. */
  10511. onBeforeRenderObservable: Observable<Layer>;
  10512. private _onBeforeRenderObserver;
  10513. onBeforeRender: () => void;
  10514. /**
  10515. * An event triggered after rendering the scene
  10516. */
  10517. onAfterRenderObservable: Observable<Layer>;
  10518. private _onAfterRenderObserver;
  10519. onAfterRender: () => void;
  10520. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10521. private _createIndexBuffer();
  10522. _rebuild(): void;
  10523. render(): void;
  10524. dispose(): void;
  10525. }
  10526. }
  10527. declare module BABYLON {
  10528. class LensFlare {
  10529. size: number;
  10530. position: number;
  10531. color: Color3;
  10532. texture: Nullable<Texture>;
  10533. alphaMode: number;
  10534. private _system;
  10535. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10536. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10537. dispose(): void;
  10538. }
  10539. }
  10540. declare module BABYLON {
  10541. class LensFlareSystem {
  10542. name: string;
  10543. lensFlares: LensFlare[];
  10544. borderLimit: number;
  10545. viewportBorder: number;
  10546. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10547. layerMask: number;
  10548. id: string;
  10549. private _scene;
  10550. private _emitter;
  10551. private _vertexBuffers;
  10552. private _indexBuffer;
  10553. private _effect;
  10554. private _positionX;
  10555. private _positionY;
  10556. private _isEnabled;
  10557. constructor(name: string, emitter: any, scene: Scene);
  10558. isEnabled: boolean;
  10559. getScene(): Scene;
  10560. getEmitter(): any;
  10561. setEmitter(newEmitter: any): void;
  10562. getEmitterPosition(): Vector3;
  10563. computeEffectivePosition(globalViewport: Viewport): boolean;
  10564. _isVisible(): boolean;
  10565. render(): boolean;
  10566. dispose(): void;
  10567. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10568. serialize(): any;
  10569. }
  10570. }
  10571. declare module BABYLON {
  10572. /**
  10573. * A directional light is defined by a direction (what a surprise!).
  10574. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10575. * 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.
  10576. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10577. */
  10578. class DirectionalLight extends ShadowLight {
  10579. private _shadowFrustumSize;
  10580. /**
  10581. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10582. */
  10583. /**
  10584. * Specifies a fix frustum size for the shadow generation.
  10585. */
  10586. shadowFrustumSize: number;
  10587. private _shadowOrthoScale;
  10588. /**
  10589. * Gets the shadow projection scale against the optimal computed one.
  10590. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10591. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10592. */
  10593. /**
  10594. * Sets the shadow projection scale against the optimal computed one.
  10595. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10596. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10597. */
  10598. shadowOrthoScale: number;
  10599. /**
  10600. * Automatically compute the projection matrix to best fit (including all the casters)
  10601. * on each frame.
  10602. */
  10603. autoUpdateExtends: boolean;
  10604. private _orthoLeft;
  10605. private _orthoRight;
  10606. private _orthoTop;
  10607. private _orthoBottom;
  10608. /**
  10609. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10610. * The directional light is emitted from everywhere in the given direction.
  10611. * It can cast shawdows.
  10612. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10613. * @param name The friendly name of the light
  10614. * @param direction The direction of the light
  10615. * @param scene The scene the light belongs to
  10616. */
  10617. constructor(name: string, direction: Vector3, scene: Scene);
  10618. /**
  10619. * Returns the string "DirectionalLight".
  10620. * @return The class name
  10621. */
  10622. getClassName(): string;
  10623. /**
  10624. * Returns the integer 1.
  10625. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10626. */
  10627. getTypeID(): number;
  10628. /**
  10629. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10630. * Returns the DirectionalLight Shadow projection matrix.
  10631. */
  10632. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10633. /**
  10634. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10635. * Returns the DirectionalLight Shadow projection matrix.
  10636. */
  10637. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10638. /**
  10639. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10640. * Returns the DirectionalLight Shadow projection matrix.
  10641. */
  10642. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10643. protected _buildUniformLayout(): void;
  10644. /**
  10645. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10646. * @param effect The effect to update
  10647. * @param lightIndex The index of the light in the effect to update
  10648. * @returns The directional light
  10649. */
  10650. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10651. /**
  10652. * Gets the minZ used for shadow according to both the scene and the light.
  10653. *
  10654. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10655. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10656. * @param activeCamera The camera we are returning the min for
  10657. * @returns the depth min z
  10658. */
  10659. getDepthMinZ(activeCamera: Camera): number;
  10660. /**
  10661. * Gets the maxZ used for shadow according to both the scene and the light.
  10662. *
  10663. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10664. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10665. * @param activeCamera The camera we are returning the max for
  10666. * @returns the depth max z
  10667. */
  10668. getDepthMaxZ(activeCamera: Camera): number;
  10669. }
  10670. }
  10671. declare module BABYLON {
  10672. /**
  10673. * The HemisphericLight simulates the ambient environment light,
  10674. * so the passed direction is the light reflection direction, not the incoming direction.
  10675. */
  10676. class HemisphericLight extends Light {
  10677. /**
  10678. * The groundColor is the light in the opposite direction to the one specified during creation.
  10679. * 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.
  10680. */
  10681. groundColor: Color3;
  10682. /**
  10683. * The light reflection direction, not the incoming direction.
  10684. */
  10685. direction: Vector3;
  10686. private _worldMatrix;
  10687. /**
  10688. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10689. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10690. * The HemisphericLight can't cast shadows.
  10691. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10692. * @param name The friendly name of the light
  10693. * @param direction The direction of the light reflection
  10694. * @param scene The scene the light belongs to
  10695. */
  10696. constructor(name: string, direction: Vector3, scene: Scene);
  10697. protected _buildUniformLayout(): void;
  10698. /**
  10699. * Returns the string "HemisphericLight".
  10700. * @return The class name
  10701. */
  10702. getClassName(): string;
  10703. /**
  10704. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10705. * Returns the updated direction.
  10706. * @param target The target the direction should point to
  10707. * @return The computed direction
  10708. */
  10709. setDirectionToTarget(target: Vector3): Vector3;
  10710. /**
  10711. * Returns the shadow generator associated to the light.
  10712. * @returns Always null for hemispheric lights because it does not support shadows.
  10713. */
  10714. getShadowGenerator(): Nullable<ShadowGenerator>;
  10715. /**
  10716. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10717. * @param effect The effect to update
  10718. * @param lightIndex The index of the light in the effect to update
  10719. * @returns The hemispheric light
  10720. */
  10721. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10722. /**
  10723. * @hidden internal use only.
  10724. */
  10725. _getWorldMatrix(): Matrix;
  10726. /**
  10727. * Returns the integer 3.
  10728. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10729. */
  10730. getTypeID(): number;
  10731. }
  10732. }
  10733. declare module BABYLON {
  10734. /**
  10735. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10736. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10737. * 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.
  10738. */
  10739. abstract class Light extends Node {
  10740. private static _LIGHTMAP_DEFAULT;
  10741. private static _LIGHTMAP_SPECULAR;
  10742. private static _LIGHTMAP_SHADOWSONLY;
  10743. /**
  10744. * If every light affecting the material is in this lightmapMode,
  10745. * material.lightmapTexture adds or multiplies
  10746. * (depends on material.useLightmapAsShadowmap)
  10747. * after every other light calculations.
  10748. */
  10749. static readonly LIGHTMAP_DEFAULT: number;
  10750. /**
  10751. * material.lightmapTexture as only diffuse lighting from this light
  10752. * adds only specular lighting from this light
  10753. * adds dynamic shadows
  10754. */
  10755. static readonly LIGHTMAP_SPECULAR: number;
  10756. /**
  10757. * material.lightmapTexture as only lighting
  10758. * no light calculation from this light
  10759. * only adds dynamic shadows from this light
  10760. */
  10761. static readonly LIGHTMAP_SHADOWSONLY: number;
  10762. private static _INTENSITYMODE_AUTOMATIC;
  10763. private static _INTENSITYMODE_LUMINOUSPOWER;
  10764. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  10765. private static _INTENSITYMODE_ILLUMINANCE;
  10766. private static _INTENSITYMODE_LUMINANCE;
  10767. /**
  10768. * Each light type uses the default quantity according to its type:
  10769. * point/spot lights use luminous intensity
  10770. * directional lights use illuminance
  10771. */
  10772. static readonly INTENSITYMODE_AUTOMATIC: number;
  10773. /**
  10774. * lumen (lm)
  10775. */
  10776. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10777. /**
  10778. * candela (lm/sr)
  10779. */
  10780. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10781. /**
  10782. * lux (lm/m^2)
  10783. */
  10784. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10785. /**
  10786. * nit (cd/m^2)
  10787. */
  10788. static readonly INTENSITYMODE_LUMINANCE: number;
  10789. private static _LIGHTTYPEID_POINTLIGHT;
  10790. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  10791. private static _LIGHTTYPEID_SPOTLIGHT;
  10792. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  10793. /**
  10794. * Light type const id of the point light.
  10795. */
  10796. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10797. /**
  10798. * Light type const id of the directional light.
  10799. */
  10800. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10801. /**
  10802. * Light type const id of the spot light.
  10803. */
  10804. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10805. /**
  10806. * Light type const id of the hemispheric light.
  10807. */
  10808. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10809. /**
  10810. * Diffuse gives the basic color to an object.
  10811. */
  10812. diffuse: Color3;
  10813. /**
  10814. * Specular produces a highlight color on an object.
  10815. * Note: This is note affecting PBR materials.
  10816. */
  10817. specular: Color3;
  10818. /**
  10819. * Strength of the light.
  10820. * Note: By default it is define in the framework own unit.
  10821. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10822. */
  10823. intensity: number;
  10824. /**
  10825. * Defines how far from the source the light is impacting in scene units.
  10826. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10827. */
  10828. range: number;
  10829. /**
  10830. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10831. * of light.
  10832. */
  10833. private _photometricScale;
  10834. private _intensityMode;
  10835. /**
  10836. * Gets the photometric scale used to interpret the intensity.
  10837. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10838. */
  10839. /**
  10840. * Sets 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. intensityMode: number;
  10844. private _radius;
  10845. /**
  10846. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10847. */
  10848. /**
  10849. * sets the light radius used by PBR Materials to simulate soft area lights.
  10850. */
  10851. radius: number;
  10852. private _renderPriority;
  10853. /**
  10854. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10855. * exceeding the number allowed of the materials.
  10856. */
  10857. renderPriority: number;
  10858. /**
  10859. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10860. * the current shadow generator.
  10861. */
  10862. shadowEnabled: boolean;
  10863. private _includedOnlyMeshes;
  10864. /**
  10865. * Gets the only meshes impacted by this light.
  10866. */
  10867. /**
  10868. * Sets the only meshes impacted by this light.
  10869. */
  10870. includedOnlyMeshes: AbstractMesh[];
  10871. private _excludedMeshes;
  10872. /**
  10873. * Gets the meshes not impacted by this light.
  10874. */
  10875. /**
  10876. * Sets the meshes not impacted by this light.
  10877. */
  10878. excludedMeshes: AbstractMesh[];
  10879. private _excludeWithLayerMask;
  10880. /**
  10881. * Gets the layer id use to find what meshes are not impacted by the light.
  10882. * Inactive if 0
  10883. */
  10884. /**
  10885. * Sets the layer id use to find what meshes are not impacted by the light.
  10886. * Inactive if 0
  10887. */
  10888. excludeWithLayerMask: number;
  10889. private _includeOnlyWithLayerMask;
  10890. /**
  10891. * Gets the layer id use to find what meshes are impacted by the light.
  10892. * Inactive if 0
  10893. */
  10894. /**
  10895. * Sets the layer id use to find what meshes are impacted by the light.
  10896. * Inactive if 0
  10897. */
  10898. includeOnlyWithLayerMask: number;
  10899. private _lightmapMode;
  10900. /**
  10901. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10902. */
  10903. /**
  10904. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10905. */
  10906. lightmapMode: number;
  10907. private _parentedWorldMatrix;
  10908. /**
  10909. * Shadow generator associted to the light.
  10910. * Internal use only.
  10911. */
  10912. _shadowGenerator: Nullable<IShadowGenerator>;
  10913. /**
  10914. * @hidden Internal use only.
  10915. */
  10916. _excludedMeshesIds: string[];
  10917. /**
  10918. * @hidden Internal use only.
  10919. */
  10920. _includedOnlyMeshesIds: string[];
  10921. /**
  10922. * The current light unifom buffer.
  10923. * @hidden Internal use only.
  10924. */
  10925. _uniformBuffer: UniformBuffer;
  10926. /**
  10927. * Creates a Light object in the scene.
  10928. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10929. * @param name The firendly name of the light
  10930. * @param scene The scene the light belongs too
  10931. */
  10932. constructor(name: string, scene: Scene);
  10933. protected abstract _buildUniformLayout(): void;
  10934. /**
  10935. * Sets the passed Effect "effect" with the Light information.
  10936. * @param effect The effect to update
  10937. * @param lightIndex The index of the light in the effect to update
  10938. * @returns The light
  10939. */
  10940. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10941. /**
  10942. * @hidden internal use only.
  10943. */
  10944. abstract _getWorldMatrix(): Matrix;
  10945. /**
  10946. * Returns the string "Light".
  10947. * @returns the class name
  10948. */
  10949. getClassName(): string;
  10950. /**
  10951. * Converts the light information to a readable string for debug purpose.
  10952. * @param fullDetails Supports for multiple levels of logging within scene loading
  10953. * @returns the human readable light info
  10954. */
  10955. toString(fullDetails?: boolean): string;
  10956. /**
  10957. * Set the enabled state of this node.
  10958. * @param value - the new enabled state
  10959. */
  10960. setEnabled(value: boolean): void;
  10961. /**
  10962. * Returns the Light associated shadow generator if any.
  10963. * @return the associated shadow generator.
  10964. */
  10965. getShadowGenerator(): Nullable<IShadowGenerator>;
  10966. /**
  10967. * Returns a Vector3, the absolute light position in the World.
  10968. * @returns the world space position of the light
  10969. */
  10970. getAbsolutePosition(): Vector3;
  10971. /**
  10972. * Specifies if the light will affect the passed mesh.
  10973. * @param mesh The mesh to test against the light
  10974. * @return true the mesh is affected otherwise, false.
  10975. */
  10976. canAffectMesh(mesh: AbstractMesh): boolean;
  10977. /**
  10978. * Computes and Returns the light World matrix.
  10979. * @returns the world matrix
  10980. */
  10981. getWorldMatrix(): Matrix;
  10982. /**
  10983. * Sort function to order lights for rendering.
  10984. * @param a First Light object to compare to second.
  10985. * @param b Second Light object to compare first.
  10986. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10987. */
  10988. static CompareLightsPriority(a: Light, b: Light): number;
  10989. /**
  10990. * Releases resources associated with this node.
  10991. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10992. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10993. */
  10994. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10995. /**
  10996. * Returns the light type ID (integer).
  10997. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10998. */
  10999. getTypeID(): number;
  11000. /**
  11001. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11002. * @returns the scaled intensity in intensity mode unit
  11003. */
  11004. getScaledIntensity(): number;
  11005. /**
  11006. * Returns a new Light object, named "name", from the current one.
  11007. * @param name The name of the cloned light
  11008. * @returns the new created light
  11009. */
  11010. clone(name: string): Nullable<Light>;
  11011. /**
  11012. * Serializes the current light into a Serialization object.
  11013. * @returns the serialized object.
  11014. */
  11015. serialize(): any;
  11016. /**
  11017. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11018. * This new light is named "name" and added to the passed scene.
  11019. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11020. * @param name The friendly name of the light
  11021. * @param scene The scene the new light will belong to
  11022. * @returns the constructor function
  11023. */
  11024. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11025. /**
  11026. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11027. * @param parsedLight The JSON representation of the light
  11028. * @param scene The scene to create the parsed light in
  11029. * @returns the created light after parsing
  11030. */
  11031. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11032. private _hookArrayForExcluded(array);
  11033. private _hookArrayForIncludedOnly(array);
  11034. private _resyncMeshes();
  11035. /**
  11036. * Forces the meshes to update their light related information in their rendering used effects
  11037. * @hidden Internal Use Only
  11038. */
  11039. _markMeshesAsLightDirty(): void;
  11040. /**
  11041. * Recomputes the cached photometric scale if needed.
  11042. */
  11043. private _computePhotometricScale();
  11044. /**
  11045. * Returns the Photometric Scale according to the light type and intensity mode.
  11046. */
  11047. private _getPhotometricScale();
  11048. /**
  11049. * Reorder the light in the scene according to their defined priority.
  11050. * @hidden Internal Use Only
  11051. */
  11052. _reorderLightsInScene(): void;
  11053. }
  11054. }
  11055. declare module BABYLON {
  11056. /**
  11057. * A point light is a light defined by an unique point in world space.
  11058. * The light is emitted in every direction from this point.
  11059. * A good example of a point light is a standard light bulb.
  11060. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11061. */
  11062. class PointLight extends ShadowLight {
  11063. private _shadowAngle;
  11064. /**
  11065. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11066. * This specifies what angle the shadow will use to be created.
  11067. *
  11068. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11069. */
  11070. /**
  11071. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11072. * This specifies what angle the shadow will use to be created.
  11073. *
  11074. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11075. */
  11076. shadowAngle: number;
  11077. /**
  11078. * Gets the direction if it has been set.
  11079. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11080. */
  11081. /**
  11082. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11083. */
  11084. direction: Vector3;
  11085. /**
  11086. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11087. * A PointLight emits the light in every direction.
  11088. * It can cast shadows.
  11089. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11090. * ```javascript
  11091. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11092. * ```
  11093. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11094. * @param name The light friendly name
  11095. * @param position The position of the point light in the scene
  11096. * @param scene The scene the lights belongs to
  11097. */
  11098. constructor(name: string, position: Vector3, scene: Scene);
  11099. /**
  11100. * Returns the string "PointLight"
  11101. * @returns the class name
  11102. */
  11103. getClassName(): string;
  11104. /**
  11105. * Returns the integer 0.
  11106. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11107. */
  11108. getTypeID(): number;
  11109. /**
  11110. * Specifies wether or not the shadowmap should be a cube texture.
  11111. * @returns true if the shadowmap needs to be a cube texture.
  11112. */
  11113. needCube(): boolean;
  11114. /**
  11115. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11116. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11117. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11118. */
  11119. getShadowDirection(faceIndex?: number): Vector3;
  11120. /**
  11121. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11122. * - fov = PI / 2
  11123. * - aspect ratio : 1.0
  11124. * - z-near and far equal to the active camera minZ and maxZ.
  11125. * Returns the PointLight.
  11126. */
  11127. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11128. protected _buildUniformLayout(): void;
  11129. /**
  11130. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11131. * @param effect The effect to update
  11132. * @param lightIndex The index of the light in the effect to update
  11133. * @returns The point light
  11134. */
  11135. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11136. }
  11137. }
  11138. declare module BABYLON {
  11139. /**
  11140. * Interface describing all the common properties and methods a shadow light needs to implement.
  11141. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11142. * as well as binding the different shadow properties to the effects.
  11143. */
  11144. interface IShadowLight extends Light {
  11145. /**
  11146. * The light id in the scene (used in scene.findLighById for instance)
  11147. */
  11148. id: string;
  11149. /**
  11150. * The position the shdow will be casted from.
  11151. */
  11152. position: Vector3;
  11153. /**
  11154. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11155. */
  11156. direction: Vector3;
  11157. /**
  11158. * The transformed position. Position of the light in world space taking parenting in account.
  11159. */
  11160. transformedPosition: Vector3;
  11161. /**
  11162. * The transformed direction. Direction of the light in world space taking parenting in account.
  11163. */
  11164. transformedDirection: Vector3;
  11165. /**
  11166. * The friendly name of the light in the scene.
  11167. */
  11168. name: string;
  11169. /**
  11170. * Defines the shadow projection clipping minimum z value.
  11171. */
  11172. shadowMinZ: number;
  11173. /**
  11174. * Defines the shadow projection clipping maximum z value.
  11175. */
  11176. shadowMaxZ: number;
  11177. /**
  11178. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11179. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11180. */
  11181. computeTransformedInformation(): boolean;
  11182. /**
  11183. * Gets the scene the light belongs to.
  11184. * @returns The scene
  11185. */
  11186. getScene(): Scene;
  11187. /**
  11188. * Callback defining a custom Projection Matrix Builder.
  11189. * This can be used to override the default projection matrix computation.
  11190. */
  11191. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11192. /**
  11193. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11194. * @param matrix The materix to updated with the projection information
  11195. * @param viewMatrix The transform matrix of the light
  11196. * @param renderList The list of mesh to render in the map
  11197. * @returns The current light
  11198. */
  11199. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11200. /**
  11201. * Gets the current depth scale used in ESM.
  11202. * @returns The scale
  11203. */
  11204. getDepthScale(): number;
  11205. /**
  11206. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11207. * @returns true if a cube texture needs to be use
  11208. */
  11209. needCube(): boolean;
  11210. /**
  11211. * Detects if the projection matrix requires to be recomputed this frame.
  11212. * @returns true if it requires to be recomputed otherwise, false.
  11213. */
  11214. needProjectionMatrixCompute(): boolean;
  11215. /**
  11216. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11217. */
  11218. forceProjectionMatrixCompute(): void;
  11219. /**
  11220. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11221. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11222. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11223. */
  11224. getShadowDirection(faceIndex?: number): Vector3;
  11225. /**
  11226. * Gets the minZ used for shadow according to both the scene and the light.
  11227. * @param activeCamera The camera we are returning the min for
  11228. * @returns the depth min z
  11229. */
  11230. getDepthMinZ(activeCamera: Camera): number;
  11231. /**
  11232. * Gets the maxZ used for shadow according to both the scene and the light.
  11233. * @param activeCamera The camera we are returning the max for
  11234. * @returns the depth max z
  11235. */
  11236. getDepthMaxZ(activeCamera: Camera): number;
  11237. }
  11238. /**
  11239. * Base implementation IShadowLight
  11240. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11241. */
  11242. abstract class ShadowLight extends Light implements IShadowLight {
  11243. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11244. protected _position: Vector3;
  11245. protected _setPosition(value: Vector3): void;
  11246. /**
  11247. * Sets the position the shadow will be casted from. Also use as the light position for both
  11248. * point and spot lights.
  11249. */
  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. position: Vector3;
  11255. protected _direction: Vector3;
  11256. protected _setDirection(value: Vector3): void;
  11257. /**
  11258. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11259. * Also use as the light direction on spot and directional lights.
  11260. */
  11261. /**
  11262. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11263. * Also use as the light direction on spot and directional lights.
  11264. */
  11265. direction: Vector3;
  11266. private _shadowMinZ;
  11267. /**
  11268. * Gets the shadow projection clipping minimum z value.
  11269. */
  11270. /**
  11271. * Sets the shadow projection clipping minimum z value.
  11272. */
  11273. shadowMinZ: number;
  11274. private _shadowMaxZ;
  11275. /**
  11276. * Sets the shadow projection clipping maximum z value.
  11277. */
  11278. /**
  11279. * Gets the shadow projection clipping maximum z value.
  11280. */
  11281. shadowMaxZ: number;
  11282. /**
  11283. * Callback defining a custom Projection Matrix Builder.
  11284. * This can be used to override the default projection matrix computation.
  11285. */
  11286. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11287. /**
  11288. * The transformed position. Position of the light in world space taking parenting in account.
  11289. */
  11290. transformedPosition: Vector3;
  11291. /**
  11292. * The transformed direction. Direction of the light in world space taking parenting in account.
  11293. */
  11294. transformedDirection: Vector3;
  11295. private _worldMatrix;
  11296. private _needProjectionMatrixCompute;
  11297. /**
  11298. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11299. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11300. */
  11301. computeTransformedInformation(): boolean;
  11302. /**
  11303. * Return the depth scale used for the shadow map.
  11304. * @returns the depth scale.
  11305. */
  11306. getDepthScale(): number;
  11307. /**
  11308. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11309. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11310. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11311. */
  11312. getShadowDirection(faceIndex?: number): Vector3;
  11313. /**
  11314. * Returns the ShadowLight absolute position in the World.
  11315. * @returns the position vector in world space
  11316. */
  11317. getAbsolutePosition(): Vector3;
  11318. /**
  11319. * Sets the ShadowLight direction toward the passed target.
  11320. * @param target The point tot target in local space
  11321. * @returns the updated ShadowLight direction
  11322. */
  11323. setDirectionToTarget(target: Vector3): Vector3;
  11324. /**
  11325. * Returns the light rotation in euler definition.
  11326. * @returns the x y z rotation in local space.
  11327. */
  11328. getRotation(): Vector3;
  11329. /**
  11330. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11331. * @returns true if a cube texture needs to be use
  11332. */
  11333. needCube(): boolean;
  11334. /**
  11335. * Detects if the projection matrix requires to be recomputed this frame.
  11336. * @returns true if it requires to be recomputed otherwise, false.
  11337. */
  11338. needProjectionMatrixCompute(): boolean;
  11339. /**
  11340. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11341. */
  11342. forceProjectionMatrixCompute(): void;
  11343. /**
  11344. * Get the world matrix of the sahdow lights.
  11345. * @hidden Internal Use Only
  11346. */
  11347. _getWorldMatrix(): Matrix;
  11348. /**
  11349. * Gets the minZ used for shadow according to both the scene and the light.
  11350. * @param activeCamera The camera we are returning the min for
  11351. * @returns the depth min z
  11352. */
  11353. getDepthMinZ(activeCamera: Camera): number;
  11354. /**
  11355. * Gets the maxZ used for shadow according to both the scene and the light.
  11356. * @param activeCamera The camera we are returning the max for
  11357. * @returns the depth max z
  11358. */
  11359. getDepthMaxZ(activeCamera: Camera): number;
  11360. /**
  11361. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11362. * @param matrix The materix to updated with the projection information
  11363. * @param viewMatrix The transform matrix of the light
  11364. * @param renderList The list of mesh to render in the map
  11365. * @returns The current light
  11366. */
  11367. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11368. }
  11369. }
  11370. declare module BABYLON {
  11371. /**
  11372. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11373. * These values define a cone of light starting from the position, emitting toward the direction.
  11374. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11375. * and the exponent defines the speed of the decay of the light with distance (reach).
  11376. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11377. */
  11378. class SpotLight extends ShadowLight {
  11379. private _angle;
  11380. /**
  11381. * Gets the cone angle of the spot light in Radians.
  11382. */
  11383. /**
  11384. * Sets the cone angle of the spot light in Radians.
  11385. */
  11386. angle: number;
  11387. private _shadowAngleScale;
  11388. /**
  11389. * Allows scaling the angle of the light for shadow generation only.
  11390. */
  11391. /**
  11392. * Allows scaling the angle of the light for shadow generation only.
  11393. */
  11394. shadowAngleScale: number;
  11395. /**
  11396. * The light decay speed with the distance from the emission spot.
  11397. */
  11398. exponent: number;
  11399. private _projectionTextureMatrix;
  11400. /**
  11401. * Allows reading the projecton texture
  11402. */
  11403. readonly projectionTextureMatrix: Matrix;
  11404. protected _projectionTextureLightNear: number;
  11405. /**
  11406. * Gets the near clip of the Spotlight for texture projection.
  11407. */
  11408. /**
  11409. * Sets the near clip of the Spotlight for texture projection.
  11410. */
  11411. projectionTextureLightNear: number;
  11412. protected _projectionTextureLightFar: number;
  11413. /**
  11414. * Gets the far clip of the Spotlight for texture projection.
  11415. */
  11416. /**
  11417. * Sets the far clip of the Spotlight for texture projection.
  11418. */
  11419. projectionTextureLightFar: number;
  11420. protected _projectionTextureUpDirection: Vector3;
  11421. /**
  11422. * Gets the Up vector of the Spotlight for texture projection.
  11423. */
  11424. /**
  11425. * Sets the Up vector of the Spotlight for texture projection.
  11426. */
  11427. projectionTextureUpDirection: Vector3;
  11428. private _projectionTexture;
  11429. /**
  11430. * Gets the projection texture of the light.
  11431. */
  11432. /**
  11433. * Sets the projection texture of the light.
  11434. */
  11435. projectionTexture: Nullable<BaseTexture>;
  11436. private _projectionTextureViewLightDirty;
  11437. private _projectionTextureProjectionLightDirty;
  11438. private _projectionTextureDirty;
  11439. private _projectionTextureViewTargetVector;
  11440. private _projectionTextureViewLightMatrix;
  11441. private _projectionTextureProjectionLightMatrix;
  11442. private _projectionTextureScalingMatrix;
  11443. /**
  11444. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11445. * It can cast shadows.
  11446. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11447. * @param name The light friendly name
  11448. * @param position The position of the spot light in the scene
  11449. * @param direction The direction of the light in the scene
  11450. * @param angle The cone angle of the light in Radians
  11451. * @param exponent The light decay speed with the distance from the emission spot
  11452. * @param scene The scene the lights belongs to
  11453. */
  11454. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11455. /**
  11456. * Returns the string "SpotLight".
  11457. * @returns the class name
  11458. */
  11459. getClassName(): string;
  11460. /**
  11461. * Returns the integer 2.
  11462. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11463. */
  11464. getTypeID(): number;
  11465. /**
  11466. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11467. */
  11468. protected _setDirection(value: Vector3): void;
  11469. /**
  11470. * Overrides the position setter to recompute the projection texture view light Matrix.
  11471. */
  11472. protected _setPosition(value: Vector3): void;
  11473. /**
  11474. * 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.
  11475. * Returns the SpotLight.
  11476. */
  11477. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11478. protected _computeProjectionTextureViewLightMatrix(): void;
  11479. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11480. /**
  11481. * Main function for light texture projection matrix computing.
  11482. */
  11483. protected _computeProjectionTextureMatrix(): void;
  11484. protected _buildUniformLayout(): void;
  11485. /**
  11486. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11487. * @param effect The effect to update
  11488. * @param lightIndex The index of the light in the effect to update
  11489. * @returns The spot light
  11490. */
  11491. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11492. /**
  11493. * Disposes the light and the associated resources.
  11494. */
  11495. dispose(): void;
  11496. }
  11497. }
  11498. declare module BABYLON {
  11499. interface ILoadingScreen {
  11500. displayLoadingUI: () => void;
  11501. hideLoadingUI: () => void;
  11502. loadingUIBackgroundColor: string;
  11503. loadingUIText: string;
  11504. }
  11505. class DefaultLoadingScreen implements ILoadingScreen {
  11506. private _renderingCanvas;
  11507. private _loadingText;
  11508. private _loadingDivBackgroundColor;
  11509. private _loadingDiv;
  11510. private _loadingTextDiv;
  11511. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11512. displayLoadingUI(): void;
  11513. hideLoadingUI(): void;
  11514. loadingUIText: string;
  11515. loadingUIBackgroundColor: string;
  11516. private _resizeLoadingUI;
  11517. }
  11518. }
  11519. declare module BABYLON {
  11520. class SceneLoaderProgressEvent {
  11521. readonly lengthComputable: boolean;
  11522. readonly loaded: number;
  11523. readonly total: number;
  11524. constructor(lengthComputable: boolean, loaded: number, total: number);
  11525. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11526. }
  11527. interface ISceneLoaderPluginExtensions {
  11528. [extension: string]: {
  11529. isBinary: boolean;
  11530. };
  11531. }
  11532. interface ISceneLoaderPluginFactory {
  11533. name: string;
  11534. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11535. canDirectLoad?: (data: string) => boolean;
  11536. }
  11537. interface ISceneLoaderPlugin {
  11538. /**
  11539. * The friendly name of this plugin.
  11540. */
  11541. name: string;
  11542. /**
  11543. * The file extensions supported by this plugin.
  11544. */
  11545. extensions: string | ISceneLoaderPluginExtensions;
  11546. /**
  11547. * Import meshes into a scene.
  11548. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11549. * @param scene The scene to import into
  11550. * @param data The data to import
  11551. * @param rootUrl The root url for scene and resources
  11552. * @param meshes The meshes array to import into
  11553. * @param particleSystems The particle systems array to import into
  11554. * @param skeletons The skeletons array to import into
  11555. * @param onError The callback when import fails
  11556. * @returns True if successful or false otherwise
  11557. */
  11558. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11559. /**
  11560. * Load into a scene.
  11561. * @param scene The scene to load into
  11562. * @param data The data to import
  11563. * @param rootUrl The root url for scene and resources
  11564. * @param onError The callback when import fails
  11565. * @returns true if successful or false otherwise
  11566. */
  11567. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11568. /**
  11569. * The callback that returns true if the data can be directly loaded.
  11570. */
  11571. canDirectLoad?: (data: string) => boolean;
  11572. /**
  11573. * The callback that allows custom handling of the root url based on the response url.
  11574. */
  11575. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11576. /**
  11577. * Load into an asset container.
  11578. * @param scene The scene to load into
  11579. * @param data The data to import
  11580. * @param rootUrl The root url for scene and resources
  11581. * @param onError The callback when import fails
  11582. * @returns The loaded asset container
  11583. */
  11584. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11585. }
  11586. interface ISceneLoaderPluginAsync {
  11587. /**
  11588. * The friendly name of this plugin.
  11589. */
  11590. name: string;
  11591. /**
  11592. * The file extensions supported by this plugin.
  11593. */
  11594. extensions: string | ISceneLoaderPluginExtensions;
  11595. /**
  11596. * Import meshes into a scene.
  11597. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11598. * @param scene The scene to import into
  11599. * @param data The data to import
  11600. * @param rootUrl The root url for scene and resources
  11601. * @param onProgress The callback when the load progresses
  11602. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11603. */
  11604. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11605. meshes: AbstractMesh[];
  11606. particleSystems: ParticleSystem[];
  11607. skeletons: Skeleton[];
  11608. animationGroups: AnimationGroup[];
  11609. }>;
  11610. /**
  11611. * Load into a scene.
  11612. * @param scene The scene to load into
  11613. * @param data The data to import
  11614. * @param rootUrl The root url for scene and resources
  11615. * @param onProgress The callback when the load progresses
  11616. * @returns Nothing
  11617. */
  11618. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11619. /**
  11620. * The callback that returns true if the data can be directly loaded.
  11621. */
  11622. canDirectLoad?: (data: string) => boolean;
  11623. /**
  11624. * The callback that allows custom handling of the root url based on the response url.
  11625. */
  11626. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11627. /**
  11628. * Load into an asset container.
  11629. * @param scene The scene to load into
  11630. * @param data The data to import
  11631. * @param rootUrl The root url for scene and resources
  11632. * @param onProgress The callback when the load progresses
  11633. * @returns The loaded asset container
  11634. */
  11635. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11636. }
  11637. class SceneLoader {
  11638. private static _ForceFullSceneLoadingForIncremental;
  11639. private static _ShowLoadingScreen;
  11640. private static _CleanBoneMatrixWeights;
  11641. static readonly NO_LOGGING: number;
  11642. static readonly MINIMAL_LOGGING: number;
  11643. static readonly SUMMARY_LOGGING: number;
  11644. static readonly DETAILED_LOGGING: number;
  11645. private static _loggingLevel;
  11646. static ForceFullSceneLoadingForIncremental: boolean;
  11647. static ShowLoadingScreen: boolean;
  11648. static loggingLevel: number;
  11649. static CleanBoneMatrixWeights: boolean;
  11650. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11651. private static _registeredPlugins;
  11652. private static _getDefaultPlugin();
  11653. private static _getPluginForExtension(extension);
  11654. private static _getPluginForDirectLoad(data);
  11655. private static _getPluginForFilename(sceneFilename);
  11656. private static _getDirectLoad(sceneFilename);
  11657. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  11658. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  11659. static IsPluginForExtensionAvailable(extension: string): boolean;
  11660. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  11661. /**
  11662. * Import meshes into a scene
  11663. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11664. * @param rootUrl a string that defines the root url for scene and resources
  11665. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11666. * @param scene the instance of BABYLON.Scene to append to
  11667. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  11668. * @param onProgress a callback with a progress event for each file being loaded
  11669. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11670. * @param pluginExtension the extension used to determine the plugin
  11671. * @returns The loaded plugin
  11672. */
  11673. 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>;
  11674. /**
  11675. * Import meshes into a scene
  11676. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11677. * @param rootUrl a string that defines the root url for scene and resources
  11678. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11679. * @param scene the instance of BABYLON.Scene to append to
  11680. * @param onProgress a callback with a progress event for each file being loaded
  11681. * @param pluginExtension the extension used to determine the plugin
  11682. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  11683. */
  11684. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  11685. meshes: AbstractMesh[];
  11686. particleSystems: ParticleSystem[];
  11687. skeletons: Skeleton[];
  11688. animationGroups: AnimationGroup[];
  11689. }>;
  11690. /**
  11691. * Load a scene
  11692. * @param rootUrl a string that defines the root url for scene and resources
  11693. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11694. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11695. * @param onSuccess a callback with the scene when import succeeds
  11696. * @param onProgress a callback with a progress event for each file being loaded
  11697. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11698. * @param pluginExtension the extension used to determine the plugin
  11699. * @returns The loaded plugin
  11700. */
  11701. 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>;
  11702. /**
  11703. * Load a scene
  11704. * @param rootUrl a string that defines the root url for scene and resources
  11705. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11706. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11707. * @param onProgress a callback with a progress event for each file being loaded
  11708. * @param pluginExtension the extension used to determine the plugin
  11709. * @returns The loaded scene
  11710. */
  11711. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11712. /**
  11713. * Append a scene
  11714. * @param rootUrl a string that defines the root url for scene and resources
  11715. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11716. * @param scene is the instance of BABYLON.Scene to append to
  11717. * @param onSuccess a callback with the scene when import succeeds
  11718. * @param onProgress a callback with a progress event for each file being loaded
  11719. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11720. * @param pluginExtension the extension used to determine the plugin
  11721. * @returns The loaded plugin
  11722. */
  11723. 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>;
  11724. /**
  11725. * Append a scene
  11726. * @param rootUrl a string that defines the root url for scene and resources
  11727. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11728. * @param scene is the instance of BABYLON.Scene to append to
  11729. * @param onProgress a callback with a progress event for each file being loaded
  11730. * @param pluginExtension the extension used to determine the plugin
  11731. * @returns The given scene
  11732. */
  11733. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11734. /**
  11735. * Load a scene into an asset container
  11736. * @param rootUrl a string that defines the root url for scene and resources
  11737. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11738. * @param scene is the instance of BABYLON.Scene to append to
  11739. * @param onSuccess a callback with the scene when import succeeds
  11740. * @param onProgress a callback with a progress event for each file being loaded
  11741. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11742. * @param pluginExtension the extension used to determine the plugin
  11743. * @returns The loaded plugin
  11744. */
  11745. static 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>;
  11746. /**
  11747. * Load a scene into an asset container
  11748. * @param rootUrl a string that defines the root url for scene and resources
  11749. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11750. * @param scene is the instance of BABYLON.Scene to append to
  11751. * @param onProgress a callback with a progress event for each file being loaded
  11752. * @param pluginExtension the extension used to determine the plugin
  11753. * @returns The loaded asset container
  11754. */
  11755. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11756. }
  11757. }
  11758. declare module BABYLON {
  11759. /**
  11760. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11761. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11762. * 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;
  11763. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11764. */
  11765. class ColorCurves {
  11766. private _dirty;
  11767. private _tempColor;
  11768. private _globalCurve;
  11769. private _highlightsCurve;
  11770. private _midtonesCurve;
  11771. private _shadowsCurve;
  11772. private _positiveCurve;
  11773. private _negativeCurve;
  11774. private _globalHue;
  11775. private _globalDensity;
  11776. private _globalSaturation;
  11777. private _globalExposure;
  11778. /**
  11779. * Gets the global Hue value.
  11780. * 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).
  11781. */
  11782. /**
  11783. * Sets the global Hue value.
  11784. * 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).
  11785. */
  11786. globalHue: number;
  11787. /**
  11788. * Gets the global Density value.
  11789. * 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.
  11790. * Values less than zero provide a filter of opposite hue.
  11791. */
  11792. /**
  11793. * Sets the global Density value.
  11794. * 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.
  11795. * Values less than zero provide a filter of opposite hue.
  11796. */
  11797. globalDensity: number;
  11798. /**
  11799. * Gets the global Saturation value.
  11800. * 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.
  11801. */
  11802. /**
  11803. * Sets the global Saturation value.
  11804. * 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.
  11805. */
  11806. globalSaturation: number;
  11807. private _highlightsHue;
  11808. private _highlightsDensity;
  11809. private _highlightsSaturation;
  11810. private _highlightsExposure;
  11811. /**
  11812. * Gets the highlights Hue value.
  11813. * 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).
  11814. */
  11815. /**
  11816. * Sets the highlights Hue value.
  11817. * 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).
  11818. */
  11819. highlightsHue: number;
  11820. /**
  11821. * Gets the highlights Density value.
  11822. * 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.
  11823. * Values less than zero provide a filter of opposite hue.
  11824. */
  11825. /**
  11826. * Sets the highlights Density value.
  11827. * 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.
  11828. * Values less than zero provide a filter of opposite hue.
  11829. */
  11830. highlightsDensity: number;
  11831. /**
  11832. * Gets the highlights Saturation value.
  11833. * 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.
  11834. */
  11835. /**
  11836. * Sets the highlights Saturation value.
  11837. * 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.
  11838. */
  11839. highlightsSaturation: number;
  11840. /**
  11841. * Gets the highlights Exposure value.
  11842. * 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.
  11843. */
  11844. /**
  11845. * Sets the highlights Exposure value.
  11846. * 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.
  11847. */
  11848. highlightsExposure: number;
  11849. private _midtonesHue;
  11850. private _midtonesDensity;
  11851. private _midtonesSaturation;
  11852. private _midtonesExposure;
  11853. /**
  11854. * Gets the midtones Hue value.
  11855. * 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).
  11856. */
  11857. /**
  11858. * Sets the midtones Hue value.
  11859. * 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).
  11860. */
  11861. midtonesHue: number;
  11862. /**
  11863. * Gets the midtones Density value.
  11864. * 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.
  11865. * Values less than zero provide a filter of opposite hue.
  11866. */
  11867. /**
  11868. * Sets the midtones Density value.
  11869. * 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.
  11870. * Values less than zero provide a filter of opposite hue.
  11871. */
  11872. midtonesDensity: number;
  11873. /**
  11874. * Gets the midtones Saturation value.
  11875. * 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.
  11876. */
  11877. /**
  11878. * Sets the midtones Saturation value.
  11879. * 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.
  11880. */
  11881. midtonesSaturation: number;
  11882. /**
  11883. * Gets the midtones Exposure value.
  11884. * 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.
  11885. */
  11886. /**
  11887. * Sets the midtones Exposure value.
  11888. * 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.
  11889. */
  11890. midtonesExposure: number;
  11891. private _shadowsHue;
  11892. private _shadowsDensity;
  11893. private _shadowsSaturation;
  11894. private _shadowsExposure;
  11895. /**
  11896. * Gets the shadows Hue value.
  11897. * 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).
  11898. */
  11899. /**
  11900. * Sets the shadows Hue value.
  11901. * 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).
  11902. */
  11903. shadowsHue: number;
  11904. /**
  11905. * Gets the shadows Density value.
  11906. * 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.
  11907. * Values less than zero provide a filter of opposite hue.
  11908. */
  11909. /**
  11910. * Sets the shadows Density value.
  11911. * 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.
  11912. * Values less than zero provide a filter of opposite hue.
  11913. */
  11914. shadowsDensity: number;
  11915. /**
  11916. * Gets the shadows Saturation value.
  11917. * 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.
  11918. */
  11919. /**
  11920. * Sets the shadows Saturation value.
  11921. * 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.
  11922. */
  11923. shadowsSaturation: number;
  11924. /**
  11925. * Gets the shadows Exposure value.
  11926. * 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.
  11927. */
  11928. /**
  11929. * Sets the shadows Exposure value.
  11930. * 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.
  11931. */
  11932. shadowsExposure: number;
  11933. getClassName(): string;
  11934. /**
  11935. * Binds the color curves to the shader.
  11936. * @param colorCurves The color curve to bind
  11937. * @param effect The effect to bind to
  11938. */
  11939. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11940. /**
  11941. * Prepare the list of uniforms associated with the ColorCurves effects.
  11942. * @param uniformsList The list of uniforms used in the effect
  11943. */
  11944. static PrepareUniforms(uniformsList: string[]): void;
  11945. /**
  11946. * Returns color grading data based on a hue, density, saturation and exposure value.
  11947. * @param filterHue The hue of the color filter.
  11948. * @param filterDensity The density of the color filter.
  11949. * @param saturation The saturation.
  11950. * @param exposure The exposure.
  11951. * @param result The result data container.
  11952. */
  11953. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  11954. /**
  11955. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11956. * @param value The input slider value in range [-100,100].
  11957. * @returns Adjusted value.
  11958. */
  11959. private static applyColorGradingSliderNonlinear(value);
  11960. /**
  11961. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11962. * @param hue The hue (H) input.
  11963. * @param saturation The saturation (S) input.
  11964. * @param brightness The brightness (B) input.
  11965. * @result An RGBA color represented as Vector4.
  11966. */
  11967. private static fromHSBToRef(hue, saturation, brightness, result);
  11968. /**
  11969. * Returns a value clamped between min and max
  11970. * @param value The value to clamp
  11971. * @param min The minimum of value
  11972. * @param max The maximum of value
  11973. * @returns The clamped value.
  11974. */
  11975. private static clamp(value, min, max);
  11976. /**
  11977. * Clones the current color curve instance.
  11978. * @return The cloned curves
  11979. */
  11980. clone(): ColorCurves;
  11981. /**
  11982. * Serializes the current color curve instance to a json representation.
  11983. * @return a JSON representation
  11984. */
  11985. serialize(): any;
  11986. /**
  11987. * Parses the color curve from a json representation.
  11988. * @param source the JSON source to parse
  11989. * @return The parsed curves
  11990. */
  11991. static Parse(source: any): ColorCurves;
  11992. }
  11993. }
  11994. declare module BABYLON {
  11995. /**
  11996. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  11997. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  11998. */
  11999. class EffectFallbacks {
  12000. private _defines;
  12001. private _currentRank;
  12002. private _maxRank;
  12003. private _mesh;
  12004. /**
  12005. * Removes the fallback from the bound mesh.
  12006. */
  12007. unBindMesh(): void;
  12008. /**
  12009. * Adds a fallback on the specified property.
  12010. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12011. * @param define The name of the define in the shader
  12012. */
  12013. addFallback(rank: number, define: string): void;
  12014. /**
  12015. * Sets the mesh to use CPU skinning when needing to fallback.
  12016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12017. * @param mesh The mesh to use the fallbacks.
  12018. */
  12019. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12020. /**
  12021. * Checks to see if more fallbacks are still availible.
  12022. */
  12023. readonly isMoreFallbacks: boolean;
  12024. /**
  12025. * Removes the defines that shoould be removed when falling back.
  12026. * @param currentDefines defines the current define statements for the shader.
  12027. * @param effect defines the current effect we try to compile
  12028. * @returns The resulting defines with defines of the current rank removed.
  12029. */
  12030. reduce(currentDefines: string, effect: Effect): string;
  12031. }
  12032. /**
  12033. * Options to be used when creating an effect.
  12034. */
  12035. class EffectCreationOptions {
  12036. /**
  12037. * Atrributes that will be used in the shader.
  12038. */
  12039. attributes: string[];
  12040. /**
  12041. * Uniform varible names that will be set in the shader.
  12042. */
  12043. uniformsNames: string[];
  12044. /**
  12045. * Uniform buffer varible names that will be set in the shader.
  12046. */
  12047. uniformBuffersNames: string[];
  12048. /**
  12049. * Sampler texture variable names that will be set in the shader.
  12050. */
  12051. samplers: string[];
  12052. /**
  12053. * Define statements that will be set in the shader.
  12054. */
  12055. defines: any;
  12056. /**
  12057. * Possible fallbacks for this effect to improve performance when needed.
  12058. */
  12059. fallbacks: Nullable<EffectFallbacks>;
  12060. /**
  12061. * Callback that will be called when the shader is compiled.
  12062. */
  12063. onCompiled: Nullable<(effect: Effect) => void>;
  12064. /**
  12065. * Callback that will be called if an error occurs during shader compilation.
  12066. */
  12067. onError: Nullable<(effect: Effect, errors: string) => void>;
  12068. /**
  12069. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12070. */
  12071. indexParameters: any;
  12072. /**
  12073. * Max number of lights that can be used in the shader.
  12074. */
  12075. maxSimultaneousLights: number;
  12076. /**
  12077. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12078. */
  12079. transformFeedbackVaryings: Nullable<string[]>;
  12080. }
  12081. /**
  12082. * Effect containing vertex and fragment shader that can be executed on an object.
  12083. */
  12084. class Effect {
  12085. /**
  12086. * Name of the effect.
  12087. */
  12088. name: any;
  12089. /**
  12090. * String container all the define statements that should be set on the shader.
  12091. */
  12092. defines: string;
  12093. /**
  12094. * Callback that will be called when the shader is compiled.
  12095. */
  12096. onCompiled: Nullable<(effect: Effect) => void>;
  12097. /**
  12098. * Callback that will be called if an error occurs during shader compilation.
  12099. */
  12100. onError: Nullable<(effect: Effect, errors: string) => void>;
  12101. /**
  12102. * Callback that will be called when effect is bound.
  12103. */
  12104. onBind: Nullable<(effect: Effect) => void>;
  12105. /**
  12106. * Unique ID of the effect.
  12107. */
  12108. uniqueId: number;
  12109. /**
  12110. * Observable that will be called when the shader is compiled.
  12111. */
  12112. onCompileObservable: Observable<Effect>;
  12113. /**
  12114. * Observable that will be called if an error occurs during shader compilation.
  12115. */
  12116. onErrorObservable: Observable<Effect>;
  12117. /**
  12118. * Observable that will be called when effect is bound.
  12119. */
  12120. onBindObservable: Observable<Effect>;
  12121. /** @hidden */
  12122. _bonesComputationForcedToCPU: boolean;
  12123. private static _uniqueIdSeed;
  12124. private _engine;
  12125. private _uniformBuffersNames;
  12126. private _uniformsNames;
  12127. private _samplers;
  12128. private _isReady;
  12129. private _compilationError;
  12130. private _attributesNames;
  12131. private _attributes;
  12132. private _uniforms;
  12133. /**
  12134. * Key for the effect.
  12135. */
  12136. _key: string;
  12137. private _indexParameters;
  12138. private _fallbacks;
  12139. private _vertexSourceCode;
  12140. private _fragmentSourceCode;
  12141. private _vertexSourceCodeOverride;
  12142. private _fragmentSourceCodeOverride;
  12143. private _transformFeedbackVaryings;
  12144. /**
  12145. * Compiled shader to webGL program.
  12146. */
  12147. _program: WebGLProgram;
  12148. private _valueCache;
  12149. private static _baseCache;
  12150. /**
  12151. * Instantiates an effect.
  12152. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12153. * @param baseName Name of the effect.
  12154. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12155. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12156. * @param samplers List of sampler variables that will be passed to the shader.
  12157. * @param engine Engine to be used to render the effect
  12158. * @param defines Define statements to be added to the shader.
  12159. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12160. * @param onCompiled Callback that will be called when the shader is compiled.
  12161. * @param onError Callback that will be called if an error occurs during shader compilation.
  12162. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12163. */
  12164. 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);
  12165. /**
  12166. * Unique key for this effect
  12167. */
  12168. readonly key: string;
  12169. /**
  12170. * If the effect has been compiled and prepared.
  12171. * @returns if the effect is compiled and prepared.
  12172. */
  12173. isReady(): boolean;
  12174. /**
  12175. * The engine the effect was initialized with.
  12176. * @returns the engine.
  12177. */
  12178. getEngine(): Engine;
  12179. /**
  12180. * The compiled webGL program for the effect
  12181. * @returns the webGL program.
  12182. */
  12183. getProgram(): WebGLProgram;
  12184. /**
  12185. * The set of names of attribute variables for the shader.
  12186. * @returns An array of attribute names.
  12187. */
  12188. getAttributesNames(): string[];
  12189. /**
  12190. * Returns the attribute at the given index.
  12191. * @param index The index of the attribute.
  12192. * @returns The location of the attribute.
  12193. */
  12194. getAttributeLocation(index: number): number;
  12195. /**
  12196. * Returns the attribute based on the name of the variable.
  12197. * @param name of the attribute to look up.
  12198. * @returns the attribute location.
  12199. */
  12200. getAttributeLocationByName(name: string): number;
  12201. /**
  12202. * The number of attributes.
  12203. * @returns the numnber of attributes.
  12204. */
  12205. getAttributesCount(): number;
  12206. /**
  12207. * Gets the index of a uniform variable.
  12208. * @param uniformName of the uniform to look up.
  12209. * @returns the index.
  12210. */
  12211. getUniformIndex(uniformName: string): number;
  12212. /**
  12213. * Returns the attribute based on the name of the variable.
  12214. * @param uniformName of the uniform to look up.
  12215. * @returns the location of the uniform.
  12216. */
  12217. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12218. /**
  12219. * Returns an array of sampler variable names
  12220. * @returns The array of sampler variable neames.
  12221. */
  12222. getSamplers(): string[];
  12223. /**
  12224. * The error from the last compilation.
  12225. * @returns the error string.
  12226. */
  12227. getCompilationError(): string;
  12228. /**
  12229. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12230. * @param func The callback to be used.
  12231. */
  12232. executeWhenCompiled(func: (effect: Effect) => void): void;
  12233. /** @hidden */
  12234. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12235. /** @hidden */
  12236. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12237. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  12238. private _processShaderConversion(sourceCode, isFragment, callback);
  12239. private _processIncludes(sourceCode, callback);
  12240. private _processPrecision(source);
  12241. /**
  12242. * Recompiles the webGL program
  12243. * @param vertexSourceCode The source code for the vertex shader.
  12244. * @param fragmentSourceCode The source code for the fragment shader.
  12245. * @param onCompiled Callback called when completed.
  12246. * @param onError Callback called on error.
  12247. */
  12248. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12249. /**
  12250. * Gets the uniform locations of the the specified variable names
  12251. * @param names THe names of the variables to lookup.
  12252. * @returns Array of locations in the same order as variable names.
  12253. */
  12254. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12255. /**
  12256. * Prepares the effect
  12257. */
  12258. _prepareEffect(): void;
  12259. /**
  12260. * Checks if the effect is supported. (Must be called after compilation)
  12261. */
  12262. readonly isSupported: boolean;
  12263. /**
  12264. * Binds a texture to the engine to be used as output of the shader.
  12265. * @param channel Name of the output variable.
  12266. * @param texture Texture to bind.
  12267. */
  12268. _bindTexture(channel: string, texture: InternalTexture): void;
  12269. /**
  12270. * Sets a texture on the engine to be used in the shader.
  12271. * @param channel Name of the sampler variable.
  12272. * @param texture Texture to set.
  12273. */
  12274. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12275. /**
  12276. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12277. * @param channel Name of the sampler variable.
  12278. * @param texture Texture to set.
  12279. */
  12280. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12281. /**
  12282. * Sets an array of textures on the engine to be used in the shader.
  12283. * @param channel Name of the variable.
  12284. * @param textures Textures to set.
  12285. */
  12286. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12287. /**
  12288. * 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)
  12289. * @param channel Name of the sampler variable.
  12290. * @param postProcess Post process to get the input texture from.
  12291. */
  12292. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12293. /**
  12294. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12295. * 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)
  12296. * @param channel Name of the sampler variable.
  12297. * @param postProcess Post process to get the output texture from.
  12298. */
  12299. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12300. /** @hidden */
  12301. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12302. /** @hidden */
  12303. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12304. /** @hidden */
  12305. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12306. /** @hidden */
  12307. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12308. /**
  12309. * Binds a buffer to a uniform.
  12310. * @param buffer Buffer to bind.
  12311. * @param name Name of the uniform variable to bind to.
  12312. */
  12313. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12314. /**
  12315. * Binds block to a uniform.
  12316. * @param blockName Name of the block to bind.
  12317. * @param index Index to bind.
  12318. */
  12319. bindUniformBlock(blockName: string, index: number): void;
  12320. /**
  12321. * Sets an interger value on a uniform variable.
  12322. * @param uniformName Name of the variable.
  12323. * @param value Value to be set.
  12324. * @returns this effect.
  12325. */
  12326. setInt(uniformName: string, value: number): Effect;
  12327. /**
  12328. * Sets an int array on a uniform variable.
  12329. * @param uniformName Name of the variable.
  12330. * @param array array to be set.
  12331. * @returns this effect.
  12332. */
  12333. setIntArray(uniformName: string, array: Int32Array): Effect;
  12334. /**
  12335. * 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)
  12336. * @param uniformName Name of the variable.
  12337. * @param array array to be set.
  12338. * @returns this effect.
  12339. */
  12340. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12341. /**
  12342. * 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)
  12343. * @param uniformName Name of the variable.
  12344. * @param array array to be set.
  12345. * @returns this effect.
  12346. */
  12347. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12348. /**
  12349. * 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)
  12350. * @param uniformName Name of the variable.
  12351. * @param array array to be set.
  12352. * @returns this effect.
  12353. */
  12354. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12355. /**
  12356. * Sets an float array on a uniform variable.
  12357. * @param uniformName Name of the variable.
  12358. * @param array array to be set.
  12359. * @returns this effect.
  12360. */
  12361. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12362. /**
  12363. * 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)
  12364. * @param uniformName Name of the variable.
  12365. * @param array array to be set.
  12366. * @returns this effect.
  12367. */
  12368. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12369. /**
  12370. * 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)
  12371. * @param uniformName Name of the variable.
  12372. * @param array array to be set.
  12373. * @returns this effect.
  12374. */
  12375. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12376. /**
  12377. * 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)
  12378. * @param uniformName Name of the variable.
  12379. * @param array array to be set.
  12380. * @returns this effect.
  12381. */
  12382. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12383. /**
  12384. * Sets an array on a uniform variable.
  12385. * @param uniformName Name of the variable.
  12386. * @param array array to be set.
  12387. * @returns this effect.
  12388. */
  12389. setArray(uniformName: string, array: number[]): Effect;
  12390. /**
  12391. * 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)
  12392. * @param uniformName Name of the variable.
  12393. * @param array array to be set.
  12394. * @returns this effect.
  12395. */
  12396. setArray2(uniformName: string, array: number[]): Effect;
  12397. /**
  12398. * 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)
  12399. * @param uniformName Name of the variable.
  12400. * @param array array to be set.
  12401. * @returns this effect.
  12402. */
  12403. setArray3(uniformName: string, array: number[]): Effect;
  12404. /**
  12405. * 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)
  12406. * @param uniformName Name of the variable.
  12407. * @param array array to be set.
  12408. * @returns this effect.
  12409. */
  12410. setArray4(uniformName: string, array: number[]): Effect;
  12411. /**
  12412. * Sets matrices on a uniform variable.
  12413. * @param uniformName Name of the variable.
  12414. * @param matrices matrices to be set.
  12415. * @returns this effect.
  12416. */
  12417. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12418. /**
  12419. * Sets matrix on a uniform variable.
  12420. * @param uniformName Name of the variable.
  12421. * @param matrix matrix to be set.
  12422. * @returns this effect.
  12423. */
  12424. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12425. /**
  12426. * 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)
  12427. * @param uniformName Name of the variable.
  12428. * @param matrix matrix to be set.
  12429. * @returns this effect.
  12430. */
  12431. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12432. /**
  12433. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12434. * @param uniformName Name of the variable.
  12435. * @param matrix matrix to be set.
  12436. * @returns this effect.
  12437. */
  12438. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12439. /**
  12440. * Sets a float on a uniform variable.
  12441. * @param uniformName Name of the variable.
  12442. * @param value value to be set.
  12443. * @returns this effect.
  12444. */
  12445. setFloat(uniformName: string, value: number): Effect;
  12446. /**
  12447. * Sets a boolean on a uniform variable.
  12448. * @param uniformName Name of the variable.
  12449. * @param bool value to be set.
  12450. * @returns this effect.
  12451. */
  12452. setBool(uniformName: string, bool: boolean): Effect;
  12453. /**
  12454. * Sets a Vector2 on a uniform variable.
  12455. * @param uniformName Name of the variable.
  12456. * @param vector2 vector2 to be set.
  12457. * @returns this effect.
  12458. */
  12459. setVector2(uniformName: string, vector2: Vector2): Effect;
  12460. /**
  12461. * Sets a float2 on a uniform variable.
  12462. * @param uniformName Name of the variable.
  12463. * @param x First float in float2.
  12464. * @param y Second float in float2.
  12465. * @returns this effect.
  12466. */
  12467. setFloat2(uniformName: string, x: number, y: number): Effect;
  12468. /**
  12469. * Sets a Vector3 on a uniform variable.
  12470. * @param uniformName Name of the variable.
  12471. * @param vector3 Value to be set.
  12472. * @returns this effect.
  12473. */
  12474. setVector3(uniformName: string, vector3: Vector3): Effect;
  12475. /**
  12476. * Sets a float3 on a uniform variable.
  12477. * @param uniformName Name of the variable.
  12478. * @param x First float in float3.
  12479. * @param y Second float in float3.
  12480. * @param z Third float in float3.
  12481. * @returns this effect.
  12482. */
  12483. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12484. /**
  12485. * Sets a Vector4 on a uniform variable.
  12486. * @param uniformName Name of the variable.
  12487. * @param vector4 Value to be set.
  12488. * @returns this effect.
  12489. */
  12490. setVector4(uniformName: string, vector4: Vector4): Effect;
  12491. /**
  12492. * Sets a float4 on a uniform variable.
  12493. * @param uniformName Name of the variable.
  12494. * @param x First float in float4.
  12495. * @param y Second float in float4.
  12496. * @param z Third float in float4.
  12497. * @param w Fourth float in float4.
  12498. * @returns this effect.
  12499. */
  12500. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12501. /**
  12502. * Sets a Color3 on a uniform variable.
  12503. * @param uniformName Name of the variable.
  12504. * @param color3 Value to be set.
  12505. * @returns this effect.
  12506. */
  12507. setColor3(uniformName: string, color3: Color3): Effect;
  12508. /**
  12509. * Sets a Color4 on a uniform variable.
  12510. * @param uniformName Name of the variable.
  12511. * @param color3 Value to be set.
  12512. * @param alpha Alpha value to be set.
  12513. * @returns this effect.
  12514. */
  12515. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12516. /**
  12517. * Sets a Color4 on a uniform variable
  12518. * @param uniformName defines the name of the variable
  12519. * @param color4 defines the value to be set
  12520. * @returns this effect.
  12521. */
  12522. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12523. /**
  12524. * Store of each shader (The can be looked up using effect.key)
  12525. */
  12526. static ShadersStore: {
  12527. [key: string]: string;
  12528. };
  12529. /**
  12530. * Store of each included file for a shader (The can be looked up using effect.key)
  12531. */
  12532. static IncludesShadersStore: {
  12533. [key: string]: string;
  12534. };
  12535. /**
  12536. * Resets the cache of effects.
  12537. */
  12538. static ResetCache(): void;
  12539. }
  12540. }
  12541. declare module BABYLON {
  12542. class FresnelParameters {
  12543. private _isEnabled;
  12544. isEnabled: boolean;
  12545. leftColor: Color3;
  12546. rightColor: Color3;
  12547. bias: number;
  12548. power: number;
  12549. clone(): FresnelParameters;
  12550. serialize(): any;
  12551. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12552. }
  12553. }
  12554. declare module BABYLON {
  12555. /**
  12556. * Interface to follow in your material defines to integrate easily the
  12557. * Image proccessing functions.
  12558. * @hidden
  12559. */
  12560. interface IImageProcessingConfigurationDefines {
  12561. IMAGEPROCESSING: boolean;
  12562. VIGNETTE: boolean;
  12563. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12564. VIGNETTEBLENDMODEOPAQUE: boolean;
  12565. TONEMAPPING: boolean;
  12566. CONTRAST: boolean;
  12567. EXPOSURE: boolean;
  12568. COLORCURVES: boolean;
  12569. COLORGRADING: boolean;
  12570. COLORGRADING3D: boolean;
  12571. SAMPLER3DGREENDEPTH: boolean;
  12572. SAMPLER3DBGRMAP: boolean;
  12573. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12574. }
  12575. /**
  12576. * This groups together the common properties used for image processing either in direct forward pass
  12577. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12578. * or not.
  12579. */
  12580. class ImageProcessingConfiguration {
  12581. /**
  12582. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12583. */
  12584. colorCurves: Nullable<ColorCurves>;
  12585. private _colorCurvesEnabled;
  12586. /**
  12587. * Gets wether the color curves effect is enabled.
  12588. */
  12589. /**
  12590. * Sets wether the color curves effect is enabled.
  12591. */
  12592. colorCurvesEnabled: boolean;
  12593. /**
  12594. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12595. */
  12596. colorGradingTexture: Nullable<BaseTexture>;
  12597. private _colorGradingEnabled;
  12598. /**
  12599. * Gets wether the color grading effect is enabled.
  12600. */
  12601. /**
  12602. * Sets wether the color grading effect is enabled.
  12603. */
  12604. colorGradingEnabled: boolean;
  12605. private _colorGradingWithGreenDepth;
  12606. /**
  12607. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12608. */
  12609. /**
  12610. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12611. */
  12612. colorGradingWithGreenDepth: boolean;
  12613. private _colorGradingBGR;
  12614. /**
  12615. * Gets wether the color grading texture contains BGR values.
  12616. */
  12617. /**
  12618. * Sets wether the color grading texture contains BGR values.
  12619. */
  12620. colorGradingBGR: boolean;
  12621. _exposure: number;
  12622. /**
  12623. * Gets the Exposure used in the effect.
  12624. */
  12625. /**
  12626. * Sets the Exposure used in the effect.
  12627. */
  12628. exposure: number;
  12629. private _toneMappingEnabled;
  12630. /**
  12631. * Gets wether the tone mapping effect is enabled.
  12632. */
  12633. /**
  12634. * Sets wether the tone mapping effect is enabled.
  12635. */
  12636. toneMappingEnabled: boolean;
  12637. protected _contrast: number;
  12638. /**
  12639. * Gets the contrast used in the effect.
  12640. */
  12641. /**
  12642. * Sets the contrast used in the effect.
  12643. */
  12644. contrast: number;
  12645. /**
  12646. * Vignette stretch size.
  12647. */
  12648. vignetteStretch: number;
  12649. /**
  12650. * Vignette centre X Offset.
  12651. */
  12652. vignetteCentreX: number;
  12653. /**
  12654. * Vignette centre Y Offset.
  12655. */
  12656. vignetteCentreY: number;
  12657. /**
  12658. * Vignette weight or intensity of the vignette effect.
  12659. */
  12660. vignetteWeight: number;
  12661. /**
  12662. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12663. * if vignetteEnabled is set to true.
  12664. */
  12665. vignetteColor: Color4;
  12666. /**
  12667. * Camera field of view used by the Vignette effect.
  12668. */
  12669. vignetteCameraFov: number;
  12670. private _vignetteBlendMode;
  12671. /**
  12672. * Gets the vignette blend mode allowing different kind of effect.
  12673. */
  12674. /**
  12675. * Sets the vignette blend mode allowing different kind of effect.
  12676. */
  12677. vignetteBlendMode: number;
  12678. private _vignetteEnabled;
  12679. /**
  12680. * Gets wether the vignette effect is enabled.
  12681. */
  12682. /**
  12683. * Sets wether the vignette effect is enabled.
  12684. */
  12685. vignetteEnabled: boolean;
  12686. private _applyByPostProcess;
  12687. /**
  12688. * Gets wether the image processing is applied through a post process or not.
  12689. */
  12690. /**
  12691. * Sets wether the image processing is applied through a post process or not.
  12692. */
  12693. applyByPostProcess: boolean;
  12694. private _isEnabled;
  12695. /**
  12696. * Gets wether the image processing is enabled or not.
  12697. */
  12698. /**
  12699. * Sets wether the image processing is enabled or not.
  12700. */
  12701. isEnabled: boolean;
  12702. /**
  12703. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12704. */
  12705. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12706. /**
  12707. * Method called each time the image processing information changes requires to recompile the effect.
  12708. */
  12709. protected _updateParameters(): void;
  12710. getClassName(): string;
  12711. /**
  12712. * Prepare the list of uniforms associated with the Image Processing effects.
  12713. * @param uniformsList The list of uniforms used in the effect
  12714. * @param defines the list of defines currently in use
  12715. */
  12716. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12717. /**
  12718. * Prepare the list of samplers associated with the Image Processing effects.
  12719. * @param uniformsList The list of uniforms used in the effect
  12720. * @param defines the list of defines currently in use
  12721. */
  12722. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12723. /**
  12724. * Prepare the list of defines associated to the shader.
  12725. * @param defines the list of defines to complete
  12726. */
  12727. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12728. /**
  12729. * Returns true if all the image processing information are ready.
  12730. */
  12731. isReady(): boolean;
  12732. /**
  12733. * Binds the image processing to the shader.
  12734. * @param effect The effect to bind to
  12735. */
  12736. bind(effect: Effect, aspectRatio?: number): void;
  12737. /**
  12738. * Clones the current image processing instance.
  12739. * @return The cloned image processing
  12740. */
  12741. clone(): ImageProcessingConfiguration;
  12742. /**
  12743. * Serializes the current image processing instance to a json representation.
  12744. * @return a JSON representation
  12745. */
  12746. serialize(): any;
  12747. /**
  12748. * Parses the image processing from a json representation.
  12749. * @param source the JSON source to parse
  12750. * @return The parsed image processing
  12751. */
  12752. static Parse(source: any): ImageProcessingConfiguration;
  12753. private static _VIGNETTEMODE_MULTIPLY;
  12754. private static _VIGNETTEMODE_OPAQUE;
  12755. /**
  12756. * Used to apply the vignette as a mix with the pixel color.
  12757. */
  12758. static readonly VIGNETTEMODE_MULTIPLY: number;
  12759. /**
  12760. * Used to apply the vignette as a replacement of the pixel color.
  12761. */
  12762. static readonly VIGNETTEMODE_OPAQUE: number;
  12763. }
  12764. }
  12765. declare module BABYLON {
  12766. /**
  12767. * Manages the defines for the Material
  12768. */
  12769. class MaterialDefines {
  12770. private _keys;
  12771. private _isDirty;
  12772. /** @hidden */
  12773. _renderId: number;
  12774. /** @hidden */
  12775. _areLightsDirty: boolean;
  12776. /** @hidden */
  12777. _areAttributesDirty: boolean;
  12778. /** @hidden */
  12779. _areTexturesDirty: boolean;
  12780. /** @hidden */
  12781. _areFresnelDirty: boolean;
  12782. /** @hidden */
  12783. _areMiscDirty: boolean;
  12784. /** @hidden */
  12785. _areImageProcessingDirty: boolean;
  12786. /** @hidden */
  12787. _normals: boolean;
  12788. /** @hidden */
  12789. _uvs: boolean;
  12790. /** @hidden */
  12791. _needNormals: boolean;
  12792. /** @hidden */
  12793. _needUVs: boolean;
  12794. /**
  12795. * Specifies if the material needs to be re-calculated
  12796. */
  12797. readonly isDirty: boolean;
  12798. /**
  12799. * Marks the material to indicate that it has been re-calculated
  12800. */
  12801. markAsProcessed(): void;
  12802. /**
  12803. * Marks the material to indicate that it needs to be re-calculated
  12804. */
  12805. markAsUnprocessed(): void;
  12806. /**
  12807. * Marks the material to indicate all of its defines need to be re-calculated
  12808. */
  12809. markAllAsDirty(): void;
  12810. /**
  12811. * Marks the material to indicate that image processing needs to be re-calculated
  12812. */
  12813. markAsImageProcessingDirty(): void;
  12814. /**
  12815. * Marks the material to indicate the lights need to be re-calculated
  12816. */
  12817. markAsLightDirty(): void;
  12818. /**
  12819. * Marks the attribute state as changed
  12820. */
  12821. markAsAttributesDirty(): void;
  12822. /**
  12823. * Marks the texture state as changed
  12824. */
  12825. markAsTexturesDirty(): void;
  12826. /**
  12827. * Marks the fresnel state as changed
  12828. */
  12829. markAsFresnelDirty(): void;
  12830. /**
  12831. * Marks the misc state as changed
  12832. */
  12833. markAsMiscDirty(): void;
  12834. /**
  12835. * Rebuilds the material defines
  12836. */
  12837. rebuild(): void;
  12838. /**
  12839. * Specifies if two material defines are equal
  12840. * @param other - A material define instance to compare to
  12841. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  12842. */
  12843. isEqual(other: MaterialDefines): boolean;
  12844. /**
  12845. * Clones this instance's defines to another instance
  12846. * @param other - material defines to clone values to
  12847. */
  12848. cloneTo(other: MaterialDefines): void;
  12849. /**
  12850. * Resets the material define values
  12851. */
  12852. reset(): void;
  12853. /**
  12854. * Converts the material define values to a string
  12855. * @returns - String of material define information
  12856. */
  12857. toString(): string;
  12858. }
  12859. /**
  12860. * Base class for the main features of a material in Babylon.js
  12861. */
  12862. class Material implements IAnimatable {
  12863. private static _TriangleFillMode;
  12864. private static _WireFrameFillMode;
  12865. private static _PointFillMode;
  12866. private static _PointListDrawMode;
  12867. private static _LineListDrawMode;
  12868. private static _LineLoopDrawMode;
  12869. private static _LineStripDrawMode;
  12870. private static _TriangleStripDrawMode;
  12871. private static _TriangleFanDrawMode;
  12872. /**
  12873. * Returns the triangle fill mode
  12874. */
  12875. static readonly TriangleFillMode: number;
  12876. /**
  12877. * Returns the wireframe mode
  12878. */
  12879. static readonly WireFrameFillMode: number;
  12880. /**
  12881. * Returns the point fill mode
  12882. */
  12883. static readonly PointFillMode: number;
  12884. /**
  12885. * Returns the point list draw mode
  12886. */
  12887. static readonly PointListDrawMode: number;
  12888. /**
  12889. * Returns the line list draw mode
  12890. */
  12891. static readonly LineListDrawMode: number;
  12892. /**
  12893. * Returns the line loop draw mode
  12894. */
  12895. static readonly LineLoopDrawMode: number;
  12896. /**
  12897. * Returns the line strip draw mode
  12898. */
  12899. static readonly LineStripDrawMode: number;
  12900. /**
  12901. * Returns the triangle strip draw mode
  12902. */
  12903. static readonly TriangleStripDrawMode: number;
  12904. /**
  12905. * Returns the triangle fan draw mode
  12906. */
  12907. static readonly TriangleFanDrawMode: number;
  12908. /**
  12909. * Stores the clock-wise side orientation
  12910. */
  12911. private static _ClockWiseSideOrientation;
  12912. /**
  12913. * Stores the counter clock-wise side orientation
  12914. */
  12915. private static _CounterClockWiseSideOrientation;
  12916. /**
  12917. * Returns the clock-wise side orientation
  12918. */
  12919. static readonly ClockWiseSideOrientation: number;
  12920. /**
  12921. * Returns the counter clock-wise side orientation
  12922. */
  12923. static readonly CounterClockWiseSideOrientation: number;
  12924. /**
  12925. * The dirty texture flag value
  12926. */
  12927. private static _TextureDirtyFlag;
  12928. /**
  12929. * The dirty light flag value
  12930. */
  12931. private static _LightDirtyFlag;
  12932. /**
  12933. * The dirty fresnel flag value
  12934. */
  12935. private static _FresnelDirtyFlag;
  12936. /**
  12937. * The dirty attribute flag value
  12938. */
  12939. private static _AttributesDirtyFlag;
  12940. /**
  12941. * The dirty misc flag value
  12942. */
  12943. private static _MiscDirtyFlag;
  12944. /**
  12945. * Returns the dirty texture flag value
  12946. */
  12947. static readonly TextureDirtyFlag: number;
  12948. /**
  12949. * Returns the dirty light flag value
  12950. */
  12951. static readonly LightDirtyFlag: number;
  12952. /**
  12953. * Returns the dirty fresnel flag value
  12954. */
  12955. static readonly FresnelDirtyFlag: number;
  12956. /**
  12957. * Returns the dirty attributes flag value
  12958. */
  12959. static readonly AttributesDirtyFlag: number;
  12960. /**
  12961. * Returns the dirty misc flag value
  12962. */
  12963. static readonly MiscDirtyFlag: number;
  12964. /**
  12965. * The ID of the material
  12966. */
  12967. id: string;
  12968. /**
  12969. * The name of the material
  12970. */
  12971. name: string;
  12972. /**
  12973. * Specifies if the ready state should be checked on each call
  12974. */
  12975. checkReadyOnEveryCall: boolean;
  12976. /**
  12977. * Specifies if the ready state should be checked once
  12978. */
  12979. checkReadyOnlyOnce: boolean;
  12980. /**
  12981. * The state of the material
  12982. */
  12983. state: string;
  12984. /**
  12985. * The alpha value of the material
  12986. */
  12987. protected _alpha: number;
  12988. /**
  12989. * Gets the alpha value of the material
  12990. */
  12991. /**
  12992. * Sets the alpha value of the material
  12993. */
  12994. alpha: number;
  12995. /**
  12996. * Specifies if back face culling is enabled
  12997. */
  12998. protected _backFaceCulling: boolean;
  12999. /**
  13000. * Gets the back-face culling state
  13001. */
  13002. /**
  13003. * Sets the back-face culling state
  13004. */
  13005. backFaceCulling: boolean;
  13006. /**
  13007. * Stores the value for side orientation
  13008. */
  13009. sideOrientation: number;
  13010. /**
  13011. * Callback triggered when the material is compiled
  13012. */
  13013. onCompiled: (effect: Effect) => void;
  13014. /**
  13015. * Callback triggered when an error occurs
  13016. */
  13017. onError: (effect: Effect, errors: string) => void;
  13018. /**
  13019. * Callback triggered to get the render target textures
  13020. */
  13021. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13022. /**
  13023. * Specifies if the material should be serialized
  13024. */
  13025. doNotSerialize: boolean;
  13026. /**
  13027. * Specifies if the effect should be stored on sub meshes
  13028. */
  13029. storeEffectOnSubMeshes: boolean;
  13030. /**
  13031. * Stores the animations for the material
  13032. */
  13033. animations: Array<Animation>;
  13034. /**
  13035. * An event triggered when the material is disposed
  13036. */
  13037. onDisposeObservable: Observable<Material>;
  13038. /**
  13039. * An observer which watches for dispose events
  13040. */
  13041. private _onDisposeObserver;
  13042. /**
  13043. * Called during a dispose event
  13044. */
  13045. onDispose: () => void;
  13046. /**
  13047. * An event triggered when the material is bound
  13048. */
  13049. onBindObservable: Observable<AbstractMesh>;
  13050. /**
  13051. * An observer which watches for bind events
  13052. */
  13053. private _onBindObserver;
  13054. /**
  13055. * Called during a bind event
  13056. */
  13057. onBind: (Mesh: AbstractMesh) => void;
  13058. /**
  13059. * An event triggered when the material is unbound
  13060. */
  13061. onUnBindObservable: Observable<Material>;
  13062. /**
  13063. * Stores the value of the alpha mode
  13064. */
  13065. private _alphaMode;
  13066. /**
  13067. * Gets the value of the alpha mode
  13068. */
  13069. /**
  13070. * Sets the value of the alpha mode.
  13071. *
  13072. * | Value | Type | Description |
  13073. * | --- | --- | --- |
  13074. * | 0 | ALPHA_DISABLE | |
  13075. * | 1 | ALPHA_ADD | |
  13076. * | 2 | ALPHA_COMBINE | |
  13077. * | 3 | ALPHA_SUBTRACT | |
  13078. * | 4 | ALPHA_MULTIPLY | |
  13079. * | 5 | ALPHA_MAXIMIZED | |
  13080. * | 6 | ALPHA_ONEONE | |
  13081. * | 7 | ALPHA_PREMULTIPLIED | |
  13082. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13083. * | 9 | ALPHA_INTERPOLATE | |
  13084. * | 10 | ALPHA_SCREENMODE | |
  13085. *
  13086. */
  13087. alphaMode: number;
  13088. /**
  13089. * Stores the state of the need depth pre-pass value
  13090. */
  13091. private _needDepthPrePass;
  13092. /**
  13093. * Gets the depth pre-pass value
  13094. */
  13095. /**
  13096. * Sets the need depth pre-pass value
  13097. */
  13098. needDepthPrePass: boolean;
  13099. /**
  13100. * Specifies if depth writing should be disabled
  13101. */
  13102. disableDepthWrite: boolean;
  13103. /**
  13104. * Specifies if depth writing should be forced
  13105. */
  13106. forceDepthWrite: boolean;
  13107. /**
  13108. * Specifies if there should be a separate pass for culling
  13109. */
  13110. separateCullingPass: boolean;
  13111. /**
  13112. * Stores the state specifing if fog should be enabled
  13113. */
  13114. private _fogEnabled;
  13115. /**
  13116. * Gets the value of the fog enabled state
  13117. */
  13118. /**
  13119. * Sets the state for enabling fog
  13120. */
  13121. fogEnabled: boolean;
  13122. /**
  13123. * Stores the size of points
  13124. */
  13125. pointSize: number;
  13126. /**
  13127. * Stores the z offset value
  13128. */
  13129. zOffset: number;
  13130. /**
  13131. * Gets a value specifying if wireframe mode is enabled
  13132. */
  13133. /**
  13134. * Sets the state of wireframe mode
  13135. */
  13136. wireframe: boolean;
  13137. /**
  13138. * Gets the value specifying if point clouds are enabled
  13139. */
  13140. /**
  13141. * Sets the state of point cloud mode
  13142. */
  13143. pointsCloud: boolean;
  13144. /**
  13145. * Gets the material fill mode
  13146. */
  13147. /**
  13148. * Sets the material fill mode
  13149. */
  13150. fillMode: number;
  13151. /**
  13152. * Stores the effects for the material
  13153. */
  13154. _effect: Nullable<Effect>;
  13155. /**
  13156. * Specifies if the material was previously ready
  13157. */
  13158. _wasPreviouslyReady: boolean;
  13159. /**
  13160. * Specifies if uniform buffers should be used
  13161. */
  13162. private _useUBO;
  13163. /**
  13164. * Stores a reference to the scene
  13165. */
  13166. private _scene;
  13167. /**
  13168. * Stores the fill mode state
  13169. */
  13170. private _fillMode;
  13171. /**
  13172. * Specifies if the depth write state should be cached
  13173. */
  13174. private _cachedDepthWriteState;
  13175. /**
  13176. * Stores the uniform buffer
  13177. */
  13178. protected _uniformBuffer: UniformBuffer;
  13179. /**
  13180. * Creates a material instance
  13181. * @param name defines the name of the material
  13182. * @param scene defines the scene to reference
  13183. * @param doNotAdd specifies if the material should be added to the scene
  13184. */
  13185. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13186. /**
  13187. * Returns a string representation of the current material
  13188. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13189. * @returns a string with material information
  13190. */
  13191. toString(fullDetails?: boolean): string;
  13192. /**
  13193. * Gets the class name of the material
  13194. * @returns a string with the class name of the material
  13195. */
  13196. getClassName(): string;
  13197. /**
  13198. * Specifies if updates for the material been locked
  13199. */
  13200. readonly isFrozen: boolean;
  13201. /**
  13202. * Locks updates for the material
  13203. */
  13204. freeze(): void;
  13205. /**
  13206. * Unlocks updates for the material
  13207. */
  13208. unfreeze(): void;
  13209. /**
  13210. * Specifies if the material is ready to be used
  13211. * @param mesh defines the mesh to check
  13212. * @param useInstances specifies if instances should be used
  13213. * @returns a boolean indicating if the material is ready to be used
  13214. */
  13215. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13216. /**
  13217. * Specifies that the submesh is ready to be used
  13218. * @param mesh defines the mesh to check
  13219. * @param subMesh defines which submesh to check
  13220. * @param useInstances specifies that instances should be used
  13221. * @returns a boolean indicating that the submesh is ready or not
  13222. */
  13223. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13224. /**
  13225. * Returns the material effect
  13226. * @returns the effect associated with the material
  13227. */
  13228. getEffect(): Nullable<Effect>;
  13229. /**
  13230. * Returns the current scene
  13231. * @returns a Scene
  13232. */
  13233. getScene(): Scene;
  13234. /**
  13235. * Specifies if the material will require alpha blending
  13236. * @returns a boolean specifying if alpha blending is needed
  13237. */
  13238. needAlphaBlending(): boolean;
  13239. /**
  13240. * Specifies if the mesh will require alpha blending
  13241. * @param mesh defines the mesh to check
  13242. * @returns a boolean specifying if alpha blending is needed for the mesh
  13243. */
  13244. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13245. /**
  13246. * Specifies if this material should be rendered in alpha test mode
  13247. * @returns a boolean specifying if an alpha test is needed.
  13248. */
  13249. needAlphaTesting(): boolean;
  13250. /**
  13251. * Gets the texture used for the alpha test
  13252. * @returns the texture to use for alpha testing
  13253. */
  13254. getAlphaTestTexture(): Nullable<BaseTexture>;
  13255. /**
  13256. * Marks the material to indicate that it needs to be re-calculated
  13257. */
  13258. markDirty(): void;
  13259. /** @hidden */
  13260. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13261. /**
  13262. * Binds the material to the mesh
  13263. * @param world defines the world transformation matrix
  13264. * @param mesh defines the mesh to bind the material to
  13265. */
  13266. bind(world: Matrix, mesh?: Mesh): void;
  13267. /**
  13268. * Binds the submesh to the material
  13269. * @param world defines the world transformation matrix
  13270. * @param mesh defines the mesh containing the submesh
  13271. * @param subMesh defines the submesh to bind the material to
  13272. */
  13273. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13274. /**
  13275. * Binds the world matrix to the material
  13276. * @param world defines the world transformation matrix
  13277. */
  13278. bindOnlyWorldMatrix(world: Matrix): void;
  13279. /**
  13280. * Binds the scene's uniform buffer to the effect.
  13281. * @param effect defines the effect to bind to the scene uniform buffer
  13282. * @param sceneUbo defines the uniform buffer storing scene data
  13283. */
  13284. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13285. /**
  13286. * Binds the view matrix to the effect
  13287. * @param effect defines the effect to bind the view matrix to
  13288. */
  13289. bindView(effect: Effect): void;
  13290. /**
  13291. * Binds the view projection matrix to the effect
  13292. * @param effect defines the effect to bind the view projection matrix to
  13293. */
  13294. bindViewProjection(effect: Effect): void;
  13295. /**
  13296. * Specifies if material alpha testing should be turned on for the mesh
  13297. * @param mesh defines the mesh to check
  13298. */
  13299. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13300. /**
  13301. * Processes to execute after binding the material to a mesh
  13302. * @param mesh defines the rendered mesh
  13303. */
  13304. protected _afterBind(mesh?: Mesh): void;
  13305. /**
  13306. * Unbinds the material from the mesh
  13307. */
  13308. unbind(): void;
  13309. /**
  13310. * Gets the active textures from the material
  13311. * @returns an array of textures
  13312. */
  13313. getActiveTextures(): BaseTexture[];
  13314. /**
  13315. * Specifies if the material uses a texture
  13316. * @param texture defines the texture to check against the material
  13317. * @returns a boolean specifying if the material uses the texture
  13318. */
  13319. hasTexture(texture: BaseTexture): boolean;
  13320. /**
  13321. * Makes a duplicate of the material, and gives it a new name
  13322. * @param name defines the new name for the duplicated material
  13323. * @returns the cloned material
  13324. */
  13325. clone(name: string): Nullable<Material>;
  13326. /**
  13327. * Gets the meshes bound to the material
  13328. * @returns an array of meshes bound to the material
  13329. */
  13330. getBindedMeshes(): AbstractMesh[];
  13331. /**
  13332. * Force shader compilation
  13333. * @param mesh defines the mesh associated with this material
  13334. * @param onCompiled defines a function to execute once the material is compiled
  13335. * @param options defines the options to configure the compilation
  13336. */
  13337. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13338. clipPlane: boolean;
  13339. }>): void;
  13340. /**
  13341. * Force shader compilation
  13342. * @param mesh defines the mesh that will use this material
  13343. * @param options defines additional options for compiling the shaders
  13344. * @returns a promise that resolves when the compilation completes
  13345. */
  13346. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13347. clipPlane: boolean;
  13348. }>): Promise<void>;
  13349. /**
  13350. * Marks a define in the material to indicate that it needs to be re-computed
  13351. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13352. */
  13353. markAsDirty(flag: number): void;
  13354. /**
  13355. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13356. * @param func defines a function which checks material defines against the submeshes
  13357. */
  13358. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13359. /**
  13360. * Indicates that image processing needs to be re-calculated for all submeshes
  13361. */
  13362. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13363. /**
  13364. * Indicates that textures need to be re-calculated for all submeshes
  13365. */
  13366. protected _markAllSubMeshesAsTexturesDirty(): void;
  13367. /**
  13368. * Indicates that fresnel needs to be re-calculated for all submeshes
  13369. */
  13370. protected _markAllSubMeshesAsFresnelDirty(): void;
  13371. /**
  13372. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13373. */
  13374. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13375. /**
  13376. * Indicates that lights need to be re-calculated for all submeshes
  13377. */
  13378. protected _markAllSubMeshesAsLightsDirty(): void;
  13379. /**
  13380. * Indicates that attributes need to be re-calculated for all submeshes
  13381. */
  13382. protected _markAllSubMeshesAsAttributesDirty(): void;
  13383. /**
  13384. * Indicates that misc needs to be re-calculated for all submeshes
  13385. */
  13386. protected _markAllSubMeshesAsMiscDirty(): void;
  13387. /**
  13388. * Indicates that textures and misc need to be re-calculated for all submeshes
  13389. */
  13390. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13391. /**
  13392. * Disposes the material
  13393. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13394. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13395. */
  13396. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13397. /**
  13398. * Serializes this material
  13399. * @returns the serialized material object
  13400. */
  13401. serialize(): any;
  13402. /**
  13403. * Creates a MultiMaterial from parsed MultiMaterial data.
  13404. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  13405. * @param scene defines the hosting scene
  13406. * @returns a new MultiMaterial
  13407. */
  13408. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  13409. /**
  13410. * Creates a material from parsed material data
  13411. * @param parsedMaterial defines parsed material data
  13412. * @param scene defines the hosting scene
  13413. * @param rootUrl defines the root URL to use to load textures
  13414. * @returns a new material
  13415. */
  13416. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13417. }
  13418. }
  13419. declare module BABYLON {
  13420. /**
  13421. * "Static Class" containing the most commonly used helper while dealing with material for
  13422. * rendering purpose.
  13423. *
  13424. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  13425. *
  13426. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  13427. */
  13428. class MaterialHelper {
  13429. /**
  13430. * Bind the current view position to an effect.
  13431. * @param effect The effect to be bound
  13432. * @param scene The scene the eyes position is used from
  13433. */
  13434. static BindEyePosition(effect: Effect, scene: Scene): void;
  13435. /**
  13436. * Helps preparing the defines values about the UVs in used in the effect.
  13437. * UVs are shared as much as we can accross chanels in the shaders.
  13438. * @param texture The texture we are preparing the UVs for
  13439. * @param defines The defines to update
  13440. * @param key The chanel key "diffuse", "specular"... used in the shader
  13441. */
  13442. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  13443. /**
  13444. * Binds a texture matrix value to its corrsponding uniform
  13445. * @param texture The texture to bind the matrix for
  13446. * @param uniformBuffer The uniform buffer receivin the data
  13447. * @param key The chanel key "diffuse", "specular"... used in the shader
  13448. */
  13449. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  13450. /**
  13451. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  13452. * @param mesh defines the current mesh
  13453. * @param scene defines the current scene
  13454. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  13455. * @param pointsCloud defines if point cloud rendering has to be turned on
  13456. * @param fogEnabled defines if fog has to be turned on
  13457. * @param alphaTest defines if alpha testing has to be turned on
  13458. * @param defines defines the current list of defines
  13459. */
  13460. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  13461. /**
  13462. * Helper used to prepare the list of defines associated with frame values for shader compilation
  13463. * @param scene defines the current scene
  13464. * @param engine defines the current engine
  13465. * @param defines specifies the list of active defines
  13466. * @param useInstances defines if instances have to be turned on
  13467. * @param useClipPlane defines if clip plane have to be turned on
  13468. */
  13469. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  13470. /**
  13471. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  13472. * @param mesh The mesh containing the geometry data we will draw
  13473. * @param defines The defines to update
  13474. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  13475. * @param useBones Precise whether bones should be used or not (override mesh info)
  13476. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  13477. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  13478. * @returns false if defines are considered not dirty and have not been checked
  13479. */
  13480. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  13481. /**
  13482. * Prepares the defines related to the light information passed in parameter
  13483. * @param scene The scene we are intending to draw
  13484. * @param mesh The mesh the effect is compiling for
  13485. * @param defines The defines to update
  13486. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  13487. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  13488. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  13489. * @returns true if normals will be required for the rest of the effect
  13490. */
  13491. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  13492. /**
  13493. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  13494. * that won t be acctive due to defines being turned off.
  13495. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  13496. * @param samplersList The samplers list
  13497. * @param defines The defines helping in the list generation
  13498. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  13499. */
  13500. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  13501. /**
  13502. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  13503. * @param defines The defines to update while falling back
  13504. * @param fallbacks The authorized effect fallbacks
  13505. * @param maxSimultaneousLights The maximum number of lights allowed
  13506. * @param rank the current rank of the Effect
  13507. * @returns The newly affected rank
  13508. */
  13509. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  13510. /**
  13511. * Prepares the list of attributes required for morph targets according to the effect defines.
  13512. * @param attribs The current list of supported attribs
  13513. * @param mesh The mesh to prepare the morph targets attributes for
  13514. * @param defines The current Defines of the effect
  13515. */
  13516. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  13517. /**
  13518. * Prepares the list of attributes required for bones according to the effect defines.
  13519. * @param attribs The current list of supported attribs
  13520. * @param mesh The mesh to prepare the bones attributes for
  13521. * @param defines The current Defines of the effect
  13522. * @param fallbacks The current efffect fallback strategy
  13523. */
  13524. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  13525. /**
  13526. * Prepares the list of attributes required for instances according to the effect defines.
  13527. * @param attribs The current list of supported attribs
  13528. * @param defines The current Defines of the effect
  13529. */
  13530. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  13531. /**
  13532. * Binds the light shadow information to the effect for the given mesh.
  13533. * @param light The light containing the generator
  13534. * @param scene The scene the lights belongs to
  13535. * @param mesh The mesh we are binding the information to render
  13536. * @param lightIndex The light index in the effect used to render the mesh
  13537. * @param effect The effect we are binding the data to
  13538. */
  13539. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  13540. /**
  13541. * Binds the light information to the effect.
  13542. * @param light The light containing the generator
  13543. * @param effect The effect we are binding the data to
  13544. * @param lightIndex The light index in the effect used to render
  13545. */
  13546. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  13547. /**
  13548. * Binds the lights information from the scene to the effect for the given mesh.
  13549. * @param scene The scene the lights belongs to
  13550. * @param mesh The mesh we are binding the information to render
  13551. * @param effect The effect we are binding the data to
  13552. * @param defines The generated defines for the effect
  13553. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13554. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13555. */
  13556. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13557. /**
  13558. * Binds the fog information from the scene to the effect for the given mesh.
  13559. * @param scene The scene the lights belongs to
  13560. * @param mesh The mesh we are binding the information to render
  13561. * @param effect The effect we are binding the data to
  13562. */
  13563. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13564. /**
  13565. * Binds the bones information from the mesh to the effect.
  13566. * @param mesh The mesh we are binding the information to render
  13567. * @param effect The effect we are binding the data to
  13568. */
  13569. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13570. /**
  13571. * Binds the morph targets information from the mesh to the effect.
  13572. * @param abstractMesh The mesh we are binding the information to render
  13573. * @param effect The effect we are binding the data to
  13574. */
  13575. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13576. /**
  13577. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13578. * @param defines The generated defines used in the effect
  13579. * @param effect The effect we are binding the data to
  13580. * @param scene The scene we are willing to render with logarithmic scale for
  13581. */
  13582. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13583. /**
  13584. * Binds the clip plane information from the scene to the effect.
  13585. * @param scene The scene the clip plane information are extracted from
  13586. * @param effect The effect we are binding the data to
  13587. */
  13588. static BindClipPlane(effect: Effect, scene: Scene): void;
  13589. }
  13590. }
  13591. declare module BABYLON {
  13592. class MultiMaterial extends Material {
  13593. private _subMaterials;
  13594. subMaterials: Nullable<Material>[];
  13595. constructor(name: string, scene: Scene);
  13596. private _hookArray(array);
  13597. getSubMaterial(index: number): Nullable<Material>;
  13598. getActiveTextures(): BaseTexture[];
  13599. getClassName(): string;
  13600. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13601. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13602. serialize(): any;
  13603. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13604. }
  13605. }
  13606. declare module BABYLON {
  13607. class PushMaterial extends Material {
  13608. protected _activeEffect: Effect;
  13609. protected _normalMatrix: Matrix;
  13610. constructor(name: string, scene: Scene);
  13611. getEffect(): Effect;
  13612. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13613. /**
  13614. * Binds the given world matrix to the active effect
  13615. *
  13616. * @param world the matrix to bind
  13617. */
  13618. bindOnlyWorldMatrix(world: Matrix): void;
  13619. /**
  13620. * Binds the given normal matrix to the active effect
  13621. *
  13622. * @param normalMatrix the matrix to bind
  13623. */
  13624. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13625. bind(world: Matrix, mesh?: Mesh): void;
  13626. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13627. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13628. }
  13629. }
  13630. declare module BABYLON {
  13631. class ShaderMaterial extends Material {
  13632. private _shaderPath;
  13633. private _options;
  13634. private _textures;
  13635. private _textureArrays;
  13636. private _floats;
  13637. private _ints;
  13638. private _floatsArrays;
  13639. private _colors3;
  13640. private _colors3Arrays;
  13641. private _colors4;
  13642. private _vectors2;
  13643. private _vectors3;
  13644. private _vectors4;
  13645. private _matrices;
  13646. private _matrices3x3;
  13647. private _matrices2x2;
  13648. private _vectors2Arrays;
  13649. private _vectors3Arrays;
  13650. private _cachedWorldViewMatrix;
  13651. private _renderId;
  13652. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  13653. getClassName(): string;
  13654. needAlphaBlending(): boolean;
  13655. needAlphaTesting(): boolean;
  13656. private _checkUniform(uniformName);
  13657. setTexture(name: string, texture: Texture): ShaderMaterial;
  13658. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  13659. setFloat(name: string, value: number): ShaderMaterial;
  13660. setInt(name: string, value: number): ShaderMaterial;
  13661. setFloats(name: string, value: number[]): ShaderMaterial;
  13662. setColor3(name: string, value: Color3): ShaderMaterial;
  13663. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  13664. setColor4(name: string, value: Color4): ShaderMaterial;
  13665. setVector2(name: string, value: Vector2): ShaderMaterial;
  13666. setVector3(name: string, value: Vector3): ShaderMaterial;
  13667. setVector4(name: string, value: Vector4): ShaderMaterial;
  13668. setMatrix(name: string, value: Matrix): ShaderMaterial;
  13669. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  13670. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  13671. setArray2(name: string, value: number[]): ShaderMaterial;
  13672. setArray3(name: string, value: number[]): ShaderMaterial;
  13673. private _checkCache(scene, mesh?, useInstances?);
  13674. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13675. bindOnlyWorldMatrix(world: Matrix): void;
  13676. bind(world: Matrix, mesh?: Mesh): void;
  13677. getActiveTextures(): BaseTexture[];
  13678. hasTexture(texture: BaseTexture): boolean;
  13679. clone(name: string): ShaderMaterial;
  13680. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13681. serialize(): any;
  13682. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  13683. }
  13684. }
  13685. declare module BABYLON {
  13686. /** @hidden */
  13687. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13688. MAINUV1: boolean;
  13689. MAINUV2: boolean;
  13690. DIFFUSE: boolean;
  13691. DIFFUSEDIRECTUV: number;
  13692. AMBIENT: boolean;
  13693. AMBIENTDIRECTUV: number;
  13694. OPACITY: boolean;
  13695. OPACITYDIRECTUV: number;
  13696. OPACITYRGB: boolean;
  13697. REFLECTION: boolean;
  13698. EMISSIVE: boolean;
  13699. EMISSIVEDIRECTUV: number;
  13700. SPECULAR: boolean;
  13701. SPECULARDIRECTUV: number;
  13702. BUMP: boolean;
  13703. BUMPDIRECTUV: number;
  13704. PARALLAX: boolean;
  13705. PARALLAXOCCLUSION: boolean;
  13706. SPECULAROVERALPHA: boolean;
  13707. CLIPPLANE: boolean;
  13708. ALPHATEST: boolean;
  13709. DEPTHPREPASS: boolean;
  13710. ALPHAFROMDIFFUSE: boolean;
  13711. POINTSIZE: boolean;
  13712. FOG: boolean;
  13713. SPECULARTERM: boolean;
  13714. DIFFUSEFRESNEL: boolean;
  13715. OPACITYFRESNEL: boolean;
  13716. REFLECTIONFRESNEL: boolean;
  13717. REFRACTIONFRESNEL: boolean;
  13718. EMISSIVEFRESNEL: boolean;
  13719. FRESNEL: boolean;
  13720. NORMAL: boolean;
  13721. UV1: boolean;
  13722. UV2: boolean;
  13723. VERTEXCOLOR: boolean;
  13724. VERTEXALPHA: boolean;
  13725. NUM_BONE_INFLUENCERS: number;
  13726. BonesPerMesh: number;
  13727. INSTANCES: boolean;
  13728. GLOSSINESS: boolean;
  13729. ROUGHNESS: boolean;
  13730. EMISSIVEASILLUMINATION: boolean;
  13731. LINKEMISSIVEWITHDIFFUSE: boolean;
  13732. REFLECTIONFRESNELFROMSPECULAR: boolean;
  13733. LIGHTMAP: boolean;
  13734. LIGHTMAPDIRECTUV: number;
  13735. OBJECTSPACE_NORMALMAP: boolean;
  13736. USELIGHTMAPASSHADOWMAP: boolean;
  13737. REFLECTIONMAP_3D: boolean;
  13738. REFLECTIONMAP_SPHERICAL: boolean;
  13739. REFLECTIONMAP_PLANAR: boolean;
  13740. REFLECTIONMAP_CUBIC: boolean;
  13741. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  13742. REFLECTIONMAP_PROJECTION: boolean;
  13743. REFLECTIONMAP_SKYBOX: boolean;
  13744. REFLECTIONMAP_EXPLICIT: boolean;
  13745. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  13746. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  13747. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  13748. INVERTCUBICMAP: boolean;
  13749. LOGARITHMICDEPTH: boolean;
  13750. REFRACTION: boolean;
  13751. REFRACTIONMAP_3D: boolean;
  13752. REFLECTIONOVERALPHA: boolean;
  13753. TWOSIDEDLIGHTING: boolean;
  13754. SHADOWFLOAT: boolean;
  13755. MORPHTARGETS: boolean;
  13756. MORPHTARGETS_NORMAL: boolean;
  13757. MORPHTARGETS_TANGENT: boolean;
  13758. NUM_MORPH_INFLUENCERS: number;
  13759. NONUNIFORMSCALING: boolean;
  13760. PREMULTIPLYALPHA: boolean;
  13761. IMAGEPROCESSING: boolean;
  13762. VIGNETTE: boolean;
  13763. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13764. VIGNETTEBLENDMODEOPAQUE: boolean;
  13765. TONEMAPPING: boolean;
  13766. CONTRAST: boolean;
  13767. COLORCURVES: boolean;
  13768. COLORGRADING: boolean;
  13769. COLORGRADING3D: boolean;
  13770. SAMPLER3DGREENDEPTH: boolean;
  13771. SAMPLER3DBGRMAP: boolean;
  13772. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13773. /**
  13774. * If the reflection texture on this material is in linear color space
  13775. * @hidden
  13776. */
  13777. IS_REFLECTION_LINEAR: boolean;
  13778. /**
  13779. * If the refraction texture on this material is in linear color space
  13780. * @hidden
  13781. */
  13782. IS_REFRACTION_LINEAR: boolean;
  13783. EXPOSURE: boolean;
  13784. constructor();
  13785. setReflectionMode(modeToEnable: string): void;
  13786. }
  13787. class StandardMaterial extends PushMaterial {
  13788. private _diffuseTexture;
  13789. diffuseTexture: Nullable<BaseTexture>;
  13790. private _ambientTexture;
  13791. ambientTexture: Nullable<BaseTexture>;
  13792. private _opacityTexture;
  13793. opacityTexture: Nullable<BaseTexture>;
  13794. private _reflectionTexture;
  13795. reflectionTexture: Nullable<BaseTexture>;
  13796. private _emissiveTexture;
  13797. emissiveTexture: Nullable<BaseTexture>;
  13798. private _specularTexture;
  13799. specularTexture: Nullable<BaseTexture>;
  13800. private _bumpTexture;
  13801. bumpTexture: Nullable<BaseTexture>;
  13802. private _lightmapTexture;
  13803. lightmapTexture: Nullable<BaseTexture>;
  13804. private _refractionTexture;
  13805. refractionTexture: Nullable<BaseTexture>;
  13806. ambientColor: Color3;
  13807. diffuseColor: Color3;
  13808. specularColor: Color3;
  13809. emissiveColor: Color3;
  13810. specularPower: number;
  13811. private _useAlphaFromDiffuseTexture;
  13812. useAlphaFromDiffuseTexture: boolean;
  13813. private _useEmissiveAsIllumination;
  13814. useEmissiveAsIllumination: boolean;
  13815. private _linkEmissiveWithDiffuse;
  13816. linkEmissiveWithDiffuse: boolean;
  13817. private _useSpecularOverAlpha;
  13818. useSpecularOverAlpha: boolean;
  13819. private _useReflectionOverAlpha;
  13820. useReflectionOverAlpha: boolean;
  13821. private _disableLighting;
  13822. disableLighting: boolean;
  13823. private _useObjectSpaceNormalMap;
  13824. /**
  13825. * Allows using an object space normal map (instead of tangent space).
  13826. */
  13827. useObjectSpaceNormalMap: boolean;
  13828. private _useParallax;
  13829. useParallax: boolean;
  13830. private _useParallaxOcclusion;
  13831. useParallaxOcclusion: boolean;
  13832. parallaxScaleBias: number;
  13833. private _roughness;
  13834. roughness: number;
  13835. indexOfRefraction: number;
  13836. invertRefractionY: boolean;
  13837. /**
  13838. * Defines the alpha limits in alpha test mode
  13839. */
  13840. alphaCutOff: number;
  13841. private _useLightmapAsShadowmap;
  13842. useLightmapAsShadowmap: boolean;
  13843. private _diffuseFresnelParameters;
  13844. diffuseFresnelParameters: FresnelParameters;
  13845. private _opacityFresnelParameters;
  13846. opacityFresnelParameters: FresnelParameters;
  13847. private _reflectionFresnelParameters;
  13848. reflectionFresnelParameters: FresnelParameters;
  13849. private _refractionFresnelParameters;
  13850. refractionFresnelParameters: FresnelParameters;
  13851. private _emissiveFresnelParameters;
  13852. emissiveFresnelParameters: FresnelParameters;
  13853. private _useReflectionFresnelFromSpecular;
  13854. useReflectionFresnelFromSpecular: boolean;
  13855. private _useGlossinessFromSpecularMapAlpha;
  13856. useGlossinessFromSpecularMapAlpha: boolean;
  13857. private _maxSimultaneousLights;
  13858. maxSimultaneousLights: number;
  13859. /**
  13860. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  13861. */
  13862. private _invertNormalMapX;
  13863. invertNormalMapX: boolean;
  13864. /**
  13865. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  13866. */
  13867. private _invertNormalMapY;
  13868. invertNormalMapY: boolean;
  13869. /**
  13870. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  13871. */
  13872. private _twoSidedLighting;
  13873. twoSidedLighting: boolean;
  13874. /**
  13875. * Default configuration related to image processing available in the standard Material.
  13876. */
  13877. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13878. /**
  13879. * Gets the image processing configuration used either in this material.
  13880. */
  13881. /**
  13882. * Sets the Default image processing configuration used either in the this material.
  13883. *
  13884. * If sets to null, the scene one is in use.
  13885. */
  13886. imageProcessingConfiguration: ImageProcessingConfiguration;
  13887. /**
  13888. * Keep track of the image processing observer to allow dispose and replace.
  13889. */
  13890. private _imageProcessingObserver;
  13891. /**
  13892. * Attaches a new image processing configuration to the Standard Material.
  13893. * @param configuration
  13894. */
  13895. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13896. /**
  13897. * Gets wether the color curves effect is enabled.
  13898. */
  13899. /**
  13900. * Sets wether the color curves effect is enabled.
  13901. */
  13902. cameraColorCurvesEnabled: boolean;
  13903. /**
  13904. * Gets wether the color grading effect is enabled.
  13905. */
  13906. /**
  13907. * Gets wether the color grading effect is enabled.
  13908. */
  13909. cameraColorGradingEnabled: boolean;
  13910. /**
  13911. * Gets wether tonemapping is enabled or not.
  13912. */
  13913. /**
  13914. * Sets wether tonemapping is enabled or not
  13915. */
  13916. cameraToneMappingEnabled: boolean;
  13917. /**
  13918. * The camera exposure used on this material.
  13919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13920. * This corresponds to a photographic exposure.
  13921. */
  13922. /**
  13923. * The camera exposure used on this material.
  13924. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13925. * This corresponds to a photographic exposure.
  13926. */
  13927. cameraExposure: number;
  13928. /**
  13929. * Gets The camera contrast used on this material.
  13930. */
  13931. /**
  13932. * Sets The camera contrast used on this material.
  13933. */
  13934. cameraContrast: number;
  13935. /**
  13936. * Gets the Color Grading 2D Lookup Texture.
  13937. */
  13938. /**
  13939. * Sets the Color Grading 2D Lookup Texture.
  13940. */
  13941. cameraColorGradingTexture: Nullable<BaseTexture>;
  13942. /**
  13943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13945. * 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;
  13946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13947. */
  13948. /**
  13949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13951. * 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;
  13952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13953. */
  13954. cameraColorCurves: Nullable<ColorCurves>;
  13955. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  13956. protected _renderTargets: SmartArray<RenderTargetTexture>;
  13957. protected _worldViewProjectionMatrix: Matrix;
  13958. protected _globalAmbientColor: Color3;
  13959. protected _useLogarithmicDepth: boolean;
  13960. constructor(name: string, scene: Scene);
  13961. getClassName(): string;
  13962. useLogarithmicDepth: boolean;
  13963. needAlphaBlending(): boolean;
  13964. needAlphaTesting(): boolean;
  13965. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  13966. getAlphaTestTexture(): Nullable<BaseTexture>;
  13967. /**
  13968. * Child classes can use it to update shaders
  13969. */
  13970. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  13971. buildUniformLayout(): void;
  13972. unbind(): void;
  13973. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13974. getAnimatables(): IAnimatable[];
  13975. getActiveTextures(): BaseTexture[];
  13976. hasTexture(texture: BaseTexture): boolean;
  13977. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13978. clone(name: string): StandardMaterial;
  13979. serialize(): any;
  13980. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  13981. static _DiffuseTextureEnabled: boolean;
  13982. static DiffuseTextureEnabled: boolean;
  13983. static _AmbientTextureEnabled: boolean;
  13984. static AmbientTextureEnabled: boolean;
  13985. static _OpacityTextureEnabled: boolean;
  13986. static OpacityTextureEnabled: boolean;
  13987. static _ReflectionTextureEnabled: boolean;
  13988. static ReflectionTextureEnabled: boolean;
  13989. static _EmissiveTextureEnabled: boolean;
  13990. static EmissiveTextureEnabled: boolean;
  13991. static _SpecularTextureEnabled: boolean;
  13992. static SpecularTextureEnabled: boolean;
  13993. static _BumpTextureEnabled: boolean;
  13994. static BumpTextureEnabled: boolean;
  13995. static _LightmapTextureEnabled: boolean;
  13996. static LightmapTextureEnabled: boolean;
  13997. static _RefractionTextureEnabled: boolean;
  13998. static RefractionTextureEnabled: boolean;
  13999. static _ColorGradingTextureEnabled: boolean;
  14000. static ColorGradingTextureEnabled: boolean;
  14001. static _FresnelEnabled: boolean;
  14002. static FresnelEnabled: boolean;
  14003. }
  14004. }
  14005. declare module BABYLON {
  14006. class UniformBuffer {
  14007. private _engine;
  14008. private _buffer;
  14009. private _data;
  14010. private _bufferData;
  14011. private _dynamic?;
  14012. private _uniformLocations;
  14013. private _uniformSizes;
  14014. private _uniformLocationPointer;
  14015. private _needSync;
  14016. private _noUBO;
  14017. private _currentEffect;
  14018. private static _MAX_UNIFORM_SIZE;
  14019. private static _tempBuffer;
  14020. /**
  14021. * Wrapper for updateUniform.
  14022. * @method updateMatrix3x3
  14023. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14024. * @param {Float32Array} matrix
  14025. */
  14026. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14027. /**
  14028. * Wrapper for updateUniform.
  14029. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14030. * @param {Float32Array} matrix
  14031. */
  14032. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14033. /**
  14034. * Wrapper for updateUniform.
  14035. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14036. * @param {number} x
  14037. */
  14038. updateFloat: (name: string, x: number) => void;
  14039. /**
  14040. * Wrapper for updateUniform.
  14041. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14042. * @param {number} x
  14043. * @param {number} y
  14044. * @param {string} [suffix] Suffix to add to the uniform name.
  14045. */
  14046. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14047. /**
  14048. * Wrapper for updateUniform.
  14049. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14050. * @param {number} x
  14051. * @param {number} y
  14052. * @param {number} z
  14053. * @param {string} [suffix] Suffix to add to the uniform name.
  14054. */
  14055. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14056. /**
  14057. * Wrapper for updateUniform.
  14058. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14059. * @param {number} x
  14060. * @param {number} y
  14061. * @param {number} z
  14062. * @param {number} w
  14063. * @param {string} [suffix] Suffix to add to the uniform name.
  14064. */
  14065. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14066. /**
  14067. * Wrapper for updateUniform.
  14068. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14069. * @param {Matrix} A 4x4 matrix.
  14070. */
  14071. updateMatrix: (name: string, mat: Matrix) => void;
  14072. /**
  14073. * Wrapper for updateUniform.
  14074. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14075. * @param {Vector3} vector
  14076. */
  14077. updateVector3: (name: string, vector: Vector3) => void;
  14078. /**
  14079. * Wrapper for updateUniform.
  14080. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14081. * @param {Vector4} vector
  14082. */
  14083. updateVector4: (name: string, vector: Vector4) => void;
  14084. /**
  14085. * Wrapper for updateUniform.
  14086. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14087. * @param {Color3} color
  14088. * @param {string} [suffix] Suffix to add to the uniform name.
  14089. */
  14090. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14091. /**
  14092. * Wrapper for updateUniform.
  14093. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14094. * @param {Color3} color
  14095. * @param {number} alpha
  14096. * @param {string} [suffix] Suffix to add to the uniform name.
  14097. */
  14098. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14099. /**
  14100. * Uniform buffer objects.
  14101. *
  14102. * Handles blocks of uniform on the GPU.
  14103. *
  14104. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14105. *
  14106. * For more information, please refer to :
  14107. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14108. */
  14109. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14110. /**
  14111. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14112. * or just falling back on setUniformXXX calls.
  14113. */
  14114. readonly useUbo: boolean;
  14115. /**
  14116. * Indicates if the WebGL underlying uniform buffer is in sync
  14117. * with the javascript cache data.
  14118. */
  14119. readonly isSync: boolean;
  14120. /**
  14121. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14122. * Also, a dynamic UniformBuffer will disable cache verification and always
  14123. * update the underlying WebGL uniform buffer to the GPU.
  14124. */
  14125. isDynamic(): boolean;
  14126. /**
  14127. * The data cache on JS side.
  14128. */
  14129. getData(): Float32Array;
  14130. /**
  14131. * The underlying WebGL Uniform buffer.
  14132. */
  14133. getBuffer(): Nullable<WebGLBuffer>;
  14134. /**
  14135. * std140 layout specifies how to align data within an UBO structure.
  14136. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14137. * for specs.
  14138. */
  14139. private _fillAlignment(size);
  14140. /**
  14141. * Adds an uniform in the buffer.
  14142. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14143. * for the layout to be correct !
  14144. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14145. * @param {number|number[]} size Data size, or data directly.
  14146. */
  14147. addUniform(name: string, size: number | number[]): void;
  14148. /**
  14149. * Wrapper for addUniform.
  14150. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14151. * @param {Matrix} mat A 4x4 matrix.
  14152. */
  14153. addMatrix(name: string, mat: Matrix): void;
  14154. /**
  14155. * Wrapper for addUniform.
  14156. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14157. * @param {number} x
  14158. * @param {number} y
  14159. */
  14160. addFloat2(name: string, x: number, y: number): void;
  14161. /**
  14162. * Wrapper for addUniform.
  14163. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14164. * @param {number} x
  14165. * @param {number} y
  14166. * @param {number} z
  14167. */
  14168. addFloat3(name: string, x: number, y: number, z: number): void;
  14169. /**
  14170. * Wrapper for addUniform.
  14171. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14172. * @param {Color3} color
  14173. */
  14174. addColor3(name: string, color: Color3): void;
  14175. /**
  14176. * Wrapper for addUniform.
  14177. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14178. * @param {Color3} color
  14179. * @param {number} alpha
  14180. */
  14181. addColor4(name: string, color: Color3, alpha: number): void;
  14182. /**
  14183. * Wrapper for addUniform.
  14184. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14185. * @param {Vector3} vector
  14186. */
  14187. addVector3(name: string, vector: Vector3): void;
  14188. /**
  14189. * Wrapper for addUniform.
  14190. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14191. */
  14192. addMatrix3x3(name: string): void;
  14193. /**
  14194. * Wrapper for addUniform.
  14195. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14196. */
  14197. addMatrix2x2(name: string): void;
  14198. /**
  14199. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14200. */
  14201. create(): void;
  14202. _rebuild(): void;
  14203. /**
  14204. * Updates the WebGL Uniform Buffer on the GPU.
  14205. * If the `dynamic` flag is set to true, no cache comparison is done.
  14206. * Otherwise, the buffer will be updated only if the cache differs.
  14207. */
  14208. update(): void;
  14209. /**
  14210. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14211. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14212. * @param {number[]|Float32Array} data Flattened data
  14213. * @param {number} size Size of the data.
  14214. */
  14215. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14216. private _updateMatrix3x3ForUniform(name, matrix);
  14217. private _updateMatrix3x3ForEffect(name, matrix);
  14218. private _updateMatrix2x2ForEffect(name, matrix);
  14219. private _updateMatrix2x2ForUniform(name, matrix);
  14220. private _updateFloatForEffect(name, x);
  14221. private _updateFloatForUniform(name, x);
  14222. private _updateFloat2ForEffect(name, x, y, suffix?);
  14223. private _updateFloat2ForUniform(name, x, y, suffix?);
  14224. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  14225. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  14226. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  14227. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  14228. private _updateMatrixForEffect(name, mat);
  14229. private _updateMatrixForUniform(name, mat);
  14230. private _updateVector3ForEffect(name, vector);
  14231. private _updateVector3ForUniform(name, vector);
  14232. private _updateVector4ForEffect(name, vector);
  14233. private _updateVector4ForUniform(name, vector);
  14234. private _updateColor3ForEffect(name, color, suffix?);
  14235. private _updateColor3ForUniform(name, color, suffix?);
  14236. private _updateColor4ForEffect(name, color, alpha, suffix?);
  14237. private _updateColor4ForUniform(name, color, alpha, suffix?);
  14238. /**
  14239. * Sets a sampler uniform on the effect.
  14240. * @param {string} name Name of the sampler.
  14241. * @param {Texture} texture
  14242. */
  14243. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  14244. /**
  14245. * Directly updates the value of the uniform in the cache AND on the GPU.
  14246. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14247. * @param {number[]|Float32Array} data Flattened data
  14248. */
  14249. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  14250. /**
  14251. * Binds this uniform buffer to an effect.
  14252. * @param {Effect} effect
  14253. * @param {string} name Name of the uniform block in the shader.
  14254. */
  14255. bindToEffect(effect: Effect, name: string): void;
  14256. /**
  14257. * Disposes the uniform buffer.
  14258. */
  14259. dispose(): void;
  14260. }
  14261. }
  14262. declare module BABYLON {
  14263. class Scalar {
  14264. /**
  14265. * Two pi constants convenient for computation.
  14266. */
  14267. static TwoPi: number;
  14268. /**
  14269. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14270. */
  14271. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14272. /**
  14273. * Returns a string : the upper case translation of the number i to hexadecimal.
  14274. */
  14275. static ToHex(i: number): string;
  14276. /**
  14277. * Returns -1 if value is negative and +1 is value is positive.
  14278. * Returns the value itself if it's equal to zero.
  14279. */
  14280. static Sign(value: number): number;
  14281. /**
  14282. * Returns the value itself if it's between min and max.
  14283. * Returns min if the value is lower than min.
  14284. * Returns max if the value is greater than max.
  14285. */
  14286. static Clamp(value: number, min?: number, max?: number): number;
  14287. /**
  14288. * Returns the log2 of value.
  14289. */
  14290. static Log2(value: number): number;
  14291. /**
  14292. * Loops the value, so that it is never larger than length and never smaller than 0.
  14293. *
  14294. * This is similar to the modulo operator but it works with floating point numbers.
  14295. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14296. * With t = 5 and length = 2.5, the result would be 0.0.
  14297. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14298. */
  14299. static Repeat(value: number, length: number): number;
  14300. /**
  14301. * Normalize the value between 0.0 and 1.0 using min and max values
  14302. */
  14303. static Normalize(value: number, min: number, max: number): number;
  14304. /**
  14305. * Denormalize the value from 0.0 and 1.0 using min and max values
  14306. */
  14307. static Denormalize(normalized: number, min: number, max: number): number;
  14308. /**
  14309. * Calculates the shortest difference between two given angles given in degrees.
  14310. */
  14311. static DeltaAngle(current: number, target: number): number;
  14312. /**
  14313. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14314. *
  14315. * The returned value will move back and forth between 0 and length
  14316. */
  14317. static PingPong(tx: number, length: number): number;
  14318. /**
  14319. * Interpolates between min and max with smoothing at the limits.
  14320. *
  14321. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14322. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14323. */
  14324. static SmoothStep(from: number, to: number, tx: number): number;
  14325. /**
  14326. * Moves a value current towards target.
  14327. *
  14328. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14329. * Negative values of maxDelta pushes the value away from target.
  14330. */
  14331. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14332. /**
  14333. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14334. *
  14335. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14336. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14337. */
  14338. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14339. /**
  14340. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14341. */
  14342. static Lerp(start: number, end: number, amount: number): number;
  14343. /**
  14344. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14345. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14346. */
  14347. static LerpAngle(start: number, end: number, amount: number): number;
  14348. /**
  14349. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14350. */
  14351. static InverseLerp(a: number, b: number, value: number): number;
  14352. /**
  14353. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14354. */
  14355. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14356. /**
  14357. * Returns a random float number between and min and max values
  14358. */
  14359. static RandomRange(min: number, max: number): number;
  14360. /**
  14361. * This function returns percentage of a number in a given range.
  14362. *
  14363. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14364. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14365. */
  14366. static RangeToPercent(number: number, min: number, max: number): number;
  14367. /**
  14368. * This function returns number that corresponds to the percentage in a given range.
  14369. *
  14370. * PercentToRange(0.34,0,100) will return 34.
  14371. */
  14372. static PercentToRange(percent: number, min: number, max: number): number;
  14373. /**
  14374. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14375. * @param angle The angle to normalize in radian.
  14376. * @return The converted angle.
  14377. */
  14378. static NormalizeRadians(angle: number): number;
  14379. }
  14380. }
  14381. declare module BABYLON {
  14382. const ToGammaSpace: number;
  14383. const ToLinearSpace = 2.2;
  14384. const Epsilon = 0.001;
  14385. /**
  14386. * Class used to hold a RBG color
  14387. */
  14388. class Color3 {
  14389. /**
  14390. * Defines the red component (between 0 and 1, default is 0)
  14391. */
  14392. r: number;
  14393. /**
  14394. * Defines the green component (between 0 and 1, default is 0)
  14395. */
  14396. g: number;
  14397. /**
  14398. * Defines the blue component (between 0 and 1, default is 0)
  14399. */
  14400. b: number;
  14401. /**
  14402. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14403. * @param r defines the red component (between 0 and 1, default is 0)
  14404. * @param g defines the green component (between 0 and 1, default is 0)
  14405. * @param b defines the blue component (between 0 and 1, default is 0)
  14406. */
  14407. constructor(
  14408. /**
  14409. * Defines the red component (between 0 and 1, default is 0)
  14410. */
  14411. r?: number,
  14412. /**
  14413. * Defines the green component (between 0 and 1, default is 0)
  14414. */
  14415. g?: number,
  14416. /**
  14417. * Defines the blue component (between 0 and 1, default is 0)
  14418. */
  14419. b?: number);
  14420. /**
  14421. * Creates a string with the Color3 current values
  14422. * @returns the string representation of the Color3 object
  14423. */
  14424. toString(): string;
  14425. /**
  14426. * Returns the string "Color3"
  14427. * @returns "Color3"
  14428. */
  14429. getClassName(): string;
  14430. /**
  14431. * Compute the Color3 hash code
  14432. * @returns an unique number that can be used to hash Color3 objects
  14433. */
  14434. getHashCode(): number;
  14435. /**
  14436. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14437. * @param array defines the array where to store the r,g,b components
  14438. * @param index defines an optional index in the target array to define where to start storing values
  14439. * @returns the current Color3 object
  14440. */
  14441. toArray(array: FloatArray, index?: number): Color3;
  14442. /**
  14443. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  14444. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14445. * @returns a new {BABYLON.Color4} object
  14446. */
  14447. toColor4(alpha?: number): Color4;
  14448. /**
  14449. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14450. * @returns the new array
  14451. */
  14452. asArray(): number[];
  14453. /**
  14454. * Returns the luminance value
  14455. * @returns a float value
  14456. */
  14457. toLuminance(): number;
  14458. /**
  14459. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  14460. * @param otherColor defines the second operand
  14461. * @returns the new Color3 object
  14462. */
  14463. multiply(otherColor: Color3): Color3;
  14464. /**
  14465. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  14466. * @param otherColor defines the second operand
  14467. * @param result defines the Color3 object where to store the result
  14468. * @returns the current Color3
  14469. */
  14470. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14471. /**
  14472. * Determines equality between Color3 objects
  14473. * @param otherColor defines the second operand
  14474. * @returns true if the rgb values are equal to the given ones
  14475. */
  14476. equals(otherColor: Color3): boolean;
  14477. /**
  14478. * Determines equality between the current Color3 object and a set of r,b,g values
  14479. * @param r defines the red component to check
  14480. * @param g defines the green component to check
  14481. * @param b defines the blue component to check
  14482. * @returns true if the rgb values are equal to the given ones
  14483. */
  14484. equalsFloats(r: number, g: number, b: number): boolean;
  14485. /**
  14486. * Multiplies in place each rgb value by scale
  14487. * @param scale defines the scaling factor
  14488. * @returns the updated Color3
  14489. */
  14490. scale(scale: number): Color3;
  14491. /**
  14492. * Multiplies the rgb values by scale and stores the result into "result"
  14493. * @param scale defines the scaling factor
  14494. * @param result defines the Color3 object where to store the result
  14495. * @returns the unmodified current Color3
  14496. */
  14497. scaleToRef(scale: number, result: Color3): Color3;
  14498. /**
  14499. * Scale the current Color3 values by a factor and add the result to a given Color3
  14500. * @param scale defines the scale factor
  14501. * @param result defines color to store the result into
  14502. * @returns the unmodified current Color3
  14503. */
  14504. scaleAndAddToRef(scale: number, result: Color3): Color3;
  14505. /**
  14506. * Clamps the rgb values by the min and max values and stores the result into "result"
  14507. * @param min defines minimum clamping value (default is 0)
  14508. * @param max defines maximum clamping value (default is 1)
  14509. * @param result defines color to store the result into
  14510. * @returns the original Color3
  14511. */
  14512. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  14513. /**
  14514. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  14515. * @param otherColor defines the second operand
  14516. * @returns the new Color3
  14517. */
  14518. add(otherColor: Color3): Color3;
  14519. /**
  14520. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  14521. * @param otherColor defines the second operand
  14522. * @param result defines Color3 object to store the result into
  14523. * @returns the unmodified current Color3
  14524. */
  14525. addToRef(otherColor: Color3, result: Color3): Color3;
  14526. /**
  14527. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  14528. * @param otherColor defines the second operand
  14529. * @returns the new Color3
  14530. */
  14531. subtract(otherColor: Color3): Color3;
  14532. /**
  14533. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  14534. * @param otherColor defines the second operand
  14535. * @param result defines Color3 object to store the result into
  14536. * @returns the unmodified current Color3
  14537. */
  14538. subtractToRef(otherColor: Color3, result: Color3): Color3;
  14539. /**
  14540. * Copy the current object
  14541. * @returns a new Color3 copied the current one
  14542. */
  14543. clone(): Color3;
  14544. /**
  14545. * Copies the rgb values from the source in the current Color3
  14546. * @param source defines the source Color3 object
  14547. * @returns the updated Color3 object
  14548. */
  14549. copyFrom(source: Color3): Color3;
  14550. /**
  14551. * Updates the Color3 rgb values from the given floats
  14552. * @param r defines the red component to read from
  14553. * @param g defines the green component to read from
  14554. * @param b defines the blue component to read from
  14555. * @returns the current Color3 object
  14556. */
  14557. copyFromFloats(r: number, g: number, b: number): Color3;
  14558. /**
  14559. * Updates the Color3 rgb values from the given floats
  14560. * @param r defines the red component to read from
  14561. * @param g defines the green component to read from
  14562. * @param b defines the blue component to read from
  14563. * @returns the current Color3 object
  14564. */
  14565. set(r: number, g: number, b: number): Color3;
  14566. /**
  14567. * Compute the Color3 hexadecimal code as a string
  14568. * @returns a string containing the hexadecimal representation of the Color3 object
  14569. */
  14570. toHexString(): string;
  14571. /**
  14572. * Computes a new Color3 converted from the current one to linear space
  14573. * @returns a new Color3 object
  14574. */
  14575. toLinearSpace(): Color3;
  14576. /**
  14577. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  14578. * @param convertedColor defines the Color3 object where to store the linear space version
  14579. * @returns the unmodified Color3
  14580. */
  14581. toLinearSpaceToRef(convertedColor: Color3): Color3;
  14582. /**
  14583. * Computes a new Color3 converted from the current one to gamma space
  14584. * @returns a new Color3 object
  14585. */
  14586. toGammaSpace(): Color3;
  14587. /**
  14588. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  14589. * @param convertedColor defines the Color3 object where to store the gamma space version
  14590. * @returns the unmodified Color3
  14591. */
  14592. toGammaSpaceToRef(convertedColor: Color3): Color3;
  14593. /**
  14594. * Creates a new Color3 from the string containing valid hexadecimal values
  14595. * @param hex defines a string containing valid hexadecimal values
  14596. * @returns a new Color3 object
  14597. */
  14598. static FromHexString(hex: string): Color3;
  14599. /**
  14600. * Creates a new Vector3 from the starting index of the given array
  14601. * @param array defines the source array
  14602. * @param offset defines an offset in the source array
  14603. * @returns a new Color3 object
  14604. */
  14605. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  14606. /**
  14607. * Creates a new Color3 from integer values (< 256)
  14608. * @param r defines the red component to read from (value between 0 and 255)
  14609. * @param g defines the green component to read from (value between 0 and 255)
  14610. * @param b defines the blue component to read from (value between 0 and 255)
  14611. * @returns a new Color3 object
  14612. */
  14613. static FromInts(r: number, g: number, b: number): Color3;
  14614. /**
  14615. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  14616. * @param start defines the start Color3 value
  14617. * @param end defines the end Color3 value
  14618. * @param amount defines the gradient value between start and end
  14619. * @returns a new Color3 object
  14620. */
  14621. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  14622. /**
  14623. * Returns a Color3 value containing a red color
  14624. * @returns a new Color3 object
  14625. */
  14626. static Red(): Color3;
  14627. /**
  14628. * Returns a Color3 value containing a green color
  14629. * @returns a new Color3 object
  14630. */
  14631. static Green(): Color3;
  14632. /**
  14633. * Returns a Color3 value containing a blue color
  14634. * @returns a new Color3 object
  14635. */
  14636. static Blue(): Color3;
  14637. /**
  14638. * Returns a Color3 value containing a black color
  14639. * @returns a new Color3 object
  14640. */
  14641. static Black(): Color3;
  14642. /**
  14643. * Returns a Color3 value containing a white color
  14644. * @returns a new Color3 object
  14645. */
  14646. static White(): Color3;
  14647. /**
  14648. * Returns a Color3 value containing a purple color
  14649. * @returns a new Color3 object
  14650. */
  14651. static Purple(): Color3;
  14652. /**
  14653. * Returns a Color3 value containing a magenta color
  14654. * @returns a new Color3 object
  14655. */
  14656. static Magenta(): Color3;
  14657. /**
  14658. * Returns a Color3 value containing a yellow color
  14659. * @returns a new Color3 object
  14660. */
  14661. static Yellow(): Color3;
  14662. /**
  14663. * Returns a Color3 value containing a gray color
  14664. * @returns a new Color3 object
  14665. */
  14666. static Gray(): Color3;
  14667. /**
  14668. * Returns a Color3 value containing a teal color
  14669. * @returns a new Color3 object
  14670. */
  14671. static Teal(): Color3;
  14672. /**
  14673. * Returns a Color3 value containing a random color
  14674. * @returns a new Color3 object
  14675. */
  14676. static Random(): Color3;
  14677. }
  14678. /**
  14679. * Class used to hold a RBGA color
  14680. */
  14681. class Color4 {
  14682. /**
  14683. * Defines the red component (between 0 and 1, default is 0)
  14684. */
  14685. r: number;
  14686. /**
  14687. * Defines the green component (between 0 and 1, default is 0)
  14688. */
  14689. g: number;
  14690. /**
  14691. * Defines the blue component (between 0 and 1, default is 0)
  14692. */
  14693. b: number;
  14694. /**
  14695. * Defines the alpha component (between 0 and 1, default is 1)
  14696. */
  14697. a: number;
  14698. /**
  14699. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  14700. * @param r defines the red component (between 0 and 1, default is 0)
  14701. * @param g defines the green component (between 0 and 1, default is 0)
  14702. * @param b defines the blue component (between 0 and 1, default is 0)
  14703. * @param a defines the alpha component (between 0 and 1, default is 1)
  14704. */
  14705. constructor(
  14706. /**
  14707. * Defines the red component (between 0 and 1, default is 0)
  14708. */
  14709. r?: number,
  14710. /**
  14711. * Defines the green component (between 0 and 1, default is 0)
  14712. */
  14713. g?: number,
  14714. /**
  14715. * Defines the blue component (between 0 and 1, default is 0)
  14716. */
  14717. b?: number,
  14718. /**
  14719. * Defines the alpha component (between 0 and 1, default is 1)
  14720. */
  14721. a?: number);
  14722. /**
  14723. * Adds in place the given Color4 values to the current Color4 object
  14724. * @param right defines the second operand
  14725. * @returns the current updated Color4 object
  14726. */
  14727. addInPlace(right: Color4): Color4;
  14728. /**
  14729. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  14730. * @returns the new array
  14731. */
  14732. asArray(): number[];
  14733. /**
  14734. * Stores from the starting index in the given array the Color4 successive values
  14735. * @param array defines the array where to store the r,g,b components
  14736. * @param index defines an optional index in the target array to define where to start storing values
  14737. * @returns the current Color4 object
  14738. */
  14739. toArray(array: number[], index?: number): Color4;
  14740. /**
  14741. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  14742. * @param right defines the second operand
  14743. * @returns a new Color4 object
  14744. */
  14745. add(right: Color4): Color4;
  14746. /**
  14747. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  14748. * @param right defines the second operand
  14749. * @returns a new Color4 object
  14750. */
  14751. subtract(right: Color4): Color4;
  14752. /**
  14753. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  14754. * @param right defines the second operand
  14755. * @param result defines the Color4 object where to store the result
  14756. * @returns the current Color4 object
  14757. */
  14758. subtractToRef(right: Color4, result: Color4): Color4;
  14759. /**
  14760. * Creates a new Color4 with the current Color4 values multiplied by scale
  14761. * @param scale defines the scaling factor to apply
  14762. * @returns a new Color4 object
  14763. */
  14764. scale(scale: number): Color4;
  14765. /**
  14766. * Multiplies the current Color4 values by scale and stores the result in "result"
  14767. * @param scale defines the scaling factor to apply
  14768. * @param result defines the Color4 object where to store the result
  14769. * @returns the current unmodified Color4
  14770. */
  14771. scaleToRef(scale: number, result: Color4): Color4;
  14772. /**
  14773. * Scale the current Color4 values by a factor and add the result to a given Color4
  14774. * @param scale defines the scale factor
  14775. * @param result defines the Color4 object where to store the result
  14776. * @returns the unmodified current Color4
  14777. */
  14778. scaleAndAddToRef(scale: number, result: Color4): Color4;
  14779. /**
  14780. * Clamps the rgb values by the min and max values and stores the result into "result"
  14781. * @param min defines minimum clamping value (default is 0)
  14782. * @param max defines maximum clamping value (default is 1)
  14783. * @param result defines color to store the result into.
  14784. * @returns the cuurent Color4
  14785. */
  14786. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  14787. /**
  14788. * Multipy an Color4 value by another and return a new Color4 object
  14789. * @param color defines the Color4 value to multiply by
  14790. * @returns a new Color4 object
  14791. */
  14792. multiply(color: Color4): Color4;
  14793. /**
  14794. * Multipy a Color4 value by another and push the result in a reference value
  14795. * @param color defines the Color4 value to multiply by
  14796. * @param result defines the Color4 to fill the result in
  14797. * @returns the result Color4
  14798. */
  14799. multiplyToRef(color: Color4, result: Color4): Color4;
  14800. /**
  14801. * Creates a string with the Color4 current values
  14802. * @returns the string representation of the Color4 object
  14803. */
  14804. toString(): string;
  14805. /**
  14806. * Returns the string "Color4"
  14807. * @returns "Color4"
  14808. */
  14809. getClassName(): string;
  14810. /**
  14811. * Compute the Color4 hash code
  14812. * @returns an unique number that can be used to hash Color4 objects
  14813. */
  14814. getHashCode(): number;
  14815. /**
  14816. * Creates a new Color4 copied from the current one
  14817. * @returns a new Color4 object
  14818. */
  14819. clone(): Color4;
  14820. /**
  14821. * Copies the given Color4 values into the current one
  14822. * @param source defines the source Color4 object
  14823. * @returns the current updated Color4 object
  14824. */
  14825. copyFrom(source: Color4): Color4;
  14826. /**
  14827. * Copies the given float values into the current one
  14828. * @param r defines the red component to read from
  14829. * @param g defines the green component to read from
  14830. * @param b defines the blue component to read from
  14831. * @param a defines the alpha component to read from
  14832. * @returns the current updated Color4 object
  14833. */
  14834. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  14835. /**
  14836. * Copies the given float values into the current one
  14837. * @param r defines the red component to read from
  14838. * @param g defines the green component to read from
  14839. * @param b defines the blue component to read from
  14840. * @param a defines the alpha component to read from
  14841. * @returns the current updated Color4 object
  14842. */
  14843. set(r: number, g: number, b: number, a: number): Color4;
  14844. /**
  14845. * Compute the Color4 hexadecimal code as a string
  14846. * @returns a string containing the hexadecimal representation of the Color4 object
  14847. */
  14848. toHexString(): string;
  14849. /**
  14850. * Computes a new Color4 converted from the current one to linear space
  14851. * @returns a new Color4 object
  14852. */
  14853. toLinearSpace(): Color4;
  14854. /**
  14855. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  14856. * @param convertedColor defines the Color4 object where to store the linear space version
  14857. * @returns the unmodified Color4
  14858. */
  14859. toLinearSpaceToRef(convertedColor: Color4): Color4;
  14860. /**
  14861. * Computes a new Color4 converted from the current one to gamma space
  14862. * @returns a new Color4 object
  14863. */
  14864. toGammaSpace(): Color4;
  14865. /**
  14866. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  14867. * @param convertedColor defines the Color4 object where to store the gamma space version
  14868. * @returns the unmodified Color4
  14869. */
  14870. toGammaSpaceToRef(convertedColor: Color4): Color4;
  14871. /**
  14872. * Creates a new Color4 from the string containing valid hexadecimal values
  14873. * @param hex defines a string containing valid hexadecimal values
  14874. * @returns a new Color4 object
  14875. */
  14876. static FromHexString(hex: string): Color4;
  14877. /**
  14878. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14879. * @param left defines the start value
  14880. * @param right defines the end value
  14881. * @param amount defines the gradient factor
  14882. * @returns a new Color4 object
  14883. */
  14884. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  14885. /**
  14886. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14887. * @param left defines the start value
  14888. * @param right defines the end value
  14889. * @param amount defines the gradient factor
  14890. * @param result defines the Color4 object where to store data
  14891. */
  14892. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  14893. /**
  14894. * Creates a new Color4 from the starting index element of the given array
  14895. * @param array defines the source array to read from
  14896. * @param offset defines the offset in the source array
  14897. * @returns a new Color4 object
  14898. */
  14899. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  14900. /**
  14901. * Creates a new Color3 from integer values (< 256)
  14902. * @param r defines the red component to read from (value between 0 and 255)
  14903. * @param g defines the green component to read from (value between 0 and 255)
  14904. * @param b defines the blue component to read from (value between 0 and 255)
  14905. * @param a defines the alpha component to read from (value between 0 and 255)
  14906. * @returns a new Color3 object
  14907. */
  14908. static FromInts(r: number, g: number, b: number, a: number): Color4;
  14909. /**
  14910. * Check the content of a given array and convert it to an array containing RGBA data
  14911. * If the original array was already containing count * 4 values then it is returned directly
  14912. * @param colors defines the array to check
  14913. * @param count defines the number of RGBA data to expect
  14914. * @returns an array containing count * 4 values (RGBA)
  14915. */
  14916. static CheckColors4(colors: number[], count: number): number[];
  14917. }
  14918. /**
  14919. * Class representing a vector containing 2 coordinates
  14920. */
  14921. class Vector2 {
  14922. /** defines the first coordinate */
  14923. x: number;
  14924. /** defines the second coordinate */
  14925. y: number;
  14926. /**
  14927. * Creates a new Vector2 from the given x and y coordinates
  14928. * @param x defines the first coordinate
  14929. * @param y defines the second coordinate
  14930. */
  14931. constructor(
  14932. /** defines the first coordinate */
  14933. x: number,
  14934. /** defines the second coordinate */
  14935. y: number);
  14936. /**
  14937. * Gets a string with the Vector2 coordinates
  14938. * @returns a string with the Vector2 coordinates
  14939. */
  14940. toString(): string;
  14941. /**
  14942. * Gets class name
  14943. * @returns the string "Vector2"
  14944. */
  14945. getClassName(): string;
  14946. /**
  14947. * Gets current vector hash code
  14948. * @returns the Vector2 hash code as a number
  14949. */
  14950. getHashCode(): number;
  14951. /**
  14952. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  14953. * @param array defines the source array
  14954. * @param index defines the offset in source array
  14955. * @returns the current Vector2
  14956. */
  14957. toArray(array: FloatArray, index?: number): Vector2;
  14958. /**
  14959. * Copy the current vector to an array
  14960. * @returns a new array with 2 elements: the Vector2 coordinates.
  14961. */
  14962. asArray(): number[];
  14963. /**
  14964. * Sets the Vector2 coordinates with the given Vector2 coordinates
  14965. * @param source defines the source Vector2
  14966. * @returns the current updated Vector2
  14967. */
  14968. copyFrom(source: Vector2): Vector2;
  14969. /**
  14970. * Sets the Vector2 coordinates with the given floats
  14971. * @param x defines the first coordinate
  14972. * @param y defines the second coordinate
  14973. * @returns the current updated Vector2
  14974. */
  14975. copyFromFloats(x: number, y: number): Vector2;
  14976. /**
  14977. * Sets the Vector2 coordinates with the given floats
  14978. * @param x defines the first coordinate
  14979. * @param y defines the second coordinate
  14980. * @returns the current updated Vector2
  14981. */
  14982. set(x: number, y: number): Vector2;
  14983. /**
  14984. * Add another vector with the current one
  14985. * @param otherVector defines the other vector
  14986. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  14987. */
  14988. add(otherVector: Vector2): Vector2;
  14989. /**
  14990. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  14991. * @param otherVector defines the other vector
  14992. * @param result defines the target vector
  14993. * @returns the unmodified current Vector2
  14994. */
  14995. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  14996. /**
  14997. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  14998. * @param otherVector defines the other vector
  14999. * @returns the current updated Vector2
  15000. */
  15001. addInPlace(otherVector: Vector2): Vector2;
  15002. /**
  15003. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15004. * @param otherVector defines the other vector
  15005. * @returns a new Vector2
  15006. */
  15007. addVector3(otherVector: Vector3): Vector2;
  15008. /**
  15009. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15010. * @param otherVector defines the other vector
  15011. * @returns a new Vector2
  15012. */
  15013. subtract(otherVector: Vector2): Vector2;
  15014. /**
  15015. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15016. * @param otherVector defines the other vector
  15017. * @param result defines the target vector
  15018. * @returns the unmodified current Vector2
  15019. */
  15020. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15021. /**
  15022. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15023. * @param otherVector defines the other vector
  15024. * @returns the current updated Vector2
  15025. */
  15026. subtractInPlace(otherVector: Vector2): Vector2;
  15027. /**
  15028. * Multiplies in place the current Vector2 coordinates by the given ones
  15029. * @param otherVector defines the other vector
  15030. * @returns the current updated Vector2
  15031. */
  15032. multiplyInPlace(otherVector: Vector2): Vector2;
  15033. /**
  15034. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15035. * @param otherVector defines the other vector
  15036. * @returns a new Vector2
  15037. */
  15038. multiply(otherVector: Vector2): Vector2;
  15039. /**
  15040. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15041. * @param otherVector defines the other vector
  15042. * @param result defines the target vector
  15043. * @returns the unmodified current Vector2
  15044. */
  15045. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15046. /**
  15047. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15048. * @param x defines the first coordinate
  15049. * @param y defines the second coordinate
  15050. * @returns a new Vector2
  15051. */
  15052. multiplyByFloats(x: number, y: number): Vector2;
  15053. /**
  15054. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15055. * @param otherVector defines the other vector
  15056. * @returns a new Vector2
  15057. */
  15058. divide(otherVector: Vector2): Vector2;
  15059. /**
  15060. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15061. * @param otherVector defines the other vector
  15062. * @param result defines the target vector
  15063. * @returns the unmodified current Vector2
  15064. */
  15065. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15066. /**
  15067. * Divides the current Vector3 coordinates by the given ones
  15068. * @param otherVector defines the other vector
  15069. * @returns the current updated Vector2
  15070. */
  15071. divideInPlace(otherVector: Vector2): Vector2;
  15072. /**
  15073. * Gets a new Vector2 with current Vector2 negated coordinates
  15074. * @returns a new Vector2
  15075. */
  15076. negate(): Vector2;
  15077. /**
  15078. * Multiply the Vector2 coordinates by scale
  15079. * @param scale defines the scaling factor
  15080. * @returns the current updated Vector2
  15081. */
  15082. scaleInPlace(scale: number): Vector2;
  15083. /**
  15084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15085. * @param scale defines the scaling factor
  15086. * @returns a new Vector2
  15087. */
  15088. scale(scale: number): Vector2;
  15089. /**
  15090. * Scale the current Vector2 values by a factor to a given Vector2
  15091. * @param scale defines the scale factor
  15092. * @param result defines the Vector2 object where to store the result
  15093. * @returns the unmodified current Vector2
  15094. */
  15095. scaleToRef(scale: number, result: Vector2): Vector2;
  15096. /**
  15097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15098. * @param scale defines the scale factor
  15099. * @param result defines the Vector2 object where to store the result
  15100. * @returns the unmodified current Vector2
  15101. */
  15102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15103. /**
  15104. * Gets a boolean if two vectors are equals
  15105. * @param otherVector defines the other vector
  15106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15107. */
  15108. equals(otherVector: Vector2): boolean;
  15109. /**
  15110. * Gets a boolean if two vectors are equals (using an epsilon value)
  15111. * @param otherVector defines the other vector
  15112. * @param epsilon defines the minimal distance to consider equality
  15113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15114. */
  15115. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15116. /**
  15117. * Gets the length of the vector
  15118. * @returns the vector length (float)
  15119. */
  15120. length(): number;
  15121. /**
  15122. * Gets the vector squared length
  15123. * @returns the vector squared length (float)
  15124. */
  15125. lengthSquared(): number;
  15126. /**
  15127. * Normalize the vector
  15128. * @returns the current updated Vector2
  15129. */
  15130. normalize(): Vector2;
  15131. /**
  15132. * Gets a new Vector2 copied from the Vector2
  15133. * @returns a new Vector2
  15134. */
  15135. clone(): Vector2;
  15136. /**
  15137. * Gets a new Vector2(0, 0)
  15138. * @returns a new Vector2
  15139. */
  15140. static Zero(): Vector2;
  15141. /**
  15142. * Gets a new Vector2(1, 1)
  15143. * @returns a new Vector2
  15144. */
  15145. static One(): Vector2;
  15146. /**
  15147. * Gets a new Vector2 set from the given index element of the given array
  15148. * @param array defines the data source
  15149. * @param offset defines the offset in the data source
  15150. * @returns a new Vector2
  15151. */
  15152. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15153. /**
  15154. * Sets "result" from the given index element of the given array
  15155. * @param array defines the data source
  15156. * @param offset defines the offset in the data source
  15157. * @param result defines the target vector
  15158. */
  15159. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15160. /**
  15161. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15162. * @param value1 defines 1st point of control
  15163. * @param value2 defines 2nd point of control
  15164. * @param value3 defines 3rd point of control
  15165. * @param value4 defines 4th point of control
  15166. * @param amount defines the interpolation factor
  15167. * @returns a new Vector2
  15168. */
  15169. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15170. /**
  15171. * 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".
  15172. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15173. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15174. * @param value defines the value to clamp
  15175. * @param min defines the lower limit
  15176. * @param max defines the upper limit
  15177. * @returns a new Vector2
  15178. */
  15179. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15180. /**
  15181. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15182. * @param value1 defines the 1st control point
  15183. * @param tangent1 defines the outgoing tangent
  15184. * @param value2 defines the 2nd control point
  15185. * @param tangent2 defines the incoming tangent
  15186. * @param amount defines the interpolation factor
  15187. * @returns a new Vector2
  15188. */
  15189. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15190. /**
  15191. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15192. * @param start defines the start vector
  15193. * @param end defines the end vector
  15194. * @param amount defines the interpolation factor
  15195. * @returns a new Vector2
  15196. */
  15197. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15198. /**
  15199. * Gets the dot product of the vector "left" and the vector "right"
  15200. * @param left defines first vector
  15201. * @param right defines second vector
  15202. * @returns the dot product (float)
  15203. */
  15204. static Dot(left: Vector2, right: Vector2): number;
  15205. /**
  15206. * Returns a new Vector2 equal to the normalized given vector
  15207. * @param vector defines the vector to normalize
  15208. * @returns a new Vector2
  15209. */
  15210. static Normalize(vector: Vector2): Vector2;
  15211. /**
  15212. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15213. * @param left defines 1st vector
  15214. * @param right defines 2nd vector
  15215. * @returns a new Vector2
  15216. */
  15217. static Minimize(left: Vector2, right: Vector2): Vector2;
  15218. /**
  15219. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15220. * @param left defines 1st vector
  15221. * @param right defines 2nd vector
  15222. * @returns a new Vector2
  15223. */
  15224. static Maximize(left: Vector2, right: Vector2): Vector2;
  15225. /**
  15226. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15227. * @param vector defines the vector to transform
  15228. * @param transformation defines the matrix to apply
  15229. * @returns a new Vector2
  15230. */
  15231. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15232. /**
  15233. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15234. * @param vector defines the vector to transform
  15235. * @param transformation defines the matrix to apply
  15236. * @param result defines the target vector
  15237. */
  15238. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15239. /**
  15240. * Determines if a given vector is included in a triangle
  15241. * @param p defines the vector to test
  15242. * @param p0 defines 1st triangle point
  15243. * @param p1 defines 2nd triangle point
  15244. * @param p2 defines 3rd triangle point
  15245. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15246. */
  15247. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15248. /**
  15249. * Gets the distance between the vectors "value1" and "value2"
  15250. * @param value1 defines first vector
  15251. * @param value2 defines second vector
  15252. * @returns the distance between vectors
  15253. */
  15254. static Distance(value1: Vector2, value2: Vector2): number;
  15255. /**
  15256. * Returns the squared distance between the vectors "value1" and "value2"
  15257. * @param value1 defines first vector
  15258. * @param value2 defines second vector
  15259. * @returns the squared distance between vectors
  15260. */
  15261. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15262. /**
  15263. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15264. * @param value1 defines first vector
  15265. * @param value2 defines second vector
  15266. * @returns a new Vector2
  15267. */
  15268. static Center(value1: Vector2, value2: Vector2): Vector2;
  15269. /**
  15270. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15271. * @param p defines the middle point
  15272. * @param segA defines one point of the segment
  15273. * @param segB defines the other point of the segment
  15274. * @returns the shortest distance
  15275. */
  15276. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15277. }
  15278. /**
  15279. * Classed used to store (x,y,z) vector representation
  15280. * A Vector3 is the main object used in 3D geometry
  15281. * It can represent etiher the coordinates of a point the space, either a direction
  15282. * Reminder: Babylon.js uses a left handed forward facing system
  15283. */
  15284. class Vector3 {
  15285. /**
  15286. * Defines the first coordinates (on X axis)
  15287. */
  15288. x: number;
  15289. /**
  15290. * Defines the second coordinates (on Y axis)
  15291. */
  15292. y: number;
  15293. /**
  15294. * Defines the third coordinates (on Z axis)
  15295. */
  15296. z: number;
  15297. /**
  15298. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15299. * @param x defines the first coordinates (on X axis)
  15300. * @param y defines the second coordinates (on Y axis)
  15301. * @param z defines the third coordinates (on Z axis)
  15302. */
  15303. constructor(
  15304. /**
  15305. * Defines the first coordinates (on X axis)
  15306. */
  15307. x: number,
  15308. /**
  15309. * Defines the second coordinates (on Y axis)
  15310. */
  15311. y: number,
  15312. /**
  15313. * Defines the third coordinates (on Z axis)
  15314. */
  15315. z: number);
  15316. /**
  15317. * Creates a string representation of the Vector3
  15318. * @returns a string with the Vector3 coordinates.
  15319. */
  15320. toString(): string;
  15321. /**
  15322. * Gets the class name
  15323. * @returns the string "Vector3"
  15324. */
  15325. getClassName(): string;
  15326. /**
  15327. * Creates the Vector3 hash code
  15328. * @returns a number which tends to be unique between Vector3 instances
  15329. */
  15330. getHashCode(): number;
  15331. /**
  15332. * Creates an array containing three elements : the coordinates of the Vector3
  15333. * @returns a new array of numbers
  15334. */
  15335. asArray(): number[];
  15336. /**
  15337. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15338. * @param array defines the destination array
  15339. * @param index defines the offset in the destination array
  15340. * @returns the current Vector3
  15341. */
  15342. toArray(array: FloatArray, index?: number): Vector3;
  15343. /**
  15344. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15345. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15346. */
  15347. toQuaternion(): Quaternion;
  15348. /**
  15349. * Adds the given vector to the current Vector3
  15350. * @param otherVector defines the second operand
  15351. * @returns the current updated Vector3
  15352. */
  15353. addInPlace(otherVector: Vector3): Vector3;
  15354. /**
  15355. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15356. * @param otherVector defines the second operand
  15357. * @returns the resulting Vector3
  15358. */
  15359. add(otherVector: Vector3): Vector3;
  15360. /**
  15361. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15362. * @param otherVector defines the second operand
  15363. * @param result defines the Vector3 object where to store the result
  15364. * @returns the current Vector3
  15365. */
  15366. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15367. /**
  15368. * Subtract the given vector from the current Vector3
  15369. * @param otherVector defines the second operand
  15370. * @returns the current updated Vector3
  15371. */
  15372. subtractInPlace(otherVector: Vector3): Vector3;
  15373. /**
  15374. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15375. * @param otherVector defines the second operand
  15376. * @returns the resulting Vector3
  15377. */
  15378. subtract(otherVector: Vector3): Vector3;
  15379. /**
  15380. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15381. * @param otherVector defines the second operand
  15382. * @param result defines the Vector3 object where to store the result
  15383. * @returns the current Vector3
  15384. */
  15385. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15386. /**
  15387. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15388. * @param x defines the x coordinate of the operand
  15389. * @param y defines the y coordinate of the operand
  15390. * @param z defines the z coordinate of the operand
  15391. * @returns the resulting Vector3
  15392. */
  15393. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15394. /**
  15395. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15396. * @param x defines the x coordinate of the operand
  15397. * @param y defines the y coordinate of the operand
  15398. * @param z defines the z coordinate of the operand
  15399. * @param result defines the Vector3 object where to store the result
  15400. * @returns the current Vector3
  15401. */
  15402. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15403. /**
  15404. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15405. * @returns a new Vector3
  15406. */
  15407. negate(): Vector3;
  15408. /**
  15409. * Multiplies the Vector3 coordinates by the float "scale"
  15410. * @param scale defines the multiplier factor
  15411. * @returns the current updated Vector3
  15412. */
  15413. scaleInPlace(scale: number): Vector3;
  15414. /**
  15415. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15416. * @param scale defines the multiplier factor
  15417. * @returns a new Vector3
  15418. */
  15419. scale(scale: number): Vector3;
  15420. /**
  15421. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15422. * @param scale defines the multiplier factor
  15423. * @param result defines the Vector3 object where to store the result
  15424. * @returns the current Vector3
  15425. */
  15426. scaleToRef(scale: number, result: Vector3): Vector3;
  15427. /**
  15428. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15429. * @param scale defines the scale factor
  15430. * @param result defines the Vector3 object where to store the result
  15431. * @returns the unmodified current Vector3
  15432. */
  15433. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15434. /**
  15435. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15436. * @param otherVector defines the second operand
  15437. * @returns true if both vectors are equals
  15438. */
  15439. equals(otherVector: Vector3): boolean;
  15440. /**
  15441. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  15442. * @param otherVector defines the second operand
  15443. * @param epsilon defines the minimal distance to define values as equals
  15444. * @returns true if both vectors are distant less than epsilon
  15445. */
  15446. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15447. /**
  15448. * Returns true if the current Vector3 coordinates equals the given floats
  15449. * @param x defines the x coordinate of the operand
  15450. * @param y defines the y coordinate of the operand
  15451. * @param z defines the z coordinate of the operand
  15452. * @returns true if both vectors are equals
  15453. */
  15454. equalsToFloats(x: number, y: number, z: number): boolean;
  15455. /**
  15456. * Multiplies the current Vector3 coordinates by the given ones
  15457. * @param otherVector defines the second operand
  15458. * @returns the current updated Vector3
  15459. */
  15460. multiplyInPlace(otherVector: Vector3): Vector3;
  15461. /**
  15462. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  15463. * @param otherVector defines the second operand
  15464. * @returns the new Vector3
  15465. */
  15466. multiply(otherVector: Vector3): Vector3;
  15467. /**
  15468. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  15469. * @param otherVector defines the second operand
  15470. * @param result defines the Vector3 object where to store the result
  15471. * @returns the current Vector3
  15472. */
  15473. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15474. /**
  15475. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  15476. * @param x defines the x coordinate of the operand
  15477. * @param y defines the y coordinate of the operand
  15478. * @param z defines the z coordinate of the operand
  15479. * @returns the new Vector3
  15480. */
  15481. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15482. /**
  15483. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  15484. * @param otherVector defines the second operand
  15485. * @returns the new Vector3
  15486. */
  15487. divide(otherVector: Vector3): Vector3;
  15488. /**
  15489. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  15490. * @param otherVector defines the second operand
  15491. * @param result defines the Vector3 object where to store the result
  15492. * @returns the current Vector3
  15493. */
  15494. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15495. /**
  15496. * Divides the current Vector3 coordinates by the given ones.
  15497. * @param otherVector defines the second operand
  15498. * @returns the current updated Vector3
  15499. */
  15500. divideInPlace(otherVector: Vector3): Vector3;
  15501. /**
  15502. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  15503. * @param other defines the second operand
  15504. * @returns the current updated Vector3
  15505. */
  15506. minimizeInPlace(other: Vector3): Vector3;
  15507. /**
  15508. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  15509. * @param other defines the second operand
  15510. * @returns the current updated Vector3
  15511. */
  15512. maximizeInPlace(other: Vector3): Vector3;
  15513. /**
  15514. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  15515. */
  15516. readonly isNonUniform: boolean;
  15517. /**
  15518. * Gets the length of the Vector3
  15519. * @returns the length of the Vecto3
  15520. */
  15521. length(): number;
  15522. /**
  15523. * Gets the squared length of the Vector3
  15524. * @returns squared length of the Vector3
  15525. */
  15526. lengthSquared(): number;
  15527. /**
  15528. * Normalize the current Vector3.
  15529. * Please note that this is an in place operation.
  15530. * @returns the current updated Vector3
  15531. */
  15532. normalize(): Vector3;
  15533. /**
  15534. * Normalize the current Vector3 to a new vector
  15535. * @returns the new Vector3
  15536. */
  15537. normalizeToNew(): Vector3;
  15538. /**
  15539. * Normalize the current Vector3 to the reference
  15540. * @param reference define the Vector3 to update
  15541. * @returns the updated Vector3
  15542. */
  15543. normalizeToRef(reference: Vector3): Vector3;
  15544. /**
  15545. * Creates a new Vector3 copied from the current Vector3
  15546. * @returns the new Vector3
  15547. */
  15548. clone(): Vector3;
  15549. /**
  15550. * Copies the given vector coordinates to the current Vector3 ones
  15551. * @param source defines the source Vector3
  15552. * @returns the current updated Vector3
  15553. */
  15554. copyFrom(source: Vector3): Vector3;
  15555. /**
  15556. * Copies the given floats to the current Vector3 coordinates
  15557. * @param x defines the x coordinate of the operand
  15558. * @param y defines the y coordinate of the operand
  15559. * @param z defines the z coordinate of the operand
  15560. * @returns the current updated Vector3
  15561. */
  15562. copyFromFloats(x: number, y: number, z: number): Vector3;
  15563. /**
  15564. * Copies the given floats to the current Vector3 coordinates
  15565. * @param x defines the x coordinate of the operand
  15566. * @param y defines the y coordinate of the operand
  15567. * @param z defines the z coordinate of the operand
  15568. * @returns the current updated Vector3
  15569. */
  15570. set(x: number, y: number, z: number): Vector3;
  15571. /**
  15572. * Get the clip factor between two vectors
  15573. * @param vector0 defines the first operand
  15574. * @param vector1 defines the second operand
  15575. * @param axis defines the axis to use
  15576. * @param size defines the size along the axis
  15577. * @returns the clip factor
  15578. */
  15579. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  15580. /**
  15581. * Get angle between two vectors
  15582. * @param vector0 angle between vector0 and vector1
  15583. * @param vector1 angle between vector0 and vector1
  15584. * @param normal direction of the normal
  15585. * @return the angle between vector0 and vector1
  15586. */
  15587. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  15588. /**
  15589. * Returns a new Vector3 set from the index "offset" of the given array
  15590. * @param array defines the source array
  15591. * @param offset defines the offset in the source array
  15592. * @returns the new Vector3
  15593. */
  15594. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  15595. /**
  15596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  15597. * This function is deprecated. Use FromArray instead
  15598. * @param array defines the source array
  15599. * @param offset defines the offset in the source array
  15600. * @returns the new Vector3
  15601. */
  15602. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  15603. /**
  15604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  15605. * @param array defines the source array
  15606. * @param offset defines the offset in the source array
  15607. * @param result defines the Vector3 where to store the result
  15608. */
  15609. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  15610. /**
  15611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  15612. * This function is deprecated. Use FromArrayToRef instead.
  15613. * @param array defines the source array
  15614. * @param offset defines the offset in the source array
  15615. * @param result defines the Vector3 where to store the result
  15616. */
  15617. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  15618. /**
  15619. * Sets the given vector "result" with the given floats.
  15620. * @param x defines the x coordinate of the source
  15621. * @param y defines the y coordinate of the source
  15622. * @param z defines the z coordinate of the source
  15623. * @param result defines the Vector3 where to store the result
  15624. */
  15625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  15626. /**
  15627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  15628. * @returns a new empty Vector3
  15629. */
  15630. static Zero(): Vector3;
  15631. /**
  15632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  15633. * @returns a new unit Vector3
  15634. */
  15635. static One(): Vector3;
  15636. /**
  15637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  15638. * @returns a new up Vector3
  15639. */
  15640. static Up(): Vector3;
  15641. /**
  15642. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  15643. * @returns a new forward Vector3
  15644. */
  15645. static Forward(): Vector3;
  15646. /**
  15647. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  15648. * @returns a new right Vector3
  15649. */
  15650. static Right(): Vector3;
  15651. /**
  15652. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  15653. * @returns a new left Vector3
  15654. */
  15655. static Left(): Vector3;
  15656. /**
  15657. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  15658. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15659. * @param vector defines the Vector3 to transform
  15660. * @param transformation defines the transformation matrix
  15661. * @returns the transformed Vector3
  15662. */
  15663. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  15664. /**
  15665. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  15666. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15667. * @param vector defines the Vector3 to transform
  15668. * @param transformation defines the transformation matrix
  15669. * @param result defines the Vector3 where to store the result
  15670. */
  15671. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15672. /**
  15673. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  15674. * This method computes tranformed coordinates only, not transformed direction vectors
  15675. * @param x define the x coordinate of the source vector
  15676. * @param y define the y coordinate of the source vector
  15677. * @param z define the z coordinate of the source vector
  15678. * @param transformation defines the transformation matrix
  15679. * @param result defines the Vector3 where to store the result
  15680. */
  15681. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15682. /**
  15683. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  15684. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15685. * @param vector defines the Vector3 to transform
  15686. * @param transformation defines the transformation matrix
  15687. * @returns the new Vector3
  15688. */
  15689. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  15690. /**
  15691. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  15692. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15693. * @param vector defines the Vector3 to transform
  15694. * @param transformation defines the transformation matrix
  15695. * @param result defines the Vector3 where to store the result
  15696. */
  15697. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15698. /**
  15699. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  15700. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15701. * @param x define the x coordinate of the source vector
  15702. * @param y define the y coordinate of the source vector
  15703. * @param z define the z coordinate of the source vector
  15704. * @param transformation defines the transformation matrix
  15705. * @param result defines the Vector3 where to store the result
  15706. */
  15707. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15708. /**
  15709. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  15710. * @param value1 defines the first control point
  15711. * @param value2 defines the second control point
  15712. * @param value3 defines the third control point
  15713. * @param value4 defines the fourth control point
  15714. * @param amount defines the amount on the spline to use
  15715. * @returns the new Vector3
  15716. */
  15717. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  15718. /**
  15719. * 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"
  15720. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  15721. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  15722. * @param value defines the current value
  15723. * @param min defines the lower range value
  15724. * @param max defines the upper range value
  15725. * @returns the new Vector3
  15726. */
  15727. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  15728. /**
  15729. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  15730. * @param value1 defines the first control point
  15731. * @param tangent1 defines the first tangent vector
  15732. * @param value2 defines the second control point
  15733. * @param tangent2 defines the second tangent vector
  15734. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  15735. * @returns the new Vector3
  15736. */
  15737. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  15738. /**
  15739. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  15740. * @param start defines the start value
  15741. * @param end defines the end value
  15742. * @param amount max defines amount between both (between 0 and 1)
  15743. * @returns the new Vector3
  15744. */
  15745. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  15746. /**
  15747. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  15748. * @param start defines the start value
  15749. * @param end defines the end value
  15750. * @param amount max defines amount between both (between 0 and 1)
  15751. * @param result defines the Vector3 where to store the result
  15752. */
  15753. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  15754. /**
  15755. * Returns the dot product (float) between the vectors "left" and "right"
  15756. * @param left defines the left operand
  15757. * @param right defines the right operand
  15758. * @returns the dot product
  15759. */
  15760. static Dot(left: Vector3, right: Vector3): number;
  15761. /**
  15762. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  15763. * The cross product is then orthogonal to both "left" and "right"
  15764. * @param left defines the left operand
  15765. * @param right defines the right operand
  15766. * @returns the cross product
  15767. */
  15768. static Cross(left: Vector3, right: Vector3): Vector3;
  15769. /**
  15770. * Sets the given vector "result" with the cross product of "left" and "right"
  15771. * The cross product is then orthogonal to both "left" and "right"
  15772. * @param left defines the left operand
  15773. * @param right defines the right operand
  15774. * @param result defines the Vector3 where to store the result
  15775. */
  15776. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  15777. /**
  15778. * Returns a new Vector3 as the normalization of the given vector
  15779. * @param vector defines the Vector3 to normalize
  15780. * @returns the new Vector3
  15781. */
  15782. static Normalize(vector: Vector3): Vector3;
  15783. /**
  15784. * Sets the given vector "result" with the normalization of the given first vector
  15785. * @param vector defines the Vector3 to normalize
  15786. * @param result defines the Vector3 where to store the result
  15787. */
  15788. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  15789. private static _viewportMatrixCache;
  15790. /**
  15791. * Project a Vector3 onto screen space
  15792. * @param vector defines the Vector3 to project
  15793. * @param world defines the world matrix to use
  15794. * @param transform defines the transform (view x projection) matrix to use
  15795. * @param viewport defines the screen viewport to use
  15796. * @returns the new Vector3
  15797. */
  15798. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  15799. /**
  15800. * Unproject from screen space to object space
  15801. * @param source defines the screen space Vector3 to use
  15802. * @param viewportWidth defines the current width of the viewport
  15803. * @param viewportHeight defines the current height of the viewport
  15804. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15805. * @param transform defines the transform (view x projection) matrix to use
  15806. * @returns the new Vector3
  15807. */
  15808. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  15809. /**
  15810. * Unproject from screen space to object space
  15811. * @param source defines the screen space Vector3 to use
  15812. * @param viewportWidth defines the current width of the viewport
  15813. * @param viewportHeight defines the current height of the viewport
  15814. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15815. * @param view defines the view matrix to use
  15816. * @param projection defines the projection matrix to use
  15817. * @returns the new Vector3
  15818. */
  15819. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  15820. /**
  15821. * Unproject from screen space to object space
  15822. * @param source defines the screen space Vector3 to use
  15823. * @param viewportWidth defines the current width of the viewport
  15824. * @param viewportHeight defines the current height of the viewport
  15825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15826. * @param view defines the view matrix to use
  15827. * @param projection defines the projection matrix to use
  15828. * @param result defines the Vector3 where to store the result
  15829. */
  15830. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15831. /**
  15832. * Unproject from screen space to object space
  15833. * @param sourceX defines the screen space x coordinate to use
  15834. * @param sourceY defines the screen space y coordinate to use
  15835. * @param sourceZ defines the screen space z coordinate to use
  15836. * @param viewportWidth defines the current width of the viewport
  15837. * @param viewportHeight defines the current height of the viewport
  15838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15839. * @param view defines the view matrix to use
  15840. * @param projection defines the projection matrix to use
  15841. * @param result defines the Vector3 where to store the result
  15842. */
  15843. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15844. /**
  15845. * Gets the minimal coordinate values between two Vector3
  15846. * @param left defines the first operand
  15847. * @param right defines the second operand
  15848. * @returns the new Vector3
  15849. */
  15850. static Minimize(left: Vector3, right: Vector3): Vector3;
  15851. /**
  15852. * Gets the maximal coordinate values between two Vector3
  15853. * @param left defines the first operand
  15854. * @param right defines the second operand
  15855. * @returns the new Vector3
  15856. */
  15857. static Maximize(left: Vector3, right: Vector3): Vector3;
  15858. /**
  15859. * Returns the distance between the vectors "value1" and "value2"
  15860. * @param value1 defines the first operand
  15861. * @param value2 defines the second operand
  15862. * @returns the distance
  15863. */
  15864. static Distance(value1: Vector3, value2: Vector3): number;
  15865. /**
  15866. * Returns the squared distance between the vectors "value1" and "value2"
  15867. * @param value1 defines the first operand
  15868. * @param value2 defines the second operand
  15869. * @returns the squared distance
  15870. */
  15871. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  15872. /**
  15873. * Returns a new Vector3 located at the center between "value1" and "value2"
  15874. * @param value1 defines the first operand
  15875. * @param value2 defines the second operand
  15876. * @returns the new Vector3
  15877. */
  15878. static Center(value1: Vector3, value2: Vector3): Vector3;
  15879. /**
  15880. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  15881. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  15882. * to something in order to rotate it from its local system to the given target system
  15883. * Note: axis1, axis2 and axis3 are normalized during this operation
  15884. * @param axis1 defines the first axis
  15885. * @param axis2 defines the second axis
  15886. * @param axis3 defines the third axis
  15887. * @returns a new Vector3
  15888. */
  15889. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  15890. /**
  15891. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  15892. * @param axis1 defines the first axis
  15893. * @param axis2 defines the second axis
  15894. * @param axis3 defines the third axis
  15895. * @param ref defines the Vector3 where to store the result
  15896. */
  15897. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  15898. }
  15899. class Vector4 {
  15900. x: number;
  15901. y: number;
  15902. z: number;
  15903. w: number;
  15904. /**
  15905. * Creates a Vector4 object from the given floats.
  15906. */
  15907. constructor(x: number, y: number, z: number, w: number);
  15908. /**
  15909. * Returns the string with the Vector4 coordinates.
  15910. */
  15911. toString(): string;
  15912. /**
  15913. * Returns the string "Vector4".
  15914. */
  15915. getClassName(): string;
  15916. /**
  15917. * Returns the Vector4 hash code.
  15918. */
  15919. getHashCode(): number;
  15920. /**
  15921. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  15922. */
  15923. asArray(): number[];
  15924. /**
  15925. * Populates the given array from the given index with the Vector4 coordinates.
  15926. * Returns the Vector4.
  15927. */
  15928. toArray(array: FloatArray, index?: number): Vector4;
  15929. /**
  15930. * Adds the given vector to the current Vector4.
  15931. * Returns the updated Vector4.
  15932. */
  15933. addInPlace(otherVector: Vector4): Vector4;
  15934. /**
  15935. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  15936. */
  15937. add(otherVector: Vector4): Vector4;
  15938. /**
  15939. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  15940. * Returns the current Vector4.
  15941. */
  15942. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  15943. /**
  15944. * Subtract in place the given vector from the current Vector4.
  15945. * Returns the updated Vector4.
  15946. */
  15947. subtractInPlace(otherVector: Vector4): Vector4;
  15948. /**
  15949. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  15950. */
  15951. subtract(otherVector: Vector4): Vector4;
  15952. /**
  15953. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  15954. * Returns the current Vector4.
  15955. */
  15956. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  15957. /**
  15958. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  15959. */
  15960. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  15961. /**
  15962. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  15963. * Returns the current Vector4.
  15964. */
  15965. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  15966. /**
  15967. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  15968. */
  15969. negate(): Vector4;
  15970. /**
  15971. * Multiplies the current Vector4 coordinates by scale (float).
  15972. * Returns the updated Vector4.
  15973. */
  15974. scaleInPlace(scale: number): Vector4;
  15975. /**
  15976. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  15977. */
  15978. scale(scale: number): Vector4;
  15979. /**
  15980. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  15981. * Returns the current Vector4.
  15982. */
  15983. scaleToRef(scale: number, result: Vector4): Vector4;
  15984. /**
  15985. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  15986. * @param scale defines the scale factor
  15987. * @param result defines the Vector4 object where to store the result
  15988. * @returns the unmodified current Vector4
  15989. */
  15990. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  15991. /**
  15992. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  15993. */
  15994. equals(otherVector: Vector4): boolean;
  15995. /**
  15996. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  15997. */
  15998. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  15999. /**
  16000. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16001. */
  16002. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16003. /**
  16004. * Multiplies in place the current Vector4 by the given one.
  16005. * Returns the updated Vector4.
  16006. */
  16007. multiplyInPlace(otherVector: Vector4): Vector4;
  16008. /**
  16009. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16010. */
  16011. multiply(otherVector: Vector4): Vector4;
  16012. /**
  16013. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16014. * Returns the current Vector4.
  16015. */
  16016. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16017. /**
  16018. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16019. */
  16020. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16021. /**
  16022. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16023. */
  16024. divide(otherVector: Vector4): Vector4;
  16025. /**
  16026. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16027. * Returns the current Vector4.
  16028. */
  16029. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16030. /**
  16031. * Divides the current Vector3 coordinates by the given ones.
  16032. * @returns the updated Vector3.
  16033. */
  16034. divideInPlace(otherVector: Vector4): Vector4;
  16035. /**
  16036. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16037. * @param other defines the second operand
  16038. * @returns the current updated Vector4
  16039. */
  16040. minimizeInPlace(other: Vector4): Vector4;
  16041. /**
  16042. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16043. * @param other defines the second operand
  16044. * @returns the current updated Vector4
  16045. */
  16046. maximizeInPlace(other: Vector4): Vector4;
  16047. /**
  16048. * Returns the Vector4 length (float).
  16049. */
  16050. length(): number;
  16051. /**
  16052. * Returns the Vector4 squared length (float).
  16053. */
  16054. lengthSquared(): number;
  16055. /**
  16056. * Normalizes in place the Vector4.
  16057. * Returns the updated Vector4.
  16058. */
  16059. normalize(): Vector4;
  16060. /**
  16061. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16062. */
  16063. toVector3(): Vector3;
  16064. /**
  16065. * Returns a new Vector4 copied from the current one.
  16066. */
  16067. clone(): Vector4;
  16068. /**
  16069. * Updates the current Vector4 with the given one coordinates.
  16070. * Returns the updated Vector4.
  16071. */
  16072. copyFrom(source: Vector4): Vector4;
  16073. /**
  16074. * Updates the current Vector4 coordinates with the given floats.
  16075. * Returns the updated Vector4.
  16076. */
  16077. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16078. /**
  16079. * Updates the current Vector4 coordinates with the given floats.
  16080. * Returns the updated Vector4.
  16081. */
  16082. set(x: number, y: number, z: number, w: number): Vector4;
  16083. /**
  16084. * Returns a new Vector4 set from the starting index of the given array.
  16085. */
  16086. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16087. /**
  16088. * Updates the given vector "result" from the starting index of the given array.
  16089. */
  16090. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16091. /**
  16092. * Updates the given vector "result" from the starting index of the given Float32Array.
  16093. */
  16094. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16095. /**
  16096. * Updates the given vector "result" coordinates from the given floats.
  16097. */
  16098. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16099. /**
  16100. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16101. */
  16102. static Zero(): Vector4;
  16103. /**
  16104. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16105. */
  16106. static One(): Vector4;
  16107. /**
  16108. * Returns a new normalized Vector4 from the given one.
  16109. */
  16110. static Normalize(vector: Vector4): Vector4;
  16111. /**
  16112. * Updates the given vector "result" from the normalization of the given one.
  16113. */
  16114. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16115. static Minimize(left: Vector4, right: Vector4): Vector4;
  16116. static Maximize(left: Vector4, right: Vector4): Vector4;
  16117. /**
  16118. * Returns the distance (float) between the vectors "value1" and "value2".
  16119. */
  16120. static Distance(value1: Vector4, value2: Vector4): number;
  16121. /**
  16122. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16123. */
  16124. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16125. /**
  16126. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16127. */
  16128. static Center(value1: Vector4, value2: Vector4): Vector4;
  16129. /**
  16130. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16131. * This methods computes transformed normalized direction vectors only.
  16132. */
  16133. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16134. /**
  16135. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16136. * This methods computes transformed normalized direction vectors only.
  16137. */
  16138. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16139. /**
  16140. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16141. * This methods computes transformed normalized direction vectors only.
  16142. */
  16143. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16144. }
  16145. interface ISize {
  16146. width: number;
  16147. height: number;
  16148. }
  16149. class Size implements ISize {
  16150. width: number;
  16151. height: number;
  16152. /**
  16153. * Creates a Size object from the given width and height (floats).
  16154. */
  16155. constructor(width: number, height: number);
  16156. toString(): string;
  16157. /**
  16158. * Returns the string "Size"
  16159. */
  16160. getClassName(): string;
  16161. /**
  16162. * Returns the Size hash code.
  16163. */
  16164. getHashCode(): number;
  16165. /**
  16166. * Updates the current size from the given one.
  16167. * Returns the updated Size.
  16168. */
  16169. copyFrom(src: Size): void;
  16170. /**
  16171. * Updates in place the current Size from the given floats.
  16172. * Returns the updated Size.
  16173. */
  16174. copyFromFloats(width: number, height: number): Size;
  16175. /**
  16176. * Updates in place the current Size from the given floats.
  16177. * Returns the updated Size.
  16178. */
  16179. set(width: number, height: number): Size;
  16180. /**
  16181. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16182. */
  16183. multiplyByFloats(w: number, h: number): Size;
  16184. /**
  16185. * Returns a new Size copied from the given one.
  16186. */
  16187. clone(): Size;
  16188. /**
  16189. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16190. */
  16191. equals(other: Size): boolean;
  16192. /**
  16193. * Returns the surface of the Size : width * height (float).
  16194. */
  16195. readonly surface: number;
  16196. /**
  16197. * Returns a new Size set to (0.0, 0.0)
  16198. */
  16199. static Zero(): Size;
  16200. /**
  16201. * Returns a new Size set as the addition result of the current Size and the given one.
  16202. */
  16203. add(otherSize: Size): Size;
  16204. /**
  16205. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16206. */
  16207. subtract(otherSize: Size): Size;
  16208. /**
  16209. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16210. */
  16211. static Lerp(start: Size, end: Size, amount: number): Size;
  16212. }
  16213. /**
  16214. * Class used to store quaternion data
  16215. * @see https://en.wikipedia.org/wiki/Quaternion
  16216. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16217. */
  16218. class Quaternion {
  16219. /** defines the first component (0 by default) */
  16220. x: number;
  16221. /** defines the second component (0 by default) */
  16222. y: number;
  16223. /** defines the third component (0 by default) */
  16224. z: number;
  16225. /** defines the fourth component (1.0 by default) */
  16226. w: number;
  16227. /**
  16228. * Creates a new Quaternion from the given floats
  16229. * @param x defines the first component (0 by default)
  16230. * @param y defines the second component (0 by default)
  16231. * @param z defines the third component (0 by default)
  16232. * @param w defines the fourth component (1.0 by default)
  16233. */
  16234. constructor(
  16235. /** defines the first component (0 by default) */
  16236. x?: number,
  16237. /** defines the second component (0 by default) */
  16238. y?: number,
  16239. /** defines the third component (0 by default) */
  16240. z?: number,
  16241. /** defines the fourth component (1.0 by default) */
  16242. w?: number);
  16243. /**
  16244. * Gets a string representation for the current quaternion
  16245. * @returns a string with the Quaternion coordinates
  16246. */
  16247. toString(): string;
  16248. /**
  16249. * Gets the class name of the quaternion
  16250. * @returns the string "Quaternion"
  16251. */
  16252. getClassName(): string;
  16253. /**
  16254. * Gets a hash code for this quaternion
  16255. * @returns the quaternion hash code
  16256. */
  16257. getHashCode(): number;
  16258. /**
  16259. * Copy the quaternion to an array
  16260. * @returns a new array populated with 4 elements from the quaternion coordinates
  16261. */
  16262. asArray(): number[];
  16263. /**
  16264. * Check if two quaternions are equals
  16265. * @param otherQuaternion defines the second operand
  16266. * @return true if the current quaternion and the given one coordinates are strictly equals
  16267. */
  16268. equals(otherQuaternion: Quaternion): boolean;
  16269. /**
  16270. * Clone the current quaternion
  16271. * @returns a new quaternion copied from the current one
  16272. */
  16273. clone(): Quaternion;
  16274. /**
  16275. * Copy a quaternion to the current one
  16276. * @param other defines the other quaternion
  16277. * @returns the updated current quaternion
  16278. */
  16279. copyFrom(other: Quaternion): Quaternion;
  16280. /**
  16281. * Updates the current quaternion with the given float coordinates
  16282. * @param x defines the x coordinate
  16283. * @param y defines the y coordinate
  16284. * @param z defines the z coordinate
  16285. * @param w defines the w coordinate
  16286. * @returns the updated current quaternion
  16287. */
  16288. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16289. /**
  16290. * Updates the current quaternion from the given float coordinates
  16291. * @param x defines the x coordinate
  16292. * @param y defines the y coordinate
  16293. * @param z defines the z coordinate
  16294. * @param w defines the w coordinate
  16295. * @returns the updated current quaternion
  16296. */
  16297. set(x: number, y: number, z: number, w: number): Quaternion;
  16298. /**
  16299. * Adds two quaternions
  16300. * @param other defines the second operand
  16301. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16302. */
  16303. add(other: Quaternion): Quaternion;
  16304. /**
  16305. * Add a quaternion to the current one
  16306. * @param other defines the quaternion to add
  16307. * @returns the current quaternion
  16308. */
  16309. addInPlace(other: Quaternion): Quaternion;
  16310. /**
  16311. * Subtract two quaternions
  16312. * @param other defines the second operand
  16313. * @returns a new quaternion as the subtraction result of the given one from the current one
  16314. */
  16315. subtract(other: Quaternion): Quaternion;
  16316. /**
  16317. * Multiplies the current quaternion by a scale factor
  16318. * @param value defines the scale factor
  16319. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16320. */
  16321. scale(value: number): Quaternion;
  16322. /**
  16323. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16324. * @param scale defines the scale factor
  16325. * @param result defines the Quaternion object where to store the result
  16326. * @returns the unmodified current quaternion
  16327. */
  16328. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16329. /**
  16330. * Multiplies in place the current quaternion by a scale factor
  16331. * @param value defines the scale factor
  16332. * @returns the current modified quaternion
  16333. */
  16334. scaleInPlace(value: number): Quaternion;
  16335. /**
  16336. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16337. * @param scale defines the scale factor
  16338. * @param result defines the Quaternion object where to store the result
  16339. * @returns the unmodified current quaternion
  16340. */
  16341. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16342. /**
  16343. * Multiplies two quaternions
  16344. * @param q1 defines the second operand
  16345. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16346. */
  16347. multiply(q1: Quaternion): Quaternion;
  16348. /**
  16349. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16350. * @param q1 defines the second operand
  16351. * @param result defines the target quaternion
  16352. * @returns the current quaternion
  16353. */
  16354. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16355. /**
  16356. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16357. * @param q1 defines the second operand
  16358. * @returns the currentupdated quaternion
  16359. */
  16360. multiplyInPlace(q1: Quaternion): Quaternion;
  16361. /**
  16362. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16363. * @param ref defines the target quaternion
  16364. * @returns the current quaternion
  16365. */
  16366. conjugateToRef(ref: Quaternion): Quaternion;
  16367. /**
  16368. * Conjugates in place (1-q) the current quaternion
  16369. * @returns the current updated quaternion
  16370. */
  16371. conjugateInPlace(): Quaternion;
  16372. /**
  16373. * Conjugates in place (1-q) the current quaternion
  16374. * @returns a new quaternion
  16375. */
  16376. conjugate(): Quaternion;
  16377. /**
  16378. * Gets length of current quaternion
  16379. * @returns the quaternion length (float)
  16380. */
  16381. length(): number;
  16382. /**
  16383. * Normalize in place the current quaternion
  16384. * @returns the current updated quaternion
  16385. */
  16386. normalize(): Quaternion;
  16387. /**
  16388. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16389. * @param order is a reserved parameter and is ignore for now
  16390. * @returns a new Vector3 containing the Euler angles
  16391. */
  16392. toEulerAngles(order?: string): Vector3;
  16393. /**
  16394. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16395. * @param result defines the vector which will be filled with the Euler angles
  16396. * @param order is a reserved parameter and is ignore for now
  16397. * @returns the current unchanged quaternion
  16398. */
  16399. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16400. /**
  16401. * Updates the given rotation matrix with the current quaternion values
  16402. * @param result defines the target matrix
  16403. * @returns the current unchanged quaternion
  16404. */
  16405. toRotationMatrix(result: Matrix): Quaternion;
  16406. /**
  16407. * Updates the current quaternion from the given rotation matrix values
  16408. * @param matrix defines the source matrix
  16409. * @returns the current updated quaternion
  16410. */
  16411. fromRotationMatrix(matrix: Matrix): Quaternion;
  16412. /**
  16413. * Creates a new quaternion from a rotation matrix
  16414. * @param matrix defines the source matrix
  16415. * @returns a new quaternion created from the given rotation matrix values
  16416. */
  16417. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16418. /**
  16419. * Updates the given quaternion with the given rotation matrix values
  16420. * @param matrix defines the source matrix
  16421. * @param result defines the target quaternion
  16422. */
  16423. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16424. /**
  16425. * Returns the dot product (float) between the quaternions "left" and "right"
  16426. * @param left defines the left operand
  16427. * @param right defines the right operand
  16428. * @returns the dot product
  16429. */
  16430. static Dot(left: Quaternion, right: Quaternion): number;
  16431. /**
  16432. * Checks if the two quaternions are close to each other
  16433. * @param quat0 defines the first quaternion to check
  16434. * @param quat1 defines the second quaternion to check
  16435. * @returns true if the two quaternions are close to each other
  16436. */
  16437. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16438. /**
  16439. * Creates an empty quaternion
  16440. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  16441. */
  16442. static Zero(): Quaternion;
  16443. /**
  16444. * Inverse a given quaternion
  16445. * @param q defines the source quaternion
  16446. * @returns a new quaternion as the inverted current quaternion
  16447. */
  16448. static Inverse(q: Quaternion): Quaternion;
  16449. /**
  16450. * Creates an identity quaternion
  16451. * @returns the identity quaternion
  16452. */
  16453. static Identity(): Quaternion;
  16454. /**
  16455. * Gets a boolean indicating if the given quaternion is identity
  16456. * @param quaternion defines the quaternion to check
  16457. * @returns true if the quaternion is identity
  16458. */
  16459. static IsIdentity(quaternion: Quaternion): boolean;
  16460. /**
  16461. * Creates a quaternion from a rotation around an axis
  16462. * @param axis defines the axis to use
  16463. * @param angle defines the angle to use
  16464. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  16465. */
  16466. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16467. /**
  16468. * Creates a rotation around an axis and stores it into the given quaternion
  16469. * @param axis defines the axis to use
  16470. * @param angle defines the angle to use
  16471. * @param result defines the target quaternion
  16472. * @returns the target quaternion
  16473. */
  16474. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16475. /**
  16476. * Creates a new quaternion from data stored into an array
  16477. * @param array defines the data source
  16478. * @param offset defines the offset in the source array where the data starts
  16479. * @returns a new quaternion
  16480. */
  16481. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16482. /**
  16483. * Creates a new quaternion from the given Euler float angles (y, x, z)
  16484. * @param yaw defines the rotation around Y axis
  16485. * @param pitch defines the rotation around X axis
  16486. * @param roll defines the rotation around Z axis
  16487. * @returns the new quaternion
  16488. */
  16489. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16490. /**
  16491. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  16492. * @param yaw defines the rotation around Y axis
  16493. * @param pitch defines the rotation around X axis
  16494. * @param roll defines the rotation around Z axis
  16495. * @param result defines the target quaternion
  16496. */
  16497. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  16498. /**
  16499. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  16500. * @param alpha defines the rotation around first axis
  16501. * @param beta defines the rotation around second axis
  16502. * @param gamma defines the rotation around third axis
  16503. * @returns the new quaternion
  16504. */
  16505. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  16506. /**
  16507. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  16508. * @param alpha defines the rotation around first axis
  16509. * @param beta defines the rotation around second axis
  16510. * @param gamma defines the rotation around third axis
  16511. * @param result defines the target quaternion
  16512. */
  16513. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  16514. /**
  16515. * 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)
  16516. * @param axis1 defines the first axis
  16517. * @param axis2 defines the second axis
  16518. * @param axis3 defines the third axis
  16519. * @returns the new quaternion
  16520. */
  16521. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  16522. /**
  16523. * 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
  16524. * @param axis1 defines the first axis
  16525. * @param axis2 defines the second axis
  16526. * @param axis3 defines the third axis
  16527. * @param ref defines the target quaternion
  16528. */
  16529. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  16530. /**
  16531. * Interpolates between two quaternions
  16532. * @param left defines first quaternion
  16533. * @param right defines second quaternion
  16534. * @param amount defines the gradient to use
  16535. * @returns the new interpolated quaternion
  16536. */
  16537. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  16538. /**
  16539. * Interpolates between two quaternions and stores it into a target quaternion
  16540. * @param left defines first quaternion
  16541. * @param right defines second quaternion
  16542. * @param amount defines the gradient to use
  16543. * @param result defines the target quaternion
  16544. */
  16545. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  16546. /**
  16547. * Interpolate between two quaternions using Hermite interpolation
  16548. * @param value1 defines first quaternion
  16549. * @param tangent1 defines the incoming tangent
  16550. * @param value2 defines second quaternion
  16551. * @param tangent2 defines the outgoing tangent
  16552. * @param amount defines the target quaternion
  16553. * @returns the new interpolated quaternion
  16554. */
  16555. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  16556. }
  16557. /**
  16558. * Class used to store matrix data (4x4)
  16559. */
  16560. class Matrix {
  16561. private static _tempQuaternion;
  16562. private static _xAxis;
  16563. private static _yAxis;
  16564. private static _zAxis;
  16565. private static _updateFlagSeed;
  16566. private static _identityReadOnly;
  16567. private _isIdentity;
  16568. private _isIdentityDirty;
  16569. /**
  16570. * Gets the update flag of the matrix which is an unique number for the matrix.
  16571. * It will be incremented every time the matrix data change.
  16572. * You can use it to speed the comparison between two versions of the same matrix.
  16573. */
  16574. updateFlag: number;
  16575. /**
  16576. * Gets or sets the internal data of the matrix
  16577. */
  16578. m: Float32Array;
  16579. /** @hidden */
  16580. _markAsUpdated(): void;
  16581. /**
  16582. * Creates an empty matrix (filled with zeros)
  16583. */
  16584. constructor();
  16585. /**
  16586. * Check if the current matrix is indentity
  16587. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  16588. * @returns true is the matrix is the identity matrix
  16589. */
  16590. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  16591. /**
  16592. * Gets the determinant of the matrix
  16593. * @returns the matrix determinant
  16594. */
  16595. determinant(): number;
  16596. /**
  16597. * Returns the matrix as a Float32Array
  16598. * @returns the matrix underlying array
  16599. */
  16600. toArray(): Float32Array;
  16601. /**
  16602. * Returns the matrix as a Float32Array
  16603. * @returns the matrix underlying array.
  16604. */
  16605. asArray(): Float32Array;
  16606. /**
  16607. * Inverts the current matrix in place
  16608. * @returns the current inverted matrix
  16609. */
  16610. invert(): Matrix;
  16611. /**
  16612. * Sets all the matrix elements to zero
  16613. * @returns the current matrix
  16614. */
  16615. reset(): Matrix;
  16616. /**
  16617. * Adds the current matrix with a second one
  16618. * @param other defines the matrix to add
  16619. * @returns a new matrix as the addition of the current matrix and the given one
  16620. */
  16621. add(other: Matrix): Matrix;
  16622. /**
  16623. * Sets the given matrix "result" to the addition of the current matrix and the given one
  16624. * @param other defines the matrix to add
  16625. * @param result defines the target matrix
  16626. * @returns the current matrix
  16627. */
  16628. addToRef(other: Matrix, result: Matrix): Matrix;
  16629. /**
  16630. * Adds in place the given matrix to the current matrix
  16631. * @param other defines the second operand
  16632. * @returns the current updated matrix
  16633. */
  16634. addToSelf(other: Matrix): Matrix;
  16635. /**
  16636. * Sets the given matrix to the current inverted Matrix
  16637. * @param other defines the target matrix
  16638. * @returns the unmodified current matrix
  16639. */
  16640. invertToRef(other: Matrix): Matrix;
  16641. /**
  16642. * Inserts the translation vector (using 3 floats) in the current matrix
  16643. * @param x defines the 1st component of the translation
  16644. * @param y defines the 2nd component of the translation
  16645. * @param z defines the 3rd component of the translation
  16646. * @returns the current updated matrix
  16647. */
  16648. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  16649. /**
  16650. * Inserts the translation vector in the current matrix
  16651. * @param vector3 defines the translation to insert
  16652. * @returns the current updated matrix
  16653. */
  16654. setTranslation(vector3: Vector3): Matrix;
  16655. /**
  16656. * Gets the translation value of the current matrix
  16657. * @returns a new Vector3 as the extracted translation from the matrix
  16658. */
  16659. getTranslation(): Vector3;
  16660. /**
  16661. * Fill a Vector3 with the extracted translation from the matrix
  16662. * @param result defines the Vector3 where to store the translation
  16663. * @returns the current matrix
  16664. */
  16665. getTranslationToRef(result: Vector3): Matrix;
  16666. /**
  16667. * Remove rotation and scaling part from the matrix
  16668. * @returns the updated matrix
  16669. */
  16670. removeRotationAndScaling(): Matrix;
  16671. /**
  16672. * Multiply two matrices
  16673. * @param other defines the second operand
  16674. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  16675. */
  16676. multiply(other: Matrix): Matrix;
  16677. /**
  16678. * Copy the current matrix from the given one
  16679. * @param other defines the source matrix
  16680. * @returns the current updated matrix
  16681. */
  16682. copyFrom(other: Matrix): Matrix;
  16683. /**
  16684. * Populates the given array from the starting index with the current matrix values
  16685. * @param array defines the target array
  16686. * @param offset defines the offset in the target array where to start storing values
  16687. * @returns the current matrix
  16688. */
  16689. copyToArray(array: Float32Array, offset?: number): Matrix;
  16690. /**
  16691. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  16692. * @param other defines the second operand
  16693. * @param result defines the matrix where to store the multiplication
  16694. * @returns the current matrix
  16695. */
  16696. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  16697. /**
  16698. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  16699. * @param other defines the second operand
  16700. * @param result defines the array where to store the multiplication
  16701. * @param offset defines the offset in the target array where to start storing values
  16702. * @returns the current matrix
  16703. */
  16704. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  16705. /**
  16706. * Check equality between this matrix and a second one
  16707. * @param value defines the second matrix to compare
  16708. * @returns true is the current matrix and the given one values are strictly equal
  16709. */
  16710. equals(value: Matrix): boolean;
  16711. /**
  16712. * Clone the current matrix
  16713. * @returns a new matrix from the current matrix
  16714. */
  16715. clone(): Matrix;
  16716. /**
  16717. * Returns the name of the current matrix class
  16718. * @returns the string "Matrix"
  16719. */
  16720. getClassName(): string;
  16721. /**
  16722. * Gets the hash code of the current matrix
  16723. * @returns the hash code
  16724. */
  16725. getHashCode(): number;
  16726. /**
  16727. * Decomposes the current Matrix into a translation, rotation and scaling components
  16728. * @param scale defines the scale vector3 given as a reference to update
  16729. * @param rotation defines the rotation quaternion given as a reference to update
  16730. * @param translation defines the translation vector3 given as a reference to update
  16731. * @returns true if operation was successful
  16732. */
  16733. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  16734. /**
  16735. * Gets specific row of the matrix
  16736. * @param index defines the number of the row to get
  16737. * @returns the index-th row of the current matrix as a new Vector4
  16738. */
  16739. getRow(index: number): Nullable<Vector4>;
  16740. /**
  16741. * Sets the index-th row of the current matrix to the vector4 values
  16742. * @param index defines the number of the row to set
  16743. * @param row defines the target vector4
  16744. * @returns the updated current matrix
  16745. */
  16746. setRow(index: number, row: Vector4): Matrix;
  16747. /**
  16748. * Compute the transpose of the matrix
  16749. * @returns the new transposed matrix
  16750. */
  16751. transpose(): Matrix;
  16752. /**
  16753. * Compute the transpose of the matrix and store it in a given matrix
  16754. * @param result defines the target matrix
  16755. * @returns the current matrix
  16756. */
  16757. transposeToRef(result: Matrix): Matrix;
  16758. /**
  16759. * Sets the index-th row of the current matrix with the given 4 x float values
  16760. * @param index defines the row index
  16761. * @param x defines the x component to set
  16762. * @param y defines the y component to set
  16763. * @param z defines the z component to set
  16764. * @param w defines the w component to set
  16765. * @returns the updated current matrix
  16766. */
  16767. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  16768. /**
  16769. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  16770. * @param scale defines the scale factor
  16771. * @returns a new matrix
  16772. */
  16773. scale(scale: number): Matrix;
  16774. /**
  16775. * Scale the current matrix values by a factor to a given result matrix
  16776. * @param scale defines the scale factor
  16777. * @param result defines the matrix to store the result
  16778. * @returns the current matrix
  16779. */
  16780. scaleToRef(scale: number, result: Matrix): Matrix;
  16781. /**
  16782. * Scale the current matrix values by a factor and add the result to a given matrix
  16783. * @param scale defines the scale factor
  16784. * @param result defines the Matrix to store the result
  16785. * @returns the current matrix
  16786. */
  16787. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  16788. /**
  16789. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  16790. * @param ref matrix to store the result
  16791. */
  16792. toNormalMatrix(ref: Matrix): void;
  16793. /**
  16794. * Gets only rotation part of the current matrix
  16795. * @returns a new matrix sets to the extracted rotation matrix from the current one
  16796. */
  16797. getRotationMatrix(): Matrix;
  16798. /**
  16799. * Extracts the rotation matrix from the current one and sets it as the given "result"
  16800. * @param result defines the target matrix to store data to
  16801. * @returns the current matrix
  16802. */
  16803. getRotationMatrixToRef(result: Matrix): Matrix;
  16804. /**
  16805. * Creates a matrix from an array
  16806. * @param array defines the source array
  16807. * @param offset defines an offset in the source array
  16808. * @returns a new Matrix set from the starting index of the given array
  16809. */
  16810. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  16811. /**
  16812. * Copy the content of an array into a given matrix
  16813. * @param array defines the source array
  16814. * @param offset defines an offset in the source array
  16815. * @param result defines the target matrix
  16816. */
  16817. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  16818. /**
  16819. * Stores an array into a matrix after having multiplied each component by a given factor
  16820. * @param array defines the source array
  16821. * @param offset defines the offset in the source array
  16822. * @param scale defines the scaling factor
  16823. * @param result defines the target matrix
  16824. */
  16825. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  16826. /**
  16827. * Stores a list of values (16) inside a given matrix
  16828. * @param initialM11 defines 1st value of 1st row
  16829. * @param initialM12 defines 2nd value of 1st row
  16830. * @param initialM13 defines 3rd value of 1st row
  16831. * @param initialM14 defines 4th value of 1st row
  16832. * @param initialM21 defines 1st value of 2nd row
  16833. * @param initialM22 defines 2nd value of 2nd row
  16834. * @param initialM23 defines 3rd value of 2nd row
  16835. * @param initialM24 defines 4th value of 2nd row
  16836. * @param initialM31 defines 1st value of 3rd row
  16837. * @param initialM32 defines 2nd value of 3rd row
  16838. * @param initialM33 defines 3rd value of 3rd row
  16839. * @param initialM34 defines 4th value of 3rd row
  16840. * @param initialM41 defines 1st value of 4th row
  16841. * @param initialM42 defines 2nd value of 4th row
  16842. * @param initialM43 defines 3rd value of 4th row
  16843. * @param initialM44 defines 4th value of 4th row
  16844. * @param result defines the target matrix
  16845. */
  16846. 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;
  16847. /**
  16848. * Gets an identity matrix that must not be updated
  16849. */
  16850. static readonly IdentityReadOnly: Matrix;
  16851. /**
  16852. * Creates new matrix from a list of values (16)
  16853. * @param initialM11 defines 1st value of 1st row
  16854. * @param initialM12 defines 2nd value of 1st row
  16855. * @param initialM13 defines 3rd value of 1st row
  16856. * @param initialM14 defines 4th value of 1st row
  16857. * @param initialM21 defines 1st value of 2nd row
  16858. * @param initialM22 defines 2nd value of 2nd row
  16859. * @param initialM23 defines 3rd value of 2nd row
  16860. * @param initialM24 defines 4th value of 2nd row
  16861. * @param initialM31 defines 1st value of 3rd row
  16862. * @param initialM32 defines 2nd value of 3rd row
  16863. * @param initialM33 defines 3rd value of 3rd row
  16864. * @param initialM34 defines 4th value of 3rd row
  16865. * @param initialM41 defines 1st value of 4th row
  16866. * @param initialM42 defines 2nd value of 4th row
  16867. * @param initialM43 defines 3rd value of 4th row
  16868. * @param initialM44 defines 4th value of 4th row
  16869. * @returns the new matrix
  16870. */
  16871. 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;
  16872. /**
  16873. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  16874. * @param scale defines the scale vector3
  16875. * @param rotation defines the rotation quaternion
  16876. * @param translation defines the translation vector3
  16877. * @returns a new matrix
  16878. */
  16879. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  16880. /**
  16881. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  16882. * @param scale defines the scale vector3
  16883. * @param rotation defines the rotation quaternion
  16884. * @param translation defines the translation vector3
  16885. * @param result defines the target matrix
  16886. */
  16887. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  16888. /**
  16889. * Creates a new identity matrix
  16890. * @returns a new identity matrix
  16891. */
  16892. static Identity(): Matrix;
  16893. /**
  16894. * Creates a new identity matrix and stores the result in a given matrix
  16895. * @param result defines the target matrix
  16896. */
  16897. static IdentityToRef(result: Matrix): void;
  16898. /**
  16899. * Creates a new zero matrix
  16900. * @returns a new zero matrix
  16901. */
  16902. static Zero(): Matrix;
  16903. /**
  16904. * Creates a new rotation matrix for "angle" radians around the X axis
  16905. * @param angle defines the angle (in radians) to use
  16906. * @return the new matrix
  16907. */
  16908. static RotationX(angle: number): Matrix;
  16909. /**
  16910. * Creates a new matrix as the invert of a given matrix
  16911. * @param source defines the source matrix
  16912. * @returns the new matrix
  16913. */
  16914. static Invert(source: Matrix): Matrix;
  16915. /**
  16916. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  16917. * @param angle defines the angle (in radians) to use
  16918. * @param result defines the target matrix
  16919. */
  16920. static RotationXToRef(angle: number, result: Matrix): void;
  16921. /**
  16922. * Creates a new rotation matrix for "angle" radians around the Y axis
  16923. * @param angle defines the angle (in radians) to use
  16924. * @return the new matrix
  16925. */
  16926. static RotationY(angle: number): Matrix;
  16927. /**
  16928. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  16929. * @param angle defines the angle (in radians) to use
  16930. * @param result defines the target matrix
  16931. */
  16932. static RotationYToRef(angle: number, result: Matrix): void;
  16933. /**
  16934. * Creates a new rotation matrix for "angle" radians around the Z axis
  16935. * @param angle defines the angle (in radians) to use
  16936. * @return the new matrix
  16937. */
  16938. static RotationZ(angle: number): Matrix;
  16939. /**
  16940. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  16941. * @param angle defines the angle (in radians) to use
  16942. * @param result defines the target matrix
  16943. */
  16944. static RotationZToRef(angle: number, result: Matrix): void;
  16945. /**
  16946. * Creates a new rotation matrix for "angle" radians around the given axis
  16947. * @param axis defines the axis to use
  16948. * @param angle defines the angle (in radians) to use
  16949. * @return the new matrix
  16950. */
  16951. static RotationAxis(axis: Vector3, angle: number): Matrix;
  16952. /**
  16953. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  16954. * @param axis defines the axis to use
  16955. * @param angle defines the angle (in radians) to use
  16956. * @param result defines the target matrix
  16957. */
  16958. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  16959. /**
  16960. * Creates a rotation matrix
  16961. * @param yaw defines the yaw angle in radians (Y axis)
  16962. * @param pitch defines the pitch angle in radians (X axis)
  16963. * @param roll defines the roll angle in radians (X axis)
  16964. * @returns the new rotation matrix
  16965. */
  16966. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  16967. /**
  16968. * Creates a rotation matrix and stores it in a given matrix
  16969. * @param yaw defines the yaw angle in radians (Y axis)
  16970. * @param pitch defines the pitch angle in radians (X axis)
  16971. * @param roll defines the roll angle in radians (X axis)
  16972. * @param result defines the target matrix
  16973. */
  16974. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  16975. /**
  16976. * Creates a scaling matrix
  16977. * @param x defines the scale factor on X axis
  16978. * @param y defines the scale factor on Y axis
  16979. * @param z defines the scale factor on Z axis
  16980. * @returns the new matrix
  16981. */
  16982. static Scaling(x: number, y: number, z: number): Matrix;
  16983. /**
  16984. * Creates a scaling matrix and stores it in a given matrix
  16985. * @param x defines the scale factor on X axis
  16986. * @param y defines the scale factor on Y axis
  16987. * @param z defines the scale factor on Z axis
  16988. * @param result defines the target matrix
  16989. */
  16990. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  16991. /**
  16992. * Creates a translation matrix
  16993. * @param x defines the translation on X axis
  16994. * @param y defines the translation on Y axis
  16995. * @param z defines the translationon Z axis
  16996. * @returns the new matrix
  16997. */
  16998. static Translation(x: number, y: number, z: number): Matrix;
  16999. /**
  17000. * Creates a translation matrix and stores it in a given matrix
  17001. * @param x defines the translation on X axis
  17002. * @param y defines the translation on Y axis
  17003. * @param z defines the translationon Z axis
  17004. * @param result defines the target matrix
  17005. */
  17006. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17007. /**
  17008. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17009. * @param startValue defines the start value
  17010. * @param endValue defines the end value
  17011. * @param gradient defines the gradient factor
  17012. * @returns the new matrix
  17013. */
  17014. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17015. /**
  17016. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17017. * @param startValue defines the start value
  17018. * @param endValue defines the end value
  17019. * @param gradient defines the gradient factor
  17020. * @param result defines the Matrix object where to store data
  17021. */
  17022. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17023. /**
  17024. * Builds a new matrix whose values are computed by:
  17025. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17026. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17027. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17028. * @param startValue defines the first matrix
  17029. * @param endValue defines the second matrix
  17030. * @param gradient defines the gradient between the two matrices
  17031. * @returns the new matrix
  17032. */
  17033. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17034. /**
  17035. * Update a matrix to values which are computed by:
  17036. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17037. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17038. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17039. * @param startValue defines the first matrix
  17040. * @param endValue defines the second matrix
  17041. * @param gradient defines the gradient between the two matrices
  17042. * @param result defines the target matrix
  17043. */
  17044. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17045. /**
  17046. * 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"
  17047. * This function works in left handed mode
  17048. * @param eye defines the final position of the entity
  17049. * @param target defines where the entity should look at
  17050. * @param up defines the up vector for the entity
  17051. * @returns the new matrix
  17052. */
  17053. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17054. /**
  17055. * 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".
  17056. * This function works in left handed mode
  17057. * @param eye defines the final position of the entity
  17058. * @param target defines where the entity should look at
  17059. * @param up defines the up vector for the entity
  17060. * @param result defines the target matrix
  17061. */
  17062. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17063. /**
  17064. * 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"
  17065. * This function works in right handed mode
  17066. * @param eye defines the final position of the entity
  17067. * @param target defines where the entity should look at
  17068. * @param up defines the up vector for the entity
  17069. * @returns the new matrix
  17070. */
  17071. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17072. /**
  17073. * 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".
  17074. * This function works in right handed mode
  17075. * @param eye defines the final position of the entity
  17076. * @param target defines where the entity should look at
  17077. * @param up defines the up vector for the entity
  17078. * @param result defines the target matrix
  17079. */
  17080. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17081. /**
  17082. * Create a left-handed orthographic projection matrix
  17083. * @param width defines the viewport width
  17084. * @param height defines the viewport height
  17085. * @param znear defines the near clip plane
  17086. * @param zfar defines the far clip plane
  17087. * @returns a new matrix as a left-handed orthographic projection matrix
  17088. */
  17089. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17090. /**
  17091. * Store a left-handed orthographic projection to a given matrix
  17092. * @param width defines the viewport width
  17093. * @param height defines the viewport height
  17094. * @param znear defines the near clip plane
  17095. * @param zfar defines the far clip plane
  17096. * @param result defines the target matrix
  17097. */
  17098. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17099. /**
  17100. * Create a left-handed orthographic projection matrix
  17101. * @param left defines the viewport left coordinate
  17102. * @param right defines the viewport right coordinate
  17103. * @param bottom defines the viewport bottom coordinate
  17104. * @param top defines the viewport top coordinate
  17105. * @param znear defines the near clip plane
  17106. * @param zfar defines the far clip plane
  17107. * @returns a new matrix as a left-handed orthographic projection matrix
  17108. */
  17109. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17110. /**
  17111. * Stores a left-handed orthographic projection into a given matrix
  17112. * @param left defines the viewport left coordinate
  17113. * @param right defines the viewport right coordinate
  17114. * @param bottom defines the viewport bottom coordinate
  17115. * @param top defines the viewport top coordinate
  17116. * @param znear defines the near clip plane
  17117. * @param zfar defines the far clip plane
  17118. * @param result defines the target matrix
  17119. */
  17120. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17121. /**
  17122. * Creates a right-handed orthographic projection matrix
  17123. * @param left defines the viewport left coordinate
  17124. * @param right defines the viewport right coordinate
  17125. * @param bottom defines the viewport bottom coordinate
  17126. * @param top defines the viewport top coordinate
  17127. * @param znear defines the near clip plane
  17128. * @param zfar defines the far clip plane
  17129. * @returns a new matrix as a right-handed orthographic projection matrix
  17130. */
  17131. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17132. /**
  17133. * Stores a right-handed orthographic projection into a given matrix
  17134. * @param left defines the viewport left coordinate
  17135. * @param right defines the viewport right coordinate
  17136. * @param bottom defines the viewport bottom coordinate
  17137. * @param top defines the viewport top coordinate
  17138. * @param znear defines the near clip plane
  17139. * @param zfar defines the far clip plane
  17140. * @param result defines the target matrix
  17141. */
  17142. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17143. /**
  17144. * Creates a left-handed perspective projection matrix
  17145. * @param width defines the viewport width
  17146. * @param height defines the viewport height
  17147. * @param znear defines the near clip plane
  17148. * @param zfar defines the far clip plane
  17149. * @returns a new matrix as a left-handed perspective projection matrix
  17150. */
  17151. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17152. /**
  17153. * Creates a left-handed perspective projection matrix
  17154. * @param fov defines the horizontal field of view
  17155. * @param aspect defines the aspect ratio
  17156. * @param znear defines the near clip plane
  17157. * @param zfar defines the far clip plane
  17158. * @returns a new matrix as a left-handed perspective projection matrix
  17159. */
  17160. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17161. /**
  17162. * Stores a left-handed perspective projection into a given matrix
  17163. * @param fov defines the horizontal field of view
  17164. * @param aspect defines the aspect ratio
  17165. * @param znear defines the near clip plane
  17166. * @param zfar defines the far clip plane
  17167. * @param result defines the target matrix
  17168. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17169. */
  17170. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17171. /**
  17172. * Creates a right-handed perspective projection matrix
  17173. * @param fov defines the horizontal field of view
  17174. * @param aspect defines the aspect ratio
  17175. * @param znear defines the near clip plane
  17176. * @param zfar defines the far clip plane
  17177. * @returns a new matrix as a right-handed perspective projection matrix
  17178. */
  17179. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17180. /**
  17181. * Stores a right-handed perspective projection into a given matrix
  17182. * @param fov defines the horizontal field of view
  17183. * @param aspect defines the aspect ratio
  17184. * @param znear defines the near clip plane
  17185. * @param zfar defines the far clip plane
  17186. * @param result defines the target matrix
  17187. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17188. */
  17189. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17190. /**
  17191. * Stores a perspective projection for WebVR info a given matrix
  17192. * @param fov defines the field of view
  17193. * @param znear defines the near clip plane
  17194. * @param zfar defines the far clip plane
  17195. * @param result defines the target matrix
  17196. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17197. */
  17198. static PerspectiveFovWebVRToRef(fov: {
  17199. upDegrees: number;
  17200. downDegrees: number;
  17201. leftDegrees: number;
  17202. rightDegrees: number;
  17203. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17204. /**
  17205. * Computes a complete transformation matrix
  17206. * @param viewport defines the viewport to use
  17207. * @param world defines the world matrix
  17208. * @param view defines the view matrix
  17209. * @param projection defines the projection matrix
  17210. * @param zmin defines the near clip plane
  17211. * @param zmax defines the far clip plane
  17212. * @returns the transformation matrix
  17213. */
  17214. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17215. /**
  17216. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17217. * @param matrix defines the matrix to use
  17218. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17219. */
  17220. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17221. /**
  17222. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17223. * @param matrix defines the matrix to use
  17224. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17225. */
  17226. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17227. /**
  17228. * Compute the transpose of a given matrix
  17229. * @param matrix defines the matrix to transpose
  17230. * @returns the new matrix
  17231. */
  17232. static Transpose(matrix: Matrix): Matrix;
  17233. /**
  17234. * Compute the transpose of a matrix and store it in a target matrix
  17235. * @param matrix defines the matrix to transpose
  17236. * @param result defines the target matrix
  17237. */
  17238. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17239. /**
  17240. * Computes a reflection matrix from a plane
  17241. * @param plane defines the reflection plane
  17242. * @returns a new matrix
  17243. */
  17244. static Reflection(plane: Plane): Matrix;
  17245. /**
  17246. * Computes a reflection matrix from a plane
  17247. * @param plane defines the reflection plane
  17248. * @param result defines the target matrix
  17249. */
  17250. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17251. /**
  17252. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17253. * @param xaxis defines the value of the 1st axis
  17254. * @param yaxis defines the value of the 2nd axis
  17255. * @param zaxis defines the value of the 3rd axis
  17256. * @param result defines the target matrix
  17257. */
  17258. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17259. /**
  17260. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17261. * @param quat defines the quaternion to use
  17262. * @param result defines the target matrix
  17263. */
  17264. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17265. }
  17266. class Plane {
  17267. normal: Vector3;
  17268. d: number;
  17269. /**
  17270. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17271. */
  17272. constructor(a: number, b: number, c: number, d: number);
  17273. /**
  17274. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17275. */
  17276. asArray(): number[];
  17277. /**
  17278. * Returns a new plane copied from the current Plane.
  17279. */
  17280. clone(): Plane;
  17281. /**
  17282. * Returns the string "Plane".
  17283. */
  17284. getClassName(): string;
  17285. /**
  17286. * Returns the Plane hash code.
  17287. */
  17288. getHashCode(): number;
  17289. /**
  17290. * Normalize the current Plane in place.
  17291. * Returns the updated Plane.
  17292. */
  17293. normalize(): Plane;
  17294. /**
  17295. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17296. */
  17297. transform(transformation: Matrix): Plane;
  17298. /**
  17299. * Returns the dot product (float) of the point coordinates and the plane normal.
  17300. */
  17301. dotCoordinate(point: Vector3): number;
  17302. /**
  17303. * Updates the current Plane from the plane defined by the three given points.
  17304. * Returns the updated Plane.
  17305. */
  17306. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17307. /**
  17308. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17309. */
  17310. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17311. /**
  17312. * Returns the signed distance (float) from the given point to the Plane.
  17313. */
  17314. signedDistanceTo(point: Vector3): number;
  17315. /**
  17316. * Returns a new Plane from the given array.
  17317. */
  17318. static FromArray(array: ArrayLike<number>): Plane;
  17319. /**
  17320. * Returns a new Plane defined by the three given points.
  17321. */
  17322. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17323. /**
  17324. * Returns a new Plane the normal vector to this plane at the given origin point.
  17325. * Note : the vector "normal" is updated because normalized.
  17326. */
  17327. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17328. /**
  17329. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17330. */
  17331. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17332. }
  17333. class Viewport {
  17334. x: number;
  17335. y: number;
  17336. width: number;
  17337. height: number;
  17338. /**
  17339. * Creates a Viewport object located at (x, y) and sized (width, height).
  17340. */
  17341. constructor(x: number, y: number, width: number, height: number);
  17342. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17343. /**
  17344. * Returns a new Viewport copied from the current one.
  17345. */
  17346. clone(): Viewport;
  17347. }
  17348. class Frustum {
  17349. /**
  17350. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17351. */
  17352. static GetPlanes(transform: Matrix): Plane[];
  17353. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17354. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17355. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17356. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17357. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17358. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17359. /**
  17360. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17361. */
  17362. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17363. }
  17364. /** Defines supported spaces */
  17365. enum Space {
  17366. /** Local (object) space */
  17367. LOCAL = 0,
  17368. /** World space */
  17369. WORLD = 1,
  17370. /** Bone space */
  17371. BONE = 2,
  17372. }
  17373. /** Defines the 3 main axes */
  17374. class Axis {
  17375. /** X axis */
  17376. static X: Vector3;
  17377. /** Y axis */
  17378. static Y: Vector3;
  17379. /** Z axis */
  17380. static Z: Vector3;
  17381. }
  17382. class BezierCurve {
  17383. /**
  17384. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17385. */
  17386. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17387. }
  17388. /**
  17389. * Defines potential orientation for back face culling
  17390. */
  17391. enum Orientation {
  17392. /**
  17393. * Clockwise
  17394. */
  17395. CW = 0,
  17396. /** Counter clockwise */
  17397. CCW = 1,
  17398. }
  17399. /**
  17400. * Defines angle representation
  17401. */
  17402. class Angle {
  17403. private _radians;
  17404. /**
  17405. * Creates an Angle object of "radians" radians (float).
  17406. */
  17407. constructor(radians: number);
  17408. /**
  17409. * Get value in degrees
  17410. * @returns the Angle value in degrees (float)
  17411. */
  17412. degrees(): number;
  17413. /**
  17414. * Get value in radians
  17415. * @returns the Angle value in radians (float)
  17416. */
  17417. radians(): number;
  17418. /**
  17419. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17420. * @param a defines first vector
  17421. * @param b defines second vector
  17422. * @returns a new Angle
  17423. */
  17424. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17425. /**
  17426. * Gets a new Angle object from the given float in radians
  17427. * @param radians defines the angle value in radians
  17428. * @returns a new Angle
  17429. */
  17430. static FromRadians(radians: number): Angle;
  17431. /**
  17432. * Gets a new Angle object from the given float in degrees
  17433. * @param degrees defines the angle value in degrees
  17434. * @returns a new Angle
  17435. */
  17436. static FromDegrees(degrees: number): Angle;
  17437. }
  17438. class Arc2 {
  17439. startPoint: Vector2;
  17440. midPoint: Vector2;
  17441. endPoint: Vector2;
  17442. centerPoint: Vector2;
  17443. radius: number;
  17444. angle: Angle;
  17445. startAngle: Angle;
  17446. orientation: Orientation;
  17447. /**
  17448. * Creates an Arc object from the three given points : start, middle and end.
  17449. */
  17450. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  17451. }
  17452. class Path2 {
  17453. private _points;
  17454. private _length;
  17455. closed: boolean;
  17456. /**
  17457. * Creates a Path2 object from the starting 2D coordinates x and y.
  17458. */
  17459. constructor(x: number, y: number);
  17460. /**
  17461. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  17462. * Returns the updated Path2.
  17463. */
  17464. addLineTo(x: number, y: number): Path2;
  17465. /**
  17466. * 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.
  17467. * Returns the updated Path2.
  17468. */
  17469. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  17470. /**
  17471. * Closes the Path2.
  17472. * Returns the Path2.
  17473. */
  17474. close(): Path2;
  17475. /**
  17476. * Returns the Path2 total length (float).
  17477. */
  17478. length(): number;
  17479. /**
  17480. * Returns the Path2 internal array of points.
  17481. */
  17482. getPoints(): Vector2[];
  17483. /**
  17484. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  17485. */
  17486. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  17487. /**
  17488. * Returns a new Path2 starting at the coordinates (x, y).
  17489. */
  17490. static StartingAt(x: number, y: number): Path2;
  17491. }
  17492. class Path3D {
  17493. path: Vector3[];
  17494. private _curve;
  17495. private _distances;
  17496. private _tangents;
  17497. private _normals;
  17498. private _binormals;
  17499. private _raw;
  17500. /**
  17501. * new Path3D(path, normal, raw)
  17502. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  17503. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  17504. * path : an array of Vector3, the curve axis of the Path3D
  17505. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  17506. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  17507. */
  17508. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  17509. /**
  17510. * Returns the Path3D array of successive Vector3 designing its curve.
  17511. */
  17512. getCurve(): Vector3[];
  17513. /**
  17514. * Returns an array populated with tangent vectors on each Path3D curve point.
  17515. */
  17516. getTangents(): Vector3[];
  17517. /**
  17518. * Returns an array populated with normal vectors on each Path3D curve point.
  17519. */
  17520. getNormals(): Vector3[];
  17521. /**
  17522. * Returns an array populated with binormal vectors on each Path3D curve point.
  17523. */
  17524. getBinormals(): Vector3[];
  17525. /**
  17526. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  17527. */
  17528. getDistances(): number[];
  17529. /**
  17530. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  17531. * Returns the same object updated.
  17532. */
  17533. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  17534. private _compute(firstNormal);
  17535. private _getFirstNonNullVector(index);
  17536. private _getLastNonNullVector(index);
  17537. private _normalVector(v0, vt, va);
  17538. }
  17539. class Curve3 {
  17540. private _points;
  17541. private _length;
  17542. /**
  17543. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  17544. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  17545. * @param v1 (Vector3) the control point
  17546. * @param v2 (Vector3) the end point of the Quadratic Bezier
  17547. * @param nbPoints (integer) the wanted number of points in the curve
  17548. */
  17549. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  17550. /**
  17551. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  17552. * @param v0 (Vector3) the origin point of the Cubic Bezier
  17553. * @param v1 (Vector3) the first control point
  17554. * @param v2 (Vector3) the second control point
  17555. * @param v3 (Vector3) the end point of the Cubic Bezier
  17556. * @param nbPoints (integer) the wanted number of points in the curve
  17557. */
  17558. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  17559. /**
  17560. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  17561. * @param p1 (Vector3) the origin point of the Hermite Spline
  17562. * @param t1 (Vector3) the tangent vector at the origin point
  17563. * @param p2 (Vector3) the end point of the Hermite Spline
  17564. * @param t2 (Vector3) the tangent vector at the end point
  17565. * @param nbPoints (integer) the wanted number of points in the curve
  17566. */
  17567. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  17568. /**
  17569. * Returns a Curve3 object along a CatmullRom Spline curve :
  17570. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  17571. * @param nbPoints (integer) the wanted number of points between each curve control points.
  17572. */
  17573. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  17574. /**
  17575. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  17576. * A Curve3 is designed from a series of successive Vector3.
  17577. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  17578. */
  17579. constructor(points: Vector3[]);
  17580. /**
  17581. * Returns the Curve3 stored array of successive Vector3
  17582. */
  17583. getPoints(): Vector3[];
  17584. /**
  17585. * Returns the computed length (float) of the curve.
  17586. */
  17587. length(): number;
  17588. /**
  17589. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  17590. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  17591. * curveA and curveB keep unchanged.
  17592. */
  17593. continue(curve: Curve3): Curve3;
  17594. private _computeLength(path);
  17595. }
  17596. class PositionNormalVertex {
  17597. position: Vector3;
  17598. normal: Vector3;
  17599. constructor(position?: Vector3, normal?: Vector3);
  17600. clone(): PositionNormalVertex;
  17601. }
  17602. class PositionNormalTextureVertex {
  17603. position: Vector3;
  17604. normal: Vector3;
  17605. uv: Vector2;
  17606. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  17607. clone(): PositionNormalTextureVertex;
  17608. }
  17609. class Tmp {
  17610. static Color3: Color3[];
  17611. static Vector2: Vector2[];
  17612. static Vector3: Vector3[];
  17613. static Vector4: Vector4[];
  17614. static Quaternion: Quaternion[];
  17615. static Matrix: Matrix[];
  17616. }
  17617. }
  17618. declare module BABYLON {
  17619. class SphericalPolynomial {
  17620. x: Vector3;
  17621. y: Vector3;
  17622. z: Vector3;
  17623. xx: Vector3;
  17624. yy: Vector3;
  17625. zz: Vector3;
  17626. xy: Vector3;
  17627. yz: Vector3;
  17628. zx: Vector3;
  17629. addAmbient(color: Color3): void;
  17630. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  17631. scale(scale: number): void;
  17632. }
  17633. class SphericalHarmonics {
  17634. L00: Vector3;
  17635. L1_1: Vector3;
  17636. L10: Vector3;
  17637. L11: Vector3;
  17638. L2_2: Vector3;
  17639. L2_1: Vector3;
  17640. L20: Vector3;
  17641. L21: Vector3;
  17642. L22: Vector3;
  17643. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  17644. scale(scale: number): void;
  17645. convertIncidentRadianceToIrradiance(): void;
  17646. convertIrradianceToLambertianRadiance(): void;
  17647. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  17648. }
  17649. }
  17650. declare module BABYLON {
  17651. /**
  17652. * Defines a target to use with MorphTargetManager
  17653. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17654. */
  17655. class MorphTarget implements IAnimatable {
  17656. /** defines the name of the target */
  17657. name: string;
  17658. /**
  17659. * Gets or sets the list of animations
  17660. */
  17661. animations: Animation[];
  17662. private _scene;
  17663. private _positions;
  17664. private _normals;
  17665. private _tangents;
  17666. private _influence;
  17667. /**
  17668. * Observable raised when the influence changes
  17669. */
  17670. onInfluenceChanged: Observable<boolean>;
  17671. /**
  17672. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  17673. */
  17674. influence: number;
  17675. private _animationPropertiesOverride;
  17676. /**
  17677. * Gets or sets the animation properties override
  17678. */
  17679. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  17680. /**
  17681. * Creates a new MorphTarget
  17682. * @param name defines the name of the target
  17683. * @param influence defines the influence to use
  17684. */
  17685. constructor(
  17686. /** defines the name of the target */
  17687. name: string, influence?: number, scene?: Nullable<Scene>);
  17688. /**
  17689. * Gets a boolean defining if the target contains position data
  17690. */
  17691. readonly hasPositions: boolean;
  17692. /**
  17693. * Gets a boolean defining if the target contains normal data
  17694. */
  17695. readonly hasNormals: boolean;
  17696. /**
  17697. * Gets a boolean defining if the target contains tangent data
  17698. */
  17699. readonly hasTangents: boolean;
  17700. /**
  17701. * Affects position data to this target
  17702. * @param data defines the position data to use
  17703. */
  17704. setPositions(data: Nullable<FloatArray>): void;
  17705. /**
  17706. * Gets the position data stored in this target
  17707. * @returns a FloatArray containing the position data (or null if not present)
  17708. */
  17709. getPositions(): Nullable<FloatArray>;
  17710. /**
  17711. * Affects normal data to this target
  17712. * @param data defines the normal data to use
  17713. */
  17714. setNormals(data: Nullable<FloatArray>): void;
  17715. /**
  17716. * Gets the normal data stored in this target
  17717. * @returns a FloatArray containing the normal data (or null if not present)
  17718. */
  17719. getNormals(): Nullable<FloatArray>;
  17720. /**
  17721. * Affects tangent data to this target
  17722. * @param data defines the tangent data to use
  17723. */
  17724. setTangents(data: Nullable<FloatArray>): void;
  17725. /**
  17726. * Gets the tangent data stored in this target
  17727. * @returns a FloatArray containing the tangent data (or null if not present)
  17728. */
  17729. getTangents(): Nullable<FloatArray>;
  17730. /**
  17731. * Serializes the current target into a Serialization object
  17732. * @returns the serialized object
  17733. */
  17734. serialize(): any;
  17735. /**
  17736. * Creates a new target from serialized data
  17737. * @param serializationObject defines the serialized data to use
  17738. * @returns a new MorphTarget
  17739. */
  17740. static Parse(serializationObject: any): MorphTarget;
  17741. /**
  17742. * Creates a MorphTarget from mesh data
  17743. * @param mesh defines the source mesh
  17744. * @param name defines the name to use for the new target
  17745. * @param influence defines the influence to attach to the target
  17746. * @returns a new MorphTarget
  17747. */
  17748. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17749. }
  17750. }
  17751. declare module BABYLON {
  17752. /**
  17753. * This class is used to deform meshes using morphing between different targets
  17754. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17755. */
  17756. class MorphTargetManager {
  17757. private _targets;
  17758. private _targetObservable;
  17759. private _activeTargets;
  17760. private _scene;
  17761. private _influences;
  17762. private _supportsNormals;
  17763. private _supportsTangents;
  17764. private _vertexCount;
  17765. private _uniqueId;
  17766. private _tempInfluences;
  17767. /**
  17768. * Creates a new MorphTargetManager
  17769. * @param scene defines the current scene
  17770. */
  17771. constructor(scene?: Nullable<Scene>);
  17772. /**
  17773. * Gets the unique ID of this manager
  17774. */
  17775. readonly uniqueId: number;
  17776. /**
  17777. * Gets the number of vertices handled by this manager
  17778. */
  17779. readonly vertexCount: number;
  17780. /**
  17781. * Gets a boolean indicating if this manager supports morphing of normals
  17782. */
  17783. readonly supportsNormals: boolean;
  17784. /**
  17785. * Gets a boolean indicating if this manager supports morphing of tangents
  17786. */
  17787. readonly supportsTangents: boolean;
  17788. /**
  17789. * Gets the number of targets stored in this manager
  17790. */
  17791. readonly numTargets: number;
  17792. /**
  17793. * Gets the number of influencers (ie. the number of targets with influences > 0)
  17794. */
  17795. readonly numInfluencers: number;
  17796. /**
  17797. * Gets the list of influences (one per target)
  17798. */
  17799. readonly influences: Float32Array;
  17800. /**
  17801. * Gets the active target at specified index. An active target is a target with an influence > 0
  17802. * @param index defines the index to check
  17803. * @returns the requested target
  17804. */
  17805. getActiveTarget(index: number): MorphTarget;
  17806. /**
  17807. * Gets the target at specified index
  17808. * @param index defines the index to check
  17809. * @returns the requested target
  17810. */
  17811. getTarget(index: number): MorphTarget;
  17812. /**
  17813. * Add a new target to this manager
  17814. * @param target defines the target to add
  17815. */
  17816. addTarget(target: MorphTarget): void;
  17817. /**
  17818. * Removes a target from the manager
  17819. * @param target defines the target to remove
  17820. */
  17821. removeTarget(target: MorphTarget): void;
  17822. /**
  17823. * Serializes the current manager into a Serialization object
  17824. * @returns the serialized object
  17825. */
  17826. serialize(): any;
  17827. private _syncActiveTargets(needUpdate);
  17828. /**
  17829. * Syncrhonize the targets with all the meshes using this morph target manager
  17830. */
  17831. synchronize(): void;
  17832. /**
  17833. * Creates a new MorphTargetManager from serialized data
  17834. * @param serializationObject defines the serialized data
  17835. * @param scene defines the hosting scene
  17836. * @returns the new MorphTargetManager
  17837. */
  17838. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17839. }
  17840. }
  17841. declare module BABYLON {
  17842. /**
  17843. * Class used to store all common mesh properties
  17844. */
  17845. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  17846. /** No occlusion */
  17847. static OCCLUSION_TYPE_NONE: number;
  17848. /** Occlusion set to optimisitic */
  17849. static OCCLUSION_TYPE_OPTIMISTIC: number;
  17850. /** Occlusion set to strict */
  17851. static OCCLUSION_TYPE_STRICT: number;
  17852. /** Use an accurante occlusion algorithm */
  17853. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  17854. /** Use a conservative occlusion algorithm */
  17855. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  17856. /**
  17857. * No billboard
  17858. */
  17859. static readonly BILLBOARDMODE_NONE: number;
  17860. /** Billboard on X axis */
  17861. static readonly BILLBOARDMODE_X: number;
  17862. /** Billboard on Y axis */
  17863. static readonly BILLBOARDMODE_Y: number;
  17864. /** Billboard on Z axis */
  17865. static readonly BILLBOARDMODE_Z: number;
  17866. /** Billboard on all axes */
  17867. static readonly BILLBOARDMODE_ALL: number;
  17868. private _facetPositions;
  17869. private _facetNormals;
  17870. private _facetPartitioning;
  17871. private _facetNb;
  17872. private _partitioningSubdivisions;
  17873. private _partitioningBBoxRatio;
  17874. private _facetDataEnabled;
  17875. private _facetParameters;
  17876. private _bbSize;
  17877. private _subDiv;
  17878. private _facetDepthSort;
  17879. private _facetDepthSortEnabled;
  17880. private _depthSortedIndices;
  17881. private _depthSortedFacets;
  17882. private _facetDepthSortFunction;
  17883. private _facetDepthSortFrom;
  17884. private _facetDepthSortOrigin;
  17885. private _invertedMatrix;
  17886. /**
  17887. * Gets the number of facets in the mesh
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17889. */
  17890. readonly facetNb: number;
  17891. /**
  17892. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  17893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17894. */
  17895. partitioningSubdivisions: number;
  17896. /**
  17897. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  17898. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  17899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17900. */
  17901. partitioningBBoxRatio: number;
  17902. /**
  17903. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  17904. * Works only for updatable meshes.
  17905. * Doesn't work with multi-materials
  17906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17907. */
  17908. mustDepthSortFacets: boolean;
  17909. /**
  17910. * The location (Vector3) where the facet depth sort must be computed from.
  17911. * By default, the active camera position.
  17912. * Used only when facet depth sort is enabled
  17913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17914. */
  17915. facetDepthSortFrom: Vector3;
  17916. /**
  17917. * gets a boolean indicating if facetData is enabled
  17918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17919. */
  17920. readonly isFacetDataEnabled: boolean;
  17921. /** @hidden */
  17922. _updateNonUniformScalingState(value: boolean): boolean;
  17923. /**
  17924. * An event triggered when this mesh collides with another one
  17925. */
  17926. onCollideObservable: Observable<AbstractMesh>;
  17927. private _onCollideObserver;
  17928. /** Set a function to call when this mesh collides with another one */
  17929. onCollide: () => void;
  17930. /**
  17931. * An event triggered when the collision's position changes
  17932. */
  17933. onCollisionPositionChangeObservable: Observable<Vector3>;
  17934. private _onCollisionPositionChangeObserver;
  17935. /** Set a function to call when the collision's position changes */
  17936. onCollisionPositionChange: () => void;
  17937. /**
  17938. * An event triggered when material is changed
  17939. */
  17940. onMaterialChangedObservable: Observable<AbstractMesh>;
  17941. /**
  17942. * Gets or sets the orientation for POV movement & rotation
  17943. */
  17944. definedFacingForward: boolean;
  17945. /**
  17946. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  17947. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  17948. * * 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.
  17949. * @see http://doc.babylonjs.com/features/occlusionquery
  17950. */
  17951. occlusionQueryAlgorithmType: number;
  17952. /**
  17953. * 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:
  17954. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  17955. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  17956. * * 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.
  17957. * @see http://doc.babylonjs.com/features/occlusionquery
  17958. */
  17959. occlusionType: number;
  17960. /**
  17961. * 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.
  17962. * The default value is -1 which means don't break the query and wait till the result
  17963. * @see http://doc.babylonjs.com/features/occlusionquery
  17964. */
  17965. occlusionRetryCount: number;
  17966. private _occlusionInternalRetryCounter;
  17967. protected _isOccluded: boolean;
  17968. /**
  17969. * 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
  17970. * @see http://doc.babylonjs.com/features/occlusionquery
  17971. */
  17972. isOccluded: boolean;
  17973. private _isOcclusionQueryInProgress;
  17974. /**
  17975. * Flag to check the progress status of the query
  17976. * @see http://doc.babylonjs.com/features/occlusionquery
  17977. */
  17978. readonly isOcclusionQueryInProgress: boolean;
  17979. private _occlusionQuery;
  17980. private _visibility;
  17981. /**
  17982. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17983. */
  17984. /**
  17985. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17986. */
  17987. visibility: number;
  17988. /** Gets or sets the alpha index used to sort transparent meshes
  17989. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  17990. */
  17991. alphaIndex: number;
  17992. /**
  17993. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  17994. */
  17995. isVisible: boolean;
  17996. /**
  17997. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  17998. */
  17999. isPickable: boolean;
  18000. /**
  18001. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  18002. */
  18003. showBoundingBox: boolean;
  18004. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18005. showSubMeshesBoundingBox: boolean;
  18006. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18007. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18008. */
  18009. isBlocker: boolean;
  18010. /**
  18011. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18012. */
  18013. enablePointerMoveEvents: boolean;
  18014. /**
  18015. * Specifies the rendering group id for this mesh (0 by default)
  18016. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18017. */
  18018. renderingGroupId: number;
  18019. private _material;
  18020. /** Gets or sets current material */
  18021. material: Nullable<Material>;
  18022. private _receiveShadows;
  18023. /**
  18024. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18025. * @see http://doc.babylonjs.com/babylon101/shadows
  18026. */
  18027. receiveShadows: boolean;
  18028. /**
  18029. * Gets or sets a boolean indicating if the outline must be rendered as well
  18030. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18031. */
  18032. renderOutline: boolean;
  18033. /** Defines color to use when rendering outline */
  18034. outlineColor: Color3;
  18035. /** Define width to use when rendering outline */
  18036. outlineWidth: number;
  18037. /**
  18038. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18039. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18040. */
  18041. renderOverlay: boolean;
  18042. /** Defines color to use when rendering overlay */
  18043. overlayColor: Color3;
  18044. /** Defines alpha to use when rendering overlay */
  18045. overlayAlpha: number;
  18046. private _hasVertexAlpha;
  18047. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18048. hasVertexAlpha: boolean;
  18049. private _useVertexColors;
  18050. /** 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) */
  18051. useVertexColors: boolean;
  18052. private _computeBonesUsingShaders;
  18053. /**
  18054. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18055. */
  18056. computeBonesUsingShaders: boolean;
  18057. private _numBoneInfluencers;
  18058. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18059. numBoneInfluencers: number;
  18060. private _applyFog;
  18061. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18062. applyFog: boolean;
  18063. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18064. useOctreeForRenderingSelection: boolean;
  18065. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18066. useOctreeForPicking: boolean;
  18067. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18068. useOctreeForCollisions: boolean;
  18069. private _layerMask;
  18070. /**
  18071. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18072. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18073. */
  18074. layerMask: number;
  18075. /**
  18076. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18077. */
  18078. alwaysSelectAsActiveMesh: boolean;
  18079. /**
  18080. * Gets or sets the current action manager
  18081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18082. */
  18083. actionManager: Nullable<ActionManager>;
  18084. /**
  18085. * Gets or sets impostor used for physic simulation
  18086. * @see http://doc.babylonjs.com/features/physics_engine
  18087. */
  18088. physicsImpostor: Nullable<PhysicsImpostor>;
  18089. private _checkCollisions;
  18090. private _collisionMask;
  18091. private _collisionGroup;
  18092. /**
  18093. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  18094. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18095. */
  18096. ellipsoid: Vector3;
  18097. /**
  18098. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  18099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18100. */
  18101. ellipsoidOffset: Vector3;
  18102. private _collider;
  18103. private _oldPositionForCollisions;
  18104. private _diffPositionForCollisions;
  18105. /**
  18106. * Gets or sets a collision mask used to mask collisions (default is -1).
  18107. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18108. */
  18109. collisionMask: number;
  18110. /**
  18111. * Gets or sets the current collision group mask (-1 by default).
  18112. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18113. */
  18114. collisionGroup: number;
  18115. /**
  18116. * Defines edge width used when edgesRenderer is enabled
  18117. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18118. */
  18119. edgesWidth: number;
  18120. /**
  18121. * Defines edge color used when edgesRenderer is enabled
  18122. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18123. */
  18124. edgesColor: Color4;
  18125. /** @hidden */
  18126. _edgesRenderer: Nullable<EdgesRenderer>;
  18127. private _collisionsTransformMatrix;
  18128. private _collisionsScalingMatrix;
  18129. /** @hidden */
  18130. _masterMesh: Nullable<AbstractMesh>;
  18131. /** @hidden */
  18132. _boundingInfo: Nullable<BoundingInfo>;
  18133. /** @hidden */
  18134. _renderId: number;
  18135. /**
  18136. * Gets or sets the list of subMeshes
  18137. * @see http://doc.babylonjs.com/how_to/multi_materials
  18138. */
  18139. subMeshes: SubMesh[];
  18140. /** @hidden */
  18141. _submeshesOctree: Octree<SubMesh>;
  18142. /** @hidden */
  18143. _intersectionsInProgress: AbstractMesh[];
  18144. /** @hidden */
  18145. _unIndexed: boolean;
  18146. /** @hidden */
  18147. _lightSources: Light[];
  18148. /** @hidden */
  18149. readonly _positions: Nullable<Vector3[]>;
  18150. /** @hidden */
  18151. _waitingActions: any;
  18152. /** @hidden */
  18153. _waitingFreezeWorldMatrix: Nullable<boolean>;
  18154. private _skeleton;
  18155. /** @hidden */
  18156. _bonesTransformMatrices: Nullable<Float32Array>;
  18157. /**
  18158. * Gets or sets a skeleton to apply skining transformations
  18159. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18160. */
  18161. skeleton: Nullable<Skeleton>;
  18162. /**
  18163. * Creates a new AbstractMesh
  18164. * @param name defines the name of the mesh
  18165. * @param scene defines the hosting scene
  18166. */
  18167. constructor(name: string, scene?: Nullable<Scene>);
  18168. /**
  18169. * Returns the string "AbstractMesh"
  18170. * @returns "AbstractMesh"
  18171. */
  18172. getClassName(): string;
  18173. /**
  18174. * Gets a string representation of the current mesh
  18175. * @param fullDetails defines a boolean indicating if full details must be included
  18176. * @returns a string representation of the current mesh
  18177. */
  18178. toString(fullDetails?: boolean): string;
  18179. /** @hidden */
  18180. _rebuild(): void;
  18181. /** @hidden */
  18182. _resyncLightSources(): void;
  18183. /** @hidden */
  18184. _resyncLighSource(light: Light): void;
  18185. /** @hidden */
  18186. _unBindEffect(): void;
  18187. /** @hidden */
  18188. _removeLightSource(light: Light): void;
  18189. private _markSubMeshesAsDirty(func);
  18190. /** @hidden */
  18191. _markSubMeshesAsLightDirty(): void;
  18192. /** @hidden */
  18193. _markSubMeshesAsAttributesDirty(): void;
  18194. /** @hidden */
  18195. _markSubMeshesAsMiscDirty(): void;
  18196. /**
  18197. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18198. */
  18199. scaling: Vector3;
  18200. /**
  18201. * Disables the mesh edge rendering mode
  18202. * @returns the currentAbstractMesh
  18203. */
  18204. disableEdgesRendering(): AbstractMesh;
  18205. /**
  18206. * Enables the edge rendering mode on the mesh.
  18207. * This mode makes the mesh edges visible
  18208. * @param epsilon defines the maximal distance between two angles to detect a face
  18209. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18210. * @returns the currentAbstractMesh
  18211. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18212. */
  18213. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18214. /**
  18215. * Returns true if the mesh is blocked. Implemented by child classes
  18216. */
  18217. readonly isBlocked: boolean;
  18218. /**
  18219. * Returns the mesh itself by default. Implemented by child classes
  18220. * @param camera defines the camera to use to pick the right LOD level
  18221. * @returns the currentAbstractMesh
  18222. */
  18223. getLOD(camera: Camera): AbstractMesh;
  18224. /**
  18225. * Returns 0 by default. Implemented by child classes
  18226. * @returns an integer
  18227. */
  18228. getTotalVertices(): number;
  18229. /**
  18230. * Returns null by default. Implemented by child classes
  18231. * @returns null
  18232. */
  18233. getIndices(): Nullable<IndicesArray>;
  18234. /**
  18235. * Returns the array of the requested vertex data kind. Implemented by child classes
  18236. * @param kind defines the vertex data kind to use
  18237. * @returns null
  18238. */
  18239. getVerticesData(kind: string): Nullable<FloatArray>;
  18240. /**
  18241. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18242. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18243. * Note that a new underlying VertexBuffer object is created each call.
  18244. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18245. * @param kind defines vertex data kind:
  18246. * * BABYLON.VertexBuffer.PositionKind
  18247. * * BABYLON.VertexBuffer.UVKind
  18248. * * BABYLON.VertexBuffer.UV2Kind
  18249. * * BABYLON.VertexBuffer.UV3Kind
  18250. * * BABYLON.VertexBuffer.UV4Kind
  18251. * * BABYLON.VertexBuffer.UV5Kind
  18252. * * BABYLON.VertexBuffer.UV6Kind
  18253. * * BABYLON.VertexBuffer.ColorKind
  18254. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18255. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18256. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18257. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18258. * @param data defines the data source
  18259. * @param updatable defines if the data must be flagged as updatable (or static)
  18260. * @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
  18261. * @returns the current mesh
  18262. */
  18263. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18264. /**
  18265. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18266. * If the mesh has no geometry, it is simply returned as it is.
  18267. * @param kind defines vertex data kind:
  18268. * * BABYLON.VertexBuffer.PositionKind
  18269. * * BABYLON.VertexBuffer.UVKind
  18270. * * BABYLON.VertexBuffer.UV2Kind
  18271. * * BABYLON.VertexBuffer.UV3Kind
  18272. * * BABYLON.VertexBuffer.UV4Kind
  18273. * * BABYLON.VertexBuffer.UV5Kind
  18274. * * BABYLON.VertexBuffer.UV6Kind
  18275. * * BABYLON.VertexBuffer.ColorKind
  18276. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18277. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18278. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18279. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18280. * @param data defines the data source
  18281. * @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
  18282. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  18283. * @returns the current mesh
  18284. */
  18285. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  18286. /**
  18287. * Sets the mesh indices,
  18288. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18289. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  18290. * @param totalVertices Defines the total number of vertices
  18291. * @returns the current mesh
  18292. */
  18293. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  18294. /**
  18295. * Gets a boolean indicating if specific vertex data is present
  18296. * @param kind defines the vertex data kind to use
  18297. * @returns true is data kind is present
  18298. */
  18299. isVerticesDataPresent(kind: string): boolean;
  18300. /**
  18301. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  18302. * @returns a BoundingInfo
  18303. */
  18304. getBoundingInfo(): BoundingInfo;
  18305. /**
  18306. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  18307. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  18308. * @returns the current mesh
  18309. */
  18310. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  18311. /**
  18312. * Overwrite the current bounding info
  18313. * @param boundingInfo defines the new bounding info
  18314. * @returns the current mesh
  18315. */
  18316. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  18317. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  18318. readonly useBones: boolean;
  18319. /** @hidden */
  18320. _preActivate(): void;
  18321. /** @hidden */
  18322. _preActivateForIntermediateRendering(renderId: number): void;
  18323. /** @hidden */
  18324. _activate(renderId: number): void;
  18325. /**
  18326. * Gets the current world matrix
  18327. * @returns a Matrix
  18328. */
  18329. getWorldMatrix(): Matrix;
  18330. /** @hidden */
  18331. _getWorldMatrixDeterminant(): number;
  18332. /**
  18333. * Perform relative position change from the point of view of behind the front of the mesh.
  18334. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18335. * Supports definition of mesh facing forward or backward
  18336. * @param amountRight defines the distance on the right axis
  18337. * @param amountUp defines the distance on the up axis
  18338. * @param amountForward defines the distance on the forward axis
  18339. * @returns the current mesh
  18340. */
  18341. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  18342. /**
  18343. * Calculate relative position change from the point of view of behind the front of the mesh.
  18344. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18345. * Supports definition of mesh facing forward or backward
  18346. * @param amountRight defines the distance on the right axis
  18347. * @param amountUp defines the distance on the up axis
  18348. * @param amountForward defines the distance on the forward axis
  18349. * @returns the new displacement vector
  18350. */
  18351. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  18352. /**
  18353. * Perform relative rotation change from the point of view of behind the front of the mesh.
  18354. * Supports definition of mesh facing forward or backward
  18355. * @param flipBack defines the flip
  18356. * @param twirlClockwise defines the twirl
  18357. * @param tiltRight defines the tilt
  18358. * @returns the current mesh
  18359. */
  18360. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  18361. /**
  18362. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  18363. * Supports definition of mesh facing forward or backward.
  18364. * @param flipBack defines the flip
  18365. * @param twirlClockwise defines the twirl
  18366. * @param tiltRight defines the tilt
  18367. * @returns the new rotation vector
  18368. */
  18369. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  18370. /**
  18371. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  18372. * @param includeDescendants Include bounding info from descendants as well (true by default)
  18373. * @returns the new bounding vectors
  18374. */
  18375. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  18376. min: Vector3;
  18377. max: Vector3;
  18378. };
  18379. /** @hidden */
  18380. _updateBoundingInfo(): AbstractMesh;
  18381. /** @hidden */
  18382. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  18383. /** @hidden */
  18384. protected _afterComputeWorldMatrix(): void;
  18385. /**
  18386. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  18387. * A mesh is in the frustum if its bounding box intersects the frustum
  18388. * @param frustumPlanes defines the frustum to test
  18389. * @returns true if the mesh is in the frustum planes
  18390. */
  18391. isInFrustum(frustumPlanes: Plane[]): boolean;
  18392. /**
  18393. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  18394. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  18395. * @param frustumPlanes defines the frustum to test
  18396. * @returns true if the mesh is completely in the frustum planes
  18397. */
  18398. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18399. /**
  18400. * True if the mesh intersects another mesh or a SolidParticle object
  18401. * @param mesh defines a target mesh or SolidParticle to test
  18402. * @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)
  18403. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  18404. * @returns true if there is an intersection
  18405. */
  18406. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  18407. /**
  18408. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  18409. * @param point defines the point to test
  18410. * @returns true if there is an intersection
  18411. */
  18412. intersectsPoint(point: Vector3): boolean;
  18413. /**
  18414. * Gets the current physics impostor
  18415. * @see http://doc.babylonjs.com/features/physics_engine
  18416. * @returns a physics impostor or null
  18417. */
  18418. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  18419. /**
  18420. * Gets the position of the current mesh in camera space
  18421. * @param camera defines the camera to use
  18422. * @returns a position
  18423. */
  18424. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  18425. /**
  18426. * Returns the distance from the mesh to the active camera
  18427. * @param camera defines the camera to use
  18428. * @returns the distance
  18429. */
  18430. getDistanceToCamera(camera?: Nullable<Camera>): number;
  18431. /**
  18432. * Apply a physic impulse to the mesh
  18433. * @param force defines the force to apply
  18434. * @param contactPoint defines where to apply the force
  18435. * @returns the current mesh
  18436. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18437. */
  18438. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  18439. /**
  18440. * Creates a physic joint between two meshes
  18441. * @param otherMesh defines the other mesh to use
  18442. * @param pivot1 defines the pivot to use on this mesh
  18443. * @param pivot2 defines the pivot to use on the other mesh
  18444. * @param options defines additional options (can be plugin dependent)
  18445. * @returns the current mesh
  18446. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  18447. */
  18448. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  18449. /**
  18450. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  18451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18452. */
  18453. checkCollisions: boolean;
  18454. /**
  18455. * Gets Collider object used to compute collisions (not physics)
  18456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18457. */
  18458. readonly collider: Collider;
  18459. /**
  18460. * Move the mesh using collision engine
  18461. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18462. * @param displacement defines the requested displacement vector
  18463. * @returns the current mesh
  18464. */
  18465. moveWithCollisions(displacement: Vector3): AbstractMesh;
  18466. private _onCollisionPositionChange;
  18467. /**
  18468. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  18469. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18470. * @param maxCapacity defines the maximum size of each block (64 by default)
  18471. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  18472. * @returns the new octree
  18473. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  18474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  18475. */
  18476. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  18477. /** @hidden */
  18478. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  18479. /** @hidden */
  18480. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  18481. /** @hidden */
  18482. _checkCollision(collider: Collider): AbstractMesh;
  18483. /** @hidden */
  18484. _generatePointsArray(): boolean;
  18485. /**
  18486. * Checks if the passed Ray intersects with the mesh
  18487. * @param ray defines the ray to use
  18488. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  18489. * @returns the picking info
  18490. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  18491. */
  18492. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  18493. /**
  18494. * Clones the current mesh
  18495. * @param name defines the mesh name
  18496. * @param newParent defines the new mesh parent
  18497. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  18498. * @returns the new mesh
  18499. */
  18500. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18501. /**
  18502. * Disposes all the submeshes of the current meshnp
  18503. * @returns the current mesh
  18504. */
  18505. releaseSubMeshes(): AbstractMesh;
  18506. /**
  18507. * Releases resources associated with this abstract mesh.
  18508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18510. */
  18511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18512. /**
  18513. * Adds the passed mesh as a child to the current mesh
  18514. * @param mesh defines the child mesh
  18515. * @returns the current mesh
  18516. */
  18517. addChild(mesh: AbstractMesh): AbstractMesh;
  18518. /**
  18519. * Removes the passed mesh from the current mesh children list
  18520. * @param mesh defines the child mesh
  18521. * @returns the current mesh
  18522. */
  18523. removeChild(mesh: AbstractMesh): AbstractMesh;
  18524. /** @hidden */
  18525. private _initFacetData();
  18526. /**
  18527. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  18528. * This method can be called within the render loop.
  18529. * 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
  18530. * @returns the current mesh
  18531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18532. */
  18533. updateFacetData(): AbstractMesh;
  18534. /**
  18535. * Returns the facetLocalNormals array.
  18536. * The normals are expressed in the mesh local spac
  18537. * @returns an array of Vector3
  18538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18539. */
  18540. getFacetLocalNormals(): Vector3[];
  18541. /**
  18542. * Returns the facetLocalPositions array.
  18543. * The facet positions are expressed in the mesh local space
  18544. * @returns an array of Vector3
  18545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18546. */
  18547. getFacetLocalPositions(): Vector3[];
  18548. /**
  18549. * Returns the facetLocalPartioning array
  18550. * @returns an array of array of numbers
  18551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18552. */
  18553. getFacetLocalPartitioning(): number[][];
  18554. /**
  18555. * Returns the i-th facet position in the world system.
  18556. * This method allocates a new Vector3 per call
  18557. * @param i defines the facet index
  18558. * @returns a new Vector3
  18559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18560. */
  18561. getFacetPosition(i: number): Vector3;
  18562. /**
  18563. * Sets the reference Vector3 with the i-th facet position in the world system
  18564. * @param i defines the facet index
  18565. * @param ref defines the target vector
  18566. * @returns the current mesh
  18567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18568. */
  18569. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  18570. /**
  18571. * Returns the i-th facet normal in the world system.
  18572. * This method allocates a new Vector3 per call
  18573. * @param i defines the facet index
  18574. * @returns a new Vector3
  18575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18576. */
  18577. getFacetNormal(i: number): Vector3;
  18578. /**
  18579. * Sets the reference Vector3 with the i-th facet normal in the world system
  18580. * @param i defines the facet index
  18581. * @param ref defines the target vector
  18582. * @returns the current mesh
  18583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18584. */
  18585. getFacetNormalToRef(i: number, ref: Vector3): this;
  18586. /**
  18587. * 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)
  18588. * @param x defines x coordinate
  18589. * @param y defines y coordinate
  18590. * @param z defines z coordinate
  18591. * @returns the array of facet indexes
  18592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18593. */
  18594. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  18595. /**
  18596. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  18597. * @param projected sets as the (x,y,z) world projection on the facet
  18598. * @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
  18599. * @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
  18600. * @param x defines x coordinate
  18601. * @param y defines y coordinate
  18602. * @param z defines z coordinate
  18603. * @returns the face index if found (or null instead)
  18604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18605. */
  18606. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18607. /**
  18608. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  18609. * @param projected sets as the (x,y,z) local projection on the facet
  18610. * @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
  18611. * @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
  18612. * @param x defines x coordinate
  18613. * @param y defines y coordinate
  18614. * @param z defines z coordinate
  18615. * @returns the face index if found (or null instead)
  18616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18617. */
  18618. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18619. /**
  18620. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  18621. * @returns the parameters
  18622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18623. */
  18624. getFacetDataParameters(): any;
  18625. /**
  18626. * Disables the feature FacetData and frees the related memory
  18627. * @returns the current mesh
  18628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18629. */
  18630. disableFacetData(): AbstractMesh;
  18631. /**
  18632. * Updates the AbstractMesh indices array
  18633. * @param indices defines the data source
  18634. * @returns the current mesh
  18635. */
  18636. updateIndices(indices: IndicesArray): AbstractMesh;
  18637. /**
  18638. * Creates new normals data for the mesh
  18639. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  18640. * @returns the current mesh
  18641. */
  18642. createNormals(updatable: boolean): AbstractMesh;
  18643. /**
  18644. * Align the mesh with a normal
  18645. * @param normal defines the normal to use
  18646. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  18647. * @returns the current mesh
  18648. */
  18649. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  18650. /** @hidden */
  18651. protected _checkOcclusionQuery(): void;
  18652. }
  18653. }
  18654. declare module BABYLON {
  18655. class Buffer {
  18656. private _engine;
  18657. private _buffer;
  18658. private _data;
  18659. private _updatable;
  18660. private _instanced;
  18661. /**
  18662. * Gets the byte stride.
  18663. */
  18664. readonly byteStride: number;
  18665. /**
  18666. * Constructor
  18667. * @param engine the engine
  18668. * @param data the data to use for this buffer
  18669. * @param updatable whether the data is updatable
  18670. * @param stride the stride (optional)
  18671. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  18672. * @param instanced whether the buffer is instanced (optional)
  18673. * @param useBytes set to true if the stride in in bytes (optional)
  18674. */
  18675. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  18676. /**
  18677. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  18678. * @param kind defines the vertex buffer kind (position, normal, etc.)
  18679. * @param offset defines offset in the buffer (0 by default)
  18680. * @param size defines the size in floats of attributes (position is 3 for instance)
  18681. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  18682. * @param instanced defines if the vertex buffer contains indexed data
  18683. * @param useBytes defines if the offset and stride are in bytes
  18684. * @returns the new vertex buffer
  18685. */
  18686. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  18687. isUpdatable(): boolean;
  18688. getData(): Nullable<DataArray>;
  18689. getBuffer(): Nullable<WebGLBuffer>;
  18690. /**
  18691. * Gets the stride in float32 units (i.e. byte stride / 4).
  18692. * May not be an integer if the byte stride is not divisible by 4.
  18693. * DEPRECATED. Use byteStride instead.
  18694. * @returns the stride in float32 units
  18695. */
  18696. getStrideSize(): number;
  18697. create(data?: Nullable<DataArray>): void;
  18698. _rebuild(): void;
  18699. update(data: DataArray): void;
  18700. /**
  18701. * Updates the data directly.
  18702. * @param data the new data
  18703. * @param offset the new offset
  18704. * @param vertexCount the vertex count (optional)
  18705. * @param useBytes set to true if the offset is in bytes
  18706. */
  18707. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  18708. dispose(): void;
  18709. }
  18710. }
  18711. declare module BABYLON {
  18712. class CSG {
  18713. private polygons;
  18714. matrix: Matrix;
  18715. position: Vector3;
  18716. rotation: Vector3;
  18717. rotationQuaternion: Nullable<Quaternion>;
  18718. scaling: Vector3;
  18719. static FromMesh(mesh: Mesh): CSG;
  18720. private static FromPolygons(polygons);
  18721. clone(): CSG;
  18722. union(csg: CSG): CSG;
  18723. unionInPlace(csg: CSG): void;
  18724. subtract(csg: CSG): CSG;
  18725. subtractInPlace(csg: CSG): void;
  18726. intersect(csg: CSG): CSG;
  18727. intersectInPlace(csg: CSG): void;
  18728. inverse(): CSG;
  18729. inverseInPlace(): void;
  18730. copyTransformAttributes(csg: CSG): CSG;
  18731. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  18732. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  18733. }
  18734. }
  18735. declare module BABYLON {
  18736. /**
  18737. * Class used to store geometry data (vertex buffers + index buffer)
  18738. */
  18739. class Geometry implements IGetSetVerticesData {
  18740. /**
  18741. * Gets or sets the unique ID of the geometry
  18742. */
  18743. id: string;
  18744. /**
  18745. * Gets the delay loading state of the geometry (none by default which means not delayed)
  18746. */
  18747. delayLoadState: number;
  18748. /**
  18749. * Gets the file containing the data to load when running in delay load state
  18750. */
  18751. delayLoadingFile: Nullable<string>;
  18752. /**
  18753. * Callback called when the geometry is updated
  18754. */
  18755. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  18756. private _scene;
  18757. private _engine;
  18758. private _meshes;
  18759. private _totalVertices;
  18760. private _indices;
  18761. private _vertexBuffers;
  18762. private _isDisposed;
  18763. private _extend;
  18764. private _boundingBias;
  18765. /** @hidden */
  18766. _delayInfo: Array<string>;
  18767. private _indexBuffer;
  18768. private _indexBufferIsUpdatable;
  18769. /** @hidden */
  18770. _boundingInfo: Nullable<BoundingInfo>;
  18771. /** @hidden */
  18772. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  18773. /** @hidden */
  18774. _softwareSkinningRenderId: number;
  18775. private _vertexArrayObjects;
  18776. private _updatable;
  18777. /** @hidden */
  18778. _positions: Nullable<Vector3[]>;
  18779. /**
  18780. * 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
  18781. */
  18782. /**
  18783. * 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
  18784. */
  18785. boundingBias: Vector2;
  18786. /**
  18787. * Static function used to attach a new empty geometry to a mesh
  18788. * @param mesh defines the mesh to attach the geometry to
  18789. * @returns the new {BABYLON.Geometry}
  18790. */
  18791. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  18792. /**
  18793. * Creates a new geometry
  18794. * @param id defines the unique ID
  18795. * @param scene defines the hosting scene
  18796. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  18797. * @param updatable defines if geometry must be updatable (false by default)
  18798. * @param mesh defines the mesh that will be associated with the geometry
  18799. */
  18800. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  18801. /**
  18802. * Gets the current extend of the geometry
  18803. */
  18804. readonly extend: {
  18805. minimum: Vector3;
  18806. maximum: Vector3;
  18807. };
  18808. /**
  18809. * Gets the hosting scene
  18810. * @returns the hosting {BABYLON.Scene}
  18811. */
  18812. getScene(): Scene;
  18813. /**
  18814. * Gets the hosting engine
  18815. * @returns the hosting {BABYLON.Engine}
  18816. */
  18817. getEngine(): Engine;
  18818. /**
  18819. * Defines if the geometry is ready to use
  18820. * @returns true if the geometry is ready to be used
  18821. */
  18822. isReady(): boolean;
  18823. /**
  18824. * Gets a value indicating that the geometry should not be serialized
  18825. */
  18826. readonly doNotSerialize: boolean;
  18827. /** @hidden */
  18828. _rebuild(): void;
  18829. /**
  18830. * Affects all gemetry data in one call
  18831. * @param vertexData defines the geometry data
  18832. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  18833. */
  18834. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  18835. /**
  18836. * Set specific vertex data
  18837. * @param kind defines the data kind (Position, normal, etc...)
  18838. * @param data defines the vertex data to use
  18839. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  18840. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  18841. */
  18842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  18843. /**
  18844. * Removes a specific vertex data
  18845. * @param kind defines the data kind (Position, normal, etc...)
  18846. */
  18847. removeVerticesData(kind: string): void;
  18848. /**
  18849. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  18850. * @param buffer defines the vertex buffer to use
  18851. * @param totalVertices defines the total number of vertices for position kind (could be null)
  18852. */
  18853. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  18854. /**
  18855. * Update a specific vertex buffer
  18856. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  18857. * It will do nothing if the buffer is not updatable
  18858. * @param kind defines the data kind (Position, normal, etc...)
  18859. * @param data defines the data to use
  18860. * @param offset defines the offset in the target buffer where to store the data
  18861. * @param useBytes set to true if the offset is in bytes
  18862. */
  18863. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  18864. /**
  18865. * Update a specific vertex buffer
  18866. * This function will create a new buffer if the current one is not updatable
  18867. * @param kind defines the data kind (Position, normal, etc...)
  18868. * @param data defines the data to use
  18869. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  18870. */
  18871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  18872. private _updateBoundingInfo(updateExtends, data);
  18873. /** @hidden */
  18874. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  18875. /**
  18876. * Gets total number of vertices
  18877. * @returns the total number of vertices
  18878. */
  18879. getTotalVertices(): number;
  18880. /**
  18881. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  18882. * @param kind defines the data kind (Position, normal, etc...)
  18883. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  18885. * @returns a float array containing vertex data
  18886. */
  18887. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  18888. /**
  18889. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  18890. * @param kind defines the data kind (Position, normal, etc...)
  18891. * @returns true if the vertex buffer with the specified kind is updatable
  18892. */
  18893. isVertexBufferUpdatable(kind: string): boolean;
  18894. /**
  18895. * Gets a specific vertex buffer
  18896. * @param kind defines the data kind (Position, normal, etc...)
  18897. * @returns a {BABYLON.VertexBuffer}
  18898. */
  18899. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  18900. /**
  18901. * Returns all vertex buffers
  18902. * @return an object holding all vertex buffers indexed by kind
  18903. */
  18904. getVertexBuffers(): Nullable<{
  18905. [key: string]: VertexBuffer;
  18906. }>;
  18907. /**
  18908. * Gets a boolean indicating if specific vertex buffer is present
  18909. * @param kind defines the data kind (Position, normal, etc...)
  18910. * @returns true if data is present
  18911. */
  18912. isVerticesDataPresent(kind: string): boolean;
  18913. /**
  18914. * Gets a list of all attached data kinds (Position, normal, etc...)
  18915. * @returns a list of string containing all kinds
  18916. */
  18917. getVerticesDataKinds(): string[];
  18918. /**
  18919. * Update index buffer
  18920. * @param indices defines the indices to store in the index buffer
  18921. * @param offset defines the offset in the target buffer where to store the data
  18922. */
  18923. updateIndices(indices: IndicesArray, offset?: number): void;
  18924. /**
  18925. * Creates a new index buffer
  18926. * @param indices defines the indices to store in the index buffer
  18927. * @param totalVertices defines the total number of vertices (could be null)
  18928. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  18929. */
  18930. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  18931. /**
  18932. * Return the total number of indices
  18933. * @returns the total number of indices
  18934. */
  18935. getTotalIndices(): number;
  18936. /**
  18937. * Gets the index buffer array
  18938. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18939. * @returns the index buffer array
  18940. */
  18941. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  18942. /**
  18943. * Gets the index buffer
  18944. * @return the index buffer
  18945. */
  18946. getIndexBuffer(): Nullable<WebGLBuffer>;
  18947. /** @hidden */
  18948. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  18949. /**
  18950. * Release the associated resources for a specific mesh
  18951. * @param mesh defines the source mesh
  18952. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  18953. */
  18954. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  18955. /**
  18956. * Apply current geometry to a given mesh
  18957. * @param mesh defines the mesh to apply geometry to
  18958. */
  18959. applyToMesh(mesh: Mesh): void;
  18960. private _updateExtend(data?);
  18961. private _applyToMesh(mesh);
  18962. private notifyUpdate(kind?);
  18963. /**
  18964. * Load the geometry if it was flagged as delay loaded
  18965. * @param scene defines the hosting scene
  18966. * @param onLoaded defines a callback called when the geometry is loaded
  18967. */
  18968. load(scene: Scene, onLoaded?: () => void): void;
  18969. private _queueLoad(scene, onLoaded?);
  18970. /**
  18971. * Invert the geometry to move from a right handed system to a left handed one.
  18972. */
  18973. toLeftHanded(): void;
  18974. /** @hidden */
  18975. _resetPointsArrayCache(): void;
  18976. /** @hidden */
  18977. _generatePointsArray(): boolean;
  18978. /**
  18979. * Gets a value indicating if the geometry is disposed
  18980. * @returns true if the geometry was disposed
  18981. */
  18982. isDisposed(): boolean;
  18983. private _disposeVertexArrayObjects();
  18984. /**
  18985. * Free all associated resources
  18986. */
  18987. dispose(): void;
  18988. /**
  18989. * Clone the current geometry into a new geometry
  18990. * @param id defines the unique ID of the new geometry
  18991. * @returns a new geometry object
  18992. */
  18993. copy(id: string): Geometry;
  18994. /**
  18995. * Serialize the current geometry info (and not the vertices data) into a JSON object
  18996. * @return a JSON representation of the current geometry data (without the vertices data)
  18997. */
  18998. serialize(): any;
  18999. private toNumberArray(origin);
  19000. /**
  19001. * Serialize all vertices data into a JSON oject
  19002. * @returns a JSON representation of the current geometry data
  19003. */
  19004. serializeVerticeData(): any;
  19005. /**
  19006. * Extracts a clone of a mesh geometry
  19007. * @param mesh defines the source mesh
  19008. * @param id defines the unique ID of the new geometry object
  19009. * @returns the new geometry object
  19010. */
  19011. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19012. /**
  19013. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19014. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19015. * Be aware Math.random() could cause collisions, but:
  19016. * "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"
  19017. * @returns a string containing a new GUID
  19018. */
  19019. static RandomId(): string;
  19020. /** @hidden */
  19021. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19022. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19023. /**
  19024. * Create a new geometry from persisted data (Using .babylon file format)
  19025. * @param parsedVertexData defines the persisted data
  19026. * @param scene defines the hosting scene
  19027. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19028. * @returns the new geometry object
  19029. */
  19030. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19031. }
  19032. /**
  19033. * Abstract class used to provide common services for all typed geometries
  19034. * @hidden
  19035. */
  19036. class _PrimitiveGeometry extends Geometry {
  19037. private _canBeRegenerated;
  19038. private _beingRegenerated;
  19039. /**
  19040. * Creates a new typed geometry
  19041. * @param id defines the unique ID of the geometry
  19042. * @param scene defines the hosting scene
  19043. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19044. * @param mesh defines the hosting mesh (can be null)
  19045. */
  19046. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19047. /**
  19048. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19049. * @returns true if the geometry can be regenerated
  19050. */
  19051. canBeRegenerated(): boolean;
  19052. /**
  19053. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19054. */
  19055. regenerate(): void;
  19056. /**
  19057. * Clone the geometry
  19058. * @param id defines the unique ID of the new geometry
  19059. * @returns the new geometry
  19060. */
  19061. asNewGeometry(id: string): Geometry;
  19062. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19063. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19064. /** @hidden */
  19065. _regenerateVertexData(): VertexData;
  19066. copy(id: string): Geometry;
  19067. serialize(): any;
  19068. }
  19069. /**
  19070. * Creates a ribbon geometry
  19071. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19072. */
  19073. class RibbonGeometry extends _PrimitiveGeometry {
  19074. /**
  19075. * Defines the array of paths to use
  19076. */
  19077. pathArray: Vector3[][];
  19078. /**
  19079. * Defines if the last and first points of each path in your pathArray must be joined
  19080. */
  19081. closeArray: boolean;
  19082. /**
  19083. * Defines if the last and first points of each path in your pathArray must be joined
  19084. */
  19085. closePath: boolean;
  19086. /**
  19087. * Defines the offset between points
  19088. */
  19089. offset: number;
  19090. /**
  19091. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19092. */
  19093. side: number;
  19094. /**
  19095. * Creates a ribbon geometry
  19096. * @param id defines the unique ID of the geometry
  19097. * @param scene defines the hosting scene
  19098. * @param pathArray defines the array of paths to use
  19099. * @param closeArray defines if the last path and the first path must be joined
  19100. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19101. * @param offset defines the offset between points
  19102. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19103. * @param mesh defines the hosting mesh (can be null)
  19104. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19105. */
  19106. constructor(id: string, scene: Scene,
  19107. /**
  19108. * Defines the array of paths to use
  19109. */
  19110. pathArray: Vector3[][],
  19111. /**
  19112. * Defines if the last and first points of each path in your pathArray must be joined
  19113. */
  19114. closeArray: boolean,
  19115. /**
  19116. * Defines if the last and first points of each path in your pathArray must be joined
  19117. */
  19118. closePath: boolean,
  19119. /**
  19120. * Defines the offset between points
  19121. */
  19122. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  19123. /**
  19124. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19125. */
  19126. side?: number);
  19127. /** @hidden */
  19128. _regenerateVertexData(): VertexData;
  19129. copy(id: string): Geometry;
  19130. }
  19131. /**
  19132. * Creates a box geometry
  19133. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  19134. */
  19135. class BoxGeometry extends _PrimitiveGeometry {
  19136. /**
  19137. * Defines the zise of the box (width, height and depth are the same)
  19138. */
  19139. size: number;
  19140. /**
  19141. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19142. */
  19143. side: number;
  19144. /**
  19145. * Creates a box geometry
  19146. * @param id defines the unique ID of the geometry
  19147. * @param scene defines the hosting scene
  19148. * @param size defines the zise of the box (width, height and depth are the same)
  19149. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19150. * @param mesh defines the hosting mesh (can be null)
  19151. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19152. */
  19153. constructor(id: string, scene: Scene,
  19154. /**
  19155. * Defines the zise of the box (width, height and depth are the same)
  19156. */
  19157. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19158. /**
  19159. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19160. */
  19161. side?: number);
  19162. _regenerateVertexData(): VertexData;
  19163. copy(id: string): Geometry;
  19164. serialize(): any;
  19165. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19166. }
  19167. /**
  19168. * Creates a sphere geometry
  19169. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19170. */
  19171. class SphereGeometry extends _PrimitiveGeometry {
  19172. /**
  19173. * Defines the number of segments to use to create the sphere
  19174. */
  19175. segments: number;
  19176. /**
  19177. * Defines the diameter of the sphere
  19178. */
  19179. diameter: number;
  19180. /**
  19181. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19182. */
  19183. side: number;
  19184. /**
  19185. * Create a new sphere geometry
  19186. * @param id defines the unique ID of the geometry
  19187. * @param scene defines the hosting scene
  19188. * @param segments defines the number of segments to use to create the sphere
  19189. * @param diameter defines the diameter of the sphere
  19190. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19191. * @param mesh defines the hosting mesh (can be null)
  19192. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19193. */
  19194. constructor(id: string, scene: Scene,
  19195. /**
  19196. * Defines the number of segments to use to create the sphere
  19197. */
  19198. segments: number,
  19199. /**
  19200. * Defines the diameter of the sphere
  19201. */
  19202. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19203. /**
  19204. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19205. */
  19206. side?: number);
  19207. _regenerateVertexData(): VertexData;
  19208. copy(id: string): Geometry;
  19209. serialize(): any;
  19210. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19211. }
  19212. /**
  19213. * Creates a disc geometry
  19214. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19215. */
  19216. class DiscGeometry extends _PrimitiveGeometry {
  19217. /**
  19218. * Defines the radius of the disc
  19219. */
  19220. radius: number;
  19221. /**
  19222. * Defines the tesselation factor to apply to the disc
  19223. */
  19224. tessellation: number;
  19225. /**
  19226. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19227. */
  19228. side: number;
  19229. /**
  19230. * Creates a new disc geometry
  19231. * @param id defines the unique ID of the geometry
  19232. * @param scene defines the hosting scene
  19233. * @param radius defines the radius of the disc
  19234. * @param tessellation defines the tesselation factor to apply to the disc
  19235. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19236. * @param mesh defines the hosting mesh (can be null)
  19237. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19238. */
  19239. constructor(id: string, scene: Scene,
  19240. /**
  19241. * Defines the radius of the disc
  19242. */
  19243. radius: number,
  19244. /**
  19245. * Defines the tesselation factor to apply to the disc
  19246. */
  19247. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19248. /**
  19249. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19250. */
  19251. side?: number);
  19252. _regenerateVertexData(): VertexData;
  19253. copy(id: string): Geometry;
  19254. }
  19255. /**
  19256. * Creates a new cylinder geometry
  19257. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  19258. */
  19259. class CylinderGeometry extends _PrimitiveGeometry {
  19260. /**
  19261. * Defines the height of the cylinder
  19262. */
  19263. height: number;
  19264. /**
  19265. * Defines the diameter of the cylinder's top cap
  19266. */
  19267. diameterTop: number;
  19268. /**
  19269. * Defines the diameter of the cylinder's bottom cap
  19270. */
  19271. diameterBottom: number;
  19272. /**
  19273. * Defines the tessellation factor to apply to the cylinder
  19274. */
  19275. tessellation: number;
  19276. /**
  19277. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19278. */
  19279. subdivisions: number;
  19280. /**
  19281. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19282. */
  19283. side: number;
  19284. /**
  19285. * Creates a new cylinder geometry
  19286. * @param id defines the unique ID of the geometry
  19287. * @param scene defines the hosting scene
  19288. * @param height defines the height of the cylinder
  19289. * @param diameterTop defines the diameter of the cylinder's top cap
  19290. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  19291. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  19292. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  19293. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19294. * @param mesh defines the hosting mesh (can be null)
  19295. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19296. */
  19297. constructor(id: string, scene: Scene,
  19298. /**
  19299. * Defines the height of the cylinder
  19300. */
  19301. height: number,
  19302. /**
  19303. * Defines the diameter of the cylinder's top cap
  19304. */
  19305. diameterTop: number,
  19306. /**
  19307. * Defines the diameter of the cylinder's bottom cap
  19308. */
  19309. diameterBottom: number,
  19310. /**
  19311. * Defines the tessellation factor to apply to the cylinder
  19312. */
  19313. tessellation: number,
  19314. /**
  19315. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19316. */
  19317. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19318. /**
  19319. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19320. */
  19321. side?: number);
  19322. _regenerateVertexData(): VertexData;
  19323. copy(id: string): Geometry;
  19324. serialize(): any;
  19325. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  19326. }
  19327. /**
  19328. * Creates a new torus geometry
  19329. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  19330. */
  19331. class TorusGeometry extends _PrimitiveGeometry {
  19332. /**
  19333. * Defines the diameter of the torus
  19334. */
  19335. diameter: number;
  19336. /**
  19337. * Defines the thickness of the torus (ie. internal diameter)
  19338. */
  19339. thickness: number;
  19340. /**
  19341. * Defines the tesselation factor to apply to the torus
  19342. */
  19343. tessellation: number;
  19344. /**
  19345. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19346. */
  19347. side: number;
  19348. /**
  19349. * Creates a new torus geometry
  19350. * @param id defines the unique ID of the geometry
  19351. * @param scene defines the hosting scene
  19352. * @param diameter defines the diameter of the torus
  19353. * @param thickness defines the thickness of the torus (ie. internal diameter)
  19354. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  19355. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19356. * @param mesh defines the hosting mesh (can be null)
  19357. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19358. */
  19359. constructor(id: string, scene: Scene,
  19360. /**
  19361. * Defines the diameter of the torus
  19362. */
  19363. diameter: number,
  19364. /**
  19365. * Defines the thickness of the torus (ie. internal diameter)
  19366. */
  19367. thickness: number,
  19368. /**
  19369. * Defines the tesselation factor to apply to the torus
  19370. */
  19371. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19372. /**
  19373. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19374. */
  19375. side?: number);
  19376. _regenerateVertexData(): VertexData;
  19377. copy(id: string): Geometry;
  19378. serialize(): any;
  19379. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  19380. }
  19381. /**
  19382. * Creates a new ground geometry
  19383. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  19384. */
  19385. class GroundGeometry extends _PrimitiveGeometry {
  19386. /**
  19387. * Defines the width of the ground
  19388. */
  19389. width: number;
  19390. /**
  19391. * Defines the height of the ground
  19392. */
  19393. height: number;
  19394. /**
  19395. * Defines the subdivisions to apply to the ground
  19396. */
  19397. subdivisions: number;
  19398. /**
  19399. * Creates a new ground geometry
  19400. * @param id defines the unique ID of the geometry
  19401. * @param scene defines the hosting scene
  19402. * @param width defines the width of the ground
  19403. * @param height defines the height of the ground
  19404. * @param subdivisions defines the subdivisions to apply to the ground
  19405. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19406. * @param mesh defines the hosting mesh (can be null)
  19407. */
  19408. constructor(id: string, scene: Scene,
  19409. /**
  19410. * Defines the width of the ground
  19411. */
  19412. width: number,
  19413. /**
  19414. * Defines the height of the ground
  19415. */
  19416. height: number,
  19417. /**
  19418. * Defines the subdivisions to apply to the ground
  19419. */
  19420. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19421. _regenerateVertexData(): VertexData;
  19422. copy(id: string): Geometry;
  19423. serialize(): any;
  19424. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  19425. }
  19426. /**
  19427. * Creates a tiled ground geometry
  19428. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  19429. */
  19430. class TiledGroundGeometry extends _PrimitiveGeometry {
  19431. /**
  19432. * Defines the minimum value on X axis
  19433. */
  19434. xmin: number;
  19435. /**
  19436. * Defines the minimum value on Z axis
  19437. */
  19438. zmin: number;
  19439. /**
  19440. * Defines the maximum value on X axis
  19441. */
  19442. xmax: number;
  19443. /**
  19444. * Defines the maximum value on Z axis
  19445. */
  19446. zmax: number;
  19447. /**
  19448. * Defines the subdivisions to apply to the ground
  19449. */
  19450. subdivisions: {
  19451. w: number;
  19452. h: number;
  19453. };
  19454. /**
  19455. * Defines the precision to use when computing the tiles
  19456. */
  19457. precision: {
  19458. w: number;
  19459. h: number;
  19460. };
  19461. /**
  19462. * Creates a tiled ground geometry
  19463. * @param id defines the unique ID of the geometry
  19464. * @param scene defines the hosting scene
  19465. * @param xmin defines the minimum value on X axis
  19466. * @param zmin defines the minimum value on Z axis
  19467. * @param xmax defines the maximum value on X axis
  19468. * @param zmax defines the maximum value on Z axis
  19469. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  19470. * @param precision defines the precision to use when computing the tiles
  19471. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19472. * @param mesh defines the hosting mesh (can be null)
  19473. */
  19474. constructor(id: string, scene: Scene,
  19475. /**
  19476. * Defines the minimum value on X axis
  19477. */
  19478. xmin: number,
  19479. /**
  19480. * Defines the minimum value on Z axis
  19481. */
  19482. zmin: number,
  19483. /**
  19484. * Defines the maximum value on X axis
  19485. */
  19486. xmax: number,
  19487. /**
  19488. * Defines the maximum value on Z axis
  19489. */
  19490. zmax: number,
  19491. /**
  19492. * Defines the subdivisions to apply to the ground
  19493. */
  19494. subdivisions: {
  19495. w: number;
  19496. h: number;
  19497. },
  19498. /**
  19499. * Defines the precision to use when computing the tiles
  19500. */
  19501. precision: {
  19502. w: number;
  19503. h: number;
  19504. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19505. _regenerateVertexData(): VertexData;
  19506. copy(id: string): Geometry;
  19507. }
  19508. /**
  19509. * Creates a plane geometry
  19510. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  19511. */
  19512. class PlaneGeometry extends _PrimitiveGeometry {
  19513. /**
  19514. * Defines the size of the plane (width === height)
  19515. */
  19516. size: number;
  19517. /**
  19518. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19519. */
  19520. side: number;
  19521. /**
  19522. * Creates a plane geometry
  19523. * @param id defines the unique ID of the geometry
  19524. * @param scene defines the hosting scene
  19525. * @param size defines the size of the plane (width === height)
  19526. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19527. * @param mesh defines the hosting mesh (can be null)
  19528. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19529. */
  19530. constructor(id: string, scene: Scene,
  19531. /**
  19532. * Defines the size of the plane (width === height)
  19533. */
  19534. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19535. /**
  19536. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19537. */
  19538. side?: number);
  19539. _regenerateVertexData(): VertexData;
  19540. copy(id: string): Geometry;
  19541. serialize(): any;
  19542. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  19543. }
  19544. /**
  19545. * Creates a torus knot geometry
  19546. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  19547. */
  19548. class TorusKnotGeometry extends _PrimitiveGeometry {
  19549. /**
  19550. * Defines the radius of the torus knot
  19551. */
  19552. radius: number;
  19553. /**
  19554. * Defines the thickness of the torus knot tube
  19555. */
  19556. tube: number;
  19557. /**
  19558. * Defines the number of radial segments
  19559. */
  19560. radialSegments: number;
  19561. /**
  19562. * Defines the number of tubular segments
  19563. */
  19564. tubularSegments: number;
  19565. /**
  19566. * Defines the first number of windings
  19567. */
  19568. p: number;
  19569. /**
  19570. * Defines the second number of windings
  19571. */
  19572. q: number;
  19573. /**
  19574. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19575. */
  19576. side: number;
  19577. /**
  19578. * Creates a torus knot geometry
  19579. * @param id defines the unique ID of the geometry
  19580. * @param scene defines the hosting scene
  19581. * @param radius defines the radius of the torus knot
  19582. * @param tube defines the thickness of the torus knot tube
  19583. * @param radialSegments defines the number of radial segments
  19584. * @param tubularSegments defines the number of tubular segments
  19585. * @param p defines the first number of windings
  19586. * @param q defines the second number of windings
  19587. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19588. * @param mesh defines the hosting mesh (can be null)
  19589. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19590. */
  19591. constructor(id: string, scene: Scene,
  19592. /**
  19593. * Defines the radius of the torus knot
  19594. */
  19595. radius: number,
  19596. /**
  19597. * Defines the thickness of the torus knot tube
  19598. */
  19599. tube: number,
  19600. /**
  19601. * Defines the number of radial segments
  19602. */
  19603. radialSegments: number,
  19604. /**
  19605. * Defines the number of tubular segments
  19606. */
  19607. tubularSegments: number,
  19608. /**
  19609. * Defines the first number of windings
  19610. */
  19611. p: number,
  19612. /**
  19613. * Defines the second number of windings
  19614. */
  19615. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19616. /**
  19617. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19618. */
  19619. side?: number);
  19620. _regenerateVertexData(): VertexData;
  19621. copy(id: string): Geometry;
  19622. serialize(): any;
  19623. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  19624. }
  19625. }
  19626. declare module BABYLON {
  19627. class GroundMesh extends Mesh {
  19628. generateOctree: boolean;
  19629. private _heightQuads;
  19630. _subdivisionsX: number;
  19631. _subdivisionsY: number;
  19632. _width: number;
  19633. _height: number;
  19634. _minX: number;
  19635. _maxX: number;
  19636. _minZ: number;
  19637. _maxZ: number;
  19638. constructor(name: string, scene: Scene);
  19639. getClassName(): string;
  19640. readonly subdivisions: number;
  19641. readonly subdivisionsX: number;
  19642. readonly subdivisionsY: number;
  19643. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19644. /**
  19645. * Returns a height (y) value in the Worl system :
  19646. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19647. * Returns the ground y position if (x, z) are outside the ground surface.
  19648. */
  19649. getHeightAtCoordinates(x: number, z: number): number;
  19650. /**
  19651. * Returns a normalized vector (Vector3) orthogonal to the ground
  19652. * at the ground coordinates (x, z) expressed in the World system.
  19653. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19654. */
  19655. getNormalAtCoordinates(x: number, z: number): Vector3;
  19656. /**
  19657. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19658. * at the ground coordinates (x, z) expressed in the World system.
  19659. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19660. * Returns the GroundMesh.
  19661. */
  19662. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19663. /**
  19664. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19665. * if the ground has been updated.
  19666. * This can be used in the render loop.
  19667. * Returns the GroundMesh.
  19668. */
  19669. updateCoordinateHeights(): GroundMesh;
  19670. private _getFacetAt(x, z);
  19671. private _initHeightQuads();
  19672. private _computeHeightQuads();
  19673. serialize(serializationObject: any): void;
  19674. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19675. }
  19676. }
  19677. declare module BABYLON {
  19678. /**
  19679. * Creates an instance based on a source mesh.
  19680. */
  19681. class InstancedMesh extends AbstractMesh {
  19682. private _sourceMesh;
  19683. private _currentLOD;
  19684. constructor(name: string, source: Mesh);
  19685. /**
  19686. * Returns the string "InstancedMesh".
  19687. */
  19688. getClassName(): string;
  19689. readonly receiveShadows: boolean;
  19690. readonly material: Nullable<Material>;
  19691. readonly visibility: number;
  19692. readonly skeleton: Nullable<Skeleton>;
  19693. renderingGroupId: number;
  19694. /**
  19695. * Returns the total number of vertices (integer).
  19696. */
  19697. getTotalVertices(): number;
  19698. readonly sourceMesh: Mesh;
  19699. /**
  19700. * Is this node ready to be used/rendered
  19701. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19702. * @return {boolean} is it ready
  19703. */
  19704. isReady(completeCheck?: boolean): boolean;
  19705. /**
  19706. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19707. */
  19708. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19709. /**
  19710. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19711. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19712. * The `data` are either a numeric array either a Float32Array.
  19713. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19714. * 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).
  19715. * Note that a new underlying VertexBuffer object is created each call.
  19716. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19717. *
  19718. * Possible `kind` values :
  19719. * - BABYLON.VertexBuffer.PositionKind
  19720. * - BABYLON.VertexBuffer.UVKind
  19721. * - BABYLON.VertexBuffer.UV2Kind
  19722. * - BABYLON.VertexBuffer.UV3Kind
  19723. * - BABYLON.VertexBuffer.UV4Kind
  19724. * - BABYLON.VertexBuffer.UV5Kind
  19725. * - BABYLON.VertexBuffer.UV6Kind
  19726. * - BABYLON.VertexBuffer.ColorKind
  19727. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19728. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19729. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19730. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19731. *
  19732. * Returns the Mesh.
  19733. */
  19734. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19735. /**
  19736. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19737. * If the mesh has no geometry, it is simply returned as it is.
  19738. * The `data` are either a numeric array either a Float32Array.
  19739. * No new underlying VertexBuffer object is created.
  19740. * 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.
  19741. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19742. *
  19743. * Possible `kind` values :
  19744. * - BABYLON.VertexBuffer.PositionKind
  19745. * - BABYLON.VertexBuffer.UVKind
  19746. * - BABYLON.VertexBuffer.UV2Kind
  19747. * - BABYLON.VertexBuffer.UV3Kind
  19748. * - BABYLON.VertexBuffer.UV4Kind
  19749. * - BABYLON.VertexBuffer.UV5Kind
  19750. * - BABYLON.VertexBuffer.UV6Kind
  19751. * - BABYLON.VertexBuffer.ColorKind
  19752. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19753. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19754. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19755. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19756. *
  19757. * Returns the Mesh.
  19758. */
  19759. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19760. /**
  19761. * Sets the mesh indices.
  19762. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19763. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19764. * This method creates a new index buffer each call.
  19765. * Returns the Mesh.
  19766. */
  19767. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19768. /**
  19769. * Boolean : True if the mesh owns the requested kind of data.
  19770. */
  19771. isVerticesDataPresent(kind: string): boolean;
  19772. /**
  19773. * Returns an array of indices (IndicesArray).
  19774. */
  19775. getIndices(): Nullable<IndicesArray>;
  19776. readonly _positions: Nullable<Vector3[]>;
  19777. /**
  19778. * Sets a new updated BoundingInfo to the mesh.
  19779. * Returns the mesh.
  19780. */
  19781. refreshBoundingInfo(): InstancedMesh;
  19782. _preActivate(): InstancedMesh;
  19783. _activate(renderId: number): InstancedMesh;
  19784. /**
  19785. * Returns the current associated LOD AbstractMesh.
  19786. */
  19787. getLOD(camera: Camera): AbstractMesh;
  19788. _syncSubMeshes(): InstancedMesh;
  19789. _generatePointsArray(): boolean;
  19790. /**
  19791. * Creates a new InstancedMesh from the current mesh.
  19792. * - name (string) : the cloned mesh name
  19793. * - newParent (optional Node) : the optional Node to parent the clone to.
  19794. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19795. *
  19796. * Returns the clone.
  19797. */
  19798. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19799. /**
  19800. * Disposes the InstancedMesh.
  19801. * Returns nothing.
  19802. */
  19803. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19804. }
  19805. }
  19806. declare module BABYLON {
  19807. class LinesMesh extends Mesh {
  19808. useVertexColor: boolean | undefined;
  19809. useVertexAlpha: boolean | undefined;
  19810. color: Color3;
  19811. alpha: number;
  19812. /**
  19813. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19814. * This margin is expressed in world space coordinates, so its value may vary.
  19815. * Default value is 0.1
  19816. * @returns the intersection Threshold value.
  19817. */
  19818. /**
  19819. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19820. * This margin is expressed in world space coordinates, so its value may vary.
  19821. * @param value the new threshold to apply
  19822. */
  19823. intersectionThreshold: number;
  19824. private _intersectionThreshold;
  19825. private _colorShader;
  19826. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  19827. /**
  19828. * Returns the string "LineMesh"
  19829. */
  19830. getClassName(): string;
  19831. material: Material;
  19832. readonly checkCollisions: boolean;
  19833. createInstance(name: string): InstancedMesh;
  19834. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19835. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19836. dispose(doNotRecurse?: boolean): void;
  19837. /**
  19838. * Returns a new LineMesh object cloned from the current one.
  19839. */
  19840. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19841. }
  19842. }
  19843. declare module BABYLON {
  19844. /**
  19845. * @hidden
  19846. **/
  19847. class _InstancesBatch {
  19848. mustReturn: boolean;
  19849. visibleInstances: Nullable<InstancedMesh[]>[];
  19850. renderSelf: boolean[];
  19851. }
  19852. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19853. static _FRONTSIDE: number;
  19854. static _BACKSIDE: number;
  19855. static _DOUBLESIDE: number;
  19856. static _DEFAULTSIDE: number;
  19857. static _NO_CAP: number;
  19858. static _CAP_START: number;
  19859. static _CAP_END: number;
  19860. static _CAP_ALL: number;
  19861. /**
  19862. * Mesh side orientation : usually the external or front surface
  19863. */
  19864. static readonly FRONTSIDE: number;
  19865. /**
  19866. * Mesh side orientation : usually the internal or back surface
  19867. */
  19868. static readonly BACKSIDE: number;
  19869. /**
  19870. * Mesh side orientation : both internal and external or front and back surfaces
  19871. */
  19872. static readonly DOUBLESIDE: number;
  19873. /**
  19874. * Mesh side orientation : by default, `FRONTSIDE`
  19875. */
  19876. static readonly DEFAULTSIDE: number;
  19877. /**
  19878. * Mesh cap setting : no cap
  19879. */
  19880. static readonly NO_CAP: number;
  19881. /**
  19882. * Mesh cap setting : one cap at the beginning of the mesh
  19883. */
  19884. static readonly CAP_START: number;
  19885. /**
  19886. * Mesh cap setting : one cap at the end of the mesh
  19887. */
  19888. static readonly CAP_END: number;
  19889. /**
  19890. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19891. */
  19892. static readonly CAP_ALL: number;
  19893. /**
  19894. * An event triggered before rendering the mesh
  19895. */
  19896. onBeforeRenderObservable: Observable<Mesh>;
  19897. /**
  19898. * An event triggered after rendering the mesh
  19899. */
  19900. onAfterRenderObservable: Observable<Mesh>;
  19901. /**
  19902. * An event triggered before drawing the mesh
  19903. */
  19904. onBeforeDrawObservable: Observable<Mesh>;
  19905. private _onBeforeDrawObserver;
  19906. onBeforeDraw: () => void;
  19907. delayLoadState: number;
  19908. instances: InstancedMesh[];
  19909. delayLoadingFile: string;
  19910. _binaryInfo: any;
  19911. private _LODLevels;
  19912. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  19913. private _morphTargetManager;
  19914. morphTargetManager: Nullable<MorphTargetManager>;
  19915. _geometry: Nullable<Geometry>;
  19916. _delayInfo: Array<string>;
  19917. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19918. _visibleInstances: any;
  19919. private _renderIdForInstances;
  19920. private _batchCache;
  19921. private _instancesBufferSize;
  19922. private _instancesBuffer;
  19923. private _instancesData;
  19924. private _overridenInstanceCount;
  19925. private _effectiveMaterial;
  19926. _shouldGenerateFlatShading: boolean;
  19927. private _preActivateId;
  19928. _originalBuilderSideOrientation: number;
  19929. overrideMaterialSideOrientation: Nullable<number>;
  19930. private _areNormalsFrozen;
  19931. private _sourcePositions;
  19932. private _sourceNormals;
  19933. private _source;
  19934. readonly source: Nullable<Mesh>;
  19935. isUnIndexed: boolean;
  19936. /**
  19937. * @constructor
  19938. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  19939. * @param {Scene} scene The scene to add this mesh to.
  19940. * @param {Node} parent The parent of this mesh, if it has one
  19941. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  19942. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19943. * When false, achieved by calling a clone(), also passing False.
  19944. * This will make creation of children, recursive.
  19945. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19946. */
  19947. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19948. /**
  19949. * Returns the string "Mesh".
  19950. */
  19951. getClassName(): string;
  19952. /**
  19953. * Returns a string.
  19954. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  19955. */
  19956. toString(fullDetails?: boolean): string;
  19957. _unBindEffect(): void;
  19958. /**
  19959. * True if the mesh has some Levels Of Details (LOD).
  19960. * Returns a boolean.
  19961. */
  19962. readonly hasLODLevels: boolean;
  19963. /**
  19964. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  19965. * @returns an array of {BABYLON.MeshLODLevel}
  19966. */
  19967. getLODLevels(): MeshLODLevel[];
  19968. private _sortLODLevels();
  19969. /**
  19970. * Add a mesh as LOD level triggered at the given distance.
  19971. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19972. * @param {number} distance The distance from the center of the object to show this level
  19973. * @param {Mesh} mesh The mesh to be added as LOD level
  19974. * @return {Mesh} This mesh (for chaining)
  19975. */
  19976. addLODLevel(distance: number, mesh: Mesh): Mesh;
  19977. /**
  19978. * Returns the LOD level mesh at the passed distance or null if not found.
  19979. * It is related to the method `addLODLevel(distance, mesh)`.
  19980. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19981. * Returns an object Mesh or `null`.
  19982. */
  19983. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19984. /**
  19985. * Remove a mesh from the LOD array
  19986. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19987. * @param {Mesh} mesh The mesh to be removed.
  19988. * @return {Mesh} This mesh (for chaining)
  19989. */
  19990. removeLODLevel(mesh: Mesh): Mesh;
  19991. /**
  19992. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19993. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19994. */
  19995. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  19996. /**
  19997. * Returns the mesh internal Geometry object.
  19998. */
  19999. readonly geometry: Nullable<Geometry>;
  20000. /**
  20001. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20002. */
  20003. getTotalVertices(): number;
  20004. /**
  20005. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20006. * 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.
  20007. * You can force the copy with forceCopy === true
  20008. * Returns null if the mesh has no geometry or no vertex buffer.
  20009. * Possible `kind` values :
  20010. * - BABYLON.VertexBuffer.PositionKind
  20011. * - BABYLON.VertexBuffer.UVKind
  20012. * - BABYLON.VertexBuffer.UV2Kind
  20013. * - BABYLON.VertexBuffer.UV3Kind
  20014. * - BABYLON.VertexBuffer.UV4Kind
  20015. * - BABYLON.VertexBuffer.UV5Kind
  20016. * - BABYLON.VertexBuffer.UV6Kind
  20017. * - BABYLON.VertexBuffer.ColorKind
  20018. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20019. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20020. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20021. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20022. */
  20023. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20024. /**
  20025. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20026. * Returns `null` if the mesh has no geometry.
  20027. * Possible `kind` values :
  20028. * - BABYLON.VertexBuffer.PositionKind
  20029. * - BABYLON.VertexBuffer.UVKind
  20030. * - BABYLON.VertexBuffer.UV2Kind
  20031. * - BABYLON.VertexBuffer.UV3Kind
  20032. * - BABYLON.VertexBuffer.UV4Kind
  20033. * - BABYLON.VertexBuffer.UV5Kind
  20034. * - BABYLON.VertexBuffer.UV6Kind
  20035. * - BABYLON.VertexBuffer.ColorKind
  20036. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20037. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20038. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20039. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20040. */
  20041. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20042. isVerticesDataPresent(kind: string): boolean;
  20043. /**
  20044. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20045. * Possible `kind` values :
  20046. * - BABYLON.VertexBuffer.PositionKind
  20047. * - BABYLON.VertexBuffer.UVKind
  20048. * - BABYLON.VertexBuffer.UV2Kind
  20049. * - BABYLON.VertexBuffer.UV3Kind
  20050. * - BABYLON.VertexBuffer.UV4Kind
  20051. * - BABYLON.VertexBuffer.UV5Kind
  20052. * - BABYLON.VertexBuffer.UV6Kind
  20053. * - BABYLON.VertexBuffer.ColorKind
  20054. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20055. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20056. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20057. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20058. */
  20059. isVertexBufferUpdatable(kind: string): boolean;
  20060. /**
  20061. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20062. * Possible `kind` values :
  20063. * - BABYLON.VertexBuffer.PositionKind
  20064. * - BABYLON.VertexBuffer.UVKind
  20065. * - BABYLON.VertexBuffer.UV2Kind
  20066. * - BABYLON.VertexBuffer.UV3Kind
  20067. * - BABYLON.VertexBuffer.UV4Kind
  20068. * - BABYLON.VertexBuffer.UV5Kind
  20069. * - BABYLON.VertexBuffer.UV6Kind
  20070. * - BABYLON.VertexBuffer.ColorKind
  20071. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20072. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20073. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20074. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20075. */
  20076. getVerticesDataKinds(): string[];
  20077. /**
  20078. * Returns a positive integer : the total number of indices in this mesh geometry.
  20079. * Returns zero if the mesh has no geometry.
  20080. */
  20081. getTotalIndices(): number;
  20082. /**
  20083. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20084. * 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.
  20085. * Returns an empty array if the mesh has no geometry.
  20086. */
  20087. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20088. readonly isBlocked: boolean;
  20089. /**
  20090. * Determine if the current mesh is ready to be rendered
  20091. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20092. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20093. * @returns true if all associated assets are ready (material, textures, shaders)
  20094. */
  20095. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20096. /**
  20097. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20098. * This property is pertinent only for updatable parametric shapes.
  20099. */
  20100. readonly areNormalsFrozen: boolean;
  20101. /**
  20102. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20103. * It has no effect at all on other shapes.
  20104. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20105. * Returns the Mesh.
  20106. */
  20107. freezeNormals(): Mesh;
  20108. /**
  20109. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20110. * It has no effect at all on other shapes.
  20111. * It reactivates the mesh normals computation if it was previously frozen.
  20112. * Returns the Mesh.
  20113. */
  20114. unfreezeNormals(): Mesh;
  20115. /**
  20116. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20117. */
  20118. overridenInstanceCount: number;
  20119. _preActivate(): Mesh;
  20120. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20121. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20122. /**
  20123. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20124. * This means the mesh underlying bounding box and sphere are recomputed.
  20125. * Returns the Mesh.
  20126. */
  20127. refreshBoundingInfo(): Mesh;
  20128. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20129. private _getPositionData(applySkeleton);
  20130. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20131. subdivide(count: number): void;
  20132. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20133. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20134. /**
  20135. * Sets the mesh VertexBuffer.
  20136. * Returns the Mesh.
  20137. */
  20138. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20139. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20140. /**
  20141. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20142. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20143. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20144. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20145. * Returns the Mesh.
  20146. */
  20147. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20148. /**
  20149. * Creates a un-shared specific occurence of the geometry for the mesh.
  20150. * Returns the Mesh.
  20151. */
  20152. makeGeometryUnique(): Mesh;
  20153. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20154. /**
  20155. * Update the current index buffer
  20156. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20157. * Returns the Mesh.
  20158. */
  20159. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20160. /**
  20161. * Invert the geometry to move from a right handed system to a left handed one.
  20162. * Returns the Mesh.
  20163. */
  20164. toLeftHanded(): Mesh;
  20165. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20166. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20167. /**
  20168. * Registers for this mesh a javascript function called just before the rendering process.
  20169. * This function is passed the current mesh.
  20170. * Return the Mesh.
  20171. */
  20172. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20173. /**
  20174. * Disposes a previously registered javascript function called before the rendering.
  20175. * This function is passed the current mesh.
  20176. * Returns the Mesh.
  20177. */
  20178. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20179. /**
  20180. * Registers for this mesh a javascript function called just after the rendering is complete.
  20181. * This function is passed the current mesh.
  20182. * Returns the Mesh.
  20183. */
  20184. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20185. /**
  20186. * Disposes a previously registered javascript function called after the rendering.
  20187. * This function is passed the current mesh.
  20188. * Return the Mesh.
  20189. */
  20190. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20191. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20192. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20193. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20194. /**
  20195. * Triggers the draw call for the mesh.
  20196. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20197. * Returns the Mesh.
  20198. */
  20199. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20200. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20201. /**
  20202. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20203. */
  20204. getEmittedParticleSystems(): IParticleSystem[];
  20205. /**
  20206. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20207. */
  20208. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20209. /**
  20210. * Normalize matrix weights so that all vertices have a total weight set to 1
  20211. */
  20212. cleanMatrixWeights(): void;
  20213. _checkDelayState(): Mesh;
  20214. private _queueLoad(scene);
  20215. /**
  20216. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20217. */
  20218. isInFrustum(frustumPlanes: Plane[]): boolean;
  20219. /**
  20220. * Sets the mesh material by the material or multiMaterial `id` property.
  20221. * The material `id` is a string identifying the material or the multiMaterial.
  20222. * This method returns the Mesh.
  20223. */
  20224. setMaterialByID(id: string): Mesh;
  20225. /**
  20226. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20227. */
  20228. getAnimatables(): IAnimatable[];
  20229. /**
  20230. * Modifies the mesh geometry according to the passed transformation matrix.
  20231. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20232. * The mesh normals are modified accordingly the same transformation.
  20233. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  20234. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20235. * Returns the Mesh.
  20236. */
  20237. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20238. /**
  20239. * Modifies the mesh geometry according to its own current World Matrix.
  20240. * The mesh World Matrix is then reset.
  20241. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20242. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  20243. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20244. * Returns the Mesh.
  20245. */
  20246. bakeCurrentTransformIntoVertices(): Mesh;
  20247. readonly _positions: Nullable<Vector3[]>;
  20248. _resetPointsArrayCache(): Mesh;
  20249. _generatePointsArray(): boolean;
  20250. /**
  20251. * Returns a new Mesh object generated from the current mesh properties.
  20252. * This method must not get confused with createInstance().
  20253. * The parameter `name` is a string, the name given to the new mesh.
  20254. * The optional parameter `newParent` can be any Node object (default `null`).
  20255. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  20256. * 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.
  20257. */
  20258. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20259. /**
  20260. * Releases resources associated with this mesh.
  20261. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20262. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20263. */
  20264. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20265. /**
  20266. * Modifies the mesh geometry according to a displacement map.
  20267. * 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.
  20268. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20269. * This method returns nothing.
  20270. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  20271. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20272. * 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.
  20273. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20274. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20275. *
  20276. * Returns the Mesh.
  20277. */
  20278. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20279. /**
  20280. * Modifies the mesh geometry according to a displacementMap buffer.
  20281. * 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.
  20282. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20283. * This method returns nothing.
  20284. * 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.
  20285. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  20286. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20287. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20288. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20289. *
  20290. * Returns the Mesh.
  20291. */
  20292. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20293. /**
  20294. * Modify the mesh to get a flat shading rendering.
  20295. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20296. * This method returns the Mesh.
  20297. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20298. */
  20299. convertToFlatShadedMesh(): Mesh;
  20300. /**
  20301. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20302. * In other words, more vertices, no more indices and a single bigger VBO.
  20303. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20304. * Returns the Mesh.
  20305. */
  20306. convertToUnIndexedMesh(): Mesh;
  20307. /**
  20308. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  20309. * This method returns the Mesh.
  20310. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20311. */
  20312. flipFaces(flipNormals?: boolean): Mesh;
  20313. /**
  20314. * Creates a new InstancedMesh object from the mesh model.
  20315. * An instance shares the same properties and the same material than its model.
  20316. * Only these properties of each instance can then be set individually :
  20317. * - position
  20318. * - rotation
  20319. * - rotationQuaternion
  20320. * - setPivotMatrix
  20321. * - scaling
  20322. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  20323. * Warning : this method is not supported for Line mesh and LineSystem
  20324. */
  20325. createInstance(name: string): InstancedMesh;
  20326. /**
  20327. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20328. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20329. * This method returns the Mesh.
  20330. */
  20331. synchronizeInstances(): Mesh;
  20332. /**
  20333. * Simplify the mesh according to the given array of settings.
  20334. * Function will return immediately and will simplify async. It returns the Mesh.
  20335. * @param settings a collection of simplification settings.
  20336. * @param parallelProcessing should all levels calculate parallel or one after the other.
  20337. * @param type the type of simplification to run.
  20338. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  20339. */
  20340. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  20341. /**
  20342. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20343. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20344. * This should be used together with the simplification to avoid disappearing triangles.
  20345. * Returns the Mesh.
  20346. * @param successCallback an optional success callback to be called after the optimization finished.
  20347. */
  20348. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20349. serialize(serializationObject: any): void;
  20350. _syncGeometryWithMorphTargetManager(): void;
  20351. /**
  20352. * Returns a new Mesh object parsed from the source provided.
  20353. * The parameter `parsedMesh` is the source.
  20354. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20355. */
  20356. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20357. /**
  20358. * Creates a ribbon mesh.
  20359. * Please consider using the same method from the MeshBuilder class instead.
  20360. * 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.
  20361. *
  20362. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  20363. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20364. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  20365. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  20366. * 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.
  20367. * 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.
  20368. * 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
  20369. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20370. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20371. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20372. */
  20373. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20374. /**
  20375. * Creates a plane polygonal mesh. By default, this is a disc.
  20376. * Please consider using the same method from the MeshBuilder class instead.
  20377. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  20378. * 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.
  20379. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20380. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20381. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20382. */
  20383. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20384. /**
  20385. * Creates a box mesh.
  20386. * Please consider using the same method from the MeshBuilder class instead.
  20387. * The parameter `size` sets the size (float) of each box side (default 1).
  20388. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20389. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20390. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20391. */
  20392. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20393. /**
  20394. * Creates a sphere mesh.
  20395. * Please consider using the same method from the MeshBuilder class instead.
  20396. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  20397. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  20398. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20399. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20400. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20401. */
  20402. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20403. /**
  20404. * Creates a cylinder or a cone mesh.
  20405. * Please consider using the same method from the MeshBuilder class instead.
  20406. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20407. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20408. * 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.
  20409. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20410. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20411. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20412. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20413. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20414. */
  20415. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20416. /**
  20417. * Creates a torus mesh.
  20418. * Please consider using the same method from the MeshBuilder class instead.
  20419. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  20420. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  20421. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  20422. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20423. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20424. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20425. */
  20426. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20427. /**
  20428. * Creates a torus knot mesh.
  20429. * Please consider using the same method from the MeshBuilder class instead.
  20430. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  20431. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  20432. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  20433. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  20434. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20435. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20436. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20437. */
  20438. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20439. /**
  20440. * Creates a line mesh.
  20441. * Please consider using the same method from the MeshBuilder class instead.
  20442. * 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.
  20443. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20444. * The parameter `points` is an array successive Vector3.
  20445. * 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
  20446. * When updating an instance, remember that only point positions can change, not the number of points.
  20447. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20448. */
  20449. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20450. /**
  20451. * Creates a dashed line mesh.
  20452. * Please consider using the same method from the MeshBuilder class instead.
  20453. * 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.
  20454. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20455. * The parameter `points` is an array successive Vector3.
  20456. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  20457. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  20458. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  20459. * 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
  20460. * When updating an instance, remember that only point positions can change, not the number of points.
  20461. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20462. */
  20463. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20464. /**
  20465. * Creates a polygon mesh.
  20466. * Please consider using the same method from the MeshBuilder class instead.
  20467. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20468. * 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.
  20469. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20470. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20471. * Remember you can only change the shape positions, not their number when updating a polygon.
  20472. */
  20473. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20474. /**
  20475. * Creates an extruded polygon mesh, with depth in the Y direction.
  20476. * Please consider using the same method from the MeshBuilder class instead.
  20477. */
  20478. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20479. /**
  20480. * Creates an extruded shape mesh.
  20481. * 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.
  20482. * Please consider using the same method from the MeshBuilder class instead.
  20483. *
  20484. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20485. * 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
  20486. * extruded along the Z axis.
  20487. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20488. * 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.
  20489. * The parameter `scale` (float, default 1) is the value to scale the shape.
  20490. * 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
  20491. * 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
  20492. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20493. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20494. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20495. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20496. */
  20497. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20498. /**
  20499. * Creates an custom extruded shape mesh.
  20500. * 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.
  20501. * Please consider using the same method from the MeshBuilder class instead.
  20502. *
  20503. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20504. * 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
  20505. * extruded along the Z axis.
  20506. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20507. * 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
  20508. * and the distance of this point from the begining of the path :
  20509. * ```javascript
  20510. * var rotationFunction = function(i, distance) {
  20511. * // do things
  20512. * return rotationValue; }
  20513. * ```
  20514. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20515. * 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
  20516. * and the distance of this point from the begining of the path :
  20517. * ```javascript
  20518. * var scaleFunction = function(i, distance) {
  20519. * // do things
  20520. * return scaleValue;}
  20521. * ```
  20522. * It must returns a float value that will be the scale value applied to the shape on each path point.
  20523. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  20524. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  20525. * 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
  20526. * 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
  20527. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20528. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20529. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20530. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20531. */
  20532. 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;
  20533. /**
  20534. * Creates lathe mesh.
  20535. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20536. * Please consider using the same method from the MeshBuilder class instead.
  20537. * 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
  20538. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  20539. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  20540. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  20541. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20542. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20543. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20544. */
  20545. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20546. /**
  20547. * Creates a plane mesh.
  20548. * Please consider using the same method from the MeshBuilder class instead.
  20549. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  20550. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20551. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20552. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20553. */
  20554. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20555. /**
  20556. * Creates a ground mesh.
  20557. * Please consider using the same method from the MeshBuilder class instead.
  20558. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  20559. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  20560. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20561. */
  20562. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20563. /**
  20564. * Creates a tiled ground mesh.
  20565. * Please consider using the same method from the MeshBuilder class instead.
  20566. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  20567. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  20568. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  20569. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  20570. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  20571. * numbers of subdivisions on the ground width and height of each tile.
  20572. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20573. */
  20574. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20575. w: number;
  20576. h: number;
  20577. }, precision: {
  20578. w: number;
  20579. h: number;
  20580. }, scene: Scene, updatable?: boolean): Mesh;
  20581. /**
  20582. * Creates a ground mesh from a height map.
  20583. * tuto : http://doc.babylonjs.com/babylon101/height_map
  20584. * Please consider using the same method from the MeshBuilder class instead.
  20585. * The parameter `url` sets the URL of the height map image resource.
  20586. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  20587. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  20588. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  20589. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  20590. * 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).
  20591. * This function is passed the newly built mesh :
  20592. * ```javascript
  20593. * function(mesh) { // do things
  20594. * return; }
  20595. * ```
  20596. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20597. */
  20598. 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;
  20599. /**
  20600. * Creates a tube mesh.
  20601. * 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.
  20602. * Please consider using the same method from the MeshBuilder class instead.
  20603. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  20604. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  20605. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  20606. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  20607. * 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.
  20608. * It must return a radius value (positive float) :
  20609. * ```javascript
  20610. * var radiusFunction = function(i, distance) {
  20611. * // do things
  20612. * return radius; }
  20613. * ```
  20614. * 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
  20615. * 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
  20616. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20617. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20618. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20619. */
  20620. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20621. (i: number, distance: number): number;
  20622. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20623. /**
  20624. * Creates a polyhedron mesh.
  20625. * Please consider using the same method from the MeshBuilder class instead.
  20626. * 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
  20627. * to choose the wanted type.
  20628. * The parameter `size` (positive float, default 1) sets the polygon size.
  20629. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  20630. * 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`.
  20631. * 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
  20632. * 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)`).
  20633. * 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
  20634. * 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.
  20635. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20636. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20637. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20638. */
  20639. static CreatePolyhedron(name: string, options: {
  20640. type?: number;
  20641. size?: number;
  20642. sizeX?: number;
  20643. sizeY?: number;
  20644. sizeZ?: number;
  20645. custom?: any;
  20646. faceUV?: Vector4[];
  20647. faceColors?: Color4[];
  20648. updatable?: boolean;
  20649. sideOrientation?: number;
  20650. }, scene: Scene): Mesh;
  20651. /**
  20652. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  20653. * Please consider using the same method from the MeshBuilder class instead.
  20654. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  20655. * 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`).
  20656. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  20657. * 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.
  20658. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20659. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20660. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20661. */
  20662. static CreateIcoSphere(name: string, options: {
  20663. radius?: number;
  20664. flat?: boolean;
  20665. subdivisions?: number;
  20666. sideOrientation?: number;
  20667. updatable?: boolean;
  20668. }, scene: Scene): Mesh;
  20669. /**
  20670. * Creates a decal mesh.
  20671. * Please consider using the same method from the MeshBuilder class instead.
  20672. * 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.
  20673. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  20674. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  20675. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  20676. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  20677. */
  20678. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20679. /**
  20680. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20681. */
  20682. setPositionsForCPUSkinning(): Float32Array;
  20683. /**
  20684. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20685. */
  20686. setNormalsForCPUSkinning(): Float32Array;
  20687. /**
  20688. * Updates the vertex buffer by applying transformation from the bones.
  20689. * Returns the Mesh.
  20690. *
  20691. * @param {skeleton} skeleton to apply
  20692. */
  20693. applySkeleton(skeleton: Skeleton): Mesh;
  20694. /**
  20695. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  20696. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  20697. */
  20698. static MinMax(meshes: AbstractMesh[]): {
  20699. min: Vector3;
  20700. max: Vector3;
  20701. };
  20702. /**
  20703. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  20704. */
  20705. static Center(meshesOrMinMaxVector: {
  20706. min: Vector3;
  20707. max: Vector3;
  20708. } | AbstractMesh[]): Vector3;
  20709. /**
  20710. * Merge the array of meshes into a single mesh for performance reasons.
  20711. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  20712. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  20713. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  20714. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20715. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  20716. */
  20717. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20718. }
  20719. }
  20720. declare module BABYLON {
  20721. /**
  20722. * Define an interface for all classes that will get and set the data on vertices
  20723. */
  20724. interface IGetSetVerticesData {
  20725. isVerticesDataPresent(kind: string): boolean;
  20726. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20727. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20728. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20729. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20730. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20731. }
  20732. /**
  20733. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20734. */
  20735. class VertexData {
  20736. /**
  20737. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20738. */
  20739. positions: Nullable<FloatArray>;
  20740. /**
  20741. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20742. */
  20743. normals: Nullable<FloatArray>;
  20744. /**
  20745. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20746. */
  20747. tangents: Nullable<FloatArray>;
  20748. /**
  20749. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20750. */
  20751. uvs: Nullable<FloatArray>;
  20752. /**
  20753. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20754. */
  20755. uvs2: Nullable<FloatArray>;
  20756. /**
  20757. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20758. */
  20759. uvs3: Nullable<FloatArray>;
  20760. /**
  20761. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20762. */
  20763. uvs4: Nullable<FloatArray>;
  20764. /**
  20765. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20766. */
  20767. uvs5: Nullable<FloatArray>;
  20768. /**
  20769. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20770. */
  20771. uvs6: Nullable<FloatArray>;
  20772. /**
  20773. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20774. */
  20775. colors: Nullable<FloatArray>;
  20776. /**
  20777. * 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).
  20778. */
  20779. matricesIndices: Nullable<FloatArray>;
  20780. /**
  20781. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20782. */
  20783. matricesWeights: Nullable<FloatArray>;
  20784. /**
  20785. * An array extending the number of possible indices
  20786. */
  20787. matricesIndicesExtra: Nullable<FloatArray>;
  20788. /**
  20789. * An array extending the number of possible weights when the number of indices is extended
  20790. */
  20791. matricesWeightsExtra: Nullable<FloatArray>;
  20792. /**
  20793. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20794. */
  20795. indices: Nullable<IndicesArray>;
  20796. /**
  20797. * Uses the passed data array to set the set the values for the specified kind of data
  20798. * @param data a linear array of floating numbers
  20799. * @param kind the type of data that is being set, eg positions, colors etc
  20800. */
  20801. set(data: FloatArray, kind: string): void;
  20802. /**
  20803. * Associates the vertexData to the passed Mesh.
  20804. * Sets it as updatable or not (default `false`)
  20805. * @param mesh the mesh the vertexData is applied to
  20806. * @param updatable when used and having the value true allows new data to update the vertexData
  20807. * @returns the VertexData
  20808. */
  20809. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20810. /**
  20811. * Associates the vertexData to the passed Geometry.
  20812. * Sets it as updatable or not (default `false`)
  20813. * @param geometry the geometry the vertexData is applied to
  20814. * @param updatable when used and having the value true allows new data to update the vertexData
  20815. * @returns VertexData
  20816. */
  20817. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20818. /**
  20819. * Updates the associated mesh
  20820. * @param mesh the mesh to be updated
  20821. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20822. * @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
  20823. * @returns VertexData
  20824. */
  20825. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20826. /**
  20827. * Updates the associated geometry
  20828. * @param geometry the geometry to be updated
  20829. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20830. * @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
  20831. * @returns VertexData.
  20832. */
  20833. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20834. private _applyTo(meshOrGeometry, updatable?);
  20835. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  20836. /**
  20837. * Transforms each position and each normal of the vertexData according to the passed Matrix
  20838. * @param matrix the transforming matrix
  20839. * @returns the VertexData
  20840. */
  20841. transform(matrix: Matrix): VertexData;
  20842. /**
  20843. * Merges the passed VertexData into the current one
  20844. * @param other the VertexData to be merged into the current one
  20845. * @returns the modified VertexData
  20846. */
  20847. merge(other: VertexData): VertexData;
  20848. private _mergeElement(source, other);
  20849. private _validate();
  20850. /**
  20851. * Serializes the VertexData
  20852. * @returns a serialized object
  20853. */
  20854. serialize(): any;
  20855. /**
  20856. * Extracts the vertexData from a mesh
  20857. * @param mesh the mesh from which to extract the VertexData
  20858. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  20859. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20860. * @returns the object VertexData associated to the passed mesh
  20861. */
  20862. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20863. /**
  20864. * Extracts the vertexData from the geometry
  20865. * @param geometry the geometry from which to extract the VertexData
  20866. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  20867. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20868. * @returns the object VertexData associated to the passed mesh
  20869. */
  20870. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20871. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  20872. /**
  20873. * Creates the VertexData for a Ribbon
  20874. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  20875. * * pathArray array of paths, each of which an array of successive Vector3
  20876. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  20877. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  20878. * * 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
  20879. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20880. * * 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)
  20881. * * 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)
  20882. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  20883. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  20884. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  20885. * @returns the VertexData of the ribbon
  20886. */
  20887. static CreateRibbon(options: {
  20888. pathArray: Vector3[][];
  20889. closeArray?: boolean;
  20890. closePath?: boolean;
  20891. offset?: number;
  20892. sideOrientation?: number;
  20893. frontUVs?: Vector4;
  20894. backUVs?: Vector4;
  20895. invertUV?: boolean;
  20896. uvs?: Vector2[];
  20897. colors?: Color4[];
  20898. }): VertexData;
  20899. /**
  20900. * Creates the VertexData for a box
  20901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20902. * * size sets the width, height and depth of the box to the value of size, optional default 1
  20903. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  20904. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  20905. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  20906. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  20907. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  20908. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20909. * * 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)
  20910. * * 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)
  20911. * @returns the VertexData of the box
  20912. */
  20913. static CreateBox(options: {
  20914. size?: number;
  20915. width?: number;
  20916. height?: number;
  20917. depth?: number;
  20918. faceUV?: Vector4[];
  20919. faceColors?: Color4[];
  20920. sideOrientation?: number;
  20921. frontUVs?: Vector4;
  20922. backUVs?: Vector4;
  20923. }): VertexData;
  20924. /**
  20925. * Creates the VertexData for an ellipsoid, defaults to a sphere
  20926. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20927. * * segments sets the number of horizontal strips optional, default 32
  20928. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  20929. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  20930. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  20931. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  20932. * * 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
  20933. * * 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
  20934. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20935. * * 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)
  20936. * * 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)
  20937. * @returns the VertexData of the ellipsoid
  20938. */
  20939. static CreateSphere(options: {
  20940. segments?: number;
  20941. diameter?: number;
  20942. diameterX?: number;
  20943. diameterY?: number;
  20944. diameterZ?: number;
  20945. arc?: number;
  20946. slice?: number;
  20947. sideOrientation?: number;
  20948. frontUVs?: Vector4;
  20949. backUVs?: Vector4;
  20950. }): VertexData;
  20951. /**
  20952. * Creates the VertexData for a cylinder, cone or prism
  20953. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20954. * * height sets the height (y direction) of the cylinder, optional, default 2
  20955. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  20956. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  20957. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  20958. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  20959. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  20960. * * 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
  20961. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  20962. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  20963. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  20964. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  20965. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20966. * * 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)
  20967. * * 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)
  20968. * @returns the VertexData of the cylinder, cone or prism
  20969. */
  20970. static CreateCylinder(options: {
  20971. height?: number;
  20972. diameterTop?: number;
  20973. diameterBottom?: number;
  20974. diameter?: number;
  20975. tessellation?: number;
  20976. subdivisions?: number;
  20977. arc?: number;
  20978. faceColors?: Color4[];
  20979. faceUV?: Vector4[];
  20980. hasRings?: boolean;
  20981. enclose?: boolean;
  20982. sideOrientation?: number;
  20983. frontUVs?: Vector4;
  20984. backUVs?: Vector4;
  20985. }): VertexData;
  20986. /**
  20987. * Creates the VertexData for a torus
  20988. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20989. * * diameter the diameter of the torus, optional default 1
  20990. * * thickness the diameter of the tube forming the torus, optional default 0.5
  20991. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  20992. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20993. * * 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)
  20994. * * 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)
  20995. * @returns the VertexData of the torus
  20996. */
  20997. static CreateTorus(options: {
  20998. diameter?: number;
  20999. thickness?: number;
  21000. tessellation?: number;
  21001. sideOrientation?: number;
  21002. frontUVs?: Vector4;
  21003. backUVs?: Vector4;
  21004. }): VertexData;
  21005. /**
  21006. * Creates the VertexData of the LineSystem
  21007. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21008. * - lines an array of lines, each line being an array of successive Vector3
  21009. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21010. * @returns the VertexData of the LineSystem
  21011. */
  21012. static CreateLineSystem(options: {
  21013. lines: Vector3[][];
  21014. colors?: Nullable<Color4[][]>;
  21015. }): VertexData;
  21016. /**
  21017. * Create the VertexData for a DashedLines
  21018. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21019. * - points an array successive Vector3
  21020. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21021. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21022. * - dashNb the intended total number of dashes, optional, default 200
  21023. * @returns the VertexData for the DashedLines
  21024. */
  21025. static CreateDashedLines(options: {
  21026. points: Vector3[];
  21027. dashSize?: number;
  21028. gapSize?: number;
  21029. dashNb?: number;
  21030. }): VertexData;
  21031. /**
  21032. * Creates the VertexData for a Ground
  21033. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21034. * - width the width (x direction) of the ground, optional, default 1
  21035. * - height the height (z direction) of the ground, optional, default 1
  21036. * - subdivisions the number of subdivisions per side, optional, default 1
  21037. * @returns the VertexData of the Ground
  21038. */
  21039. static CreateGround(options: {
  21040. width?: number;
  21041. height?: number;
  21042. subdivisions?: number;
  21043. subdivisionsX?: number;
  21044. subdivisionsY?: number;
  21045. }): VertexData;
  21046. /**
  21047. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21048. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21049. * * xmin the ground minimum X coordinate, optional, default -1
  21050. * * zmin the ground minimum Z coordinate, optional, default -1
  21051. * * xmax the ground maximum X coordinate, optional, default 1
  21052. * * zmax the ground maximum Z coordinate, optional, default 1
  21053. * * 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}
  21054. * * 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}
  21055. * @returns the VertexData of the TiledGround
  21056. */
  21057. static CreateTiledGround(options: {
  21058. xmin: number;
  21059. zmin: number;
  21060. xmax: number;
  21061. zmax: number;
  21062. subdivisions?: {
  21063. w: number;
  21064. h: number;
  21065. };
  21066. precision?: {
  21067. w: number;
  21068. h: number;
  21069. };
  21070. }): VertexData;
  21071. /**
  21072. * Creates the VertexData of the Ground designed from a heightmap
  21073. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21074. * * width the width (x direction) of the ground
  21075. * * height the height (z direction) of the ground
  21076. * * subdivisions the number of subdivisions per side
  21077. * * minHeight the minimum altitude on the ground, optional, default 0
  21078. * * maxHeight the maximum altitude on the ground, optional default 1
  21079. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21080. * * buffer the array holding the image color data
  21081. * * bufferWidth the width of image
  21082. * * bufferHeight the height of image
  21083. * @returns the VertexData of the Ground designed from a heightmap
  21084. */
  21085. static CreateGroundFromHeightMap(options: {
  21086. width: number;
  21087. height: number;
  21088. subdivisions: number;
  21089. minHeight: number;
  21090. maxHeight: number;
  21091. colorFilter: Color3;
  21092. buffer: Uint8Array;
  21093. bufferWidth: number;
  21094. bufferHeight: number;
  21095. }): VertexData;
  21096. /**
  21097. * Creates the VertexData for a Plane
  21098. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21099. * * size sets the width and height of the plane to the value of size, optional default 1
  21100. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21101. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21102. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21103. * * 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)
  21104. * * 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)
  21105. * @returns the VertexData of the box
  21106. */
  21107. static CreatePlane(options: {
  21108. size?: number;
  21109. width?: number;
  21110. height?: number;
  21111. sideOrientation?: number;
  21112. frontUVs?: Vector4;
  21113. backUVs?: Vector4;
  21114. }): VertexData;
  21115. /**
  21116. * Creates the VertexData of the Disc or regular Polygon
  21117. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21118. * * radius the radius of the disc, optional default 0.5
  21119. * * tessellation the number of polygon sides, optional, default 64
  21120. * * 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
  21121. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21122. * * 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)
  21123. * * 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)
  21124. * @returns the VertexData of the box
  21125. */
  21126. static CreateDisc(options: {
  21127. radius?: number;
  21128. tessellation?: number;
  21129. arc?: number;
  21130. sideOrientation?: number;
  21131. frontUVs?: Vector4;
  21132. backUVs?: Vector4;
  21133. }): VertexData;
  21134. /**
  21135. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21136. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21137. * @param polygon a mesh built from polygonTriangulation.build()
  21138. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21139. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21140. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21141. * @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)
  21142. * @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)
  21143. * @returns the VertexData of the Polygon
  21144. */
  21145. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21146. /**
  21147. * Creates the VertexData of the IcoSphere
  21148. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21149. * * radius the radius of the IcoSphere, optional default 1
  21150. * * radiusX allows stretching in the x direction, optional, default radius
  21151. * * radiusY allows stretching in the y direction, optional, default radius
  21152. * * radiusZ allows stretching in the z direction, optional, default radius
  21153. * * flat when true creates a flat shaded mesh, optional, default true
  21154. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21155. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21156. * * 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)
  21157. * * 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)
  21158. * @returns the VertexData of the IcoSphere
  21159. */
  21160. static CreateIcoSphere(options: {
  21161. radius?: number;
  21162. radiusX?: number;
  21163. radiusY?: number;
  21164. radiusZ?: number;
  21165. flat?: boolean;
  21166. subdivisions?: number;
  21167. sideOrientation?: number;
  21168. frontUVs?: Vector4;
  21169. backUVs?: Vector4;
  21170. }): VertexData;
  21171. /**
  21172. * Creates the VertexData for a Polyhedron
  21173. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21174. * * type provided types are:
  21175. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21176. * * 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)
  21177. * * size the size of the IcoSphere, optional default 1
  21178. * * sizeX allows stretching in the x direction, optional, default size
  21179. * * sizeY allows stretching in the y direction, optional, default size
  21180. * * sizeZ allows stretching in the z direction, optional, default size
  21181. * * 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
  21182. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21183. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21184. * * flat when true creates a flat shaded mesh, optional, default true
  21185. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21186. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21187. * * 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)
  21188. * * 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)
  21189. * @returns the VertexData of the Polyhedron
  21190. */
  21191. static CreatePolyhedron(options: {
  21192. type?: number;
  21193. size?: number;
  21194. sizeX?: number;
  21195. sizeY?: number;
  21196. sizeZ?: number;
  21197. custom?: any;
  21198. faceUV?: Vector4[];
  21199. faceColors?: Color4[];
  21200. flat?: boolean;
  21201. sideOrientation?: number;
  21202. frontUVs?: Vector4;
  21203. backUVs?: Vector4;
  21204. }): VertexData;
  21205. /**
  21206. * Creates the VertexData for a TorusKnot
  21207. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21208. * * radius the radius of the torus knot, optional, default 2
  21209. * * tube the thickness of the tube, optional, default 0.5
  21210. * * radialSegments the number of sides on each tube segments, optional, default 32
  21211. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21212. * * p the number of windings around the z axis, optional, default 2
  21213. * * q the number of windings around the x axis, optional, default 3
  21214. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21215. * * 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)
  21216. * * 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)
  21217. * @returns the VertexData of the Torus Knot
  21218. */
  21219. static CreateTorusKnot(options: {
  21220. radius?: number;
  21221. tube?: number;
  21222. radialSegments?: number;
  21223. tubularSegments?: number;
  21224. p?: number;
  21225. q?: number;
  21226. sideOrientation?: number;
  21227. frontUVs?: Vector4;
  21228. backUVs?: Vector4;
  21229. }): VertexData;
  21230. /**
  21231. * Compute normals for given positions and indices
  21232. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21233. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21234. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21235. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21236. * * facetNormals : optional array of facet normals (vector3)
  21237. * * facetPositions : optional array of facet positions (vector3)
  21238. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21239. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21240. * * bInfo : optional bounding info, required for facetPartitioning computation
  21241. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21242. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21243. * * useRightHandedSystem: optional boolean to for right handed system computation
  21244. * * depthSort : optional boolean to enable the facet depth sort computation
  21245. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21246. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21247. */
  21248. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21249. facetNormals?: any;
  21250. facetPositions?: any;
  21251. facetPartitioning?: any;
  21252. ratio?: number;
  21253. bInfo?: any;
  21254. bbSize?: Vector3;
  21255. subDiv?: any;
  21256. useRightHandedSystem?: boolean;
  21257. depthSort?: boolean;
  21258. distanceTo?: Vector3;
  21259. depthSortedFacets?: any;
  21260. }): void;
  21261. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  21262. /**
  21263. * Applies VertexData created from the imported parameters to the geometry
  21264. * @param parsedVertexData the parsed data from an imported file
  21265. * @param geometry the geometry to apply the VertexData to
  21266. */
  21267. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21268. }
  21269. }
  21270. declare module BABYLON {
  21271. /**
  21272. * Class containing static functions to help procedurally build meshes
  21273. */
  21274. class MeshBuilder {
  21275. private static updateSideOrientation(orientation?);
  21276. /**
  21277. * Creates a box mesh
  21278. * * The parameter `size` sets the size (float) of each box side (default 1)
  21279. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  21280. * * 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)
  21281. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21283. * * 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
  21284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21285. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  21286. * @param name defines the name of the mesh
  21287. * @param options defines the options used to create the mesh
  21288. * @param scene defines the hosting scene
  21289. * @returns the box mesh
  21290. */
  21291. static CreateBox(name: string, options: {
  21292. size?: number;
  21293. width?: number;
  21294. height?: number;
  21295. depth?: number;
  21296. faceUV?: Vector4[];
  21297. faceColors?: Color4[];
  21298. sideOrientation?: number;
  21299. frontUVs?: Vector4;
  21300. backUVs?: Vector4;
  21301. updatable?: boolean;
  21302. }, scene?: Nullable<Scene>): Mesh;
  21303. /**
  21304. * Creates a sphere mesh
  21305. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  21306. * * 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`)
  21307. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  21308. * * 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
  21309. * * 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)
  21310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21311. * * 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
  21312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21313. * @param name defines the name of the mesh
  21314. * @param options defines the options used to create the mesh
  21315. * @param scene defines the hosting scene
  21316. * @returns the sphere mesh
  21317. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  21318. */
  21319. static CreateSphere(name: string, options: {
  21320. segments?: number;
  21321. diameter?: number;
  21322. diameterX?: number;
  21323. diameterY?: number;
  21324. diameterZ?: number;
  21325. arc?: number;
  21326. slice?: number;
  21327. sideOrientation?: number;
  21328. frontUVs?: Vector4;
  21329. backUVs?: Vector4;
  21330. updatable?: boolean;
  21331. }, scene: any): Mesh;
  21332. /**
  21333. * Creates a plane polygonal mesh. By default, this is a disc
  21334. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21335. * * 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
  21336. * * 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
  21337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21338. * * 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
  21339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21340. * @param name defines the name of the mesh
  21341. * @param options defines the options used to create the mesh
  21342. * @param scene defines the hosting scene
  21343. * @returns the plane polygonal mesh
  21344. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21345. */
  21346. static CreateDisc(name: string, options: {
  21347. radius?: number;
  21348. tessellation?: number;
  21349. arc?: number;
  21350. updatable?: boolean;
  21351. sideOrientation?: number;
  21352. frontUVs?: Vector4;
  21353. backUVs?: Vector4;
  21354. }, scene?: Nullable<Scene>): Mesh;
  21355. /**
  21356. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21357. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21358. * * 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`)
  21359. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21360. * * 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
  21361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21362. * * 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
  21363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21364. * @param name defines the name of the mesh
  21365. * @param options defines the options used to create the mesh
  21366. * @param scene defines the hosting scene
  21367. * @returns the icosahedron mesh
  21368. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21369. */
  21370. static CreateIcoSphere(name: string, options: {
  21371. radius?: number;
  21372. radiusX?: number;
  21373. radiusY?: number;
  21374. radiusZ?: number;
  21375. flat?: boolean;
  21376. subdivisions?: number;
  21377. sideOrientation?: number;
  21378. frontUVs?: Vector4;
  21379. backUVs?: Vector4;
  21380. updatable?: boolean;
  21381. }, scene: Scene): Mesh;
  21382. /**
  21383. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21384. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  21385. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  21386. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  21387. * * 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
  21388. * * 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
  21389. * * 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
  21390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21391. * * 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
  21392. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21393. * * 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
  21394. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  21395. * * 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
  21396. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  21397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21398. * @param name defines the name of the mesh
  21399. * @param options defines the options used to create the mesh
  21400. * @param scene defines the hosting scene
  21401. * @returns the ribbon mesh
  21402. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21403. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21404. */
  21405. static CreateRibbon(name: string, options: {
  21406. pathArray: Vector3[][];
  21407. closeArray?: boolean;
  21408. closePath?: boolean;
  21409. offset?: number;
  21410. updatable?: boolean;
  21411. sideOrientation?: number;
  21412. frontUVs?: Vector4;
  21413. backUVs?: Vector4;
  21414. instance?: Mesh;
  21415. invertUV?: boolean;
  21416. uvs?: Vector2[];
  21417. colors?: Color4[];
  21418. }, scene?: Nullable<Scene>): Mesh;
  21419. /**
  21420. * Creates a cylinder or a cone mesh
  21421. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21422. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21423. * * 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.
  21424. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21425. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21426. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  21427. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  21428. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  21429. * * 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).
  21430. * * 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
  21431. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  21432. * * 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
  21433. * * 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.
  21434. * * If `enclose` is false, a ring surface is one element.
  21435. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  21436. * * 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
  21437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21438. * * 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
  21439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21440. * @param name defines the name of the mesh
  21441. * @param options defines the options used to create the mesh
  21442. * @param scene defines the hosting scene
  21443. * @returns the cylinder mesh
  21444. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  21445. */
  21446. static CreateCylinder(name: string, options: {
  21447. height?: number;
  21448. diameterTop?: number;
  21449. diameterBottom?: number;
  21450. diameter?: number;
  21451. tessellation?: number;
  21452. subdivisions?: number;
  21453. arc?: number;
  21454. faceColors?: Color4[];
  21455. faceUV?: Vector4[];
  21456. updatable?: boolean;
  21457. hasRings?: boolean;
  21458. enclose?: boolean;
  21459. sideOrientation?: number;
  21460. frontUVs?: Vector4;
  21461. backUVs?: Vector4;
  21462. }, scene: any): Mesh;
  21463. /**
  21464. * Creates a torus mesh
  21465. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  21466. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  21467. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  21468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21469. * * 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
  21470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21471. * @param name defines the name of the mesh
  21472. * @param options defines the options used to create the mesh
  21473. * @param scene defines the hosting scene
  21474. * @returns the torus mesh
  21475. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  21476. */
  21477. static CreateTorus(name: string, options: {
  21478. diameter?: number;
  21479. thickness?: number;
  21480. tessellation?: number;
  21481. updatable?: boolean;
  21482. sideOrientation?: number;
  21483. frontUVs?: Vector4;
  21484. backUVs?: Vector4;
  21485. }, scene: any): Mesh;
  21486. /**
  21487. * Creates a torus knot mesh
  21488. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  21489. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  21490. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  21491. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  21492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21493. * * 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
  21494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21495. * @param name defines the name of the mesh
  21496. * @param options defines the options used to create the mesh
  21497. * @param scene defines the hosting scene
  21498. * @returns the torus knot mesh
  21499. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  21500. */
  21501. static CreateTorusKnot(name: string, options: {
  21502. radius?: number;
  21503. tube?: number;
  21504. radialSegments?: number;
  21505. tubularSegments?: number;
  21506. p?: number;
  21507. q?: number;
  21508. updatable?: boolean;
  21509. sideOrientation?: number;
  21510. frontUVs?: Vector4;
  21511. backUVs?: Vector4;
  21512. }, scene: any): Mesh;
  21513. /**
  21514. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  21515. * * 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
  21516. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  21517. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  21518. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  21519. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  21520. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  21521. * * 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
  21522. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  21523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21524. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  21525. * @param name defines the name of the new line system
  21526. * @param options defines the options used to create the line system
  21527. * @param scene defines the hosting scene
  21528. * @returns a new line system mesh
  21529. */
  21530. static CreateLineSystem(name: string, options: {
  21531. lines: Vector3[][];
  21532. updatable?: boolean;
  21533. instance?: Nullable<LinesMesh>;
  21534. colors?: Nullable<Color4[][]>;
  21535. useVertexAlpha?: boolean;
  21536. }, scene: Nullable<Scene>): LinesMesh;
  21537. /**
  21538. * Creates a line mesh
  21539. * 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
  21540. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21541. * * The parameter `points` is an array successive Vector3
  21542. * * 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
  21543. * * The optional parameter `colors` is an array of successive Color4, one per line point
  21544. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  21545. * * When updating an instance, remember that only point positions can change, not the number of points
  21546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21547. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  21548. * @param name defines the name of the new line system
  21549. * @param options defines the options used to create the line system
  21550. * @param scene defines the hosting scene
  21551. * @returns a new line mesh
  21552. */
  21553. static CreateLines(name: string, options: {
  21554. points: Vector3[];
  21555. updatable?: boolean;
  21556. instance?: Nullable<LinesMesh>;
  21557. colors?: Color4[];
  21558. useVertexAlpha?: boolean;
  21559. }, scene?: Nullable<Scene>): LinesMesh;
  21560. /**
  21561. * Creates a dashed line mesh
  21562. * * 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
  21563. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21564. * * The parameter `points` is an array successive Vector3
  21565. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  21566. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  21567. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21568. * * 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
  21569. * * When updating an instance, remember that only point positions can change, not the number of points
  21570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21571. * @param name defines the name of the mesh
  21572. * @param options defines the options used to create the mesh
  21573. * @param scene defines the hosting scene
  21574. * @returns the dashed line mesh
  21575. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  21576. */
  21577. static CreateDashedLines(name: string, options: {
  21578. points: Vector3[];
  21579. dashSize?: number;
  21580. gapSize?: number;
  21581. dashNb?: number;
  21582. updatable?: boolean;
  21583. instance?: LinesMesh;
  21584. }, scene?: Nullable<Scene>): LinesMesh;
  21585. /**
  21586. * 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.
  21587. * * 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.
  21588. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21589. * * 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.
  21590. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  21591. * * 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
  21592. * * 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
  21593. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21595. * * 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
  21596. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21598. * @param name defines the name of the mesh
  21599. * @param options defines the options used to create the mesh
  21600. * @param scene defines the hosting scene
  21601. * @returns the extruded shape mesh
  21602. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21603. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21604. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21605. */
  21606. static ExtrudeShape(name: string, options: {
  21607. shape: Vector3[];
  21608. path: Vector3[];
  21609. scale?: number;
  21610. rotation?: number;
  21611. cap?: number;
  21612. updatable?: boolean;
  21613. sideOrientation?: number;
  21614. frontUVs?: Vector4;
  21615. backUVs?: Vector4;
  21616. instance?: Mesh;
  21617. invertUV?: boolean;
  21618. }, scene?: Nullable<Scene>): Mesh;
  21619. /**
  21620. * Creates an custom extruded shape mesh.
  21621. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  21622. * * 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.
  21623. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21624. * * 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
  21625. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21626. * * 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
  21627. * * It must returns a float value that will be the scale value applied to the shape on each path point
  21628. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21629. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  21630. * * 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
  21631. * * 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
  21632. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  21633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21634. * * 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
  21635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21637. * @param name defines the name of the mesh
  21638. * @param options defines the options used to create the mesh
  21639. * @param scene defines the hosting scene
  21640. * @returns the custom extruded shape mesh
  21641. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  21642. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21643. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21644. */
  21645. static ExtrudeShapeCustom(name: string, options: {
  21646. shape: Vector3[];
  21647. path: Vector3[];
  21648. scaleFunction?: any;
  21649. rotationFunction?: any;
  21650. ribbonCloseArray?: boolean;
  21651. ribbonClosePath?: boolean;
  21652. cap?: number;
  21653. updatable?: boolean;
  21654. sideOrientation?: number;
  21655. frontUVs?: Vector4;
  21656. backUVs?: Vector4;
  21657. instance?: Mesh;
  21658. invertUV?: boolean;
  21659. }, scene: Scene): Mesh;
  21660. /**
  21661. * Creates lathe mesh.
  21662. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  21663. * * 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
  21664. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  21665. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  21666. * * 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
  21667. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  21668. * * 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
  21669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21670. * * 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
  21671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21673. * @param name defines the name of the mesh
  21674. * @param options defines the options used to create the mesh
  21675. * @param scene defines the hosting scene
  21676. * @returns the lathe mesh
  21677. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  21678. */
  21679. static CreateLathe(name: string, options: {
  21680. shape: Vector3[];
  21681. radius?: number;
  21682. tessellation?: number;
  21683. arc?: number;
  21684. closed?: boolean;
  21685. updatable?: boolean;
  21686. sideOrientation?: number;
  21687. frontUVs?: Vector4;
  21688. backUVs?: Vector4;
  21689. cap?: number;
  21690. invertUV?: boolean;
  21691. }, scene: Scene): Mesh;
  21692. /**
  21693. * Creates a plane mesh
  21694. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  21695. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  21696. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  21697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21698. * * 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
  21699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21700. * @param name defines the name of the mesh
  21701. * @param options defines the options used to create the mesh
  21702. * @param scene defines the hosting scene
  21703. * @returns the plane mesh
  21704. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21705. */
  21706. static CreatePlane(name: string, options: {
  21707. size?: number;
  21708. width?: number;
  21709. height?: number;
  21710. sideOrientation?: number;
  21711. frontUVs?: Vector4;
  21712. backUVs?: Vector4;
  21713. updatable?: boolean;
  21714. sourcePlane?: Plane;
  21715. }, scene: Scene): Mesh;
  21716. /**
  21717. * Creates a ground mesh
  21718. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  21719. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  21720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21721. * @param name defines the name of the mesh
  21722. * @param options defines the options used to create the mesh
  21723. * @param scene defines the hosting scene
  21724. * @returns the ground mesh
  21725. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21726. */
  21727. static CreateGround(name: string, options: {
  21728. width?: number;
  21729. height?: number;
  21730. subdivisions?: number;
  21731. subdivisionsX?: number;
  21732. subdivisionsY?: number;
  21733. updatable?: boolean;
  21734. }, scene: any): Mesh;
  21735. /**
  21736. * Creates a tiled ground mesh
  21737. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  21738. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  21739. * * 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
  21740. * * 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
  21741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21742. * @param name defines the name of the mesh
  21743. * @param options defines the options used to create the mesh
  21744. * @param scene defines the hosting scene
  21745. * @returns the tiled ground mesh
  21746. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  21747. */
  21748. static CreateTiledGround(name: string, options: {
  21749. xmin: number;
  21750. zmin: number;
  21751. xmax: number;
  21752. zmax: number;
  21753. subdivisions?: {
  21754. w: number;
  21755. h: number;
  21756. };
  21757. precision?: {
  21758. w: number;
  21759. h: number;
  21760. };
  21761. updatable?: boolean;
  21762. }, scene: Scene): Mesh;
  21763. /**
  21764. * Creates a ground mesh from a height map
  21765. * * The parameter `url` sets the URL of the height map image resource.
  21766. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21767. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21768. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21769. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21770. * * 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.
  21771. * * 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).
  21772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21773. * @param name defines the name of the mesh
  21774. * @param url defines the url to the height map
  21775. * @param options defines the options used to create the mesh
  21776. * @param scene defines the hosting scene
  21777. * @returns the ground mesh
  21778. * @see http://doc.babylonjs.com/babylon101/height_map
  21779. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  21780. */
  21781. static CreateGroundFromHeightMap(name: string, url: string, options: {
  21782. width?: number;
  21783. height?: number;
  21784. subdivisions?: number;
  21785. minHeight?: number;
  21786. maxHeight?: number;
  21787. colorFilter?: Color3;
  21788. updatable?: boolean;
  21789. onReady?: (mesh: GroundMesh) => void;
  21790. }, scene: Scene): GroundMesh;
  21791. /**
  21792. * Creates a polygon mesh
  21793. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  21794. * * 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
  21795. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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. * * 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)
  21798. * * Remember you can only change the shape positions, not their number when updating a polygon
  21799. * @param name defines the name of the mesh
  21800. * @param options defines the options used to create the mesh
  21801. * @param scene defines the hosting scene
  21802. * @returns the polygon mesh
  21803. */
  21804. static CreatePolygon(name: string, options: {
  21805. shape: Vector3[];
  21806. holes?: Vector3[][];
  21807. depth?: number;
  21808. faceUV?: Vector4[];
  21809. faceColors?: Color4[];
  21810. updatable?: boolean;
  21811. sideOrientation?: number;
  21812. frontUVs?: Vector4;
  21813. backUVs?: Vector4;
  21814. }, scene: Scene): Mesh;
  21815. /**
  21816. * Creates an extruded polygon mesh, with depth in the Y direction.
  21817. * * 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)
  21818. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21819. * @param name defines the name of the mesh
  21820. * @param options defines the options used to create the mesh
  21821. * @param scene defines the hosting scene
  21822. * @returns the polygon mesh
  21823. */
  21824. static ExtrudePolygon(name: string, options: {
  21825. shape: Vector3[];
  21826. holes?: Vector3[][];
  21827. depth?: number;
  21828. faceUV?: Vector4[];
  21829. faceColors?: Color4[];
  21830. updatable?: boolean;
  21831. sideOrientation?: number;
  21832. frontUVs?: Vector4;
  21833. backUVs?: Vector4;
  21834. }, scene: Scene): Mesh;
  21835. /**
  21836. * Creates a tube mesh.
  21837. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21838. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  21839. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  21840. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  21841. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  21842. * * 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)
  21843. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  21844. * * 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
  21845. * * 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
  21846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21847. * * 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
  21848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21850. * @param name defines the name of the mesh
  21851. * @param options defines the options used to create the mesh
  21852. * @param scene defines the hosting scene
  21853. * @returns the tube mesh
  21854. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21855. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  21856. */
  21857. static CreateTube(name: string, options: {
  21858. path: Vector3[];
  21859. radius?: number;
  21860. tessellation?: number;
  21861. radiusFunction?: {
  21862. (i: number, distance: number): number;
  21863. };
  21864. cap?: number;
  21865. arc?: number;
  21866. updatable?: boolean;
  21867. sideOrientation?: number;
  21868. frontUVs?: Vector4;
  21869. backUVs?: Vector4;
  21870. instance?: Mesh;
  21871. invertUV?: boolean;
  21872. }, scene: Scene): Mesh;
  21873. /**
  21874. * Creates a polyhedron mesh
  21875. * * 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
  21876. * * The parameter `size` (positive float, default 1) sets the polygon size
  21877. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21878. * * 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`
  21879. * * 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
  21880. * * 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)`)
  21881. * * 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
  21882. * * 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
  21883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21884. * * 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
  21885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21886. * @param name defines the name of the mesh
  21887. * @param options defines the options used to create the mesh
  21888. * @param scene defines the hosting scene
  21889. * @returns the polyhedron mesh
  21890. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  21891. */
  21892. static CreatePolyhedron(name: string, options: {
  21893. type?: number;
  21894. size?: number;
  21895. sizeX?: number;
  21896. sizeY?: number;
  21897. sizeZ?: number;
  21898. custom?: any;
  21899. faceUV?: Vector4[];
  21900. faceColors?: Color4[];
  21901. flat?: boolean;
  21902. updatable?: boolean;
  21903. sideOrientation?: number;
  21904. frontUVs?: Vector4;
  21905. backUVs?: Vector4;
  21906. }, scene: Scene): Mesh;
  21907. /**
  21908. * Creates a decal mesh.
  21909. * 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
  21910. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  21911. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  21912. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  21913. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  21914. * @param name defines the name of the mesh
  21915. * @param sourceMesh defines the mesh where the decal must be applied
  21916. * @param options defines the options used to create the mesh
  21917. * @param scene defines the hosting scene
  21918. * @returns the decal mesh
  21919. * @see http://doc.babylonjs.com/how_to/decals
  21920. */
  21921. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  21922. position?: Vector3;
  21923. normal?: Vector3;
  21924. size?: Vector3;
  21925. angle?: number;
  21926. }): Mesh;
  21927. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  21928. }
  21929. }
  21930. declare module BABYLON {
  21931. class MeshLODLevel {
  21932. distance: number;
  21933. mesh: Mesh;
  21934. constructor(distance: number, mesh: Mesh);
  21935. }
  21936. }
  21937. declare module BABYLON {
  21938. /**
  21939. * A simplifier interface for future simplification implementations.
  21940. */
  21941. interface ISimplifier {
  21942. /**
  21943. * Simplification of a given mesh according to the given settings.
  21944. * Since this requires computation, it is assumed that the function runs async.
  21945. * @param settings The settings of the simplification, including quality and distance
  21946. * @param successCallback A callback that will be called after the mesh was simplified.
  21947. * @param errorCallback in case of an error, this callback will be called. optional.
  21948. */
  21949. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  21950. }
  21951. /**
  21952. * Expected simplification settings.
  21953. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  21954. */
  21955. interface ISimplificationSettings {
  21956. quality: number;
  21957. distance: number;
  21958. optimizeMesh?: boolean;
  21959. }
  21960. class SimplificationSettings implements ISimplificationSettings {
  21961. quality: number;
  21962. distance: number;
  21963. optimizeMesh: boolean | undefined;
  21964. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  21965. }
  21966. interface ISimplificationTask {
  21967. settings: Array<ISimplificationSettings>;
  21968. simplificationType: SimplificationType;
  21969. mesh: Mesh;
  21970. successCallback?: () => void;
  21971. parallelProcessing: boolean;
  21972. }
  21973. class SimplificationQueue {
  21974. private _simplificationArray;
  21975. running: boolean;
  21976. constructor();
  21977. addTask(task: ISimplificationTask): void;
  21978. executeNext(): void;
  21979. runSimplification(task: ISimplificationTask): void;
  21980. private getSimplifier(task);
  21981. }
  21982. /**
  21983. * The implemented types of simplification
  21984. * At the moment only Quadratic Error Decimation is implemented
  21985. */
  21986. enum SimplificationType {
  21987. /** Quadratic error decimation */
  21988. QUADRATIC = 0,
  21989. }
  21990. class DecimationTriangle {
  21991. vertices: Array<DecimationVertex>;
  21992. normal: Vector3;
  21993. error: Array<number>;
  21994. deleted: boolean;
  21995. isDirty: boolean;
  21996. borderFactor: number;
  21997. deletePending: boolean;
  21998. originalOffset: number;
  21999. constructor(vertices: Array<DecimationVertex>);
  22000. }
  22001. class DecimationVertex {
  22002. position: Vector3;
  22003. id: number;
  22004. q: QuadraticMatrix;
  22005. isBorder: boolean;
  22006. triangleStart: number;
  22007. triangleCount: number;
  22008. originalOffsets: Array<number>;
  22009. constructor(position: Vector3, id: number);
  22010. updatePosition(newPosition: Vector3): void;
  22011. }
  22012. class QuadraticMatrix {
  22013. data: Array<number>;
  22014. constructor(data?: Array<number>);
  22015. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22016. addInPlace(matrix: QuadraticMatrix): void;
  22017. addArrayInPlace(data: Array<number>): void;
  22018. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22019. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22020. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22021. }
  22022. class Reference {
  22023. vertexId: number;
  22024. triangleId: number;
  22025. constructor(vertexId: number, triangleId: number);
  22026. }
  22027. /**
  22028. * An implementation of the Quadratic Error simplification algorithm.
  22029. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22030. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22031. * @author RaananW
  22032. */
  22033. class QuadraticErrorSimplification implements ISimplifier {
  22034. private _mesh;
  22035. private triangles;
  22036. private vertices;
  22037. private references;
  22038. private _reconstructedMesh;
  22039. syncIterations: number;
  22040. aggressiveness: number;
  22041. decimationIterations: number;
  22042. boundingBoxEpsilon: number;
  22043. constructor(_mesh: Mesh);
  22044. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22045. private runDecimation(settings, submeshIndex, successCallback);
  22046. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22047. private init(callback);
  22048. private reconstructMesh(submeshIndex);
  22049. private initDecimatedMesh();
  22050. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22051. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22052. private identifyBorder();
  22053. private updateMesh(identifyBorders?);
  22054. private vertexError(q, point);
  22055. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22056. }
  22057. }
  22058. declare module BABYLON {
  22059. class Polygon {
  22060. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22061. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22062. static Parse(input: string): Vector2[];
  22063. static StartingAt(x: number, y: number): Path2;
  22064. }
  22065. class PolygonMeshBuilder {
  22066. private _points;
  22067. private _outlinepoints;
  22068. private _holes;
  22069. private _name;
  22070. private _scene;
  22071. private _epoints;
  22072. private _eholes;
  22073. private _addToepoint(points);
  22074. constructor(name: string, contours: Path2, scene: Scene);
  22075. constructor(name: string, contours: Vector2[], scene: Scene);
  22076. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22077. build(updatable?: boolean, depth?: number): Mesh;
  22078. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22079. }
  22080. }
  22081. declare module BABYLON {
  22082. class BaseSubMesh {
  22083. _materialDefines: Nullable<MaterialDefines>;
  22084. _materialEffect: Nullable<Effect>;
  22085. readonly effect: Nullable<Effect>;
  22086. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22087. }
  22088. class SubMesh extends BaseSubMesh implements ICullable {
  22089. materialIndex: number;
  22090. verticesStart: number;
  22091. verticesCount: number;
  22092. indexStart: number;
  22093. indexCount: number;
  22094. linesIndexCount: number;
  22095. private _mesh;
  22096. private _renderingMesh;
  22097. private _boundingInfo;
  22098. private _linesIndexBuffer;
  22099. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22100. _trianglePlanes: Plane[];
  22101. _lastColliderTransformMatrix: Matrix;
  22102. _renderId: number;
  22103. _alphaIndex: number;
  22104. _distanceToCamera: number;
  22105. _id: number;
  22106. private _currentMaterial;
  22107. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22108. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22109. readonly IsGlobal: boolean;
  22110. /**
  22111. * Returns the submesh BoudingInfo object.
  22112. */
  22113. getBoundingInfo(): BoundingInfo;
  22114. /**
  22115. * Sets the submesh BoundingInfo.
  22116. * Return the SubMesh.
  22117. */
  22118. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22119. /**
  22120. * Returns the mesh of the current submesh.
  22121. */
  22122. getMesh(): AbstractMesh;
  22123. /**
  22124. * Returns the rendering mesh of the submesh.
  22125. */
  22126. getRenderingMesh(): Mesh;
  22127. /**
  22128. * Returns the submesh material.
  22129. */
  22130. getMaterial(): Nullable<Material>;
  22131. /**
  22132. * Sets a new updated BoundingInfo object to the submesh.
  22133. * Returns the SubMesh.
  22134. */
  22135. refreshBoundingInfo(): SubMesh;
  22136. _checkCollision(collider: Collider): boolean;
  22137. /**
  22138. * Updates the submesh BoundingInfo.
  22139. * Returns the Submesh.
  22140. */
  22141. updateBoundingInfo(world: Matrix): SubMesh;
  22142. /**
  22143. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22144. * Boolean returned.
  22145. */
  22146. isInFrustum(frustumPlanes: Plane[]): boolean;
  22147. /**
  22148. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22149. * Boolean returned.
  22150. */
  22151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22152. /**
  22153. * Renders the submesh.
  22154. * Returns it.
  22155. */
  22156. render(enableAlphaMode: boolean): SubMesh;
  22157. /**
  22158. * Returns a new Index Buffer.
  22159. * Type returned : WebGLBuffer.
  22160. */
  22161. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22162. /**
  22163. * True is the passed Ray intersects the submesh bounding box.
  22164. * Boolean returned.
  22165. */
  22166. canIntersects(ray: Ray): boolean;
  22167. /**
  22168. * Returns an object IntersectionInfo.
  22169. */
  22170. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22171. _rebuild(): void;
  22172. /**
  22173. * Creates a new Submesh from the passed Mesh.
  22174. */
  22175. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22176. /**
  22177. * Disposes the Submesh.
  22178. * Returns nothing.
  22179. */
  22180. dispose(): void;
  22181. /**
  22182. * Creates a new Submesh from the passed parameters :
  22183. * - materialIndex (integer) : the index of the main mesh material.
  22184. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22185. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22186. * - mesh (Mesh) : the main mesh to create the submesh from.
  22187. * - renderingMesh (optional Mesh) : rendering mesh.
  22188. */
  22189. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22190. }
  22191. }
  22192. declare module BABYLON {
  22193. class TransformNode extends Node {
  22194. static BILLBOARDMODE_NONE: number;
  22195. static BILLBOARDMODE_X: number;
  22196. static BILLBOARDMODE_Y: number;
  22197. static BILLBOARDMODE_Z: number;
  22198. static BILLBOARDMODE_ALL: number;
  22199. private _forward;
  22200. private _forwardInverted;
  22201. private _up;
  22202. private _right;
  22203. private _rightInverted;
  22204. private _rotation;
  22205. private _rotationQuaternion;
  22206. protected _scaling: Vector3;
  22207. protected _isDirty: boolean;
  22208. private _transformToBoneReferal;
  22209. billboardMode: number;
  22210. scalingDeterminant: number;
  22211. infiniteDistance: boolean;
  22212. position: Vector3;
  22213. _poseMatrix: Matrix;
  22214. private _localWorld;
  22215. _worldMatrix: Matrix;
  22216. _worldMatrixDeterminant: number;
  22217. private _absolutePosition;
  22218. private _pivotMatrix;
  22219. private _pivotMatrixInverse;
  22220. private _postMultiplyPivotMatrix;
  22221. protected _isWorldMatrixFrozen: boolean;
  22222. /**
  22223. * An event triggered after the world matrix is updated
  22224. */
  22225. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  22226. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  22227. /**
  22228. * Gets a string idenfifying the name of the class
  22229. * @returns "TransformNode" string
  22230. */
  22231. getClassName(): string;
  22232. /**
  22233. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  22234. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  22235. * Default : (0.0, 0.0, 0.0)
  22236. */
  22237. rotation: Vector3;
  22238. /**
  22239. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22240. * Default : (1.0, 1.0, 1.0)
  22241. */
  22242. /**
  22243. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22244. * Default : (1.0, 1.0, 1.0)
  22245. */
  22246. scaling: Vector3;
  22247. /**
  22248. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  22249. * It's null by default.
  22250. * 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)
  22251. */
  22252. rotationQuaternion: Nullable<Quaternion>;
  22253. /**
  22254. * The forward direction of that transform in world space.
  22255. */
  22256. readonly forward: Vector3;
  22257. /**
  22258. * The up direction of that transform in world space.
  22259. */
  22260. readonly up: Vector3;
  22261. /**
  22262. * The right direction of that transform in world space.
  22263. */
  22264. readonly right: Vector3;
  22265. /**
  22266. * Returns the latest update of the World matrix
  22267. * Returns a Matrix.
  22268. */
  22269. getWorldMatrix(): Matrix;
  22270. /** @hidden */
  22271. _getWorldMatrixDeterminant(): number;
  22272. /**
  22273. * Returns directly the latest state of the mesh World matrix.
  22274. * A Matrix is returned.
  22275. */
  22276. readonly worldMatrixFromCache: Matrix;
  22277. /**
  22278. * Copies the paramater passed Matrix into the mesh Pose matrix.
  22279. * Returns the TransformNode.
  22280. */
  22281. updatePoseMatrix(matrix: Matrix): TransformNode;
  22282. /**
  22283. * Returns the mesh Pose matrix.
  22284. * Returned object : Matrix
  22285. */
  22286. getPoseMatrix(): Matrix;
  22287. _isSynchronized(): boolean;
  22288. _initCache(): void;
  22289. markAsDirty(property: string): TransformNode;
  22290. /**
  22291. * Returns the current mesh absolute position.
  22292. * Retuns a Vector3.
  22293. */
  22294. readonly absolutePosition: Vector3;
  22295. /**
  22296. * Sets a new matrix to apply before all other transformation
  22297. * @param matrix defines the transform matrix
  22298. * @returns the current TransformNode
  22299. */
  22300. setPreTransformMatrix(matrix: Matrix): TransformNode;
  22301. /**
  22302. * Sets a new pivot matrix to the current node
  22303. * @param matrix defines the new pivot matrix to use
  22304. * @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
  22305. * @returns the current TransformNode
  22306. */
  22307. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  22308. /**
  22309. * Returns the mesh pivot matrix.
  22310. * Default : Identity.
  22311. * A Matrix is returned.
  22312. */
  22313. getPivotMatrix(): Matrix;
  22314. /**
  22315. * Prevents the World matrix to be computed any longer.
  22316. * Returns the TransformNode.
  22317. */
  22318. freezeWorldMatrix(): TransformNode;
  22319. /**
  22320. * Allows back the World matrix computation.
  22321. * Returns the TransformNode.
  22322. */
  22323. unfreezeWorldMatrix(): this;
  22324. /**
  22325. * True if the World matrix has been frozen.
  22326. * Returns a boolean.
  22327. */
  22328. readonly isWorldMatrixFrozen: boolean;
  22329. /**
  22330. * Retuns the mesh absolute position in the World.
  22331. * Returns a Vector3.
  22332. */
  22333. getAbsolutePosition(): Vector3;
  22334. /**
  22335. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  22336. * Returns the TransformNode.
  22337. */
  22338. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22339. /**
  22340. * Sets the mesh position in its local space.
  22341. * Returns the TransformNode.
  22342. */
  22343. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  22344. /**
  22345. * Returns the mesh position in the local space from the current World matrix values.
  22346. * Returns a new Vector3.
  22347. */
  22348. getPositionExpressedInLocalSpace(): Vector3;
  22349. /**
  22350. * Translates the mesh along the passed Vector3 in its local space.
  22351. * Returns the TransformNode.
  22352. */
  22353. locallyTranslate(vector3: Vector3): TransformNode;
  22354. private static _lookAtVectorCache;
  22355. /**
  22356. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  22357. * @param targetPoint the position (must be in same space as current mesh) to look at
  22358. * @param yawCor optional yaw (y-axis) correction in radians
  22359. * @param pitchCor optional pitch (x-axis) correction in radians
  22360. * @param rollCor optional roll (z-axis) correction in radians
  22361. * @param space the choosen space of the target
  22362. * @returns the TransformNode.
  22363. */
  22364. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  22365. /**
  22366. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  22367. * This Vector3 is expressed in the World space.
  22368. */
  22369. getDirection(localAxis: Vector3): Vector3;
  22370. /**
  22371. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  22372. * localAxis is expressed in the mesh local space.
  22373. * result is computed in the Wordl space from the mesh World matrix.
  22374. * Returns the TransformNode.
  22375. */
  22376. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  22377. /**
  22378. * Sets a new pivot point to the current node
  22379. * @param point defines the new pivot point to use
  22380. * @param space defines if the point is in world or local space (local by default)
  22381. * @returns the current TransformNode
  22382. */
  22383. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  22384. /**
  22385. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  22386. */
  22387. getPivotPoint(): Vector3;
  22388. /**
  22389. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  22390. * Returns the TransformNode.
  22391. */
  22392. getPivotPointToRef(result: Vector3): TransformNode;
  22393. /**
  22394. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  22395. */
  22396. getAbsolutePivotPoint(): Vector3;
  22397. /**
  22398. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  22399. * Returns the TransformNode.
  22400. */
  22401. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  22402. /**
  22403. * Defines the passed node as the parent of the current node.
  22404. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  22405. * Returns the TransformNode.
  22406. */
  22407. setParent(node: Nullable<Node>): TransformNode;
  22408. private _nonUniformScaling;
  22409. readonly nonUniformScaling: boolean;
  22410. _updateNonUniformScalingState(value: boolean): boolean;
  22411. /**
  22412. * Attach the current TransformNode to another TransformNode associated with a bone
  22413. * @param bone Bone affecting the TransformNode
  22414. * @param affectedTransformNode TransformNode associated with the bone
  22415. */
  22416. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  22417. detachFromBone(): TransformNode;
  22418. private static _rotationAxisCache;
  22419. /**
  22420. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  22421. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22422. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22423. * The passed axis is also normalized.
  22424. * Returns the TransformNode.
  22425. */
  22426. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22427. /**
  22428. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  22429. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22430. * The passed axis is also normalized.
  22431. * Returns the TransformNode.
  22432. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  22433. */
  22434. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  22435. /**
  22436. * Translates the mesh along the axis vector for the passed distance in the given space.
  22437. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22438. * Returns the TransformNode.
  22439. */
  22440. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22441. /**
  22442. * Adds a rotation step to the mesh current rotation.
  22443. * x, y, z are Euler angles expressed in radians.
  22444. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  22445. * This means this rotation is made in the mesh local space only.
  22446. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  22447. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  22448. * ```javascript
  22449. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  22450. * ```
  22451. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  22452. * 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.
  22453. * Returns the TransformNode.
  22454. */
  22455. addRotation(x: number, y: number, z: number): TransformNode;
  22456. /**
  22457. * Computes the mesh World matrix and returns it.
  22458. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  22459. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  22460. * If the parameter `force`is set to `true`, the actual computation is done.
  22461. * Returns the mesh World Matrix.
  22462. */
  22463. computeWorldMatrix(force?: boolean): Matrix;
  22464. protected _afterComputeWorldMatrix(): void;
  22465. /**
  22466. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  22467. * @param func: callback function to add
  22468. *
  22469. * Returns the TransformNode.
  22470. */
  22471. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22472. /**
  22473. * Removes a registered callback function.
  22474. * Returns the TransformNode.
  22475. */
  22476. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22477. /**
  22478. * Clone the current transform node
  22479. * Returns the new transform node
  22480. * @param name Name of the new clone
  22481. * @param newParent New parent for the clone
  22482. * @param doNotCloneChildren Do not clone children hierarchy
  22483. */
  22484. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  22485. serialize(currentSerializationObject?: any): any;
  22486. /**
  22487. * Returns a new TransformNode object parsed from the source provided.
  22488. * The parameter `parsedMesh` is the source.
  22489. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22490. */
  22491. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  22492. /**
  22493. * Releases resources associated with this transform node.
  22494. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22495. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22496. */
  22497. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22498. }
  22499. }
  22500. declare module BABYLON {
  22501. class VertexBuffer {
  22502. private _buffer;
  22503. private _kind;
  22504. private _size;
  22505. private _ownsBuffer;
  22506. private _instanced;
  22507. private _instanceDivisor;
  22508. /**
  22509. * The byte type.
  22510. */
  22511. static readonly BYTE: number;
  22512. /**
  22513. * The unsigned byte type.
  22514. */
  22515. static readonly UNSIGNED_BYTE: number;
  22516. /**
  22517. * The short type.
  22518. */
  22519. static readonly SHORT: number;
  22520. /**
  22521. * The unsigned short type.
  22522. */
  22523. static readonly UNSIGNED_SHORT: number;
  22524. /**
  22525. * The integer type.
  22526. */
  22527. static readonly INT: number;
  22528. /**
  22529. * The unsigned integer type.
  22530. */
  22531. static readonly UNSIGNED_INT: number;
  22532. /**
  22533. * The float type.
  22534. */
  22535. static readonly FLOAT: number;
  22536. /**
  22537. * Gets or sets the instance divisor when in instanced mode
  22538. */
  22539. instanceDivisor: number;
  22540. /**
  22541. * Gets the byte stride.
  22542. */
  22543. readonly byteStride: number;
  22544. /**
  22545. * Gets the byte offset.
  22546. */
  22547. readonly byteOffset: number;
  22548. /**
  22549. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  22550. */
  22551. readonly normalized: boolean;
  22552. /**
  22553. * Gets the data type of each component in the array.
  22554. */
  22555. readonly type: number;
  22556. /**
  22557. * Constructor
  22558. * @param engine the engine
  22559. * @param data the data to use for this vertex buffer
  22560. * @param kind the vertex buffer kind
  22561. * @param updatable whether the data is updatable
  22562. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  22563. * @param stride the stride (optional)
  22564. * @param instanced whether the buffer is instanced (optional)
  22565. * @param offset the offset of the data (optional)
  22566. * @param size the number of components (optional)
  22567. * @param type the type of the component (optional)
  22568. * @param normalized whether the data contains normalized data (optional)
  22569. * @param useBytes set to true if stride and offset are in bytes (optional)
  22570. */
  22571. 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);
  22572. _rebuild(): void;
  22573. /**
  22574. * Returns the kind of the VertexBuffer (string).
  22575. */
  22576. getKind(): string;
  22577. /**
  22578. * Boolean : is the VertexBuffer updatable ?
  22579. */
  22580. isUpdatable(): boolean;
  22581. /**
  22582. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  22583. */
  22584. getData(): Nullable<DataArray>;
  22585. /**
  22586. * Returns the WebGLBuffer associated to the VertexBuffer.
  22587. */
  22588. getBuffer(): Nullable<WebGLBuffer>;
  22589. /**
  22590. * Returns the stride as a multiple of the type byte length.
  22591. * DEPRECATED. Use byteStride instead.
  22592. */
  22593. getStrideSize(): number;
  22594. /**
  22595. * Returns the offset as a multiple of the type byte length.
  22596. * DEPRECATED. Use byteOffset instead.
  22597. */
  22598. getOffset(): number;
  22599. /**
  22600. * Returns the number of components per vertex attribute (integer).
  22601. */
  22602. getSize(): number;
  22603. /**
  22604. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  22605. */
  22606. getIsInstanced(): boolean;
  22607. /**
  22608. * Returns the instancing divisor, zero for non-instanced (integer).
  22609. */
  22610. getInstanceDivisor(): number;
  22611. /**
  22612. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  22613. * Returns the created WebGLBuffer.
  22614. */
  22615. create(data?: DataArray): void;
  22616. /**
  22617. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22618. * This function will create a new buffer if the current one is not updatable
  22619. * Returns the updated WebGLBuffer.
  22620. */
  22621. update(data: DataArray): void;
  22622. /**
  22623. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22624. * Returns the directly updated WebGLBuffer.
  22625. * @param data the new data
  22626. * @param offset the new offset
  22627. * @param useBytes set to true if the offset is in bytes
  22628. */
  22629. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  22630. /**
  22631. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  22632. */
  22633. dispose(): void;
  22634. /**
  22635. * Enumerates each value of this vertex buffer as numbers.
  22636. * @param count the number of values to enumerate
  22637. * @param callback the callback function called for each value
  22638. */
  22639. forEach(count: number, callback: (value: number, index: number) => void): void;
  22640. private static _PositionKind;
  22641. private static _NormalKind;
  22642. private static _TangentKind;
  22643. private static _UVKind;
  22644. private static _UV2Kind;
  22645. private static _UV3Kind;
  22646. private static _UV4Kind;
  22647. private static _UV5Kind;
  22648. private static _UV6Kind;
  22649. private static _ColorKind;
  22650. private static _MatricesIndicesKind;
  22651. private static _MatricesWeightsKind;
  22652. private static _MatricesIndicesExtraKind;
  22653. private static _MatricesWeightsExtraKind;
  22654. static readonly PositionKind: string;
  22655. static readonly NormalKind: string;
  22656. static readonly TangentKind: string;
  22657. static readonly UVKind: string;
  22658. static readonly UV2Kind: string;
  22659. static readonly UV3Kind: string;
  22660. static readonly UV4Kind: string;
  22661. static readonly UV5Kind: string;
  22662. static readonly UV6Kind: string;
  22663. static readonly ColorKind: string;
  22664. static readonly MatricesIndicesKind: string;
  22665. static readonly MatricesWeightsKind: string;
  22666. static readonly MatricesIndicesExtraKind: string;
  22667. static readonly MatricesWeightsExtraKind: string;
  22668. /**
  22669. * Deduces the stride given a kind.
  22670. * @param kind The kind string to deduce
  22671. * @returns The deduced stride
  22672. */
  22673. static DeduceStride(kind: string): number;
  22674. /**
  22675. * Gets the byte length of the given type.
  22676. * @param type the type
  22677. * @returns the number of bytes
  22678. */
  22679. static GetTypeByteLength(type: number): number;
  22680. /**
  22681. * Enumerates each value of the given parameters as numbers.
  22682. * @param data the data to enumerate
  22683. * @param byteOffset the byte offset of the data
  22684. * @param byteStride the byte stride of the data
  22685. * @param componentCount the number of components per element
  22686. * @param componentType the type of the component
  22687. * @param count the total number of components
  22688. * @param normalized whether the data is normalized
  22689. * @param callback the callback function called for each value
  22690. */
  22691. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  22692. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  22693. }
  22694. }
  22695. declare module BABYLON {
  22696. /**
  22697. * This represents a GPU particle system in Babylon
  22698. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  22699. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  22700. */
  22701. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  22702. /**
  22703. * The id of the Particle system.
  22704. */
  22705. id: string;
  22706. /**
  22707. * The friendly name of the Particle system.
  22708. */
  22709. name: string;
  22710. /**
  22711. * The emitter represents the Mesh or position we are attaching the particle system to.
  22712. */
  22713. emitter: Nullable<AbstractMesh | Vector3>;
  22714. /**
  22715. * The rendering group used by the Particle system to chose when to render.
  22716. */
  22717. renderingGroupId: number;
  22718. /**
  22719. * The layer mask we are rendering the particles through.
  22720. */
  22721. layerMask: number;
  22722. private _capacity;
  22723. private _activeCount;
  22724. private _currentActiveCount;
  22725. private _renderEffect;
  22726. private _updateEffect;
  22727. private _buffer0;
  22728. private _buffer1;
  22729. private _spriteBuffer;
  22730. private _updateVAO;
  22731. private _renderVAO;
  22732. private _targetIndex;
  22733. private _sourceBuffer;
  22734. private _targetBuffer;
  22735. private _scene;
  22736. private _engine;
  22737. private _currentRenderId;
  22738. private _started;
  22739. private _stopped;
  22740. private _timeDelta;
  22741. private _randomTexture;
  22742. private readonly _attributesStrideSize;
  22743. private _updateEffectOptions;
  22744. private _randomTextureSize;
  22745. private _actualFrame;
  22746. /**
  22747. * List of animations used by the particle system.
  22748. */
  22749. animations: Animation[];
  22750. /**
  22751. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  22752. */
  22753. static readonly IsSupported: boolean;
  22754. /**
  22755. * An event triggered when the system is disposed.
  22756. */
  22757. onDisposeObservable: Observable<GPUParticleSystem>;
  22758. /**
  22759. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22760. */
  22761. updateSpeed: number;
  22762. /**
  22763. * The amount of time the particle system is running (depends of the overall update speed).
  22764. */
  22765. targetStopDuration: number;
  22766. /**
  22767. * The texture used to render each particle. (this can be a spritesheet)
  22768. */
  22769. particleTexture: Nullable<Texture>;
  22770. /**
  22771. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  22772. */
  22773. blendMode: number;
  22774. /**
  22775. * Minimum life time of emitting particles.
  22776. */
  22777. minLifeTime: number;
  22778. /**
  22779. * Maximum life time of emitting particles.
  22780. */
  22781. maxLifeTime: number;
  22782. /**
  22783. * Minimum Size of emitting particles.
  22784. */
  22785. minSize: number;
  22786. /**
  22787. * Maximum Size of emitting particles.
  22788. */
  22789. maxSize: number;
  22790. /**
  22791. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22792. */
  22793. color1: Color4;
  22794. /**
  22795. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22796. */
  22797. color2: Color4;
  22798. /**
  22799. * Color the particle will have at the end of its lifetime.
  22800. */
  22801. colorDead: Color4;
  22802. /**
  22803. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  22804. */
  22805. emitRate: number;
  22806. /**
  22807. * You can use gravity if you want to give an orientation to your particles.
  22808. */
  22809. gravity: Vector3;
  22810. /**
  22811. * Minimum power of emitting particles.
  22812. */
  22813. minEmitPower: number;
  22814. /**
  22815. * Maximum power of emitting particles.
  22816. */
  22817. maxEmitPower: number;
  22818. /**
  22819. * The particle emitter type defines the emitter used by the particle system.
  22820. * It can be for example box, sphere, or cone...
  22821. */
  22822. particleEmitterType: Nullable<IParticleEmitterType>;
  22823. /**
  22824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22825. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22826. */
  22827. direction1: Vector3;
  22828. /**
  22829. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22830. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22831. */
  22832. direction2: Vector3;
  22833. /**
  22834. * 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.
  22835. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22836. */
  22837. minEmitBox: Vector3;
  22838. /**
  22839. * 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.
  22840. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22841. */
  22842. maxEmitBox: Vector3;
  22843. /**
  22844. * Gets the maximum number of particles active at the same time.
  22845. * @returns The max number of active particles.
  22846. */
  22847. getCapacity(): number;
  22848. /**
  22849. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  22850. * to override the particles.
  22851. */
  22852. forceDepthWrite: boolean;
  22853. /**
  22854. * Gets or set the number of active particles
  22855. */
  22856. activeParticleCount: number;
  22857. /**
  22858. * Is this system ready to be used/rendered
  22859. * @return true if the system is ready
  22860. */
  22861. isReady(): boolean;
  22862. /**
  22863. * Gets Wether the system has been started.
  22864. * @returns True if it has been started, otherwise false.
  22865. */
  22866. isStarted(): boolean;
  22867. /**
  22868. * Starts the particle system and begins to emit.
  22869. */
  22870. start(): void;
  22871. /**
  22872. * Stops the particle system.
  22873. */
  22874. stop(): void;
  22875. /**
  22876. * Remove all active particles
  22877. */
  22878. reset(): void;
  22879. /**
  22880. * Returns the string "GPUParticleSystem"
  22881. * @returns a string containing the class name
  22882. */
  22883. getClassName(): string;
  22884. /**
  22885. * Instantiates a GPU particle system.
  22886. * 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.
  22887. * @param name The name of the particle system
  22888. * @param capacity The max number of particles alive at the same time
  22889. * @param scene The scene the particle system belongs to
  22890. */
  22891. constructor(name: string, options: Partial<{
  22892. capacity: number;
  22893. randomTextureSize: number;
  22894. }>, scene: Scene);
  22895. private _createUpdateVAO(source);
  22896. private _createRenderVAO(source, spriteSource);
  22897. private _initialize(force?);
  22898. /** @hidden */
  22899. _recreateUpdateEffect(): void;
  22900. /** @hidden */
  22901. _recreateRenderEffect(): void;
  22902. /**
  22903. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  22904. */
  22905. animate(): void;
  22906. /**
  22907. * Renders the particle system in its current state.
  22908. * @returns the current number of particles
  22909. */
  22910. render(): number;
  22911. /**
  22912. * Rebuilds the particle system
  22913. */
  22914. rebuild(): void;
  22915. private _releaseBuffers();
  22916. private _releaseVAOs();
  22917. /**
  22918. * Disposes the particle system and free the associated resources
  22919. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  22920. */
  22921. dispose(disposeTexture?: boolean): void;
  22922. /**
  22923. * Clones the particle system.
  22924. * @param name The name of the cloned object
  22925. * @param newEmitter The new emitter to use
  22926. * @returns the cloned particle system
  22927. */
  22928. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  22929. /**
  22930. * Serializes the particle system to a JSON object.
  22931. * @returns the JSON object
  22932. */
  22933. serialize(): any;
  22934. /**
  22935. * Parses a JSON object to create a GPU particle system.
  22936. * @param parsedParticleSystem The JSON object to parse
  22937. * @param scene The scene to create the particle system in
  22938. * @param rootUrl The root url to use to load external dependencies like texture
  22939. * @returns the parsed GPU particle system
  22940. */
  22941. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  22942. }
  22943. }
  22944. declare module BABYLON {
  22945. /**
  22946. * Interface representing a particle system in Babylon.
  22947. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  22948. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  22949. */
  22950. interface IParticleSystem {
  22951. /**
  22952. * The id of the Particle system.
  22953. */
  22954. id: string;
  22955. /**
  22956. * The name of the Particle system.
  22957. */
  22958. name: string;
  22959. /**
  22960. * The emitter represents the Mesh or position we are attaching the particle system to.
  22961. */
  22962. emitter: Nullable<AbstractMesh | Vector3>;
  22963. /**
  22964. * The rendering group used by the Particle system to chose when to render.
  22965. */
  22966. renderingGroupId: number;
  22967. /**
  22968. * The layer mask we are rendering the particles through.
  22969. */
  22970. layerMask: number;
  22971. /**
  22972. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22973. */
  22974. updateSpeed: number;
  22975. /**
  22976. * The amount of time the particle system is running (depends of the overall update speed).
  22977. */
  22978. targetStopDuration: number;
  22979. /**
  22980. * The texture used to render each particle. (this can be a spritesheet)
  22981. */
  22982. particleTexture: Nullable<Texture>;
  22983. /**
  22984. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  22985. */
  22986. blendMode: number;
  22987. /**
  22988. * Minimum life time of emitting particles.
  22989. */
  22990. minLifeTime: number;
  22991. /**
  22992. * Maximum life time of emitting particles.
  22993. */
  22994. maxLifeTime: number;
  22995. /**
  22996. * Minimum Size of emitting particles.
  22997. */
  22998. minSize: number;
  22999. /**
  23000. * Maximum Size of emitting particles.
  23001. */
  23002. maxSize: number;
  23003. /**
  23004. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23005. */
  23006. color1: Color4;
  23007. /**
  23008. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23009. */
  23010. color2: Color4;
  23011. /**
  23012. * Color the particle will have at the end of its lifetime.
  23013. */
  23014. colorDead: Color4;
  23015. /**
  23016. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23017. */
  23018. emitRate: number;
  23019. /**
  23020. * You can use gravity if you want to give an orientation to your particles.
  23021. */
  23022. gravity: Vector3;
  23023. /**
  23024. * Minimum power of emitting particles.
  23025. */
  23026. minEmitPower: number;
  23027. /**
  23028. * Maximum power of emitting particles.
  23029. */
  23030. maxEmitPower: number;
  23031. /**
  23032. * The particle emitter type defines the emitter used by the particle system.
  23033. * It can be for example box, sphere, or cone...
  23034. */
  23035. particleEmitterType: Nullable<IParticleEmitterType>;
  23036. /**
  23037. * Gets the maximum number of particles active at the same time.
  23038. * @returns The max number of active particles.
  23039. */
  23040. getCapacity(): number;
  23041. /**
  23042. * Gets Wether the system has been started.
  23043. * @returns True if it has been started, otherwise false.
  23044. */
  23045. isStarted(): boolean;
  23046. /**
  23047. * Gets if the particle system has been started.
  23048. * @return true if the system has been started, otherwise false.
  23049. */
  23050. isStarted(): boolean;
  23051. /**
  23052. * Animates the particle system for this frame.
  23053. */
  23054. animate(): void;
  23055. /**
  23056. * Renders the particle system in its current state.
  23057. * @returns the current number of particles
  23058. */
  23059. render(): number;
  23060. /**
  23061. * Dispose the particle system and frees its associated resources.
  23062. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23063. */
  23064. dispose(disposeTexture?: boolean): void;
  23065. /**
  23066. * Clones the particle system.
  23067. * @param name The name of the cloned object
  23068. * @param newEmitter The new emitter to use
  23069. * @returns the cloned particle system
  23070. */
  23071. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  23072. /**
  23073. * Serializes the particle system to a JSON object.
  23074. * @returns the JSON object
  23075. */
  23076. serialize(): any;
  23077. /**
  23078. * Rebuild the particle system
  23079. */
  23080. rebuild(): void;
  23081. /**
  23082. * Starts the particle system and begins to emit.
  23083. */
  23084. start(): void;
  23085. /**
  23086. * Stops the particle system.
  23087. */
  23088. stop(): void;
  23089. /**
  23090. * Remove all active particles
  23091. */
  23092. reset(): void;
  23093. /**
  23094. * Is this system ready to be used/rendered
  23095. * @return true if the system is ready
  23096. */
  23097. isReady(): boolean;
  23098. }
  23099. }
  23100. declare module BABYLON {
  23101. /**
  23102. * A particle represents one of the element emitted by a particle system.
  23103. * This is mainly define by its coordinates, direction, velocity and age.
  23104. */
  23105. class Particle {
  23106. /**
  23107. * particleSystem the particle system the particle belongs to.
  23108. */
  23109. particleSystem: ParticleSystem;
  23110. /**
  23111. * The world position of the particle in the scene.
  23112. */
  23113. position: Vector3;
  23114. /**
  23115. * The world direction of the particle in the scene.
  23116. */
  23117. direction: Vector3;
  23118. /**
  23119. * The color of the particle.
  23120. */
  23121. color: Color4;
  23122. /**
  23123. * The color change of the particle per step.
  23124. */
  23125. colorStep: Color4;
  23126. /**
  23127. * Defines how long will the life of the particle be.
  23128. */
  23129. lifeTime: number;
  23130. /**
  23131. * The current age of the particle.
  23132. */
  23133. age: number;
  23134. /**
  23135. * The current size of the particle.
  23136. */
  23137. size: number;
  23138. /**
  23139. * The current angle of the particle.
  23140. */
  23141. angle: number;
  23142. /**
  23143. * Defines how fast is the angle changing.
  23144. */
  23145. angularSpeed: number;
  23146. /**
  23147. * Defines the cell index used by the particle to be rendered from a sprite.
  23148. */
  23149. cellIndex: number;
  23150. private _currentFrameCounter;
  23151. /**
  23152. * Creates a new instance Particle
  23153. * @param particleSystem the particle system the particle belongs to
  23154. */
  23155. constructor(
  23156. /**
  23157. * particleSystem the particle system the particle belongs to.
  23158. */
  23159. particleSystem: ParticleSystem);
  23160. private updateCellInfoFromSystem();
  23161. /**
  23162. * Defines how the sprite cell index is updated for the particle. This is
  23163. * defined as a callback.
  23164. */
  23165. updateCellIndex: (scaledUpdateSpeed: number) => void;
  23166. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  23167. private _updateCellIndexWithCustomSpeed();
  23168. /**
  23169. * Copy the properties of particle to another one.
  23170. * @param other the particle to copy the information to.
  23171. */
  23172. copyTo(other: Particle): void;
  23173. }
  23174. }
  23175. declare module BABYLON {
  23176. /**
  23177. * This represents a particle system in Babylon.
  23178. * 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.
  23179. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  23180. * @example https://doc.babylonjs.com/babylon101/particles
  23181. */
  23182. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  23183. /**
  23184. * Source color is added to the destination color without alpha affecting the result.
  23185. */
  23186. static BLENDMODE_ONEONE: number;
  23187. /**
  23188. * Blend current color and particle color using particle’s alpha.
  23189. */
  23190. static BLENDMODE_STANDARD: number;
  23191. /**
  23192. * List of animations used by the particle system.
  23193. */
  23194. animations: Animation[];
  23195. /**
  23196. * The id of the Particle system.
  23197. */
  23198. id: string;
  23199. /**
  23200. * The friendly name of the Particle system.
  23201. */
  23202. name: string;
  23203. /**
  23204. * The rendering group used by the Particle system to chose when to render.
  23205. */
  23206. renderingGroupId: number;
  23207. /**
  23208. * The emitter represents the Mesh or position we are attaching the particle system to.
  23209. */
  23210. emitter: Nullable<AbstractMesh | Vector3>;
  23211. /**
  23212. * The maximum number of particles to emit per frame
  23213. */
  23214. emitRate: number;
  23215. /**
  23216. * If you want to launch only a few particles at once, that can be done, as well.
  23217. */
  23218. manualEmitCount: number;
  23219. /**
  23220. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23221. */
  23222. updateSpeed: number;
  23223. /**
  23224. * The amount of time the particle system is running (depends of the overall update speed).
  23225. */
  23226. targetStopDuration: number;
  23227. /**
  23228. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  23229. */
  23230. disposeOnStop: boolean;
  23231. /**
  23232. * Minimum power of emitting particles.
  23233. */
  23234. minEmitPower: number;
  23235. /**
  23236. * Maximum power of emitting particles.
  23237. */
  23238. maxEmitPower: number;
  23239. /**
  23240. * Minimum life time of emitting particles.
  23241. */
  23242. minLifeTime: number;
  23243. /**
  23244. * Maximum life time of emitting particles.
  23245. */
  23246. maxLifeTime: number;
  23247. /**
  23248. * Minimum Size of emitting particles.
  23249. */
  23250. minSize: number;
  23251. /**
  23252. * Maximum Size of emitting particles.
  23253. */
  23254. maxSize: number;
  23255. /**
  23256. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23257. */
  23258. minAngularSpeed: number;
  23259. /**
  23260. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23261. */
  23262. maxAngularSpeed: number;
  23263. /**
  23264. * The texture used to render each particle. (this can be a spritesheet)
  23265. */
  23266. particleTexture: Nullable<Texture>;
  23267. /**
  23268. * The layer mask we are rendering the particles through.
  23269. */
  23270. layerMask: number;
  23271. /**
  23272. * This can help using your own shader to render the particle system.
  23273. * The according effect will be created
  23274. */
  23275. customShader: any;
  23276. /**
  23277. * By default particle system starts as soon as they are created. This prevents the
  23278. * automatic start to happen and let you decide when to start emitting particles.
  23279. */
  23280. preventAutoStart: boolean;
  23281. /**
  23282. * This function can be defined to provide custom update for active particles.
  23283. * This function will be called instead of regular update (age, position, color, etc.).
  23284. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  23285. */
  23286. updateFunction: (particles: Particle[]) => void;
  23287. /**
  23288. * Callback triggered when the particle animation is ending.
  23289. */
  23290. onAnimationEnd: Nullable<() => void>;
  23291. /**
  23292. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23293. */
  23294. blendMode: number;
  23295. /**
  23296. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23297. * to override the particles.
  23298. */
  23299. forceDepthWrite: boolean;
  23300. /**
  23301. * You can use gravity if you want to give an orientation to your particles.
  23302. */
  23303. gravity: Vector3;
  23304. /**
  23305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23306. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23307. */
  23308. direction1: Vector3;
  23309. /**
  23310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23311. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23312. */
  23313. direction2: Vector3;
  23314. /**
  23315. * 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.
  23316. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23317. */
  23318. minEmitBox: Vector3;
  23319. /**
  23320. * 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.
  23321. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23322. */
  23323. maxEmitBox: Vector3;
  23324. /**
  23325. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23326. */
  23327. color1: Color4;
  23328. /**
  23329. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23330. */
  23331. color2: Color4;
  23332. /**
  23333. * Color the particle will have at the end of its lifetime.
  23334. */
  23335. colorDead: Color4;
  23336. /**
  23337. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  23338. */
  23339. textureMask: Color4;
  23340. /**
  23341. * The particle emitter type defines the emitter used by the particle system.
  23342. * It can be for example box, sphere, or cone...
  23343. */
  23344. particleEmitterType: IParticleEmitterType;
  23345. /**
  23346. * This function can be defined to specify initial direction for every new particle.
  23347. * It by default use the emitterType defined function.
  23348. */
  23349. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  23350. /**
  23351. * This function can be defined to specify initial position for every new particle.
  23352. * It by default use the emitterType defined function.
  23353. */
  23354. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  23355. /**
  23356. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  23357. */
  23358. spriteCellLoop: boolean;
  23359. /**
  23360. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  23361. */
  23362. spriteCellChangeSpeed: number;
  23363. /**
  23364. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  23365. */
  23366. startSpriteCellID: number;
  23367. /**
  23368. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  23369. */
  23370. endSpriteCellID: number;
  23371. /**
  23372. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  23373. */
  23374. spriteCellWidth: number;
  23375. /**
  23376. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  23377. */
  23378. spriteCellHeight: number;
  23379. /**
  23380. * An event triggered when the system is disposed.
  23381. */
  23382. onDisposeObservable: Observable<ParticleSystem>;
  23383. private _onDisposeObserver;
  23384. /**
  23385. * Sets a callback that will be triggered when the system is disposed.
  23386. */
  23387. onDispose: () => void;
  23388. /**
  23389. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  23390. */
  23391. readonly isAnimationSheetEnabled: Boolean;
  23392. private _particles;
  23393. private _epsilon;
  23394. private _capacity;
  23395. private _scene;
  23396. private _stockParticles;
  23397. private _newPartsExcess;
  23398. private _vertexData;
  23399. private _vertexBuffer;
  23400. private _vertexBuffers;
  23401. private _indexBuffer;
  23402. private _effect;
  23403. private _customEffect;
  23404. private _cachedDefines;
  23405. private _scaledColorStep;
  23406. private _colorDiff;
  23407. private _scaledDirection;
  23408. private _scaledGravity;
  23409. private _currentRenderId;
  23410. private _alive;
  23411. private _started;
  23412. private _stopped;
  23413. private _actualFrame;
  23414. private _scaledUpdateSpeed;
  23415. private _vertexBufferSize;
  23416. private _isAnimationSheetEnabled;
  23417. /**
  23418. * 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.
  23419. */
  23420. subEmitters: ParticleSystem[];
  23421. /**
  23422. * The current active Sub-systems, this property is used by the root particle system only.
  23423. */
  23424. activeSubSystems: Array<ParticleSystem>;
  23425. private _rootParticleSystem;
  23426. /**
  23427. * Gets the current list of active particles
  23428. */
  23429. readonly particles: Particle[];
  23430. /**
  23431. * Returns the string "ParticleSystem"
  23432. * @returns a string containing the class name
  23433. */
  23434. getClassName(): string;
  23435. /**
  23436. * Instantiates a particle system.
  23437. * 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.
  23438. * @param name The name of the particle system
  23439. * @param capacity The max number of particles alive at the same time
  23440. * @param scene The scene the particle system belongs to
  23441. * @param customEffect a custom effect used to change the way particles are rendered by default
  23442. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  23443. * @param epsilon Offset used to render the particles
  23444. */
  23445. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  23446. private _createIndexBuffer();
  23447. /**
  23448. * Gets the maximum number of particles active at the same time.
  23449. * @returns The max number of active particles.
  23450. */
  23451. getCapacity(): number;
  23452. /**
  23453. * Gets Wether there are still active particles in the system.
  23454. * @returns True if it is alive, otherwise false.
  23455. */
  23456. isAlive(): boolean;
  23457. /**
  23458. * Gets Wether the system has been started.
  23459. * @returns True if it has been started, otherwise false.
  23460. */
  23461. isStarted(): boolean;
  23462. /**
  23463. * Starts the particle system and begins to emit.
  23464. */
  23465. start(): void;
  23466. /**
  23467. * Stops the particle system.
  23468. * @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.
  23469. */
  23470. stop(stopSubEmitters?: boolean): void;
  23471. /**
  23472. * Remove all active particles
  23473. */
  23474. reset(): void;
  23475. /**
  23476. * @hidden (for internal use only)
  23477. */
  23478. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23479. /**
  23480. * @hidden (for internal use only)
  23481. */
  23482. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23483. /**
  23484. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  23485. * Its lifetime will start back at 0.
  23486. */
  23487. recycleParticle: (particle: Particle) => void;
  23488. private _stopSubEmitters();
  23489. private _createParticle;
  23490. private _removeFromRoot();
  23491. private _emitFromParticle;
  23492. private _update(newParticles);
  23493. private _getEffect();
  23494. /**
  23495. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23496. */
  23497. animate(): void;
  23498. private _appendParticleVertexes;
  23499. private _appenedParticleVertexesWithSheet(offset, particle);
  23500. private _appenedParticleVertexesNoSheet(offset, particle);
  23501. /**
  23502. * Rebuilds the particle system.
  23503. */
  23504. rebuild(): void;
  23505. /**
  23506. * Is this system ready to be used/rendered
  23507. * @return true if the system is ready
  23508. */
  23509. isReady(): boolean;
  23510. /**
  23511. * Renders the particle system in its current state.
  23512. * @returns the current number of particles
  23513. */
  23514. render(): number;
  23515. /**
  23516. * Disposes the particle system and free the associated resources
  23517. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23518. */
  23519. dispose(disposeTexture?: boolean): void;
  23520. /**
  23521. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  23522. * @param radius The radius of the sphere to emit from
  23523. * @returns the emitter
  23524. */
  23525. createSphereEmitter(radius?: number): SphereParticleEmitter;
  23526. /**
  23527. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  23528. * @param radius The radius of the sphere to emit from
  23529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  23530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  23531. * @returns the emitter
  23532. */
  23533. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  23534. /**
  23535. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  23536. * @param radius The radius of the cone to emit from
  23537. * @param angle The base angle of the cone
  23538. * @returns the emitter
  23539. */
  23540. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  23541. /**
  23542. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  23543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  23544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  23545. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23546. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23547. * @returns the emitter
  23548. */
  23549. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  23550. /**
  23551. * Clones the particle system.
  23552. * @param name The name of the cloned object
  23553. * @param newEmitter The new emitter to use
  23554. * @returns the cloned particle system
  23555. */
  23556. clone(name: string, newEmitter: any): ParticleSystem;
  23557. /**
  23558. * Serializes the particle system to a JSON object.
  23559. * @returns the JSON object
  23560. */
  23561. serialize(): any;
  23562. /**
  23563. * Parses a JSON object to create a particle system.
  23564. * @param parsedParticleSystem The JSON object to parse
  23565. * @param scene The scene to create the particle system in
  23566. * @param rootUrl The root url to use to load external dependencies like texture
  23567. * @returns the Parsed particle system
  23568. */
  23569. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  23570. }
  23571. }
  23572. declare module BABYLON {
  23573. /**
  23574. * Represents one particle of a solid particle system.
  23575. */
  23576. class SolidParticle {
  23577. /**
  23578. * particle global index
  23579. */
  23580. idx: number;
  23581. /**
  23582. * The color of the particle
  23583. */
  23584. color: Nullable<Color4>;
  23585. /**
  23586. * The world space position of the particle.
  23587. */
  23588. position: Vector3;
  23589. /**
  23590. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23591. */
  23592. rotation: Vector3;
  23593. /**
  23594. * The world space rotation quaternion of the particle.
  23595. */
  23596. rotationQuaternion: Nullable<Quaternion>;
  23597. /**
  23598. * The scaling of the particle.
  23599. */
  23600. scaling: Vector3;
  23601. /**
  23602. * The uvs of the particle.
  23603. */
  23604. uvs: Vector4;
  23605. /**
  23606. * The current speed of the particle.
  23607. */
  23608. velocity: Vector3;
  23609. /**
  23610. * The pivot point in the particle local space.
  23611. */
  23612. pivot: Vector3;
  23613. /**
  23614. * Must the particle be translated from its pivot point in its local space ?
  23615. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23616. * Default : false
  23617. */
  23618. translateFromPivot: boolean;
  23619. /**
  23620. * Is the particle active or not ?
  23621. */
  23622. alive: boolean;
  23623. /**
  23624. * Is the particle visible or not ?
  23625. */
  23626. isVisible: boolean;
  23627. /**
  23628. * Index of this particle in the global "positions" array (Internal use)
  23629. */
  23630. _pos: number;
  23631. /**
  23632. * Index of this particle in the global "indices" array (Internal use)
  23633. */
  23634. _ind: number;
  23635. /**
  23636. * ModelShape of this particle (Internal use)
  23637. */
  23638. _model: ModelShape;
  23639. /**
  23640. * ModelShape id of this particle
  23641. */
  23642. shapeId: number;
  23643. /**
  23644. * Index of the particle in its shape id (Internal use)
  23645. */
  23646. idxInShape: number;
  23647. /**
  23648. * Reference to the shape model BoundingInfo object (Internal use)
  23649. */
  23650. _modelBoundingInfo: BoundingInfo;
  23651. /**
  23652. * Particle BoundingInfo object (Internal use)
  23653. */
  23654. _boundingInfo: BoundingInfo;
  23655. /**
  23656. * Reference to the SPS what the particle belongs to (Internal use)
  23657. */
  23658. _sps: SolidParticleSystem;
  23659. /**
  23660. * Still set as invisible in order to skip useless computations (Internal use)
  23661. */
  23662. _stillInvisible: boolean;
  23663. /**
  23664. * Last computed particle rotation matrix
  23665. */
  23666. _rotationMatrix: number[];
  23667. /**
  23668. * Parent particle Id, if any.
  23669. * Default null.
  23670. */
  23671. parentId: Nullable<number>;
  23672. /**
  23673. * Internal global position in the SPS.
  23674. */
  23675. _globalPosition: Vector3;
  23676. /**
  23677. * Creates a Solid Particle object.
  23678. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23679. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23680. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23681. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23682. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23683. * @param shapeId (integer) is the model shape identifier in the SPS.
  23684. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23685. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23686. */
  23687. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23688. /**
  23689. * Legacy support, changed scale to scaling
  23690. */
  23691. /**
  23692. * Legacy support, changed scale to scaling
  23693. */
  23694. scale: Vector3;
  23695. /**
  23696. * Legacy support, changed quaternion to rotationQuaternion
  23697. */
  23698. /**
  23699. * Legacy support, changed quaternion to rotationQuaternion
  23700. */
  23701. quaternion: Nullable<Quaternion>;
  23702. /**
  23703. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23704. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23705. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23706. * @returns true if it intersects
  23707. */
  23708. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23709. }
  23710. /**
  23711. * Represents the shape of the model used by one particle of a solid particle system.
  23712. * SPS internal tool, don't use it manually.
  23713. */
  23714. class ModelShape {
  23715. /**
  23716. * The shape id.
  23717. */
  23718. shapeID: number;
  23719. /**
  23720. * flat array of model positions (internal use)
  23721. */
  23722. _shape: Vector3[];
  23723. /**
  23724. * flat array of model UVs (internal use)
  23725. */
  23726. _shapeUV: number[];
  23727. /**
  23728. * length of the shape in the model indices array (internal use)
  23729. */
  23730. _indicesLength: number;
  23731. /**
  23732. * Custom position function (internal use)
  23733. */
  23734. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23735. /**
  23736. * Custom vertex function (internal use)
  23737. */
  23738. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23739. /**
  23740. * 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.
  23741. * SPS internal tool, don't use it manually.
  23742. * @hidden
  23743. */
  23744. 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>);
  23745. }
  23746. /**
  23747. * Represents a Depth Sorted Particle in the solid particle system.
  23748. */
  23749. class DepthSortedParticle {
  23750. /**
  23751. * Index of the particle in the "indices" array
  23752. */
  23753. ind: number;
  23754. /**
  23755. * Length of the particle shape in the "indices" array
  23756. */
  23757. indicesLength: number;
  23758. /**
  23759. * Squared distance from the particle to the camera
  23760. */
  23761. sqDistance: number;
  23762. }
  23763. }
  23764. declare module BABYLON {
  23765. /**
  23766. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23767. *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.
  23768. * The SPS is also a particle system. It provides some methods to manage the particles.
  23769. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23770. *
  23771. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23772. */
  23773. class SolidParticleSystem implements IDisposable {
  23774. /**
  23775. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23776. * Example : var p = SPS.particles[i];
  23777. */
  23778. particles: SolidParticle[];
  23779. /**
  23780. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23781. */
  23782. nbParticles: number;
  23783. /**
  23784. * If the particles must ever face the camera (default false). Useful for planar particles.
  23785. */
  23786. billboard: boolean;
  23787. /**
  23788. * Recompute normals when adding a shape
  23789. */
  23790. recomputeNormals: boolean;
  23791. /**
  23792. * This a counter ofr your own usage. It's not set by any SPS functions.
  23793. */
  23794. counter: number;
  23795. /**
  23796. * The SPS name. This name is also given to the underlying mesh.
  23797. */
  23798. name: string;
  23799. /**
  23800. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23801. */
  23802. mesh: Mesh;
  23803. /**
  23804. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23805. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23806. */
  23807. vars: any;
  23808. /**
  23809. * This array is populated when the SPS is set as 'pickable'.
  23810. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23811. * Each element of this array is an object `{idx: int, faceId: int}`.
  23812. * `idx` is the picked particle index in the `SPS.particles` array
  23813. * `faceId` is the picked face index counted within this particle.
  23814. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23815. */
  23816. pickedParticles: {
  23817. idx: number;
  23818. faceId: number;
  23819. }[];
  23820. /**
  23821. * This array is populated when `enableDepthSort` is set to true.
  23822. * Each element of this array is an instance of the class DepthSortedParticle.
  23823. */
  23824. depthSortedParticles: DepthSortedParticle[];
  23825. /**
  23826. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23827. */
  23828. _bSphereOnly: boolean;
  23829. /**
  23830. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23831. */
  23832. _bSphereRadiusFactor: number;
  23833. private _scene;
  23834. private _positions;
  23835. private _indices;
  23836. private _normals;
  23837. private _colors;
  23838. private _uvs;
  23839. private _indices32;
  23840. private _positions32;
  23841. private _normals32;
  23842. private _fixedNormal32;
  23843. private _colors32;
  23844. private _uvs32;
  23845. private _index;
  23846. private _updatable;
  23847. private _pickable;
  23848. private _isVisibilityBoxLocked;
  23849. private _alwaysVisible;
  23850. private _depthSort;
  23851. private _shapeCounter;
  23852. private _copy;
  23853. private _shape;
  23854. private _shapeUV;
  23855. private _color;
  23856. private _computeParticleColor;
  23857. private _computeParticleTexture;
  23858. private _computeParticleRotation;
  23859. private _computeParticleVertex;
  23860. private _computeBoundingBox;
  23861. private _depthSortParticles;
  23862. private _cam_axisZ;
  23863. private _cam_axisY;
  23864. private _cam_axisX;
  23865. private _axisZ;
  23866. private _camera;
  23867. private _particle;
  23868. private _camDir;
  23869. private _camInvertedPosition;
  23870. private _rotMatrix;
  23871. private _invertMatrix;
  23872. private _rotated;
  23873. private _quaternion;
  23874. private _vertex;
  23875. private _normal;
  23876. private _yaw;
  23877. private _pitch;
  23878. private _roll;
  23879. private _halfroll;
  23880. private _halfpitch;
  23881. private _halfyaw;
  23882. private _sinRoll;
  23883. private _cosRoll;
  23884. private _sinPitch;
  23885. private _cosPitch;
  23886. private _sinYaw;
  23887. private _cosYaw;
  23888. private _mustUnrotateFixedNormals;
  23889. private _minimum;
  23890. private _maximum;
  23891. private _minBbox;
  23892. private _maxBbox;
  23893. private _particlesIntersect;
  23894. private _depthSortFunction;
  23895. private _needs32Bits;
  23896. private _pivotBackTranslation;
  23897. private _scaledPivot;
  23898. private _particleHasParent;
  23899. private _parent;
  23900. /**
  23901. * Creates a SPS (Solid Particle System) object.
  23902. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23903. * @param scene (Scene) is the scene in which the SPS is added.
  23904. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23905. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23906. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23907. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23908. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23909. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23910. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23911. */
  23912. constructor(name: string, scene: Scene, options?: {
  23913. updatable?: boolean;
  23914. isPickable?: boolean;
  23915. enableDepthSort?: boolean;
  23916. particleIntersection?: boolean;
  23917. boundingSphereOnly?: boolean;
  23918. bSphereRadiusFactor?: number;
  23919. });
  23920. /**
  23921. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23922. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23923. * @returns the created mesh
  23924. */
  23925. buildMesh(): Mesh;
  23926. /**
  23927. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23928. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23929. * Thus the particles generated from `digest()` have their property `position` set yet.
  23930. * @param mesh ( Mesh ) is the mesh to be digested
  23931. * @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
  23932. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23933. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23934. * @returns the current SPS
  23935. */
  23936. digest(mesh: Mesh, options?: {
  23937. facetNb?: number;
  23938. number?: number;
  23939. delta?: number;
  23940. }): SolidParticleSystem;
  23941. private _unrotateFixedNormals();
  23942. private _resetCopy();
  23943. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  23944. private _posToShape(positions);
  23945. private _uvsToShapeUV(uvs);
  23946. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  23947. /**
  23948. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23949. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23950. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23951. * @param nb (positive integer) the number of particles to be created from this model
  23952. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23953. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23954. * @returns the number of shapes in the system
  23955. */
  23956. addShape(mesh: Mesh, nb: number, options?: {
  23957. positionFunction?: any;
  23958. vertexFunction?: any;
  23959. }): number;
  23960. private _rebuildParticle(particle);
  23961. /**
  23962. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23963. * @returns the SPS.
  23964. */
  23965. rebuildMesh(): SolidParticleSystem;
  23966. /**
  23967. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23968. * This method calls `updateParticle()` for each particle of the SPS.
  23969. * For an animated SPS, it is usually called within the render loop.
  23970. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23971. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23972. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23973. * @returns the SPS.
  23974. */
  23975. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23976. private _quaternionRotationYPR();
  23977. private _quaternionToRotationMatrix();
  23978. /**
  23979. * Disposes the SPS.
  23980. */
  23981. dispose(): void;
  23982. /**
  23983. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23984. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23985. * @returns the SPS.
  23986. */
  23987. refreshVisibleSize(): SolidParticleSystem;
  23988. /**
  23989. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23990. * @param size the size (float) of the visibility box
  23991. * note : this doesn't lock the SPS mesh bounding box.
  23992. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23993. */
  23994. setVisibilityBox(size: number): void;
  23995. /**
  23996. * Gets whether the SPS as always visible or not
  23997. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23998. */
  23999. /**
  24000. * Sets the SPS as always visible or not
  24001. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24002. */
  24003. isAlwaysVisible: boolean;
  24004. /**
  24005. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24006. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24007. */
  24008. /**
  24009. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24010. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24011. */
  24012. isVisibilityBoxLocked: boolean;
  24013. /**
  24014. * Gets if `setParticles()` computes the particle rotations or not.
  24015. * Default value : true. The SPS is faster when it's set to false.
  24016. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24017. */
  24018. /**
  24019. * Tells to `setParticles()` to compute the particle rotations or not.
  24020. * Default value : true. The SPS is faster when it's set to false.
  24021. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24022. */
  24023. computeParticleRotation: boolean;
  24024. /**
  24025. * Gets if `setParticles()` computes the particle colors or not.
  24026. * Default value : true. The SPS is faster when it's set to false.
  24027. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24028. */
  24029. /**
  24030. * Tells to `setParticles()` to compute the particle colors or not.
  24031. * Default value : true. The SPS is faster when it's set to false.
  24032. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24033. */
  24034. computeParticleColor: boolean;
  24035. /**
  24036. * Gets if `setParticles()` computes the particle textures or not.
  24037. * Default value : true. The SPS is faster when it's set to false.
  24038. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24039. */
  24040. computeParticleTexture: boolean;
  24041. /**
  24042. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24043. * Default value : false. The SPS is faster when it's set to false.
  24044. * Note : the particle custom vertex positions aren't stored values.
  24045. */
  24046. /**
  24047. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24048. * Default value : false. The SPS is faster when it's set to false.
  24049. * Note : the particle custom vertex positions aren't stored values.
  24050. */
  24051. computeParticleVertex: boolean;
  24052. /**
  24053. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24054. */
  24055. /**
  24056. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24057. */
  24058. computeBoundingBox: boolean;
  24059. /**
  24060. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24061. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24062. * Default : `true`
  24063. */
  24064. /**
  24065. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24066. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24067. * Default : `true`
  24068. */
  24069. depthSortParticles: boolean;
  24070. /**
  24071. * This function does nothing. It may be overwritten to set all the particle first values.
  24072. * The SPS doesn't call this function, you may have to call it by your own.
  24073. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24074. */
  24075. initParticles(): void;
  24076. /**
  24077. * This function does nothing. It may be overwritten to recycle a particle.
  24078. * The SPS doesn't call this function, you may have to call it by your own.
  24079. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24080. * @param particle The particle to recycle
  24081. * @returns the recycled particle
  24082. */
  24083. recycleParticle(particle: SolidParticle): SolidParticle;
  24084. /**
  24085. * Updates a particle : this function should be overwritten by the user.
  24086. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24087. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24088. * @example : just set a particle position or velocity and recycle conditions
  24089. * @param particle The particle to update
  24090. * @returns the updated particle
  24091. */
  24092. updateParticle(particle: SolidParticle): SolidParticle;
  24093. /**
  24094. * Updates a vertex of a particle : it can be overwritten by the user.
  24095. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24096. * @param particle the current particle
  24097. * @param vertex the current index of the current particle
  24098. * @param pt the index of the current vertex in the particle shape
  24099. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24100. * @example : just set a vertex particle position
  24101. * @returns the updated vertex
  24102. */
  24103. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24104. /**
  24105. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24106. * This does nothing and may be overwritten by the user.
  24107. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24108. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24109. * @param update the boolean update value actually passed to setParticles()
  24110. */
  24111. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24112. /**
  24113. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24114. * This will be passed three parameters.
  24115. * This does nothing and may be overwritten by the user.
  24116. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24117. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24118. * @param update the boolean update value actually passed to setParticles()
  24119. */
  24120. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24121. }
  24122. }
  24123. declare module BABYLON {
  24124. interface PhysicsImpostorJoint {
  24125. mainImpostor: PhysicsImpostor;
  24126. connectedImpostor: PhysicsImpostor;
  24127. joint: PhysicsJoint;
  24128. }
  24129. class PhysicsEngine {
  24130. private _physicsPlugin;
  24131. gravity: Vector3;
  24132. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24133. setGravity(gravity: Vector3): void;
  24134. /**
  24135. * Set the time step of the physics engine.
  24136. * default is 1/60.
  24137. * To slow it down, enter 1/600 for example.
  24138. * To speed it up, 1/30
  24139. * @param {number} newTimeStep the new timestep to apply to this world.
  24140. */
  24141. setTimeStep(newTimeStep?: number): void;
  24142. /**
  24143. * Get the time step of the physics engine.
  24144. */
  24145. getTimeStep(): number;
  24146. dispose(): void;
  24147. getPhysicsPluginName(): string;
  24148. static Epsilon: number;
  24149. private _impostors;
  24150. private _joints;
  24151. /**
  24152. * Adding a new impostor for the impostor tracking.
  24153. * This will be done by the impostor itself.
  24154. * @param {PhysicsImpostor} impostor the impostor to add
  24155. */
  24156. addImpostor(impostor: PhysicsImpostor): void;
  24157. /**
  24158. * Remove an impostor from the engine.
  24159. * This impostor and its mesh will not longer be updated by the physics engine.
  24160. * @param {PhysicsImpostor} impostor the impostor to remove
  24161. */
  24162. removeImpostor(impostor: PhysicsImpostor): void;
  24163. /**
  24164. * Add a joint to the physics engine
  24165. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24166. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24167. * @param {PhysicsJoint} the joint that will connect both impostors.
  24168. */
  24169. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24170. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24171. /**
  24172. * Called by the scene. no need to call it.
  24173. */
  24174. _step(delta: number): void;
  24175. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24176. getImpostors(): Array<PhysicsImpostor>;
  24177. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24178. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24179. }
  24180. interface IPhysicsEnginePlugin {
  24181. world: any;
  24182. name: string;
  24183. setGravity(gravity: Vector3): void;
  24184. setTimeStep(timeStep: number): void;
  24185. getTimeStep(): number;
  24186. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24187. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24189. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24190. removePhysicsBody(impostor: PhysicsImpostor): void;
  24191. generateJoint(joint: PhysicsImpostorJoint): void;
  24192. removeJoint(joint: PhysicsImpostorJoint): void;
  24193. isSupported(): boolean;
  24194. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24195. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24196. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24197. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24198. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24199. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24200. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24201. getBodyMass(impostor: PhysicsImpostor): number;
  24202. getBodyFriction(impostor: PhysicsImpostor): number;
  24203. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24204. getBodyRestitution(impostor: PhysicsImpostor): number;
  24205. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24206. sleepBody(impostor: PhysicsImpostor): void;
  24207. wakeUpBody(impostor: PhysicsImpostor): void;
  24208. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24209. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24210. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24211. getRadius(impostor: PhysicsImpostor): number;
  24212. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24213. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24214. dispose(): void;
  24215. }
  24216. }
  24217. declare module BABYLON {
  24218. class PhysicsHelper {
  24219. private _scene;
  24220. private _physicsEngine;
  24221. constructor(scene: Scene);
  24222. /**
  24223. * @param {Vector3} origin the origin of the explosion
  24224. * @param {number} radius the explosion radius
  24225. * @param {number} strength the explosion strength
  24226. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24227. */
  24228. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24229. /**
  24230. * @param {Vector3} origin the origin of the explosion
  24231. * @param {number} radius the explosion radius
  24232. * @param {number} strength the explosion strength
  24233. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24234. */
  24235. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24236. /**
  24237. * @param {Vector3} origin the origin of the explosion
  24238. * @param {number} radius the explosion radius
  24239. * @param {number} strength the explosion strength
  24240. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24241. */
  24242. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24243. /**
  24244. * @param {Vector3} origin the origin of the updraft
  24245. * @param {number} radius the radius of the updraft
  24246. * @param {number} strength the strength of the updraft
  24247. * @param {number} height the height of the updraft
  24248. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24249. */
  24250. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24251. /**
  24252. * @param {Vector3} origin the of the vortex
  24253. * @param {number} radius the radius of the vortex
  24254. * @param {number} strength the strength of the vortex
  24255. * @param {number} height the height of the vortex
  24256. */
  24257. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24258. }
  24259. /***** Radial explosion *****/
  24260. class PhysicsRadialExplosionEvent {
  24261. private _scene;
  24262. private _sphere;
  24263. private _sphereOptions;
  24264. private _rays;
  24265. private _dataFetched;
  24266. constructor(scene: Scene);
  24267. /**
  24268. * Returns the data related to the radial explosion event (sphere & rays).
  24269. * @returns {PhysicsRadialExplosionEventData}
  24270. */
  24271. getData(): PhysicsRadialExplosionEventData;
  24272. /**
  24273. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24274. * @param impostor
  24275. * @param {Vector3} origin the origin of the explosion
  24276. * @param {number} radius the explosion radius
  24277. * @param {number} strength the explosion strength
  24278. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24279. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24280. */
  24281. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24282. /**
  24283. * Disposes the sphere.
  24284. * @param {bolean} force
  24285. */
  24286. dispose(force?: boolean): void;
  24287. /*** Helpers ***/
  24288. private _prepareSphere();
  24289. private _intersectsWithSphere(impostor, origin, radius);
  24290. }
  24291. /***** Gravitational Field *****/
  24292. class PhysicsGravitationalFieldEvent {
  24293. private _physicsHelper;
  24294. private _scene;
  24295. private _origin;
  24296. private _radius;
  24297. private _strength;
  24298. private _falloff;
  24299. private _tickCallback;
  24300. private _sphere;
  24301. private _dataFetched;
  24302. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24303. /**
  24304. * Returns the data related to the gravitational field event (sphere).
  24305. * @returns {PhysicsGravitationalFieldEventData}
  24306. */
  24307. getData(): PhysicsGravitationalFieldEventData;
  24308. /**
  24309. * Enables the gravitational field.
  24310. */
  24311. enable(): void;
  24312. /**
  24313. * Disables the gravitational field.
  24314. */
  24315. disable(): void;
  24316. /**
  24317. * Disposes the sphere.
  24318. * @param {bolean} force
  24319. */
  24320. dispose(force?: boolean): void;
  24321. private _tick();
  24322. }
  24323. /***** Updraft *****/
  24324. class PhysicsUpdraftEvent {
  24325. private _scene;
  24326. private _origin;
  24327. private _radius;
  24328. private _strength;
  24329. private _height;
  24330. private _updraftMode;
  24331. private _physicsEngine;
  24332. private _originTop;
  24333. private _originDirection;
  24334. private _tickCallback;
  24335. private _cylinder;
  24336. private _cylinderPosition;
  24337. private _dataFetched;
  24338. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24339. /**
  24340. * Returns the data related to the updraft event (cylinder).
  24341. * @returns {PhysicsUpdraftEventData}
  24342. */
  24343. getData(): PhysicsUpdraftEventData;
  24344. /**
  24345. * Enables the updraft.
  24346. */
  24347. enable(): void;
  24348. /**
  24349. * Disables the cortex.
  24350. */
  24351. disable(): void;
  24352. /**
  24353. * Disposes the sphere.
  24354. * @param {bolean} force
  24355. */
  24356. dispose(force?: boolean): void;
  24357. private getImpostorForceAndContactPoint(impostor);
  24358. private _tick();
  24359. /*** Helpers ***/
  24360. private _prepareCylinder();
  24361. private _intersectsWithCylinder(impostor);
  24362. }
  24363. /***** Vortex *****/
  24364. class PhysicsVortexEvent {
  24365. private _scene;
  24366. private _origin;
  24367. private _radius;
  24368. private _strength;
  24369. private _height;
  24370. private _physicsEngine;
  24371. private _originTop;
  24372. private _centripetalForceThreshold;
  24373. private _updraftMultiplier;
  24374. private _tickCallback;
  24375. private _cylinder;
  24376. private _cylinderPosition;
  24377. private _dataFetched;
  24378. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24379. /**
  24380. * Returns the data related to the vortex event (cylinder).
  24381. * @returns {PhysicsVortexEventData}
  24382. */
  24383. getData(): PhysicsVortexEventData;
  24384. /**
  24385. * Enables the vortex.
  24386. */
  24387. enable(): void;
  24388. /**
  24389. * Disables the cortex.
  24390. */
  24391. disable(): void;
  24392. /**
  24393. * Disposes the sphere.
  24394. * @param {bolean} force
  24395. */
  24396. dispose(force?: boolean): void;
  24397. private getImpostorForceAndContactPoint(impostor);
  24398. private _tick();
  24399. /*** Helpers ***/
  24400. private _prepareCylinder();
  24401. private _intersectsWithCylinder(impostor);
  24402. }
  24403. /***** Enums *****/
  24404. /**
  24405. * The strenght of the force in correspondence to the distance of the affected object
  24406. */
  24407. enum PhysicsRadialImpulseFalloff {
  24408. /** Defines that impulse is constant in strength across it's whole radius */
  24409. Constant = 0,
  24410. /** DEfines that impulse gets weaker if it's further from the origin */
  24411. Linear = 1,
  24412. }
  24413. /**
  24414. * The strenght of the force in correspondence to the distance of the affected object
  24415. */
  24416. enum PhysicsUpdraftMode {
  24417. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24418. Center = 0,
  24419. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24420. Perpendicular = 1,
  24421. }
  24422. /***** Data interfaces *****/
  24423. interface PhysicsForceAndContactPoint {
  24424. force: Vector3;
  24425. contactPoint: Vector3;
  24426. }
  24427. interface PhysicsRadialExplosionEventData {
  24428. sphere: Mesh;
  24429. rays: Array<Ray>;
  24430. }
  24431. interface PhysicsGravitationalFieldEventData {
  24432. sphere: Mesh;
  24433. }
  24434. interface PhysicsUpdraftEventData {
  24435. cylinder: Mesh;
  24436. }
  24437. interface PhysicsVortexEventData {
  24438. cylinder: Mesh;
  24439. }
  24440. }
  24441. declare module BABYLON {
  24442. interface PhysicsImpostorParameters {
  24443. mass: number;
  24444. friction?: number;
  24445. restitution?: number;
  24446. nativeOptions?: any;
  24447. ignoreParent?: boolean;
  24448. disableBidirectionalTransformation?: boolean;
  24449. }
  24450. interface IPhysicsEnabledObject {
  24451. position: Vector3;
  24452. rotationQuaternion: Nullable<Quaternion>;
  24453. scaling: Vector3;
  24454. rotation?: Vector3;
  24455. parent?: any;
  24456. getBoundingInfo(): BoundingInfo;
  24457. computeWorldMatrix(force: boolean): Matrix;
  24458. getWorldMatrix?(): Matrix;
  24459. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24460. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24461. getIndices?(): Nullable<IndicesArray>;
  24462. getScene?(): Scene;
  24463. getAbsolutePosition(): Vector3;
  24464. getAbsolutePivotPoint(): Vector3;
  24465. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24466. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24467. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24468. getClassName(): string;
  24469. }
  24470. class PhysicsImpostor {
  24471. object: IPhysicsEnabledObject;
  24472. type: number;
  24473. private _options;
  24474. private _scene;
  24475. static DEFAULT_OBJECT_SIZE: Vector3;
  24476. static IDENTITY_QUATERNION: Quaternion;
  24477. private _physicsEngine;
  24478. private _physicsBody;
  24479. private _bodyUpdateRequired;
  24480. private _onBeforePhysicsStepCallbacks;
  24481. private _onAfterPhysicsStepCallbacks;
  24482. private _onPhysicsCollideCallbacks;
  24483. private _deltaPosition;
  24484. private _deltaRotation;
  24485. private _deltaRotationConjugated;
  24486. private _parent;
  24487. private _isDisposed;
  24488. private static _tmpVecs;
  24489. private static _tmpQuat;
  24490. readonly isDisposed: boolean;
  24491. mass: number;
  24492. friction: number;
  24493. restitution: number;
  24494. uniqueId: number;
  24495. private _joints;
  24496. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24497. /**
  24498. * This function will completly initialize this impostor.
  24499. * It will create a new body - but only if this mesh has no parent.
  24500. * If it has, this impostor will not be used other than to define the impostor
  24501. * of the child mesh.
  24502. */
  24503. _init(): void;
  24504. private _getPhysicsParent();
  24505. /**
  24506. * Should a new body be generated.
  24507. */
  24508. isBodyInitRequired(): boolean;
  24509. setScalingUpdated(updated: boolean): void;
  24510. /**
  24511. * Force a regeneration of this or the parent's impostor's body.
  24512. * Use under cautious - This will remove all joints already implemented.
  24513. */
  24514. forceUpdate(): void;
  24515. /**
  24516. * Gets the body that holds this impostor. Either its own, or its parent.
  24517. */
  24518. /**
  24519. * Set the physics body. Used mainly by the physics engine/plugin
  24520. */
  24521. physicsBody: any;
  24522. parent: Nullable<PhysicsImpostor>;
  24523. resetUpdateFlags(): void;
  24524. getObjectExtendSize(): Vector3;
  24525. getObjectCenter(): Vector3;
  24526. /**
  24527. * Get a specific parametes from the options parameter.
  24528. */
  24529. getParam(paramName: string): any;
  24530. /**
  24531. * Sets a specific parameter in the options given to the physics plugin
  24532. */
  24533. setParam(paramName: string, value: number): void;
  24534. /**
  24535. * Specifically change the body's mass option. Won't recreate the physics body object
  24536. */
  24537. setMass(mass: number): void;
  24538. getLinearVelocity(): Nullable<Vector3>;
  24539. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24540. getAngularVelocity(): Nullable<Vector3>;
  24541. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24542. /**
  24543. * Execute a function with the physics plugin native code.
  24544. * Provide a function the will have two variables - the world object and the physics body object.
  24545. */
  24546. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24547. /**
  24548. * Register a function that will be executed before the physics world is stepping forward.
  24549. */
  24550. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24551. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24552. /**
  24553. * Register a function that will be executed after the physics step
  24554. */
  24555. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24556. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24557. /**
  24558. * register a function that will be executed when this impostor collides against a different body.
  24559. */
  24560. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24561. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24562. private _tmpQuat;
  24563. private _tmpQuat2;
  24564. getParentsRotation(): Quaternion;
  24565. /**
  24566. * this function is executed by the physics engine.
  24567. */
  24568. beforeStep: () => void;
  24569. /**
  24570. * this function is executed by the physics engine.
  24571. */
  24572. afterStep: () => void;
  24573. /**
  24574. * Legacy collision detection event support
  24575. */
  24576. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24577. onCollide: (e: {
  24578. body: any;
  24579. }) => void;
  24580. /**
  24581. * Apply a force
  24582. */
  24583. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24584. /**
  24585. * Apply an impulse
  24586. */
  24587. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24588. /**
  24589. * A help function to create a joint.
  24590. */
  24591. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24592. /**
  24593. * Add a joint to this impostor with a different impostor.
  24594. */
  24595. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24596. /**
  24597. * Will keep this body still, in a sleep mode.
  24598. */
  24599. sleep(): PhysicsImpostor;
  24600. /**
  24601. * Wake the body up.
  24602. */
  24603. wakeUp(): PhysicsImpostor;
  24604. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24605. dispose(): void;
  24606. setDeltaPosition(position: Vector3): void;
  24607. setDeltaRotation(rotation: Quaternion): void;
  24608. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24609. getRadius(): number;
  24610. /**
  24611. * Sync a bone with this impostor
  24612. * @param bone The bone to sync to the impostor.
  24613. * @param boneMesh The mesh that the bone is influencing.
  24614. * @param jointPivot The pivot of the joint / bone in local space.
  24615. * @param distToJoint Optional distance from the impostor to the joint.
  24616. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24617. */
  24618. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24619. /**
  24620. * Sync impostor to a bone
  24621. * @param bone The bone that the impostor will be synced to.
  24622. * @param boneMesh The mesh that the bone is influencing.
  24623. * @param jointPivot The pivot of the joint / bone in local space.
  24624. * @param distToJoint Optional distance from the impostor to the joint.
  24625. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24626. * @param boneAxis Optional vector3 axis the bone is aligned with
  24627. */
  24628. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24629. static NoImpostor: number;
  24630. static SphereImpostor: number;
  24631. static BoxImpostor: number;
  24632. static PlaneImpostor: number;
  24633. static MeshImpostor: number;
  24634. static CylinderImpostor: number;
  24635. static ParticleImpostor: number;
  24636. static HeightmapImpostor: number;
  24637. }
  24638. }
  24639. declare module BABYLON {
  24640. interface PhysicsJointData {
  24641. mainPivot?: Vector3;
  24642. connectedPivot?: Vector3;
  24643. mainAxis?: Vector3;
  24644. connectedAxis?: Vector3;
  24645. collision?: boolean;
  24646. nativeParams?: any;
  24647. }
  24648. /**
  24649. * This is a holder class for the physics joint created by the physics plugin.
  24650. * It holds a set of functions to control the underlying joint.
  24651. */
  24652. class PhysicsJoint {
  24653. type: number;
  24654. jointData: PhysicsJointData;
  24655. private _physicsJoint;
  24656. protected _physicsPlugin: IPhysicsEnginePlugin;
  24657. constructor(type: number, jointData: PhysicsJointData);
  24658. physicsJoint: any;
  24659. physicsPlugin: IPhysicsEnginePlugin;
  24660. /**
  24661. * Execute a function that is physics-plugin specific.
  24662. * @param {Function} func the function that will be executed.
  24663. * It accepts two parameters: the physics world and the physics joint.
  24664. */
  24665. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24666. static DistanceJoint: number;
  24667. static HingeJoint: number;
  24668. static BallAndSocketJoint: number;
  24669. static WheelJoint: number;
  24670. static SliderJoint: number;
  24671. static PrismaticJoint: number;
  24672. static UniversalJoint: number;
  24673. static Hinge2Joint: number;
  24674. static PointToPointJoint: number;
  24675. static SpringJoint: number;
  24676. static LockJoint: number;
  24677. }
  24678. /**
  24679. * A class representing a physics distance joint.
  24680. */
  24681. class DistanceJoint extends PhysicsJoint {
  24682. constructor(jointData: DistanceJointData);
  24683. /**
  24684. * Update the predefined distance.
  24685. */
  24686. updateDistance(maxDistance: number, minDistance?: number): void;
  24687. }
  24688. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24689. constructor(type: number, jointData: PhysicsJointData);
  24690. /**
  24691. * Set the motor values.
  24692. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24693. * @param {number} force the force to apply
  24694. * @param {number} maxForce max force for this motor.
  24695. */
  24696. setMotor(force?: number, maxForce?: number): void;
  24697. /**
  24698. * Set the motor's limits.
  24699. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24700. */
  24701. setLimit(upperLimit: number, lowerLimit?: number): void;
  24702. }
  24703. /**
  24704. * This class represents a single hinge physics joint
  24705. */
  24706. class HingeJoint extends MotorEnabledJoint {
  24707. constructor(jointData: PhysicsJointData);
  24708. /**
  24709. * Set the motor values.
  24710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24711. * @param {number} force the force to apply
  24712. * @param {number} maxForce max force for this motor.
  24713. */
  24714. setMotor(force?: number, maxForce?: number): void;
  24715. /**
  24716. * Set the motor's limits.
  24717. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24718. */
  24719. setLimit(upperLimit: number, lowerLimit?: number): void;
  24720. }
  24721. /**
  24722. * This class represents a dual hinge physics joint (same as wheel joint)
  24723. */
  24724. class Hinge2Joint extends MotorEnabledJoint {
  24725. constructor(jointData: PhysicsJointData);
  24726. /**
  24727. * Set the motor values.
  24728. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24729. * @param {number} force the force to apply
  24730. * @param {number} maxForce max force for this motor.
  24731. * @param {motorIndex} the motor's index, 0 or 1.
  24732. */
  24733. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24734. /**
  24735. * Set the motor limits.
  24736. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24737. * @param {number} upperLimit the upper limit
  24738. * @param {number} lowerLimit lower limit
  24739. * @param {motorIndex} the motor's index, 0 or 1.
  24740. */
  24741. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24742. }
  24743. interface IMotorEnabledJoint {
  24744. physicsJoint: any;
  24745. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24746. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24747. }
  24748. interface DistanceJointData extends PhysicsJointData {
  24749. maxDistance: number;
  24750. }
  24751. interface SpringJointData extends PhysicsJointData {
  24752. length: number;
  24753. stiffness: number;
  24754. damping: number;
  24755. }
  24756. }
  24757. declare module BABYLON {
  24758. class ReflectionProbe {
  24759. name: string;
  24760. private _scene;
  24761. private _renderTargetTexture;
  24762. private _projectionMatrix;
  24763. private _viewMatrix;
  24764. private _target;
  24765. private _add;
  24766. private _attachedMesh;
  24767. private _invertYAxis;
  24768. position: Vector3;
  24769. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24770. samples: number;
  24771. refreshRate: number;
  24772. getScene(): Scene;
  24773. readonly cubeTexture: RenderTargetTexture;
  24774. readonly renderList: Nullable<AbstractMesh[]>;
  24775. attachToMesh(mesh: AbstractMesh): void;
  24776. /**
  24777. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24778. *
  24779. * @param renderingGroupId The rendering group id corresponding to its index
  24780. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24781. */
  24782. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24783. dispose(): void;
  24784. }
  24785. }
  24786. declare module BABYLON {
  24787. class BoundingBoxRenderer {
  24788. frontColor: Color3;
  24789. backColor: Color3;
  24790. showBackLines: boolean;
  24791. renderList: SmartArray<BoundingBox>;
  24792. private _scene;
  24793. private _colorShader;
  24794. private _vertexBuffers;
  24795. private _indexBuffer;
  24796. constructor(scene: Scene);
  24797. private _prepareRessources();
  24798. private _createIndexBuffer();
  24799. _rebuild(): void;
  24800. reset(): void;
  24801. render(): void;
  24802. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  24803. dispose(): void;
  24804. }
  24805. }
  24806. declare module BABYLON {
  24807. /**
  24808. * This represents a depth renderer in Babylon.
  24809. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  24810. */
  24811. class DepthRenderer {
  24812. private _scene;
  24813. private _depthMap;
  24814. private _effect;
  24815. private _cachedDefines;
  24816. private _camera;
  24817. /**
  24818. * Instantiates a depth renderer
  24819. * @param scene The scene the renderer belongs to
  24820. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  24821. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  24822. */
  24823. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  24824. /**
  24825. * Creates the depth rendering effect and checks if the effect is ready.
  24826. * @param subMesh The submesh to be used to render the depth map of
  24827. * @param useInstances If multiple world instances should be used
  24828. * @returns if the depth renderer is ready to render the depth map
  24829. */
  24830. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24831. /**
  24832. * Gets the texture which the depth map will be written to.
  24833. * @returns The depth map texture
  24834. */
  24835. getDepthMap(): RenderTargetTexture;
  24836. /**
  24837. * Disposes of the depth renderer.
  24838. */
  24839. dispose(): void;
  24840. }
  24841. }
  24842. declare module BABYLON {
  24843. class EdgesRenderer {
  24844. edgesWidthScalerForOrthographic: number;
  24845. edgesWidthScalerForPerspective: number;
  24846. private _source;
  24847. private _linesPositions;
  24848. private _linesNormals;
  24849. private _linesIndices;
  24850. private _epsilon;
  24851. private _indicesCount;
  24852. private _lineShader;
  24853. private _ib;
  24854. private _buffers;
  24855. private _checkVerticesInsteadOfIndices;
  24856. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  24857. private _prepareRessources();
  24858. _rebuild(): void;
  24859. dispose(): void;
  24860. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  24861. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  24862. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  24863. _generateEdgesLines(): void;
  24864. render(): void;
  24865. }
  24866. }
  24867. declare module BABYLON {
  24868. /**
  24869. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  24870. */
  24871. class GeometryBufferRenderer {
  24872. private _scene;
  24873. private _multiRenderTarget;
  24874. private _ratio;
  24875. private _enablePosition;
  24876. protected _effect: Effect;
  24877. protected _cachedDefines: string;
  24878. /**
  24879. * Set the render list (meshes to be rendered) used in the G buffer.
  24880. */
  24881. renderList: Mesh[];
  24882. /**
  24883. * Gets wether or not G buffer are supported by the running hardware.
  24884. * This requires draw buffer supports
  24885. */
  24886. readonly isSupported: boolean;
  24887. /**
  24888. * Gets wether or not position are enabled for the G buffer.
  24889. */
  24890. /**
  24891. * Sets wether or not position are enabled for the G buffer.
  24892. */
  24893. enablePosition: boolean;
  24894. /**
  24895. * Gets the scene associated with the buffer.
  24896. */
  24897. readonly scene: Scene;
  24898. /**
  24899. * Gets the ratio used by the buffer during its creation.
  24900. * How big is the buffer related to the main canvas.
  24901. */
  24902. readonly ratio: number;
  24903. /**
  24904. * Creates a new G Buffer for the scene
  24905. * @param scene The scene the buffer belongs to
  24906. * @param ratio How big is the buffer related to the main canvas.
  24907. */
  24908. constructor(scene: Scene, ratio?: number);
  24909. /**
  24910. * Checks wether everything is ready to render a submesh to the G buffer.
  24911. * @param subMesh the submesh to check readiness for
  24912. * @param useInstances is the mesh drawn using instance or not
  24913. * @returns true if ready otherwise false
  24914. */
  24915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24916. /**
  24917. * Gets the current underlying G Buffer.
  24918. * @returns the buffer
  24919. */
  24920. getGBuffer(): MultiRenderTarget;
  24921. /**
  24922. * Gets the number of samples used to render the buffer (anti aliasing).
  24923. */
  24924. /**
  24925. * Sets the number of samples used to render the buffer (anti aliasing).
  24926. */
  24927. samples: number;
  24928. /**
  24929. * Disposes the renderer and frees up associated resources.
  24930. */
  24931. dispose(): void;
  24932. protected _createRenderTargets(): void;
  24933. }
  24934. }
  24935. declare module BABYLON {
  24936. class OutlineRenderer {
  24937. private _scene;
  24938. private _effect;
  24939. private _cachedDefines;
  24940. zOffset: number;
  24941. constructor(scene: Scene);
  24942. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  24943. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24944. }
  24945. }
  24946. declare module BABYLON {
  24947. class RenderingGroup {
  24948. index: number;
  24949. private _scene;
  24950. private _opaqueSubMeshes;
  24951. private _transparentSubMeshes;
  24952. private _alphaTestSubMeshes;
  24953. private _depthOnlySubMeshes;
  24954. private _particleSystems;
  24955. private _spriteManagers;
  24956. private _opaqueSortCompareFn;
  24957. private _alphaTestSortCompareFn;
  24958. private _transparentSortCompareFn;
  24959. private _renderOpaque;
  24960. private _renderAlphaTest;
  24961. private _renderTransparent;
  24962. private _edgesRenderers;
  24963. onBeforeTransparentRendering: () => void;
  24964. /**
  24965. * Set the opaque sort comparison function.
  24966. * If null the sub meshes will be render in the order they were created
  24967. */
  24968. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24969. /**
  24970. * Set the alpha test sort comparison function.
  24971. * If null the sub meshes will be render in the order they were created
  24972. */
  24973. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24974. /**
  24975. * Set the transparent sort comparison function.
  24976. * If null the sub meshes will be render in the order they were created
  24977. */
  24978. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24979. /**
  24980. * Creates a new rendering group.
  24981. * @param index The rendering group index
  24982. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  24983. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  24984. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  24985. */
  24986. 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>);
  24987. /**
  24988. * Render all the sub meshes contained in the group.
  24989. * @param customRenderFunction Used to override the default render behaviour of the group.
  24990. * @returns true if rendered some submeshes.
  24991. */
  24992. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  24993. /**
  24994. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  24995. * @param subMeshes The submeshes to render
  24996. */
  24997. private renderOpaqueSorted(subMeshes);
  24998. /**
  24999. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25000. * @param subMeshes The submeshes to render
  25001. */
  25002. private renderAlphaTestSorted(subMeshes);
  25003. /**
  25004. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25005. * @param subMeshes The submeshes to render
  25006. */
  25007. private renderTransparentSorted(subMeshes);
  25008. /**
  25009. * Renders the submeshes in a specified order.
  25010. * @param subMeshes The submeshes to sort before render
  25011. * @param sortCompareFn The comparison function use to sort
  25012. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25013. * @param transparent Specifies to activate blending if true
  25014. */
  25015. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25016. /**
  25017. * Renders the submeshes in the order they were dispatched (no sort applied).
  25018. * @param subMeshes The submeshes to render
  25019. */
  25020. private static renderUnsorted(subMeshes);
  25021. /**
  25022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25023. * are rendered back to front if in the same alpha index.
  25024. *
  25025. * @param a The first submesh
  25026. * @param b The second submesh
  25027. * @returns The result of the comparison
  25028. */
  25029. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25030. /**
  25031. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25032. * are rendered back to front.
  25033. *
  25034. * @param a The first submesh
  25035. * @param b The second submesh
  25036. * @returns The result of the comparison
  25037. */
  25038. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25039. /**
  25040. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25041. * are rendered front to back (prevent overdraw).
  25042. *
  25043. * @param a The first submesh
  25044. * @param b The second submesh
  25045. * @returns The result of the comparison
  25046. */
  25047. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25048. /**
  25049. * Resets the different lists of submeshes to prepare a new frame.
  25050. */
  25051. prepare(): void;
  25052. dispose(): void;
  25053. /**
  25054. * Inserts the submesh in its correct queue depending on its material.
  25055. * @param subMesh The submesh to dispatch
  25056. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25057. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25058. */
  25059. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25060. dispatchSprites(spriteManager: SpriteManager): void;
  25061. dispatchParticles(particleSystem: IParticleSystem): void;
  25062. private _renderParticles(activeMeshes);
  25063. private _renderSprites();
  25064. }
  25065. }
  25066. declare module BABYLON {
  25067. class RenderingManager {
  25068. /**
  25069. * The max id used for rendering groups (not included)
  25070. */
  25071. static MAX_RENDERINGGROUPS: number;
  25072. /**
  25073. * The min id used for rendering groups (included)
  25074. */
  25075. static MIN_RENDERINGGROUPS: number;
  25076. /**
  25077. * Used to globally prevent autoclearing scenes.
  25078. */
  25079. static AUTOCLEAR: boolean;
  25080. private _scene;
  25081. private _renderingGroups;
  25082. private _depthStencilBufferAlreadyCleaned;
  25083. private _autoClearDepthStencil;
  25084. private _customOpaqueSortCompareFn;
  25085. private _customAlphaTestSortCompareFn;
  25086. private _customTransparentSortCompareFn;
  25087. private _renderinGroupInfo;
  25088. constructor(scene: Scene);
  25089. private _clearDepthStencilBuffer(depth?, stencil?);
  25090. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25091. reset(): void;
  25092. dispose(): void;
  25093. /**
  25094. * Clear the info related to rendering groups preventing retention points during dispose.
  25095. */
  25096. freeRenderingGroups(): void;
  25097. private _prepareRenderingGroup(renderingGroupId);
  25098. dispatchSprites(spriteManager: SpriteManager): void;
  25099. dispatchParticles(particleSystem: IParticleSystem): void;
  25100. /**
  25101. * @param subMesh The submesh to dispatch
  25102. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25103. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25104. */
  25105. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25106. /**
  25107. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25108. * This allowed control for front to back rendering or reversly depending of the special needs.
  25109. *
  25110. * @param renderingGroupId The rendering group id corresponding to its index
  25111. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25112. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25113. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25114. */
  25115. 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;
  25116. /**
  25117. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25118. *
  25119. * @param renderingGroupId The rendering group id corresponding to its index
  25120. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25121. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25122. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25123. */
  25124. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25125. }
  25126. }
  25127. declare module BABYLON {
  25128. /**
  25129. * Postprocess used to generate anaglyphic rendering
  25130. */
  25131. class AnaglyphPostProcess extends PostProcess {
  25132. private _passedProcess;
  25133. /**
  25134. * Creates a new AnaglyphPostProcess
  25135. * @param name defines postprocess name
  25136. * @param options defines creation options or target ratio scale
  25137. * @param rigCameras defines cameras using this postprocess
  25138. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25139. * @param engine defines hosting engine
  25140. * @param reusable defines if the postprocess will be reused multiple times per frame
  25141. */
  25142. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25143. }
  25144. }
  25145. declare module BABYLON {
  25146. class BlackAndWhitePostProcess extends PostProcess {
  25147. degree: number;
  25148. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25149. }
  25150. }
  25151. declare module BABYLON {
  25152. /**
  25153. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25154. */
  25155. class BloomEffect extends PostProcessRenderEffect {
  25156. private bloomScale;
  25157. /**
  25158. * Internal
  25159. */
  25160. _effects: Array<PostProcess>;
  25161. /**
  25162. * Internal
  25163. */
  25164. _downscale: ExtractHighlightsPostProcess;
  25165. private _blurX;
  25166. private _blurY;
  25167. private _merge;
  25168. /**
  25169. * The luminance threshold to find bright areas of the image to bloom.
  25170. */
  25171. threshold: number;
  25172. /**
  25173. * The strength of the bloom.
  25174. */
  25175. weight: number;
  25176. /**
  25177. * Specifies the size of the bloom blur kernel, relative to the final output size
  25178. */
  25179. kernel: number;
  25180. /**
  25181. * Creates a new instance of @see BloomEffect
  25182. * @param scene The scene the effect belongs to.
  25183. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25184. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25185. * @param bloomWeight The the strength of bloom.
  25186. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25187. * @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)
  25188. */
  25189. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25190. /**
  25191. * Disposes each of the internal effects for a given camera.
  25192. * @param camera The camera to dispose the effect on.
  25193. */
  25194. disposeEffects(camera: Camera): void;
  25195. /**
  25196. * Internal
  25197. */
  25198. _updateEffects(): void;
  25199. /**
  25200. * Internal
  25201. * @returns if all the contained post processes are ready.
  25202. */
  25203. _isReady(): boolean;
  25204. }
  25205. }
  25206. declare module BABYLON {
  25207. /**
  25208. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25209. */
  25210. class BloomMergePostProcess extends PostProcess {
  25211. /** Weight of the bloom to be added to the original input. */ weight: number;
  25212. /**
  25213. * Creates a new instance of @see BloomMergePostProcess
  25214. * @param name The name of the effect.
  25215. * @param originalFromInput Post process which's input will be used for the merge.
  25216. * @param blurred Blurred highlights post process which's output will be used.
  25217. * @param weight Weight of the bloom to be added to the original input.
  25218. * @param options The required width/height ratio to downsize to before computing the render pass.
  25219. * @param camera The camera to apply the render pass to.
  25220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25221. * @param engine The engine which the post process will be applied. (default: current engine)
  25222. * @param reusable If the post process can be reused on the same frame. (default: false)
  25223. * @param textureType Type of textures used when performing the post process. (default: 0)
  25224. * @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)
  25225. */
  25226. 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);
  25227. }
  25228. }
  25229. declare module BABYLON {
  25230. /**
  25231. * The Blur Post Process which blurs an image based on a kernel and direction.
  25232. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25233. */
  25234. class BlurPostProcess extends PostProcess {
  25235. /** The direction in which to blur the image. */ direction: Vector2;
  25236. private blockCompilation;
  25237. protected _kernel: number;
  25238. protected _idealKernel: number;
  25239. protected _packedFloat: boolean;
  25240. private _staticDefines;
  25241. /**
  25242. * Gets the length in pixels of the blur sample region
  25243. */
  25244. /**
  25245. * Sets the length in pixels of the blur sample region
  25246. */
  25247. kernel: number;
  25248. /**
  25249. * Gets wether or not the blur is unpacking/repacking floats
  25250. */
  25251. /**
  25252. * Sets wether or not the blur needs to unpack/repack floats
  25253. */
  25254. packedFloat: boolean;
  25255. /**
  25256. * Creates a new instance BlurPostProcess
  25257. * @param name The name of the effect.
  25258. * @param direction The direction in which to blur the image.
  25259. * @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.
  25260. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25261. * @param camera The camera to apply the render pass to.
  25262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25263. * @param engine The engine which the post process will be applied. (default: current engine)
  25264. * @param reusable If the post process can be reused on the same frame. (default: false)
  25265. * @param textureType Type of textures used when performing the post process. (default: 0)
  25266. * @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)
  25267. */
  25268. 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);
  25269. /**
  25270. * Updates the effect with the current post process compile time values and recompiles the shader.
  25271. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25272. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25273. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25274. * @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
  25275. * @param onCompiled Called when the shader has been compiled.
  25276. * @param onError Called if there is an error when compiling a shader.
  25277. */
  25278. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25279. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25280. /**
  25281. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25282. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25283. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25284. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25285. * The gaps between physical kernels are compensated for in the weighting of the samples
  25286. * @param idealKernel Ideal blur kernel.
  25287. * @return Nearest best kernel.
  25288. */
  25289. protected _nearestBestKernel(idealKernel: number): number;
  25290. /**
  25291. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25292. * @param x The point on the Gaussian distribution to sample.
  25293. * @return the value of the Gaussian function at x.
  25294. */
  25295. protected _gaussianWeight(x: number): number;
  25296. /**
  25297. * Generates a string that can be used as a floating point number in GLSL.
  25298. * @param x Value to print.
  25299. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25300. * @return GLSL float string.
  25301. */
  25302. protected _glslFloat(x: number, decimalFigures?: number): string;
  25303. }
  25304. }
  25305. declare module BABYLON {
  25306. /**
  25307. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25308. */
  25309. class ChromaticAberrationPostProcess extends PostProcess {
  25310. /**
  25311. * The amount of seperation of rgb channels (default: 30)
  25312. */
  25313. aberrationAmount: number;
  25314. /**
  25315. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25316. */
  25317. radialIntensity: number;
  25318. /**
  25319. * 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))
  25320. */
  25321. direction: Vector2;
  25322. /**
  25323. * 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))
  25324. */
  25325. centerPosition: Vector2;
  25326. /**
  25327. * Creates a new instance ChromaticAberrationPostProcess
  25328. * @param name The name of the effect.
  25329. * @param screenWidth The width of the screen to apply the effect on.
  25330. * @param screenHeight The height of the screen to apply the effect on.
  25331. * @param options The required width/height ratio to downsize to before computing the render pass.
  25332. * @param camera The camera to apply the render pass to.
  25333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25334. * @param engine The engine which the post process will be applied. (default: current engine)
  25335. * @param reusable If the post process can be reused on the same frame. (default: false)
  25336. * @param textureType Type of textures used when performing the post process. (default: 0)
  25337. * @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)
  25338. */
  25339. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25340. }
  25341. }
  25342. declare module BABYLON {
  25343. /**
  25344. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25345. */
  25346. class CircleOfConfusionPostProcess extends PostProcess {
  25347. /**
  25348. * 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.
  25349. */
  25350. lensSize: number;
  25351. /**
  25352. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25353. */
  25354. fStop: number;
  25355. /**
  25356. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25357. */
  25358. focusDistance: number;
  25359. /**
  25360. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25361. */
  25362. focalLength: number;
  25363. private _depthTexture;
  25364. /**
  25365. * Creates a new instance CircleOfConfusionPostProcess
  25366. * @param name The name of the effect.
  25367. * @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.
  25368. * @param options The required width/height ratio to downsize to before computing the render pass.
  25369. * @param camera The camera to apply the render pass to.
  25370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25371. * @param engine The engine which the post process will be applied. (default: current engine)
  25372. * @param reusable If the post process can be reused on the same frame. (default: false)
  25373. * @param textureType Type of textures used when performing the post process. (default: 0)
  25374. * @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)
  25375. */
  25376. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25377. /**
  25378. * 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.
  25379. */
  25380. depthTexture: RenderTargetTexture;
  25381. }
  25382. }
  25383. declare module BABYLON {
  25384. class ColorCorrectionPostProcess extends PostProcess {
  25385. private _colorTableTexture;
  25386. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25387. }
  25388. }
  25389. declare module BABYLON {
  25390. /**
  25391. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25392. * input texture to perform effects such as edge detection or sharpening
  25393. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25394. */
  25395. class ConvolutionPostProcess extends PostProcess {
  25396. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25397. /**
  25398. * Creates a new instance ConvolutionPostProcess
  25399. * @param name The name of the effect.
  25400. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25401. * @param options The required width/height ratio to downsize to before computing the render pass.
  25402. * @param camera The camera to apply the render pass to.
  25403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25404. * @param engine The engine which the post process will be applied. (default: current engine)
  25405. * @param reusable If the post process can be reused on the same frame. (default: false)
  25406. * @param textureType Type of textures used when performing the post process. (default: 0)
  25407. */
  25408. 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);
  25409. /**
  25410. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25411. */
  25412. static EdgeDetect0Kernel: number[];
  25413. /**
  25414. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25415. */
  25416. static EdgeDetect1Kernel: number[];
  25417. /**
  25418. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25419. */
  25420. static EdgeDetect2Kernel: number[];
  25421. /**
  25422. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25423. */
  25424. static SharpenKernel: number[];
  25425. /**
  25426. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25427. */
  25428. static EmbossKernel: number[];
  25429. /**
  25430. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25431. */
  25432. static GaussianKernel: number[];
  25433. }
  25434. }
  25435. declare module BABYLON {
  25436. /**
  25437. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25438. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25439. * based on samples that have a large difference in distance than the center pixel.
  25440. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25441. */
  25442. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25443. direction: Vector2;
  25444. /**
  25445. * Creates a new instance CircleOfConfusionPostProcess
  25446. * @param name The name of the effect.
  25447. * @param scene The scene the effect belongs to.
  25448. * @param direction The direction the blur should be applied.
  25449. * @param kernel The size of the kernel used to blur.
  25450. * @param options The required width/height ratio to downsize to before computing the render pass.
  25451. * @param camera The camera to apply the render pass to.
  25452. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25453. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25455. * @param engine The engine which the post process will be applied. (default: current engine)
  25456. * @param reusable If the post process can be reused on the same frame. (default: false)
  25457. * @param textureType Type of textures used when performing the post process. (default: 0)
  25458. * @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)
  25459. */
  25460. 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);
  25461. }
  25462. }
  25463. declare module BABYLON {
  25464. /**
  25465. * Specifies the level of max blur that should be applied when using the depth of field effect
  25466. */
  25467. enum DepthOfFieldEffectBlurLevel {
  25468. /**
  25469. * Subtle blur
  25470. */
  25471. Low = 0,
  25472. /**
  25473. * Medium blur
  25474. */
  25475. Medium = 1,
  25476. /**
  25477. * Large blur
  25478. */
  25479. High = 2,
  25480. }
  25481. /**
  25482. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25483. */
  25484. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25485. private _circleOfConfusion;
  25486. /**
  25487. * Internal, blurs from high to low
  25488. */
  25489. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25490. private _depthOfFieldBlurY;
  25491. private _dofMerge;
  25492. /**
  25493. * Internal post processes in depth of field effect
  25494. */
  25495. _effects: Array<PostProcess>;
  25496. /**
  25497. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25498. */
  25499. focalLength: number;
  25500. /**
  25501. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25502. */
  25503. fStop: number;
  25504. /**
  25505. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25506. */
  25507. focusDistance: number;
  25508. /**
  25509. * 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.
  25510. */
  25511. lensSize: number;
  25512. /**
  25513. * Creates a new instance DepthOfFieldEffect
  25514. * @param scene The scene the effect belongs to.
  25515. * @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.
  25516. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25517. * @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)
  25518. */
  25519. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25520. /**
  25521. * 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.
  25522. */
  25523. depthTexture: RenderTargetTexture;
  25524. /**
  25525. * Disposes each of the internal effects for a given camera.
  25526. * @param camera The camera to dispose the effect on.
  25527. */
  25528. disposeEffects(camera: Camera): void;
  25529. /**
  25530. * Internal
  25531. */
  25532. _updateEffects(): void;
  25533. /**
  25534. * Internal
  25535. * @returns if all the contained post processes are ready.
  25536. */
  25537. _isReady(): boolean;
  25538. }
  25539. }
  25540. declare module BABYLON {
  25541. /**
  25542. * Options to be set when merging outputs from the default pipeline.
  25543. */
  25544. class DepthOfFieldMergePostProcessOptions {
  25545. /**
  25546. * The original image to merge on top of
  25547. */
  25548. originalFromInput: PostProcess;
  25549. /**
  25550. * Parameters to perform the merge of the depth of field effect
  25551. */
  25552. depthOfField?: {
  25553. circleOfConfusion: PostProcess;
  25554. blurSteps: Array<PostProcess>;
  25555. };
  25556. /**
  25557. * Parameters to perform the merge of bloom effect
  25558. */
  25559. bloom?: {
  25560. blurred: PostProcess;
  25561. weight: number;
  25562. };
  25563. }
  25564. /**
  25565. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25566. */
  25567. class DepthOfFieldMergePostProcess extends PostProcess {
  25568. private blurSteps;
  25569. /**
  25570. * Creates a new instance of DepthOfFieldMergePostProcess
  25571. * @param name The name of the effect.
  25572. * @param originalFromInput Post process which's input will be used for the merge.
  25573. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25574. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25575. * @param options The required width/height ratio to downsize to before computing the render pass.
  25576. * @param camera The camera to apply the render pass to.
  25577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25578. * @param engine The engine which the post process will be applied. (default: current engine)
  25579. * @param reusable If the post process can be reused on the same frame. (default: false)
  25580. * @param textureType Type of textures used when performing the post process. (default: 0)
  25581. * @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)
  25582. */
  25583. 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);
  25584. /**
  25585. * Updates the effect with the current post process compile time values and recompiles the shader.
  25586. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25587. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25588. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25589. * @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
  25590. * @param onCompiled Called when the shader has been compiled.
  25591. * @param onError Called if there is an error when compiling a shader.
  25592. */
  25593. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25594. }
  25595. }
  25596. declare module BABYLON {
  25597. class DisplayPassPostProcess extends PostProcess {
  25598. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25599. }
  25600. }
  25601. declare module BABYLON {
  25602. /**
  25603. * 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.
  25604. */
  25605. class ExtractHighlightsPostProcess extends PostProcess {
  25606. /**
  25607. * The luminance threshold, pixels below this value will be set to black.
  25608. */
  25609. threshold: number;
  25610. /**
  25611. * Internal
  25612. */
  25613. _exposure: number;
  25614. /**
  25615. * Post process which has the input texture to be used when performing highlight extraction
  25616. */
  25617. _inputPostProcess: Nullable<PostProcess>;
  25618. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25619. }
  25620. }
  25621. declare module BABYLON {
  25622. class FilterPostProcess extends PostProcess {
  25623. kernelMatrix: Matrix;
  25624. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25625. }
  25626. }
  25627. declare module BABYLON {
  25628. class FxaaPostProcess extends PostProcess {
  25629. texelWidth: number;
  25630. texelHeight: number;
  25631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25632. private _getDefines();
  25633. }
  25634. }
  25635. declare module BABYLON {
  25636. /**
  25637. * The GrainPostProcess adds noise to the image at mid luminance levels
  25638. */
  25639. class GrainPostProcess extends PostProcess {
  25640. /**
  25641. * The intensity of the grain added (default: 30)
  25642. */
  25643. intensity: number;
  25644. /**
  25645. * If the grain should be randomized on every frame
  25646. */
  25647. animated: boolean;
  25648. /**
  25649. * Creates a new instance of @see GrainPostProcess
  25650. * @param name The name of the effect.
  25651. * @param options The required width/height ratio to downsize to before computing the render pass.
  25652. * @param camera The camera to apply the render pass to.
  25653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25654. * @param engine The engine which the post process will be applied. (default: current engine)
  25655. * @param reusable If the post process can be reused on the same frame. (default: false)
  25656. * @param textureType Type of textures used when performing the post process. (default: 0)
  25657. * @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)
  25658. */
  25659. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25660. }
  25661. }
  25662. declare module BABYLON {
  25663. class HighlightsPostProcess extends PostProcess {
  25664. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25665. }
  25666. }
  25667. declare module BABYLON {
  25668. class ImageProcessingPostProcess extends PostProcess {
  25669. /**
  25670. * Default configuration related to image processing available in the PBR Material.
  25671. */
  25672. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25673. /**
  25674. * Gets the image processing configuration used either in this material.
  25675. */
  25676. /**
  25677. * Sets the Default image processing configuration used either in the this material.
  25678. *
  25679. * If sets to null, the scene one is in use.
  25680. */
  25681. imageProcessingConfiguration: ImageProcessingConfiguration;
  25682. /**
  25683. * Keep track of the image processing observer to allow dispose and replace.
  25684. */
  25685. private _imageProcessingObserver;
  25686. /**
  25687. * Attaches a new image processing configuration to the PBR Material.
  25688. * @param configuration
  25689. */
  25690. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25691. /**
  25692. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25693. */
  25694. /**
  25695. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25696. */
  25697. colorCurves: Nullable<ColorCurves>;
  25698. /**
  25699. * Gets wether the color curves effect is enabled.
  25700. */
  25701. /**
  25702. * Sets wether the color curves effect is enabled.
  25703. */
  25704. colorCurvesEnabled: boolean;
  25705. /**
  25706. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25707. */
  25708. /**
  25709. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25710. */
  25711. colorGradingTexture: Nullable<BaseTexture>;
  25712. /**
  25713. * Gets wether the color grading effect is enabled.
  25714. */
  25715. /**
  25716. * Gets wether the color grading effect is enabled.
  25717. */
  25718. colorGradingEnabled: boolean;
  25719. /**
  25720. * Gets exposure used in the effect.
  25721. */
  25722. /**
  25723. * Sets exposure used in the effect.
  25724. */
  25725. exposure: number;
  25726. /**
  25727. * Gets wether tonemapping is enabled or not.
  25728. */
  25729. /**
  25730. * Sets wether tonemapping is enabled or not
  25731. */
  25732. toneMappingEnabled: boolean;
  25733. /**
  25734. * Gets contrast used in the effect.
  25735. */
  25736. /**
  25737. * Sets contrast used in the effect.
  25738. */
  25739. contrast: number;
  25740. /**
  25741. * Gets Vignette stretch size.
  25742. */
  25743. /**
  25744. * Sets Vignette stretch size.
  25745. */
  25746. vignetteStretch: number;
  25747. /**
  25748. * Gets Vignette centre X Offset.
  25749. */
  25750. /**
  25751. * Sets Vignette centre X Offset.
  25752. */
  25753. vignetteCentreX: number;
  25754. /**
  25755. * Gets Vignette centre Y Offset.
  25756. */
  25757. /**
  25758. * Sets Vignette centre Y Offset.
  25759. */
  25760. vignetteCentreY: number;
  25761. /**
  25762. * Gets Vignette weight or intensity of the vignette effect.
  25763. */
  25764. /**
  25765. * Sets Vignette weight or intensity of the vignette effect.
  25766. */
  25767. vignetteWeight: number;
  25768. /**
  25769. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25770. * if vignetteEnabled is set to true.
  25771. */
  25772. /**
  25773. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25774. * if vignetteEnabled is set to true.
  25775. */
  25776. vignetteColor: Color4;
  25777. /**
  25778. * Gets Camera field of view used by the Vignette effect.
  25779. */
  25780. /**
  25781. * Sets Camera field of view used by the Vignette effect.
  25782. */
  25783. vignetteCameraFov: number;
  25784. /**
  25785. * Gets the vignette blend mode allowing different kind of effect.
  25786. */
  25787. /**
  25788. * Sets the vignette blend mode allowing different kind of effect.
  25789. */
  25790. vignetteBlendMode: number;
  25791. /**
  25792. * Gets wether the vignette effect is enabled.
  25793. */
  25794. /**
  25795. * Sets wether the vignette effect is enabled.
  25796. */
  25797. vignetteEnabled: boolean;
  25798. private _fromLinearSpace;
  25799. /**
  25800. * Gets wether the input of the processing is in Gamma or Linear Space.
  25801. */
  25802. /**
  25803. * Sets wether the input of the processing is in Gamma or Linear Space.
  25804. */
  25805. fromLinearSpace: boolean;
  25806. /**
  25807. * Defines cache preventing GC.
  25808. */
  25809. private _defines;
  25810. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25811. getClassName(): string;
  25812. protected _updateParameters(): void;
  25813. dispose(camera?: Camera): void;
  25814. }
  25815. }
  25816. declare module BABYLON {
  25817. class PassPostProcess extends PostProcess {
  25818. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25819. }
  25820. }
  25821. declare module BABYLON {
  25822. type PostProcessOptions = {
  25823. width: number;
  25824. height: number;
  25825. };
  25826. /**
  25827. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25828. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25829. */
  25830. class PostProcess {
  25831. /** Name of the PostProcess. */ name: string;
  25832. /**
  25833. * Width of the texture to apply the post process on
  25834. */
  25835. width: number;
  25836. /**
  25837. * Height of the texture to apply the post process on
  25838. */
  25839. height: number;
  25840. /**
  25841. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25842. */
  25843. _outputTexture: Nullable<InternalTexture>;
  25844. /**
  25845. * Sampling mode used by the shader
  25846. * See https://doc.babylonjs.com/classes/3.1/texture
  25847. */
  25848. renderTargetSamplingMode: number;
  25849. /**
  25850. * Clear color to use when screen clearing
  25851. */
  25852. clearColor: Color4;
  25853. /**
  25854. * If the buffer needs to be cleared before applying the post process. (default: true)
  25855. * Should be set to false if shader will overwrite all previous pixels.
  25856. */
  25857. autoClear: boolean;
  25858. /**
  25859. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  25860. */
  25861. alphaMode: number;
  25862. /**
  25863. * Sets the setAlphaBlendConstants of the babylon engine
  25864. */
  25865. alphaConstants: Color4;
  25866. /**
  25867. * Animations to be used for the post processing
  25868. */
  25869. animations: Animation[];
  25870. /**
  25871. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  25872. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  25873. */
  25874. enablePixelPerfectMode: boolean;
  25875. /**
  25876. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  25877. */
  25878. scaleMode: number;
  25879. /**
  25880. * Force textures to be a power of two (default: false)
  25881. */
  25882. alwaysForcePOT: boolean;
  25883. /**
  25884. * Number of sample textures (default: 1)
  25885. */
  25886. samples: number;
  25887. /**
  25888. * Modify the scale of the post process to be the same as the viewport (default: false)
  25889. */
  25890. adaptScaleToCurrentViewport: boolean;
  25891. private _camera;
  25892. private _scene;
  25893. private _engine;
  25894. private _options;
  25895. private _reusable;
  25896. private _textureType;
  25897. /**
  25898. * Smart array of input and output textures for the post process.
  25899. */
  25900. _textures: SmartArray<InternalTexture>;
  25901. /**
  25902. * The index in _textures that corresponds to the output texture.
  25903. */
  25904. _currentRenderTextureInd: number;
  25905. private _effect;
  25906. private _samplers;
  25907. private _fragmentUrl;
  25908. private _vertexUrl;
  25909. private _parameters;
  25910. private _scaleRatio;
  25911. protected _indexParameters: any;
  25912. private _shareOutputWithPostProcess;
  25913. private _texelSize;
  25914. private _forcedOutputTexture;
  25915. /**
  25916. * An event triggered when the postprocess is activated.
  25917. */
  25918. onActivateObservable: Observable<Camera>;
  25919. private _onActivateObserver;
  25920. /**
  25921. * A function that is added to the onActivateObservable
  25922. */
  25923. onActivate: Nullable<(camera: Camera) => void>;
  25924. /**
  25925. * An event triggered when the postprocess changes its size.
  25926. */
  25927. onSizeChangedObservable: Observable<PostProcess>;
  25928. private _onSizeChangedObserver;
  25929. /**
  25930. * A function that is added to the onSizeChangedObservable
  25931. */
  25932. onSizeChanged: (postProcess: PostProcess) => void;
  25933. /**
  25934. * An event triggered when the postprocess applies its effect.
  25935. */
  25936. onApplyObservable: Observable<Effect>;
  25937. private _onApplyObserver;
  25938. /**
  25939. * A function that is added to the onApplyObservable
  25940. */
  25941. onApply: (effect: Effect) => void;
  25942. /**
  25943. * An event triggered before rendering the postprocess
  25944. */
  25945. onBeforeRenderObservable: Observable<Effect>;
  25946. private _onBeforeRenderObserver;
  25947. /**
  25948. * A function that is added to the onBeforeRenderObservable
  25949. */
  25950. onBeforeRender: (effect: Effect) => void;
  25951. /**
  25952. * An event triggered after rendering the postprocess
  25953. */
  25954. onAfterRenderObservable: Observable<Effect>;
  25955. private _onAfterRenderObserver;
  25956. /**
  25957. * A function that is added to the onAfterRenderObservable
  25958. */
  25959. onAfterRender: (efect: Effect) => void;
  25960. /**
  25961. * 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
  25962. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  25963. */
  25964. inputTexture: InternalTexture;
  25965. /**
  25966. * Gets the camera which post process is applied to.
  25967. * @returns The camera the post process is applied to.
  25968. */
  25969. getCamera(): Camera;
  25970. /**
  25971. * Gets the texel size of the postprocess.
  25972. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  25973. */
  25974. readonly texelSize: Vector2;
  25975. /**
  25976. * Creates a new instance PostProcess
  25977. * @param name The name of the PostProcess.
  25978. * @param fragmentUrl The url of the fragment shader to be used.
  25979. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  25980. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  25981. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25982. * @param camera The camera to apply the render pass to.
  25983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25984. * @param engine The engine which the post process will be applied. (default: current engine)
  25985. * @param reusable If the post process can be reused on the same frame. (default: false)
  25986. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  25987. * @param textureType Type of textures used when performing the post process. (default: 0)
  25988. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  25989. * @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
  25990. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  25991. */
  25992. 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);
  25993. /**
  25994. * Gets the engine which this post process belongs to.
  25995. * @returns The engine the post process was enabled with.
  25996. */
  25997. getEngine(): Engine;
  25998. /**
  25999. * The effect that is created when initializing the post process.
  26000. * @returns The created effect corrisponding the the postprocess.
  26001. */
  26002. getEffect(): Effect;
  26003. /**
  26004. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26005. * @param postProcess The post process to share the output with.
  26006. * @returns This post process.
  26007. */
  26008. shareOutputWith(postProcess: PostProcess): PostProcess;
  26009. /**
  26010. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26011. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26012. */
  26013. useOwnOutput(): void;
  26014. /**
  26015. * Updates the effect with the current post process compile time values and recompiles the shader.
  26016. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26017. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26018. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26019. * @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
  26020. * @param onCompiled Called when the shader has been compiled.
  26021. * @param onError Called if there is an error when compiling a shader.
  26022. */
  26023. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26024. /**
  26025. * The post process is reusable if it can be used multiple times within one frame.
  26026. * @returns If the post process is reusable
  26027. */
  26028. isReusable(): boolean;
  26029. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26030. markTextureDirty(): void;
  26031. /**
  26032. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26033. * 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.
  26034. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26035. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26036. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26037. * @returns The target texture that was bound to be written to.
  26038. */
  26039. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26040. /**
  26041. * If the post process is supported.
  26042. */
  26043. readonly isSupported: boolean;
  26044. /**
  26045. * The aspect ratio of the output texture.
  26046. */
  26047. readonly aspectRatio: number;
  26048. /**
  26049. * Get a value indicating if the post-process is ready to be used
  26050. * @returns true if the post-process is ready (shader is compiled)
  26051. */
  26052. isReady(): boolean;
  26053. /**
  26054. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26055. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26056. */
  26057. apply(): Nullable<Effect>;
  26058. private _disposeTextures();
  26059. /**
  26060. * Disposes the post process.
  26061. * @param camera The camera to dispose the post process on.
  26062. */
  26063. dispose(camera?: Camera): void;
  26064. }
  26065. }
  26066. declare module BABYLON {
  26067. /**
  26068. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26069. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26070. */
  26071. class PostProcessManager {
  26072. private _scene;
  26073. private _indexBuffer;
  26074. private _vertexBuffers;
  26075. /**
  26076. * Creates a new instance PostProcess
  26077. * @param scene The scene that the post process is associated with.
  26078. */
  26079. constructor(scene: Scene);
  26080. private _prepareBuffers();
  26081. private _buildIndexBuffer();
  26082. /**
  26083. * Rebuilds the vertex buffers of the manager.
  26084. */
  26085. _rebuild(): void;
  26086. /**
  26087. * Prepares a frame to be run through a post process.
  26088. * @param sourceTexture The input texture to the post procesess. (default: null)
  26089. * @param postProcesses An array of post processes to be run. (default: null)
  26090. * @returns True if the post processes were able to be run.
  26091. */
  26092. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26093. /**
  26094. * Manually render a set of post processes to a texture.
  26095. * @param postProcesses An array of post processes to be run.
  26096. * @param targetTexture The target texture to render to.
  26097. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26098. */
  26099. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26100. /**
  26101. * Finalize the result of the output of the postprocesses.
  26102. * @param doNotPresent If true the result will not be displayed to the screen.
  26103. * @param targetTexture The target texture to render to.
  26104. * @param faceIndex The index of the face to bind the target texture to.
  26105. * @param postProcesses The array of post processes to render.
  26106. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26107. */
  26108. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26109. /**
  26110. * Disposes of the post process manager.
  26111. */
  26112. dispose(): void;
  26113. }
  26114. }
  26115. declare module BABYLON {
  26116. class RefractionPostProcess extends PostProcess {
  26117. color: Color3;
  26118. depth: number;
  26119. colorLevel: number;
  26120. private _refTexture;
  26121. private _ownRefractionTexture;
  26122. /**
  26123. * Gets or sets the refraction texture
  26124. * Please note that you are responsible for disposing the texture if you set it manually
  26125. */
  26126. refractionTexture: Texture;
  26127. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26128. dispose(camera: Camera): void;
  26129. }
  26130. }
  26131. declare module BABYLON {
  26132. /**
  26133. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26134. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26135. */
  26136. class SharpenPostProcess extends PostProcess {
  26137. /**
  26138. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26139. */
  26140. colorAmount: number;
  26141. /**
  26142. * How much sharpness should be applied (default: 0.3)
  26143. */
  26144. edgeAmount: number;
  26145. /**
  26146. * Creates a new instance ConvolutionPostProcess
  26147. * @param name The name of the effect.
  26148. * @param options The required width/height ratio to downsize to before computing the render pass.
  26149. * @param camera The camera to apply the render pass to.
  26150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26151. * @param engine The engine which the post process will be applied. (default: current engine)
  26152. * @param reusable If the post process can be reused on the same frame. (default: false)
  26153. * @param textureType Type of textures used when performing the post process. (default: 0)
  26154. * @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)
  26155. */
  26156. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26157. }
  26158. }
  26159. declare module BABYLON {
  26160. class StereoscopicInterlacePostProcess extends PostProcess {
  26161. private _stepSize;
  26162. private _passedProcess;
  26163. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26164. }
  26165. }
  26166. declare module BABYLON {
  26167. /** Defines operator used for tonemapping */
  26168. enum TonemappingOperator {
  26169. /** Hable */
  26170. Hable = 0,
  26171. /** Reinhard */
  26172. Reinhard = 1,
  26173. /** HejiDawson */
  26174. HejiDawson = 2,
  26175. /** Photographic */
  26176. Photographic = 3,
  26177. }
  26178. /**
  26179. * Defines a post process to apply tone mapping
  26180. */
  26181. class TonemapPostProcess extends PostProcess {
  26182. private _operator;
  26183. /** Defines the required exposure adjustement */
  26184. exposureAdjustment: number;
  26185. /**
  26186. * Creates a new TonemapPostProcess
  26187. * @param name defines the name of the postprocess
  26188. * @param _operator defines the operator to use
  26189. * @param exposureAdjustment defines the required exposure adjustement
  26190. * @param camera defines the camera to use (can be null)
  26191. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26192. * @param engine defines the hosting engine (can be ignore if camera is set)
  26193. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26194. */
  26195. constructor(name: string, _operator: TonemappingOperator,
  26196. /** Defines the required exposure adjustement */
  26197. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26198. }
  26199. }
  26200. declare module BABYLON {
  26201. class VolumetricLightScatteringPostProcess extends PostProcess {
  26202. private _volumetricLightScatteringPass;
  26203. private _volumetricLightScatteringRTT;
  26204. private _viewPort;
  26205. private _screenCoordinates;
  26206. private _cachedDefines;
  26207. /**
  26208. * If not undefined, the mesh position is computed from the attached node position
  26209. */
  26210. attachedNode: {
  26211. position: Vector3;
  26212. };
  26213. /**
  26214. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26215. */
  26216. customMeshPosition: Vector3;
  26217. /**
  26218. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26219. */
  26220. useCustomMeshPosition: boolean;
  26221. /**
  26222. * If the post-process should inverse the light scattering direction
  26223. */
  26224. invert: boolean;
  26225. /**
  26226. * The internal mesh used by the post-process
  26227. */
  26228. mesh: Mesh;
  26229. useDiffuseColor: boolean;
  26230. /**
  26231. * Array containing the excluded meshes not rendered in the internal pass
  26232. */
  26233. excludedMeshes: AbstractMesh[];
  26234. /**
  26235. * Controls the overall intensity of the post-process
  26236. */
  26237. exposure: number;
  26238. /**
  26239. * Dissipates each sample's contribution in range [0, 1]
  26240. */
  26241. decay: number;
  26242. /**
  26243. * Controls the overall intensity of each sample
  26244. */
  26245. weight: number;
  26246. /**
  26247. * Controls the density of each sample
  26248. */
  26249. density: number;
  26250. /**
  26251. * @constructor
  26252. * @param {string} name - The post-process name
  26253. * @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)
  26254. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26255. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26256. * @param {number} samples - The post-process quality, default 100
  26257. * @param {number} samplingMode - The post-process filtering mode
  26258. * @param {BABYLON.Engine} engine - The babylon engine
  26259. * @param {boolean} reusable - If the post-process is reusable
  26260. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26261. */
  26262. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26263. getClassName(): string;
  26264. private _isReady(subMesh, useInstances);
  26265. /**
  26266. * Sets the new light position for light scattering effect
  26267. * @param {BABYLON.Vector3} The new custom light position
  26268. */
  26269. setCustomMeshPosition(position: Vector3): void;
  26270. /**
  26271. * Returns the light position for light scattering effect
  26272. * @return {BABYLON.Vector3} The custom light position
  26273. */
  26274. getCustomMeshPosition(): Vector3;
  26275. /**
  26276. * Disposes the internal assets and detaches the post-process from the camera
  26277. */
  26278. dispose(camera: Camera): void;
  26279. /**
  26280. * Returns the render target texture used by the post-process
  26281. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26282. */
  26283. getPass(): RenderTargetTexture;
  26284. private _meshExcluded(mesh);
  26285. private _createPass(scene, ratio);
  26286. private _updateMeshScreenCoordinates(scene);
  26287. /**
  26288. * Creates a default mesh for the Volumeric Light Scattering post-process
  26289. * @param {string} The mesh name
  26290. * @param {BABYLON.Scene} The scene where to create the mesh
  26291. * @return {BABYLON.Mesh} the default mesh
  26292. */
  26293. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26294. }
  26295. }
  26296. declare module BABYLON {
  26297. class VRDistortionCorrectionPostProcess extends PostProcess {
  26298. private _isRightEye;
  26299. private _distortionFactors;
  26300. private _postProcessScaleFactor;
  26301. private _lensCenterOffset;
  26302. private _scaleIn;
  26303. private _scaleFactor;
  26304. private _lensCenter;
  26305. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26306. }
  26307. }
  26308. declare module BABYLON {
  26309. class Sprite {
  26310. name: string;
  26311. position: Vector3;
  26312. color: Color4;
  26313. width: number;
  26314. height: number;
  26315. angle: number;
  26316. cellIndex: number;
  26317. invertU: number;
  26318. invertV: number;
  26319. disposeWhenFinishedAnimating: boolean;
  26320. animations: Animation[];
  26321. isPickable: boolean;
  26322. actionManager: ActionManager;
  26323. private _animationStarted;
  26324. private _loopAnimation;
  26325. private _fromIndex;
  26326. private _toIndex;
  26327. private _delay;
  26328. private _direction;
  26329. private _manager;
  26330. private _time;
  26331. private _onAnimationEnd;
  26332. size: number;
  26333. constructor(name: string, manager: SpriteManager);
  26334. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26335. stopAnimation(): void;
  26336. _animate(deltaTime: number): void;
  26337. dispose(): void;
  26338. }
  26339. }
  26340. declare module BABYLON {
  26341. class SpriteManager {
  26342. name: string;
  26343. sprites: Sprite[];
  26344. renderingGroupId: number;
  26345. layerMask: number;
  26346. fogEnabled: boolean;
  26347. isPickable: boolean;
  26348. cellWidth: number;
  26349. cellHeight: number;
  26350. /**
  26351. * An event triggered when the manager is disposed.
  26352. */
  26353. onDisposeObservable: Observable<SpriteManager>;
  26354. private _onDisposeObserver;
  26355. onDispose: () => void;
  26356. private _capacity;
  26357. private _spriteTexture;
  26358. private _epsilon;
  26359. private _scene;
  26360. private _vertexData;
  26361. private _buffer;
  26362. private _vertexBuffers;
  26363. private _indexBuffer;
  26364. private _effectBase;
  26365. private _effectFog;
  26366. texture: Texture;
  26367. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26368. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26369. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26370. render(): void;
  26371. dispose(): void;
  26372. }
  26373. }
  26374. declare module BABYLON {
  26375. /**
  26376. * @hidden
  26377. **/
  26378. class _AlphaState {
  26379. private _isAlphaBlendDirty;
  26380. private _isBlendFunctionParametersDirty;
  26381. private _isBlendEquationParametersDirty;
  26382. private _isBlendConstantsDirty;
  26383. private _alphaBlend;
  26384. private _blendFunctionParameters;
  26385. private _blendEquationParameters;
  26386. private _blendConstants;
  26387. /**
  26388. * Initializes the state.
  26389. */
  26390. constructor();
  26391. readonly isDirty: boolean;
  26392. alphaBlend: boolean;
  26393. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26394. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26395. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26396. reset(): void;
  26397. apply(gl: WebGLRenderingContext): void;
  26398. }
  26399. }
  26400. declare module BABYLON {
  26401. /**
  26402. * @hidden
  26403. **/
  26404. class _DepthCullingState {
  26405. private _isDepthTestDirty;
  26406. private _isDepthMaskDirty;
  26407. private _isDepthFuncDirty;
  26408. private _isCullFaceDirty;
  26409. private _isCullDirty;
  26410. private _isZOffsetDirty;
  26411. private _isFrontFaceDirty;
  26412. private _depthTest;
  26413. private _depthMask;
  26414. private _depthFunc;
  26415. private _cull;
  26416. private _cullFace;
  26417. private _zOffset;
  26418. private _frontFace;
  26419. /**
  26420. * Initializes the state.
  26421. */
  26422. constructor();
  26423. readonly isDirty: boolean;
  26424. zOffset: number;
  26425. cullFace: Nullable<number>;
  26426. cull: Nullable<boolean>;
  26427. depthFunc: Nullable<number>;
  26428. depthMask: boolean;
  26429. depthTest: boolean;
  26430. frontFace: Nullable<number>;
  26431. reset(): void;
  26432. apply(gl: WebGLRenderingContext): void;
  26433. }
  26434. }
  26435. declare module BABYLON {
  26436. /**
  26437. * @hidden
  26438. **/
  26439. class _StencilState {
  26440. private _isStencilTestDirty;
  26441. private _isStencilMaskDirty;
  26442. private _isStencilFuncDirty;
  26443. private _isStencilOpDirty;
  26444. private _stencilTest;
  26445. private _stencilMask;
  26446. private _stencilFunc;
  26447. private _stencilFuncRef;
  26448. private _stencilFuncMask;
  26449. private _stencilOpStencilFail;
  26450. private _stencilOpDepthFail;
  26451. private _stencilOpStencilDepthPass;
  26452. readonly isDirty: boolean;
  26453. stencilFunc: number;
  26454. stencilFuncRef: number;
  26455. stencilFuncMask: number;
  26456. stencilOpStencilFail: number;
  26457. stencilOpDepthFail: number;
  26458. stencilOpStencilDepthPass: number;
  26459. stencilMask: number;
  26460. stencilTest: boolean;
  26461. constructor();
  26462. reset(): void;
  26463. apply(gl: WebGLRenderingContext): void;
  26464. }
  26465. }
  26466. declare module BABYLON {
  26467. /**
  26468. * Class used to evalaute queries containing `and` and `or` operators
  26469. */
  26470. class AndOrNotEvaluator {
  26471. /**
  26472. * Evaluate a query
  26473. * @param query defines the query to evaluate
  26474. * @param evaluateCallback defines the callback used to filter result
  26475. * @returns true if the query matches
  26476. */
  26477. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26478. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26479. private static _SimplifyNegation(booleanString);
  26480. }
  26481. }
  26482. declare module BABYLON {
  26483. /**
  26484. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26485. */
  26486. enum AssetTaskState {
  26487. /**
  26488. * Initialization
  26489. */
  26490. INIT = 0,
  26491. /**
  26492. * Running
  26493. */
  26494. RUNNING = 1,
  26495. /**
  26496. * Done
  26497. */
  26498. DONE = 2,
  26499. /**
  26500. * Error
  26501. */
  26502. ERROR = 3,
  26503. }
  26504. /**
  26505. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26506. */
  26507. abstract class AbstractAssetTask {
  26508. /**
  26509. * Task name
  26510. */ name: string;
  26511. /**
  26512. * Callback called when the task is successful
  26513. */
  26514. onSuccess: (task: any) => void;
  26515. /**
  26516. * Callback called when the task is not successful
  26517. */
  26518. onError: (task: any, message?: string, exception?: any) => void;
  26519. /**
  26520. * Creates a new {BABYLON.AssetsManager}
  26521. * @param name defines the name of the task
  26522. */
  26523. constructor(
  26524. /**
  26525. * Task name
  26526. */ name: string);
  26527. private _isCompleted;
  26528. private _taskState;
  26529. private _errorObject;
  26530. /**
  26531. * Get if the task is completed
  26532. */
  26533. readonly isCompleted: boolean;
  26534. /**
  26535. * Gets the current state of the task
  26536. */
  26537. readonly taskState: AssetTaskState;
  26538. /**
  26539. * Gets the current error object (if task is in error)
  26540. */
  26541. readonly errorObject: {
  26542. message?: string;
  26543. exception?: any;
  26544. };
  26545. /**
  26546. * Internal only
  26547. * @hidden
  26548. */
  26549. _setErrorObject(message?: string, exception?: any): void;
  26550. /**
  26551. * Execute the current task
  26552. * @param scene defines the scene where you want your assets to be loaded
  26553. * @param onSuccess is a callback called when the task is successfully executed
  26554. * @param onError is a callback called if an error occurs
  26555. */
  26556. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26557. /**
  26558. * Execute the current task
  26559. * @param scene defines the scene where you want your assets to be loaded
  26560. * @param onSuccess is a callback called when the task is successfully executed
  26561. * @param onError is a callback called if an error occurs
  26562. */
  26563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26564. private onErrorCallback(onError, message?, exception?);
  26565. private onDoneCallback(onSuccess, onError);
  26566. }
  26567. /**
  26568. * Define the interface used by progress events raised during assets loading
  26569. */
  26570. interface IAssetsProgressEvent {
  26571. /**
  26572. * Defines the number of remaining tasks to process
  26573. */
  26574. remainingCount: number;
  26575. /**
  26576. * Defines the total number of tasks
  26577. */
  26578. totalCount: number;
  26579. /**
  26580. * Defines the task that was just processed
  26581. */
  26582. task: AbstractAssetTask;
  26583. }
  26584. /**
  26585. * Class used to share progress information about assets loading
  26586. */
  26587. class AssetsProgressEvent implements IAssetsProgressEvent {
  26588. /**
  26589. * Defines the number of remaining tasks to process
  26590. */
  26591. remainingCount: number;
  26592. /**
  26593. * Defines the total number of tasks
  26594. */
  26595. totalCount: number;
  26596. /**
  26597. * Defines the task that was just processed
  26598. */
  26599. task: AbstractAssetTask;
  26600. /**
  26601. * Creates a {BABYLON.AssetsProgressEvent}
  26602. * @param remainingCount defines the number of remaining tasks to process
  26603. * @param totalCount defines the total number of tasks
  26604. * @param task defines the task that was just processed
  26605. */
  26606. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26607. }
  26608. /**
  26609. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26610. */
  26611. class MeshAssetTask extends AbstractAssetTask {
  26612. /**
  26613. * Defines the name of the task
  26614. */
  26615. name: string;
  26616. /**
  26617. * Defines the list of mesh's names you want to load
  26618. */
  26619. meshesNames: any;
  26620. /**
  26621. * Defines the root url to use as a base to load your meshes and associated resources
  26622. */
  26623. rootUrl: string;
  26624. /**
  26625. * Defines the filename of the scene to load from
  26626. */
  26627. sceneFilename: string;
  26628. /**
  26629. * Gets the list of loaded meshes
  26630. */
  26631. loadedMeshes: Array<AbstractMesh>;
  26632. /**
  26633. * Gets the list of loaded particle systems
  26634. */
  26635. loadedParticleSystems: Array<ParticleSystem>;
  26636. /**
  26637. * Gets the list of loaded skeletons
  26638. */
  26639. loadedSkeletons: Array<Skeleton>;
  26640. /**
  26641. * Callback called when the task is successful
  26642. */
  26643. onSuccess: (task: MeshAssetTask) => void;
  26644. /**
  26645. * Callback called when the task is successful
  26646. */
  26647. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26648. /**
  26649. * Creates a new {BABYLON.MeshAssetTask}
  26650. * @param name defines the name of the task
  26651. * @param meshesNames defines the list of mesh's names you want to load
  26652. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26653. * @param sceneFilename defines the filename of the scene to load from
  26654. */
  26655. constructor(
  26656. /**
  26657. * Defines the name of the task
  26658. */
  26659. name: string,
  26660. /**
  26661. * Defines the list of mesh's names you want to load
  26662. */
  26663. meshesNames: any,
  26664. /**
  26665. * Defines the root url to use as a base to load your meshes and associated resources
  26666. */
  26667. rootUrl: string,
  26668. /**
  26669. * Defines the filename of the scene to load from
  26670. */
  26671. sceneFilename: string);
  26672. /**
  26673. * Execute the current task
  26674. * @param scene defines the scene where you want your assets to be loaded
  26675. * @param onSuccess is a callback called when the task is successfully executed
  26676. * @param onError is a callback called if an error occurs
  26677. */
  26678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26679. }
  26680. /**
  26681. * Define a task used by {BABYLON.AssetsManager} to load text content
  26682. */
  26683. class TextFileAssetTask extends AbstractAssetTask {
  26684. /**
  26685. * Defines the name of the task
  26686. */
  26687. name: string;
  26688. /**
  26689. * Defines the location of the file to load
  26690. */
  26691. url: string;
  26692. /**
  26693. * Gets the loaded text string
  26694. */
  26695. text: string;
  26696. /**
  26697. * Callback called when the task is successful
  26698. */
  26699. onSuccess: (task: TextFileAssetTask) => void;
  26700. /**
  26701. * Callback called when the task is successful
  26702. */
  26703. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26704. /**
  26705. * Creates a new TextFileAssetTask object
  26706. * @param name defines the name of the task
  26707. * @param url defines the location of the file to load
  26708. */
  26709. constructor(
  26710. /**
  26711. * Defines the name of the task
  26712. */
  26713. name: string,
  26714. /**
  26715. * Defines the location of the file to load
  26716. */
  26717. url: string);
  26718. /**
  26719. * Execute the current task
  26720. * @param scene defines the scene where you want your assets to be loaded
  26721. * @param onSuccess is a callback called when the task is successfully executed
  26722. * @param onError is a callback called if an error occurs
  26723. */
  26724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26725. }
  26726. /**
  26727. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26728. */
  26729. class BinaryFileAssetTask extends AbstractAssetTask {
  26730. /**
  26731. * Defines the name of the task
  26732. */
  26733. name: string;
  26734. /**
  26735. * Defines the location of the file to load
  26736. */
  26737. url: string;
  26738. /**
  26739. * Gets the lodaded data (as an array buffer)
  26740. */
  26741. data: ArrayBuffer;
  26742. /**
  26743. * Callback called when the task is successful
  26744. */
  26745. onSuccess: (task: BinaryFileAssetTask) => void;
  26746. /**
  26747. * Callback called when the task is successful
  26748. */
  26749. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  26750. /**
  26751. * Creates a new BinaryFileAssetTask object
  26752. * @param name defines the name of the new task
  26753. * @param url defines the location of the file to load
  26754. */
  26755. constructor(
  26756. /**
  26757. * Defines the name of the task
  26758. */
  26759. name: string,
  26760. /**
  26761. * Defines the location of the file to load
  26762. */
  26763. url: string);
  26764. /**
  26765. * Execute the current task
  26766. * @param scene defines the scene where you want your assets to be loaded
  26767. * @param onSuccess is a callback called when the task is successfully executed
  26768. * @param onError is a callback called if an error occurs
  26769. */
  26770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26771. }
  26772. /**
  26773. * Define a task used by {BABYLON.AssetsManager} to load images
  26774. */
  26775. class ImageAssetTask extends AbstractAssetTask {
  26776. /**
  26777. * Defines the name of the task
  26778. */
  26779. name: string;
  26780. /**
  26781. * Defines the location of the image to load
  26782. */
  26783. url: string;
  26784. /**
  26785. * Gets the loaded images
  26786. */
  26787. image: HTMLImageElement;
  26788. /**
  26789. * Callback called when the task is successful
  26790. */
  26791. onSuccess: (task: ImageAssetTask) => void;
  26792. /**
  26793. * Callback called when the task is successful
  26794. */
  26795. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  26796. /**
  26797. * Creates a new ImageAssetTask
  26798. * @param name defines the name of the task
  26799. * @param url defines the location of the image to load
  26800. */
  26801. constructor(
  26802. /**
  26803. * Defines the name of the task
  26804. */
  26805. name: string,
  26806. /**
  26807. * Defines the location of the image to load
  26808. */
  26809. url: string);
  26810. /**
  26811. * Execute the current task
  26812. * @param scene defines the scene where you want your assets to be loaded
  26813. * @param onSuccess is a callback called when the task is successfully executed
  26814. * @param onError is a callback called if an error occurs
  26815. */
  26816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26817. }
  26818. /**
  26819. * Defines the interface used by texture loading tasks
  26820. */
  26821. interface ITextureAssetTask<TEX extends BaseTexture> {
  26822. /**
  26823. * Gets the loaded texture
  26824. */
  26825. texture: TEX;
  26826. }
  26827. /**
  26828. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  26829. */
  26830. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  26831. /**
  26832. * Defines the name of the task
  26833. */
  26834. name: string;
  26835. /**
  26836. * Defines the location of the file to load
  26837. */
  26838. url: string;
  26839. /**
  26840. * Defines if mipmap should not be generated (default is false)
  26841. */
  26842. noMipmap: boolean | undefined;
  26843. /**
  26844. * Defines if texture must be inverted on Y axis (default is false)
  26845. */
  26846. invertY: boolean | undefined;
  26847. /**
  26848. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26849. */
  26850. samplingMode: number;
  26851. /**
  26852. * Gets the loaded texture
  26853. */
  26854. texture: Texture;
  26855. /**
  26856. * Callback called when the task is successful
  26857. */
  26858. onSuccess: (task: TextureAssetTask) => void;
  26859. /**
  26860. * Callback called when the task is successful
  26861. */
  26862. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  26863. /**
  26864. * Creates a new TextureAssetTask object
  26865. * @param name defines the name of the task
  26866. * @param url defines the location of the file to load
  26867. * @param noMipmap defines if mipmap should not be generated (default is false)
  26868. * @param invertY defines if texture must be inverted on Y axis (default is false)
  26869. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26870. */
  26871. constructor(
  26872. /**
  26873. * Defines the name of the task
  26874. */
  26875. name: string,
  26876. /**
  26877. * Defines the location of the file to load
  26878. */
  26879. url: string,
  26880. /**
  26881. * Defines if mipmap should not be generated (default is false)
  26882. */
  26883. noMipmap?: boolean | undefined,
  26884. /**
  26885. * Defines if texture must be inverted on Y axis (default is false)
  26886. */
  26887. invertY?: boolean | undefined,
  26888. /**
  26889. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26890. */
  26891. samplingMode?: number);
  26892. /**
  26893. * Execute the current task
  26894. * @param scene defines the scene where you want your assets to be loaded
  26895. * @param onSuccess is a callback called when the task is successfully executed
  26896. * @param onError is a callback called if an error occurs
  26897. */
  26898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26899. }
  26900. /**
  26901. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  26902. */
  26903. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  26904. /**
  26905. * Defines the name of the task
  26906. */
  26907. name: string;
  26908. /**
  26909. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26910. */
  26911. url: string;
  26912. /**
  26913. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26914. */
  26915. extensions: string[] | undefined;
  26916. /**
  26917. * Defines if mipmaps should not be generated (default is false)
  26918. */
  26919. noMipmap: boolean | undefined;
  26920. /**
  26921. * Defines the explicit list of files (undefined by default)
  26922. */
  26923. files: string[] | undefined;
  26924. /**
  26925. * Gets the loaded texture
  26926. */
  26927. texture: CubeTexture;
  26928. /**
  26929. * Callback called when the task is successful
  26930. */
  26931. onSuccess: (task: CubeTextureAssetTask) => void;
  26932. /**
  26933. * Callback called when the task is successful
  26934. */
  26935. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  26936. /**
  26937. * Creates a new CubeTextureAssetTask
  26938. * @param name defines the name of the task
  26939. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26940. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26941. * @param noMipmap defines if mipmaps should not be generated (default is false)
  26942. * @param files defines the explicit list of files (undefined by default)
  26943. */
  26944. constructor(
  26945. /**
  26946. * Defines the name of the task
  26947. */
  26948. name: string,
  26949. /**
  26950. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26951. */
  26952. url: string,
  26953. /**
  26954. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26955. */
  26956. extensions?: string[] | undefined,
  26957. /**
  26958. * Defines if mipmaps should not be generated (default is false)
  26959. */
  26960. noMipmap?: boolean | undefined,
  26961. /**
  26962. * Defines the explicit list of files (undefined by default)
  26963. */
  26964. files?: string[] | undefined);
  26965. /**
  26966. * Execute the current task
  26967. * @param scene defines the scene where you want your assets to be loaded
  26968. * @param onSuccess is a callback called when the task is successfully executed
  26969. * @param onError is a callback called if an error occurs
  26970. */
  26971. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26972. }
  26973. /**
  26974. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  26975. */
  26976. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  26977. /**
  26978. * Defines the name of the task
  26979. */
  26980. name: string;
  26981. /**
  26982. * Defines the location of the file to load
  26983. */
  26984. url: string;
  26985. /**
  26986. * Defines the desired size (the more it increases the longer the generation will be)
  26987. */
  26988. size: number;
  26989. /**
  26990. * Defines if mipmaps should not be generated (default is false)
  26991. */
  26992. noMipmap: boolean;
  26993. /**
  26994. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  26995. */
  26996. generateHarmonics: boolean;
  26997. /**
  26998. * 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)
  26999. */
  27000. gammaSpace: boolean;
  27001. /**
  27002. * Internal Use Only
  27003. */
  27004. reserved: boolean;
  27005. /**
  27006. * Gets the loaded texture
  27007. */
  27008. texture: HDRCubeTexture;
  27009. /**
  27010. * Callback called when the task is successful
  27011. */
  27012. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27013. /**
  27014. * Callback called when the task is successful
  27015. */
  27016. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27017. /**
  27018. * Creates a new HDRCubeTextureAssetTask object
  27019. * @param name defines the name of the task
  27020. * @param url defines the location of the file to load
  27021. * @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.
  27022. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27023. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27024. * @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)
  27025. * @param reserved Internal use only
  27026. */
  27027. constructor(
  27028. /**
  27029. * Defines the name of the task
  27030. */
  27031. name: string,
  27032. /**
  27033. * Defines the location of the file to load
  27034. */
  27035. url: string,
  27036. /**
  27037. * Defines the desired size (the more it increases the longer the generation will be)
  27038. */
  27039. size: number,
  27040. /**
  27041. * Defines if mipmaps should not be generated (default is false)
  27042. */
  27043. noMipmap?: boolean,
  27044. /**
  27045. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27046. */
  27047. generateHarmonics?: boolean,
  27048. /**
  27049. * 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)
  27050. */
  27051. gammaSpace?: boolean,
  27052. /**
  27053. * Internal Use Only
  27054. */
  27055. reserved?: boolean);
  27056. /**
  27057. * Execute the current task
  27058. * @param scene defines the scene where you want your assets to be loaded
  27059. * @param onSuccess is a callback called when the task is successfully executed
  27060. * @param onError is a callback called if an error occurs
  27061. */
  27062. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27063. }
  27064. /**
  27065. * This class can be used to easily import assets into a scene
  27066. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27067. */
  27068. class AssetsManager {
  27069. private _scene;
  27070. private _isLoading;
  27071. protected _tasks: AbstractAssetTask[];
  27072. protected _waitingTasksCount: number;
  27073. protected _totalTasksCount: number;
  27074. /**
  27075. * Callback called when all tasks are processed
  27076. */
  27077. onFinish: (tasks: AbstractAssetTask[]) => void;
  27078. /**
  27079. * Callback called when a task is successful
  27080. */
  27081. onTaskSuccess: (task: AbstractAssetTask) => void;
  27082. /**
  27083. * Callback called when a task had an error
  27084. */
  27085. onTaskError: (task: AbstractAssetTask) => void;
  27086. /**
  27087. * Callback called when a task is done (whatever the result is)
  27088. */
  27089. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27090. /**
  27091. * Observable called when all tasks are processed
  27092. */
  27093. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27094. /**
  27095. * Observable called when a task had an error
  27096. */
  27097. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27098. /**
  27099. * Observable called when a task is successful
  27100. */
  27101. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27102. /**
  27103. * Observable called when a task is done (whatever the result is)
  27104. */
  27105. onProgressObservable: Observable<IAssetsProgressEvent>;
  27106. /**
  27107. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27109. */
  27110. useDefaultLoadingScreen: boolean;
  27111. /**
  27112. * Creates a new AssetsManager
  27113. * @param scene defines the scene to work on
  27114. */
  27115. constructor(scene: Scene);
  27116. /**
  27117. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27118. * @param taskName defines the name of the new task
  27119. * @param meshesNames defines the name of meshes to load
  27120. * @param rootUrl defines the root url to use to locate files
  27121. * @param sceneFilename defines the filename of the scene file
  27122. * @returns a new {BABYLON.MeshAssetTask} object
  27123. */
  27124. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27125. /**
  27126. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27127. * @param taskName defines the name of the new task
  27128. * @param url defines the url of the file to load
  27129. * @returns a new {BABYLON.TextFileAssetTask} object
  27130. */
  27131. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27132. /**
  27133. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27134. * @param taskName defines the name of the new task
  27135. * @param url defines the url of the file to load
  27136. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27137. */
  27138. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27139. /**
  27140. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27141. * @param taskName defines the name of the new task
  27142. * @param url defines the url of the file to load
  27143. * @returns a new {BABYLON.ImageAssetTask} object
  27144. */
  27145. addImageTask(taskName: string, url: string): ImageAssetTask;
  27146. /**
  27147. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27148. * @param taskName defines the name of the new task
  27149. * @param url defines the url of the file to load
  27150. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27151. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27152. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27153. * @returns a new {BABYLON.TextureAssetTask} object
  27154. */
  27155. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27156. /**
  27157. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27158. * @param taskName defines the name of the new task
  27159. * @param url defines the url of the file to load
  27160. * @param extensions defines the extension to use to load the cube map (can be null)
  27161. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27162. * @param files defines the list of files to load (can be null)
  27163. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27164. */
  27165. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27166. /**
  27167. *
  27168. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27169. * @param taskName defines the name of the new task
  27170. * @param url defines the url of the file to load
  27171. * @param size defines the size you want for the cubemap (can be null)
  27172. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27173. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27174. * @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)
  27175. * @param reserved Internal use only
  27176. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27177. */
  27178. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27179. private _decreaseWaitingTasksCount(task);
  27180. private _runTask(task);
  27181. /**
  27182. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27183. * @return the current instance of the {BABYLON.AssetsManager}
  27184. */
  27185. reset(): AssetsManager;
  27186. /**
  27187. * Start the loading process
  27188. * @return the current instance of the {BABYLON.AssetsManager}
  27189. */
  27190. load(): AssetsManager;
  27191. }
  27192. }
  27193. declare module BABYLON {
  27194. /**
  27195. * Class used to enable access to IndexedDB
  27196. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27197. */
  27198. class Database {
  27199. private callbackManifestChecked;
  27200. private currentSceneUrl;
  27201. private db;
  27202. private _enableSceneOffline;
  27203. private _enableTexturesOffline;
  27204. private manifestVersionFound;
  27205. private mustUpdateRessources;
  27206. private hasReachedQuota;
  27207. private isSupported;
  27208. private idbFactory;
  27209. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27210. static IsUASupportingBlobStorage: boolean;
  27211. /** Gets a boolean indicating if Database storate is enabled */
  27212. static IDBStorageEnabled: boolean;
  27213. /**
  27214. * Gets a boolean indicating if scene must be saved in the database
  27215. */
  27216. readonly enableSceneOffline: boolean;
  27217. /**
  27218. * Gets a boolean indicating if textures must be saved in the database
  27219. */
  27220. readonly enableTexturesOffline: boolean;
  27221. /**
  27222. * Creates a new Database
  27223. * @param urlToScene defines the url to load the scene
  27224. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27225. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27226. */
  27227. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27228. private static _ParseURL;
  27229. private static _ReturnFullUrlLocation;
  27230. private _checkManifestFile();
  27231. /**
  27232. * Open the database and make it available
  27233. * @param successCallback defines the callback to call on success
  27234. * @param errorCallback defines the callback to call on error
  27235. */
  27236. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27237. /**
  27238. * Loads an image from the database
  27239. * @param url defines the url to load from
  27240. * @param image defines the target DOM image
  27241. */
  27242. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27243. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27244. private _saveImageIntoDBAsync(url, image);
  27245. private _checkVersionFromDB(url, versionLoaded);
  27246. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27247. private _saveVersionIntoDBAsync(url, callback);
  27248. /**
  27249. * Loads a file from database
  27250. * @param url defines the URL to load from
  27251. * @param sceneLoaded defines a callback to call on success
  27252. * @param progressCallBack defines a callback to call when progress changed
  27253. * @param errorCallback defines a callback to call on error
  27254. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27255. */
  27256. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27257. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27258. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27259. }
  27260. }
  27261. declare module BABYLON {
  27262. interface DDSInfo {
  27263. width: number;
  27264. height: number;
  27265. mipmapCount: number;
  27266. isFourCC: boolean;
  27267. isRGB: boolean;
  27268. isLuminance: boolean;
  27269. isCube: boolean;
  27270. isCompressed: boolean;
  27271. dxgiFormat: number;
  27272. textureType: number;
  27273. /** Sphericle polynomial created for the dds texture */
  27274. sphericalPolynomial?: SphericalPolynomial;
  27275. }
  27276. class DDSTools {
  27277. static StoreLODInAlphaChannel: boolean;
  27278. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27279. private static _FloatView;
  27280. private static _Int32View;
  27281. private static _ToHalfFloat(value);
  27282. private static _FromHalfFloat(value);
  27283. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27284. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27285. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27286. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27287. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27288. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27289. private static _ExtractLongWordOrder(value);
  27290. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27291. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27292. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27293. }
  27294. }
  27295. declare module BABYLON {
  27296. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27297. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27298. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27299. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27300. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27301. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27302. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27303. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27304. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27305. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27306. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27307. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27308. /**
  27309. * Decorator used to define property that can be serialized as reference to a camera
  27310. * @param sourceName defines the name of the property to decorate
  27311. */
  27312. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27313. class SerializationHelper {
  27314. static Serialize<T>(entity: T, serializationObject?: any): any;
  27315. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27316. static Clone<T>(creationFunction: () => T, source: T): T;
  27317. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27318. }
  27319. }
  27320. declare module BABYLON {
  27321. /**
  27322. * Wrapper class for promise with external resolve and reject.
  27323. */
  27324. class Deferred<T> {
  27325. /**
  27326. * The promise associated with this deferred object.
  27327. */
  27328. readonly promise: Promise<T>;
  27329. private _resolve;
  27330. private _reject;
  27331. /**
  27332. * The resolve method of the promise associated with this deferred object.
  27333. */
  27334. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27335. /**
  27336. * The reject method of the promise associated with this deferred object.
  27337. */
  27338. readonly reject: (reason?: any) => void;
  27339. /**
  27340. * Constructor for this deferred object.
  27341. */
  27342. constructor();
  27343. }
  27344. }
  27345. declare module BABYLON {
  27346. class FilesInput {
  27347. static FilesToLoad: {
  27348. [key: string]: File;
  27349. };
  27350. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27351. private _engine;
  27352. private _currentScene;
  27353. private _sceneLoadedCallback;
  27354. private _progressCallback;
  27355. private _additionalRenderLoopLogicCallback;
  27356. private _textureLoadingCallback;
  27357. private _startingProcessingFilesCallback;
  27358. private _onReloadCallback;
  27359. private _errorCallback;
  27360. private _elementToMonitor;
  27361. private _sceneFileToLoad;
  27362. private _filesToLoad;
  27363. 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);
  27364. private _dragEnterHandler;
  27365. private _dragOverHandler;
  27366. private _dropHandler;
  27367. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27368. dispose(): void;
  27369. private renderFunction();
  27370. private drag(e);
  27371. private drop(eventDrop);
  27372. private _traverseFolder(folder, files, remaining, callback);
  27373. private _processFiles(files);
  27374. loadFiles(event: any): void;
  27375. private _processReload();
  27376. reload(): void;
  27377. }
  27378. }
  27379. declare module BABYLON {
  27380. /**
  27381. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27382. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27383. */
  27384. class KhronosTextureContainer {
  27385. arrayBuffer: any;
  27386. static HEADER_LEN: number;
  27387. static COMPRESSED_2D: number;
  27388. static COMPRESSED_3D: number;
  27389. static TEX_2D: number;
  27390. static TEX_3D: number;
  27391. glType: number;
  27392. glTypeSize: number;
  27393. glFormat: number;
  27394. glInternalFormat: number;
  27395. glBaseInternalFormat: number;
  27396. pixelWidth: number;
  27397. pixelHeight: number;
  27398. pixelDepth: number;
  27399. numberOfArrayElements: number;
  27400. numberOfFaces: number;
  27401. numberOfMipmapLevels: number;
  27402. bytesOfKeyValueData: number;
  27403. loadType: number;
  27404. /**
  27405. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27406. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27407. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27408. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27409. */
  27410. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27411. switchEndainness(val: number): number;
  27412. /**
  27413. * It is assumed that the texture has already been created & is currently bound
  27414. */
  27415. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27416. private _upload2DCompressedLevels(gl, loadMipmaps);
  27417. }
  27418. }
  27419. declare module BABYLON {
  27420. /**
  27421. * A class serves as a medium between the observable and its observers
  27422. */
  27423. class EventState {
  27424. /**
  27425. * Create a new EventState
  27426. * @param mask defines the mask associated with this state
  27427. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27428. * @param target defines the original target of the state
  27429. * @param currentTarget defines the current target of the state
  27430. */
  27431. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27432. /**
  27433. * Initialize the current event state
  27434. * @param mask defines the mask associated with this state
  27435. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27436. * @param target defines the original target of the state
  27437. * @param currentTarget defines the current target of the state
  27438. * @returns the current event state
  27439. */
  27440. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27441. /**
  27442. * An Observer can set this property to true to prevent subsequent observers of being notified
  27443. */
  27444. skipNextObservers: boolean;
  27445. /**
  27446. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27447. */
  27448. mask: number;
  27449. /**
  27450. * The object that originally notified the event
  27451. */
  27452. target?: any;
  27453. /**
  27454. * The current object in the bubbling phase
  27455. */
  27456. currentTarget?: any;
  27457. /**
  27458. * This will be populated with the return value of the last function that was executed.
  27459. * If it is the first function in the callback chain it will be the event data.
  27460. */
  27461. lastReturnValue?: any;
  27462. }
  27463. /**
  27464. * Represent an Observer registered to a given Observable object.
  27465. */
  27466. class Observer<T> {
  27467. /**
  27468. * Defines the callback to call when the observer is notified
  27469. */
  27470. callback: (eventData: T, eventState: EventState) => void;
  27471. /**
  27472. * Defines the mask of the observer (used to filter notifications)
  27473. */
  27474. mask: number;
  27475. /**
  27476. * Defines the current scope used to restore the JS context
  27477. */
  27478. scope: any;
  27479. /** @hidden */
  27480. _willBeUnregistered: boolean;
  27481. /**
  27482. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27483. */
  27484. unregisterOnNextCall: boolean;
  27485. /**
  27486. * Creates a new observer
  27487. * @param callback defines the callback to call when the observer is notified
  27488. * @param mask defines the mask of the observer (used to filter notifications)
  27489. * @param scope defines the current scope used to restore the JS context
  27490. */
  27491. constructor(
  27492. /**
  27493. * Defines the callback to call when the observer is notified
  27494. */
  27495. callback: (eventData: T, eventState: EventState) => void,
  27496. /**
  27497. * Defines the mask of the observer (used to filter notifications)
  27498. */
  27499. mask: number,
  27500. /**
  27501. * Defines the current scope used to restore the JS context
  27502. */
  27503. scope?: any);
  27504. }
  27505. /**
  27506. * Represent a list of observers registered to multiple Observables object.
  27507. */
  27508. class MultiObserver<T> {
  27509. private _observers;
  27510. private _observables;
  27511. /**
  27512. * Release associated resources
  27513. */
  27514. dispose(): void;
  27515. /**
  27516. * Raise a callback when one of the observable will notify
  27517. * @param observables defines a list of observables to watch
  27518. * @param callback defines the callback to call on notification
  27519. * @param mask defines the mask used to filter notifications
  27520. * @param scope defines the current scope used to restore the JS context
  27521. * @returns the new MultiObserver
  27522. */
  27523. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27524. }
  27525. /**
  27526. * The Observable class is a simple implementation of the Observable pattern.
  27527. *
  27528. * 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.
  27529. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27530. * 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).
  27531. * 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.
  27532. */
  27533. class Observable<T> {
  27534. private _observers;
  27535. private _eventState;
  27536. private _onObserverAdded;
  27537. /**
  27538. * Creates a new observable
  27539. * @param onObserverAdded defines a callback to call when a new observer is added
  27540. */
  27541. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27542. /**
  27543. * Create a new Observer with the specified callback
  27544. * @param callback the callback that will be executed for that Observer
  27545. * @param mask the mask used to filter observers
  27546. * @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.
  27547. * @param scope optional scope for the callback to be called from
  27548. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27549. * @returns the new observer created for the callback
  27550. */
  27551. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27552. /**
  27553. * Remove an Observer from the Observable object
  27554. * @param observer the instance of the Observer to remove
  27555. * @returns false if it doesn't belong to this Observable
  27556. */
  27557. remove(observer: Nullable<Observer<T>>): boolean;
  27558. /**
  27559. * Remove a callback from the Observable object
  27560. * @param callback the callback to remove
  27561. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27562. * @returns false if it doesn't belong to this Observable
  27563. */
  27564. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27565. private _deferUnregister(observer);
  27566. /**
  27567. * Notify all Observers by calling their respective callback with the given data
  27568. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27569. * @param eventData defines the data to send to all observers
  27570. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27571. * @param target defines the original target of the state
  27572. * @param currentTarget defines the current target of the state
  27573. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27574. */
  27575. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27576. /**
  27577. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27578. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27579. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27580. * and it is crucial that all callbacks will be executed.
  27581. * The order of the callbacks is kept, callbacks are not executed parallel.
  27582. *
  27583. * @param eventData The data to be sent to each callback
  27584. * @param mask is used to filter observers defaults to -1
  27585. * @param target defines the callback target (see EventState)
  27586. * @param currentTarget defines he current object in the bubbling phase
  27587. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27588. */
  27589. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27590. /**
  27591. * Notify a specific observer
  27592. * @param observer defines the observer to notify
  27593. * @param eventData defines the data to be sent to each callback
  27594. * @param mask is used to filter observers defaults to -1
  27595. */
  27596. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27597. /**
  27598. * Gets a boolean indicating if the observable has at least one observer
  27599. * @returns true is the Observable has at least one Observer registered
  27600. */
  27601. hasObservers(): boolean;
  27602. /**
  27603. * Clear the list of observers
  27604. */
  27605. clear(): void;
  27606. /**
  27607. * Clone the current observable
  27608. * @returns a new observable
  27609. */
  27610. clone(): Observable<T>;
  27611. /**
  27612. * Does this observable handles observer registered with a given mask
  27613. * @param mask defines the mask to be tested
  27614. * @return whether or not one observer registered with the given mask is handeled
  27615. **/
  27616. hasSpecificMask(mask?: number): boolean;
  27617. }
  27618. }
  27619. declare module BABYLON {
  27620. /**
  27621. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27622. */
  27623. class PerformanceMonitor {
  27624. private _enabled;
  27625. private _rollingFrameTime;
  27626. private _lastFrameTimeMs;
  27627. /**
  27628. * constructor
  27629. * @param frameSampleSize The number of samples required to saturate the sliding window
  27630. */
  27631. constructor(frameSampleSize?: number);
  27632. /**
  27633. * Samples current frame
  27634. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27635. */
  27636. sampleFrame(timeMs?: number): void;
  27637. /**
  27638. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27639. * @return Average frame time in milliseconds
  27640. */
  27641. readonly averageFrameTime: number;
  27642. /**
  27643. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27644. * @return Frame time variance in milliseconds squared
  27645. */
  27646. readonly averageFrameTimeVariance: number;
  27647. /**
  27648. * Returns the frame time of the most recent frame
  27649. * @return Frame time in milliseconds
  27650. */
  27651. readonly instantaneousFrameTime: number;
  27652. /**
  27653. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27654. * @return Framerate in frames per second
  27655. */
  27656. readonly averageFPS: number;
  27657. /**
  27658. * Returns the average framerate in frames per second using the most recent frame time
  27659. * @return Framerate in frames per second
  27660. */
  27661. readonly instantaneousFPS: number;
  27662. /**
  27663. * Returns true if enough samples have been taken to completely fill the sliding window
  27664. * @return true if saturated
  27665. */
  27666. readonly isSaturated: boolean;
  27667. /**
  27668. * Enables contributions to the sliding window sample set
  27669. */
  27670. enable(): void;
  27671. /**
  27672. * Disables contributions to the sliding window sample set
  27673. * Samples will not be interpolated over the disabled period
  27674. */
  27675. disable(): void;
  27676. /**
  27677. * Returns true if sampling is enabled
  27678. * @return true if enabled
  27679. */
  27680. readonly isEnabled: boolean;
  27681. /**
  27682. * Resets performance monitor
  27683. */
  27684. reset(): void;
  27685. }
  27686. /**
  27687. * RollingAverage
  27688. *
  27689. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27690. */
  27691. class RollingAverage {
  27692. /**
  27693. * Current average
  27694. */
  27695. average: number;
  27696. /**
  27697. * Current variance
  27698. */
  27699. variance: number;
  27700. protected _samples: Array<number>;
  27701. protected _sampleCount: number;
  27702. protected _pos: number;
  27703. protected _m2: number;
  27704. /**
  27705. * constructor
  27706. * @param length The number of samples required to saturate the sliding window
  27707. */
  27708. constructor(length: number);
  27709. /**
  27710. * Adds a sample to the sample set
  27711. * @param v The sample value
  27712. */
  27713. add(v: number): void;
  27714. /**
  27715. * Returns previously added values or null if outside of history or outside the sliding window domain
  27716. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27717. * @return Value previously recorded with add() or null if outside of range
  27718. */
  27719. history(i: number): number;
  27720. /**
  27721. * Returns true if enough samples have been taken to completely fill the sliding window
  27722. * @return true if sample-set saturated
  27723. */
  27724. isSaturated(): boolean;
  27725. /**
  27726. * Resets the rolling average (equivalent to 0 samples taken so far)
  27727. */
  27728. reset(): void;
  27729. /**
  27730. * Wraps a value around the sample range boundaries
  27731. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27732. * @return Wrapped position in sample range
  27733. */
  27734. protected _wrapPosition(i: number): number;
  27735. }
  27736. }
  27737. declare module BABYLON {
  27738. /**
  27739. * Helper class that provides a small promise polyfill
  27740. */
  27741. class PromisePolyfill {
  27742. /**
  27743. * Static function used to check if the polyfill is required
  27744. * If this is the case then the function will inject the polyfill to window.Promise
  27745. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  27746. */
  27747. static Apply(force?: boolean): void;
  27748. }
  27749. }
  27750. declare module BABYLON {
  27751. /**
  27752. * Defines the root class used to create scene optimization to use with SceneOptimizer
  27753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27754. */
  27755. class SceneOptimization {
  27756. /**
  27757. * Defines the priority of this optimization (0 by default which means first in the list)
  27758. */
  27759. priority: number;
  27760. /**
  27761. * Gets a string describing the action executed by the current optimization
  27762. * @returns description string
  27763. */
  27764. getDescription(): string;
  27765. /**
  27766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27767. * @param scene defines the current scene where to apply this optimization
  27768. * @param optimizer defines the current optimizer
  27769. * @returns true if everything that can be done was applied
  27770. */
  27771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27772. /**
  27773. * Creates the SceneOptimization object
  27774. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27775. * @param desc defines the description associated with the optimization
  27776. */
  27777. constructor(
  27778. /**
  27779. * Defines the priority of this optimization (0 by default which means first in the list)
  27780. */
  27781. priority?: number);
  27782. }
  27783. /**
  27784. * Defines an optimization used to reduce the size of render target textures
  27785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27786. */
  27787. class TextureOptimization extends SceneOptimization {
  27788. /**
  27789. * Defines the priority of this optimization (0 by default which means first in the list)
  27790. */
  27791. priority: number;
  27792. /**
  27793. * 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
  27794. */
  27795. maximumSize: number;
  27796. /**
  27797. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27798. */
  27799. step: number;
  27800. /**
  27801. * Gets a string describing the action executed by the current optimization
  27802. * @returns description string
  27803. */
  27804. getDescription(): string;
  27805. /**
  27806. * Creates the TextureOptimization object
  27807. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27808. * @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
  27809. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27810. */
  27811. constructor(
  27812. /**
  27813. * Defines the priority of this optimization (0 by default which means first in the list)
  27814. */
  27815. priority?: number,
  27816. /**
  27817. * 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
  27818. */
  27819. maximumSize?: number,
  27820. /**
  27821. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27822. */
  27823. step?: number);
  27824. /**
  27825. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27826. * @param scene defines the current scene where to apply this optimization
  27827. * @param optimizer defines the current optimizer
  27828. * @returns true if everything that can be done was applied
  27829. */
  27830. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27831. }
  27832. /**
  27833. * Defines an optimization used to increase or decrease the rendering resolution
  27834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27835. */
  27836. class HardwareScalingOptimization extends SceneOptimization {
  27837. /**
  27838. * Defines the priority of this optimization (0 by default which means first in the list)
  27839. */
  27840. priority: number;
  27841. /**
  27842. * Defines the maximum scale to use (2 by default)
  27843. */
  27844. maximumScale: number;
  27845. /**
  27846. * Defines the step to use between two passes (0.5 by default)
  27847. */
  27848. step: number;
  27849. private _currentScale;
  27850. private _directionOffset;
  27851. /**
  27852. * Gets a string describing the action executed by the current optimization
  27853. * @return description string
  27854. */
  27855. getDescription(): string;
  27856. /**
  27857. * Creates the HardwareScalingOptimization object
  27858. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27859. * @param maximumScale defines the maximum scale to use (2 by default)
  27860. * @param step defines the step to use between two passes (0.5 by default)
  27861. */
  27862. constructor(
  27863. /**
  27864. * Defines the priority of this optimization (0 by default which means first in the list)
  27865. */
  27866. priority?: number,
  27867. /**
  27868. * Defines the maximum scale to use (2 by default)
  27869. */
  27870. maximumScale?: number,
  27871. /**
  27872. * Defines the step to use between two passes (0.5 by default)
  27873. */
  27874. step?: number);
  27875. /**
  27876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27877. * @param scene defines the current scene where to apply this optimization
  27878. * @param optimizer defines the current optimizer
  27879. * @returns true if everything that can be done was applied
  27880. */
  27881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27882. }
  27883. /**
  27884. * Defines an optimization used to remove shadows
  27885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27886. */
  27887. class ShadowsOptimization extends SceneOptimization {
  27888. /**
  27889. * Gets a string describing the action executed by the current optimization
  27890. * @return description string
  27891. */
  27892. getDescription(): string;
  27893. /**
  27894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27895. * @param scene defines the current scene where to apply this optimization
  27896. * @param optimizer defines the current optimizer
  27897. * @returns true if everything that can be done was applied
  27898. */
  27899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27900. }
  27901. /**
  27902. * Defines an optimization used to turn post-processes off
  27903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27904. */
  27905. class PostProcessesOptimization extends SceneOptimization {
  27906. /**
  27907. * Gets a string describing the action executed by the current optimization
  27908. * @return description string
  27909. */
  27910. getDescription(): string;
  27911. /**
  27912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27913. * @param scene defines the current scene where to apply this optimization
  27914. * @param optimizer defines the current optimizer
  27915. * @returns true if everything that can be done was applied
  27916. */
  27917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27918. }
  27919. /**
  27920. * Defines an optimization used to turn lens flares off
  27921. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27922. */
  27923. class LensFlaresOptimization extends SceneOptimization {
  27924. /**
  27925. * Gets a string describing the action executed by the current optimization
  27926. * @return description string
  27927. */
  27928. getDescription(): string;
  27929. /**
  27930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27931. * @param scene defines the current scene where to apply this optimization
  27932. * @param optimizer defines the current optimizer
  27933. * @returns true if everything that can be done was applied
  27934. */
  27935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27936. }
  27937. /**
  27938. * Defines an optimization based on user defined callback.
  27939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27940. */
  27941. class CustomOptimization extends SceneOptimization {
  27942. /**
  27943. * Callback called to apply the custom optimization.
  27944. */
  27945. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  27946. /**
  27947. * Callback called to get custom description
  27948. */
  27949. onGetDescription: () => string;
  27950. /**
  27951. * Gets a string describing the action executed by the current optimization
  27952. * @returns description string
  27953. */
  27954. getDescription(): string;
  27955. /**
  27956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27957. * @param scene defines the current scene where to apply this optimization
  27958. * @param optimizer defines the current optimizer
  27959. * @returns true if everything that can be done was applied
  27960. */
  27961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27962. }
  27963. /**
  27964. * Defines an optimization used to turn particles off
  27965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27966. */
  27967. class ParticlesOptimization extends SceneOptimization {
  27968. /**
  27969. * Gets a string describing the action executed by the current optimization
  27970. * @return description string
  27971. */
  27972. getDescription(): string;
  27973. /**
  27974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27975. * @param scene defines the current scene where to apply this optimization
  27976. * @param optimizer defines the current optimizer
  27977. * @returns true if everything that can be done was applied
  27978. */
  27979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27980. }
  27981. /**
  27982. * Defines an optimization used to turn render targets off
  27983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27984. */
  27985. class RenderTargetsOptimization extends SceneOptimization {
  27986. /**
  27987. * Gets a string describing the action executed by the current optimization
  27988. * @return description string
  27989. */
  27990. getDescription(): string;
  27991. /**
  27992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27993. * @param scene defines the current scene where to apply this optimization
  27994. * @param optimizer defines the current optimizer
  27995. * @returns true if everything that can be done was applied
  27996. */
  27997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27998. }
  27999. /**
  28000. * Defines an optimization used to merge meshes with compatible materials
  28001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28002. */
  28003. class MergeMeshesOptimization extends SceneOptimization {
  28004. private static _UpdateSelectionTree;
  28005. /**
  28006. * Gets or sets a boolean which defines if optimization octree has to be updated
  28007. */
  28008. /**
  28009. * Gets or sets a boolean which defines if optimization octree has to be updated
  28010. */
  28011. static UpdateSelectionTree: boolean;
  28012. /**
  28013. * Gets a string describing the action executed by the current optimization
  28014. * @return description string
  28015. */
  28016. getDescription(): string;
  28017. private _canBeMerged;
  28018. /**
  28019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28020. * @param scene defines the current scene where to apply this optimization
  28021. * @param optimizer defines the current optimizer
  28022. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28023. * @returns true if everything that can be done was applied
  28024. */
  28025. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28026. }
  28027. /**
  28028. * Defines a list of options used by SceneOptimizer
  28029. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28030. */
  28031. class SceneOptimizerOptions {
  28032. /**
  28033. * Defines the target frame rate to reach (60 by default)
  28034. */
  28035. targetFrameRate: number;
  28036. /**
  28037. * Defines the interval between two checkes (2000ms by default)
  28038. */
  28039. trackerDuration: number;
  28040. /**
  28041. * Gets the list of optimizations to apply
  28042. */
  28043. optimizations: SceneOptimization[];
  28044. /**
  28045. * Creates a new list of options used by SceneOptimizer
  28046. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28047. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28048. */
  28049. constructor(
  28050. /**
  28051. * Defines the target frame rate to reach (60 by default)
  28052. */
  28053. targetFrameRate?: number,
  28054. /**
  28055. * Defines the interval between two checkes (2000ms by default)
  28056. */
  28057. trackerDuration?: number);
  28058. /**
  28059. * Add a new optimization
  28060. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28061. * @returns the current SceneOptimizerOptions
  28062. */
  28063. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28064. /**
  28065. * Add a new custom optimization
  28066. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28067. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28068. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28069. * @returns the current SceneOptimizerOptions
  28070. */
  28071. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28072. /**
  28073. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28074. * @param targetFrameRate defines the target frame rate (60 by default)
  28075. * @returns a SceneOptimizerOptions object
  28076. */
  28077. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28078. /**
  28079. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28080. * @param targetFrameRate defines the target frame rate (60 by default)
  28081. * @returns a SceneOptimizerOptions object
  28082. */
  28083. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28084. /**
  28085. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28086. * @param targetFrameRate defines the target frame rate (60 by default)
  28087. * @returns a SceneOptimizerOptions object
  28088. */
  28089. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28090. }
  28091. /**
  28092. * Class used to run optimizations in order to reach a target frame rate
  28093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28094. */
  28095. class SceneOptimizer implements IDisposable {
  28096. private _isRunning;
  28097. private _options;
  28098. private _scene;
  28099. private _currentPriorityLevel;
  28100. private _targetFrameRate;
  28101. private _trackerDuration;
  28102. private _currentFrameRate;
  28103. private _sceneDisposeObserver;
  28104. private _improvementMode;
  28105. /**
  28106. * Defines an observable called when the optimizer reaches the target frame rate
  28107. */
  28108. onSuccessObservable: Observable<SceneOptimizer>;
  28109. /**
  28110. * Defines an observable called when the optimizer enables an optimization
  28111. */
  28112. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28113. /**
  28114. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28115. */
  28116. onFailureObservable: Observable<SceneOptimizer>;
  28117. /**
  28118. * Gets a boolean indicating if the optimizer is in improvement mode
  28119. */
  28120. readonly isInImprovementMode: boolean;
  28121. /**
  28122. * Gets the current priority level (0 at start)
  28123. */
  28124. readonly currentPriorityLevel: number;
  28125. /**
  28126. * Gets the current frame rate checked by the SceneOptimizer
  28127. */
  28128. readonly currentFrameRate: number;
  28129. /**
  28130. * Gets or sets the current target frame rate (60 by default)
  28131. */
  28132. /**
  28133. * Gets or sets the current target frame rate (60 by default)
  28134. */
  28135. targetFrameRate: number;
  28136. /**
  28137. * Gets or sets the current interval between two checks (every 2000ms by default)
  28138. */
  28139. /**
  28140. * Gets or sets the current interval between two checks (every 2000ms by default)
  28141. */
  28142. trackerDuration: number;
  28143. /**
  28144. * Gets the list of active optimizations
  28145. */
  28146. readonly optimizations: SceneOptimization[];
  28147. /**
  28148. * Creates a new SceneOptimizer
  28149. * @param scene defines the scene to work on
  28150. * @param options defines the options to use with the SceneOptimizer
  28151. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28152. * @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)
  28153. */
  28154. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28155. /**
  28156. * Stops the current optimizer
  28157. */
  28158. stop(): void;
  28159. /**
  28160. * Reset the optimizer to initial step (current priority level = 0)
  28161. */
  28162. reset(): void;
  28163. /**
  28164. * Start the optimizer. By default it will try to reach a specific framerate
  28165. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28166. */
  28167. start(): void;
  28168. private _checkCurrentState();
  28169. /**
  28170. * Release all resources
  28171. */
  28172. dispose(): void;
  28173. /**
  28174. * Helper function to create a SceneOptimizer with one single line of code
  28175. * @param scene defines the scene to work on
  28176. * @param options defines the options to use with the SceneOptimizer
  28177. * @param onSuccess defines a callback to call on success
  28178. * @param onFailure defines a callback to call on failure
  28179. * @returns the new SceneOptimizer object
  28180. */
  28181. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28182. }
  28183. }
  28184. declare module BABYLON {
  28185. class SceneSerializer {
  28186. static ClearCache(): void;
  28187. static Serialize(scene: Scene): any;
  28188. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28189. }
  28190. }
  28191. declare module BABYLON {
  28192. class SmartArray<T> {
  28193. data: Array<T>;
  28194. length: number;
  28195. protected _id: number;
  28196. [index: number]: T;
  28197. constructor(capacity: number);
  28198. push(value: T): void;
  28199. forEach(func: (content: T) => void): void;
  28200. sort(compareFn: (a: T, b: T) => number): void;
  28201. reset(): void;
  28202. dispose(): void;
  28203. concat(array: any): void;
  28204. indexOf(value: T): number;
  28205. contains(value: T): boolean;
  28206. private static _GlobalId;
  28207. }
  28208. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28209. private _duplicateId;
  28210. [index: number]: T;
  28211. push(value: T): void;
  28212. pushNoDuplicate(value: T): boolean;
  28213. reset(): void;
  28214. concatWithNoDuplicate(array: any): void;
  28215. }
  28216. }
  28217. declare module BABYLON {
  28218. /**
  28219. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28220. * The underlying implementation relies on an associative array to ensure the best performances.
  28221. * The value can be anything including 'null' but except 'undefined'
  28222. */
  28223. class StringDictionary<T> {
  28224. /**
  28225. * This will clear this dictionary and copy the content from the 'source' one.
  28226. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28227. * @param source the dictionary to take the content from and copy to this dictionary
  28228. */
  28229. copyFrom(source: StringDictionary<T>): void;
  28230. /**
  28231. * Get a value based from its key
  28232. * @param key the given key to get the matching value from
  28233. * @return the value if found, otherwise undefined is returned
  28234. */
  28235. get(key: string): T | undefined;
  28236. /**
  28237. * Get a value from its key or add it if it doesn't exist.
  28238. * This method will ensure you that a given key/data will be present in the dictionary.
  28239. * @param key the given key to get the matching value from
  28240. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28241. * The factory will only be invoked if there's no data for the given key.
  28242. * @return the value corresponding to the key.
  28243. */
  28244. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28245. /**
  28246. * Get a value from its key if present in the dictionary otherwise add it
  28247. * @param key the key to get the value from
  28248. * @param val if there's no such key/value pair in the dictionary add it with this value
  28249. * @return the value corresponding to the key
  28250. */
  28251. getOrAdd(key: string, val: T): T;
  28252. /**
  28253. * Check if there's a given key in the dictionary
  28254. * @param key the key to check for
  28255. * @return true if the key is present, false otherwise
  28256. */
  28257. contains(key: string): boolean;
  28258. /**
  28259. * Add a new key and its corresponding value
  28260. * @param key the key to add
  28261. * @param value the value corresponding to the key
  28262. * @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
  28263. */
  28264. add(key: string, value: T): boolean;
  28265. set(key: string, value: T): boolean;
  28266. /**
  28267. * Get the element of the given key and remove it from the dictionary
  28268. * @param key
  28269. */
  28270. getAndRemove(key: string): Nullable<T>;
  28271. /**
  28272. * Remove a key/value from the dictionary.
  28273. * @param key the key to remove
  28274. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28275. */
  28276. remove(key: string): boolean;
  28277. /**
  28278. * Clear the whole content of the dictionary
  28279. */
  28280. clear(): void;
  28281. readonly count: number;
  28282. /**
  28283. * Execute a callback on each key/val of the dictionary.
  28284. * Note that you can remove any element in this dictionary in the callback implementation
  28285. * @param callback the callback to execute on a given key/value pair
  28286. */
  28287. forEach(callback: (key: string, val: T) => void): void;
  28288. /**
  28289. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28290. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28291. * Note that you can remove any element in this dictionary in the callback implementation
  28292. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28293. */
  28294. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28295. private _count;
  28296. private _data;
  28297. }
  28298. }
  28299. declare module BABYLON {
  28300. class Tags {
  28301. static EnableFor(obj: any): void;
  28302. static DisableFor(obj: any): void;
  28303. static HasTags(obj: any): boolean;
  28304. static GetTags(obj: any, asString?: boolean): any;
  28305. static AddTagsTo(obj: any, tagsString: string): void;
  28306. static _AddTagTo(obj: any, tag: string): void;
  28307. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28308. static _RemoveTagFrom(obj: any, tag: string): void;
  28309. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28310. }
  28311. }
  28312. declare module BABYLON {
  28313. class TextureTools {
  28314. /**
  28315. * Uses the GPU to create a copy texture rescaled at a given size
  28316. * @param texture Texture to copy from
  28317. * @param width Desired width
  28318. * @param height Desired height
  28319. * @return Generated texture
  28320. */
  28321. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28322. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28323. private static _environmentBRDFBase64Texture;
  28324. }
  28325. }
  28326. declare module BABYLON {
  28327. class TGATools {
  28328. private static _TYPE_INDEXED;
  28329. private static _TYPE_RGB;
  28330. private static _TYPE_GREY;
  28331. private static _TYPE_RLE_INDEXED;
  28332. private static _TYPE_RLE_RGB;
  28333. private static _TYPE_RLE_GREY;
  28334. private static _ORIGIN_MASK;
  28335. private static _ORIGIN_SHIFT;
  28336. private static _ORIGIN_BL;
  28337. private static _ORIGIN_BR;
  28338. private static _ORIGIN_UL;
  28339. private static _ORIGIN_UR;
  28340. static GetTGAHeader(data: Uint8Array): any;
  28341. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28342. 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;
  28343. 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;
  28344. 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;
  28345. 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;
  28346. 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;
  28347. 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;
  28348. }
  28349. }
  28350. declare module BABYLON {
  28351. interface IAnimatable {
  28352. animations: Array<Animation>;
  28353. }
  28354. class LoadFileError extends Error {
  28355. request: XMLHttpRequest | undefined;
  28356. private static _setPrototypeOf;
  28357. constructor(message: string, request?: XMLHttpRequest | undefined);
  28358. }
  28359. class RetryStrategy {
  28360. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28361. }
  28362. interface IFileRequest {
  28363. /**
  28364. * Raised when the request is complete (success or error).
  28365. */
  28366. onCompleteObservable: Observable<IFileRequest>;
  28367. /**
  28368. * Aborts the request for a file.
  28369. */
  28370. abort: () => void;
  28371. }
  28372. class Tools {
  28373. static BaseUrl: string;
  28374. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28375. /**
  28376. * Default behaviour for cors in the application.
  28377. * It can be a string if the expected behavior is identical in the entire app.
  28378. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28379. */
  28380. static CorsBehavior: string | ((url: string | string[]) => string);
  28381. static UseFallbackTexture: boolean;
  28382. /**
  28383. * Use this object to register external classes like custom textures or material
  28384. * to allow the laoders to instantiate them
  28385. */
  28386. static RegisteredExternalClasses: {
  28387. [key: string]: Object;
  28388. };
  28389. static fallbackTexture: string;
  28390. /**
  28391. * Interpolates between a and b via alpha
  28392. * @param a The lower value (returned when alpha = 0)
  28393. * @param b The upper value (returned when alpha = 1)
  28394. * @param alpha The interpolation-factor
  28395. * @return The mixed value
  28396. */
  28397. static Mix(a: number, b: number, alpha: number): number;
  28398. static Instantiate(className: string): any;
  28399. /**
  28400. * Provides a slice function that will work even on IE
  28401. * @param data defines the array to slice
  28402. * @param start defines the start of the data (optional)
  28403. * @param end defines the end of the data (optional)
  28404. * @returns the new sliced array
  28405. */
  28406. static Slice<T>(data: T, start?: number, end?: number): T;
  28407. static SetImmediate(action: () => void): void;
  28408. static IsExponentOfTwo(value: number): boolean;
  28409. private static _tmpFloatArray;
  28410. /**
  28411. * Returns the nearest 32-bit single precision float representation of a Number
  28412. * @param value A Number. If the parameter is of a different type, it will get converted
  28413. * to a number or to NaN if it cannot be converted
  28414. * @returns number
  28415. */
  28416. static FloatRound(value: number): number;
  28417. /**
  28418. * Find the next highest power of two.
  28419. * @param x Number to start search from.
  28420. * @return Next highest power of two.
  28421. */
  28422. static CeilingPOT(x: number): number;
  28423. /**
  28424. * Find the next lowest power of two.
  28425. * @param x Number to start search from.
  28426. * @return Next lowest power of two.
  28427. */
  28428. static FloorPOT(x: number): number;
  28429. /**
  28430. * Find the nearest power of two.
  28431. * @param x Number to start search from.
  28432. * @return Next nearest power of two.
  28433. */
  28434. static NearestPOT(x: number): number;
  28435. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28436. static GetFilename(path: string): string;
  28437. /**
  28438. * Extracts the "folder" part of a path (everything before the filename).
  28439. * @param uri The URI to extract the info from
  28440. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28441. * @returns The "folder" part of the path
  28442. */
  28443. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28444. static GetDOMTextContent(element: HTMLElement): string;
  28445. static ToDegrees(angle: number): number;
  28446. static ToRadians(angle: number): number;
  28447. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28448. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28449. minimum: Vector3;
  28450. maximum: Vector3;
  28451. };
  28452. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28453. minimum: Vector3;
  28454. maximum: Vector3;
  28455. };
  28456. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28457. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28458. minimum: Vector2;
  28459. maximum: Vector2;
  28460. };
  28461. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28462. static GetPointerPrefix(): string;
  28463. /**
  28464. * @param func - the function to be called
  28465. * @param requester - the object that will request the next frame. Falls back to window.
  28466. */
  28467. static QueueNewFrame(func: () => void, requester?: any): number;
  28468. static RequestFullscreen(element: HTMLElement): void;
  28469. static ExitFullscreen(): void;
  28470. static SetCorsBehavior(url: string | string[], element: {
  28471. crossOrigin: string | null;
  28472. }): void;
  28473. static CleanUrl(url: string): string;
  28474. static PreprocessUrl: (url: string) => string;
  28475. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28476. 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;
  28477. /**
  28478. * Load a script (identified by an url). When the url returns, the
  28479. * content of this file is added into a new script element, attached to the DOM (body element)
  28480. */
  28481. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28482. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28483. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28484. static FileAsURL(content: string): string;
  28485. static Format(value: number, decimals?: number): string;
  28486. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28487. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28488. static IsEmpty(obj: any): boolean;
  28489. static RegisterTopRootEvents(events: {
  28490. name: string;
  28491. handler: Nullable<(e: FocusEvent) => any>;
  28492. }[]): void;
  28493. static UnregisterTopRootEvents(events: {
  28494. name: string;
  28495. handler: Nullable<(e: FocusEvent) => any>;
  28496. }[]): void;
  28497. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28498. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28499. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28500. /**
  28501. * Generates an image screenshot from the specified camera.
  28502. *
  28503. * @param engine The engine to use for rendering
  28504. * @param camera The camera to use for rendering
  28505. * @param size This parameter can be set to a single number or to an object with the
  28506. * following (optional) properties: precision, width, height. If a single number is passed,
  28507. * it will be used for both width and height. If an object is passed, the screenshot size
  28508. * will be derived from the parameters. The precision property is a multiplier allowing
  28509. * rendering at a higher or lower resolution.
  28510. * @param successCallback The callback receives a single parameter which contains the
  28511. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28512. * src parameter of an <img> to display it.
  28513. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28514. * Check your browser for supported MIME types.
  28515. * @param samples Texture samples (default: 1)
  28516. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28517. * @param fileName A name for for the downloaded file.
  28518. * @constructor
  28519. */
  28520. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28521. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28522. /**
  28523. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28524. * Be aware Math.random() could cause collisions, but:
  28525. * "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"
  28526. */
  28527. static RandomId(): string;
  28528. /**
  28529. * Test if the given uri is a base64 string.
  28530. * @param uri The uri to test
  28531. * @return True if the uri is a base64 string or false otherwise.
  28532. */
  28533. static IsBase64(uri: string): boolean;
  28534. /**
  28535. * Decode the given base64 uri.
  28536. * @param uri The uri to decode
  28537. * @return The decoded base64 data.
  28538. */
  28539. static DecodeBase64(uri: string): ArrayBuffer;
  28540. private static _NoneLogLevel;
  28541. private static _MessageLogLevel;
  28542. private static _WarningLogLevel;
  28543. private static _ErrorLogLevel;
  28544. private static _LogCache;
  28545. static errorsCount: number;
  28546. static OnNewCacheEntry: (entry: string) => void;
  28547. static readonly NoneLogLevel: number;
  28548. static readonly MessageLogLevel: number;
  28549. static readonly WarningLogLevel: number;
  28550. static readonly ErrorLogLevel: number;
  28551. static readonly AllLogLevel: number;
  28552. private static _AddLogEntry(entry);
  28553. private static _FormatMessage(message);
  28554. private static _LogDisabled(message);
  28555. private static _LogEnabled(message);
  28556. private static _WarnDisabled(message);
  28557. private static _WarnEnabled(message);
  28558. private static _ErrorDisabled(message);
  28559. private static _ErrorEnabled(message);
  28560. static Log: (message: string) => void;
  28561. static Warn: (message: string) => void;
  28562. static Error: (message: string) => void;
  28563. static readonly LogCache: string;
  28564. static ClearLogCache(): void;
  28565. static LogLevels: number;
  28566. static IsWindowObjectExist(): boolean;
  28567. private static _PerformanceNoneLogLevel;
  28568. private static _PerformanceUserMarkLogLevel;
  28569. private static _PerformanceConsoleLogLevel;
  28570. private static _performance;
  28571. static readonly PerformanceNoneLogLevel: number;
  28572. static readonly PerformanceUserMarkLogLevel: number;
  28573. static readonly PerformanceConsoleLogLevel: number;
  28574. static PerformanceLogLevel: number;
  28575. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28576. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28577. static _StartUserMark(counterName: string, condition?: boolean): void;
  28578. static _EndUserMark(counterName: string, condition?: boolean): void;
  28579. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28580. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28581. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28582. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28583. static readonly Now: number;
  28584. /**
  28585. * This method will return the name of the class used to create the instance of the given object.
  28586. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28587. * @param object the object to get the class name from
  28588. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28589. */
  28590. static GetClassName(object: any, isType?: boolean): string;
  28591. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28592. /**
  28593. * This method will return the name of the full name of the class, including its owning module (if any).
  28594. * 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).
  28595. * @param object the object to get the class name from
  28596. * @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.
  28597. */
  28598. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28599. /**
  28600. * 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.
  28601. * @param array
  28602. */
  28603. static arrayOrStringFeeder(array: any): (i: number) => number;
  28604. /**
  28605. * Compute the hashCode of a stream of number
  28606. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28607. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28608. * @return the hash code computed
  28609. */
  28610. static hashCodeFromStream(feeder: (index: number) => number): number;
  28611. /**
  28612. * Returns a promise that resolves after the given amount of time.
  28613. * @param delay Number of milliseconds to delay
  28614. * @returns Promise that resolves after the given amount of time
  28615. */
  28616. static DelayAsync(delay: number): Promise<void>;
  28617. }
  28618. /**
  28619. * This class is used to track a performance counter which is number based.
  28620. * The user has access to many properties which give statistics of different nature
  28621. *
  28622. * The implementer can track two kinds of Performance Counter: time and count
  28623. * 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.
  28624. * 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.
  28625. */
  28626. class PerfCounter {
  28627. static Enabled: boolean;
  28628. /**
  28629. * Returns the smallest value ever
  28630. */
  28631. readonly min: number;
  28632. /**
  28633. * Returns the biggest value ever
  28634. */
  28635. readonly max: number;
  28636. /**
  28637. * Returns the average value since the performance counter is running
  28638. */
  28639. readonly average: number;
  28640. /**
  28641. * Returns the average value of the last second the counter was monitored
  28642. */
  28643. readonly lastSecAverage: number;
  28644. /**
  28645. * Returns the current value
  28646. */
  28647. readonly current: number;
  28648. readonly total: number;
  28649. readonly count: number;
  28650. constructor();
  28651. /**
  28652. * Call this method to start monitoring a new frame.
  28653. * 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.
  28654. */
  28655. fetchNewFrame(): void;
  28656. /**
  28657. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28658. * @param newCount the count value to add to the monitored count
  28659. * @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.
  28660. */
  28661. addCount(newCount: number, fetchResult: boolean): void;
  28662. /**
  28663. * Start monitoring this performance counter
  28664. */
  28665. beginMonitoring(): void;
  28666. /**
  28667. * Compute the time lapsed since the previous beginMonitoring() call.
  28668. * @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
  28669. */
  28670. endMonitoring(newFrame?: boolean): void;
  28671. private _fetchResult();
  28672. private _startMonitoringTime;
  28673. private _min;
  28674. private _max;
  28675. private _average;
  28676. private _current;
  28677. private _totalValueCount;
  28678. private _totalAccumulated;
  28679. private _lastSecAverage;
  28680. private _lastSecAccumulated;
  28681. private _lastSecTime;
  28682. private _lastSecValueCount;
  28683. }
  28684. /**
  28685. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28686. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28687. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28688. * @param name The name of the class, case should be preserved
  28689. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28690. */
  28691. function className(name: string, module?: string): (target: Object) => void;
  28692. /**
  28693. * An implementation of a loop for asynchronous functions.
  28694. */
  28695. class AsyncLoop {
  28696. iterations: number;
  28697. private _fn;
  28698. private _successCallback;
  28699. index: number;
  28700. private _done;
  28701. /**
  28702. * Constroctor.
  28703. * @param iterations the number of iterations.
  28704. * @param _fn the function to run each iteration
  28705. * @param _successCallback the callback that will be called upon succesful execution
  28706. * @param offset starting offset.
  28707. */
  28708. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28709. /**
  28710. * Execute the next iteration. Must be called after the last iteration was finished.
  28711. */
  28712. executeNext(): void;
  28713. /**
  28714. * Break the loop and run the success callback.
  28715. */
  28716. breakLoop(): void;
  28717. /**
  28718. * Helper function
  28719. */
  28720. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28721. /**
  28722. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28723. * @param iterations total number of iterations
  28724. * @param syncedIterations number of synchronous iterations in each async iteration.
  28725. * @param fn the function to call each iteration.
  28726. * @param callback a success call back that will be called when iterating stops.
  28727. * @param breakFunction a break condition (optional)
  28728. * @param timeout timeout settings for the setTimeout function. default - 0.
  28729. * @constructor
  28730. */
  28731. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28732. }
  28733. }
  28734. declare module BABYLON {
  28735. /**
  28736. * Defines the potential axis of a Joystick
  28737. */
  28738. enum JoystickAxis {
  28739. /** X axis */
  28740. X = 0,
  28741. /** Y axis */
  28742. Y = 1,
  28743. /** Z axis */
  28744. Z = 2,
  28745. }
  28746. /**
  28747. * Class used to define virtual joystick (used in touch mode)
  28748. */
  28749. class VirtualJoystick {
  28750. /**
  28751. * Gets or sets a boolean indicating that left and right values must be inverted
  28752. */
  28753. reverseLeftRight: boolean;
  28754. /**
  28755. * Gets or sets a boolean indicating that up and down values must be inverted
  28756. */
  28757. reverseUpDown: boolean;
  28758. /**
  28759. * Gets the offset value for the position (ie. the change of the position value)
  28760. */
  28761. deltaPosition: Vector3;
  28762. /**
  28763. * Gets a boolean indicating if the virtual joystick was pressed
  28764. */
  28765. pressed: boolean;
  28766. private static _globalJoystickIndex;
  28767. private static vjCanvas;
  28768. private static vjCanvasContext;
  28769. private static vjCanvasWidth;
  28770. private static vjCanvasHeight;
  28771. private static halfWidth;
  28772. private _action;
  28773. private _axisTargetedByLeftAndRight;
  28774. private _axisTargetedByUpAndDown;
  28775. private _joystickSensibility;
  28776. private _inversedSensibility;
  28777. private _joystickPointerID;
  28778. private _joystickColor;
  28779. private _joystickPointerPos;
  28780. private _joystickPreviousPointerPos;
  28781. private _joystickPointerStartPos;
  28782. private _deltaJoystickVector;
  28783. private _leftJoystick;
  28784. private _touches;
  28785. private _onPointerDownHandlerRef;
  28786. private _onPointerMoveHandlerRef;
  28787. private _onPointerUpHandlerRef;
  28788. private _onResize;
  28789. /**
  28790. * Creates a new virtual joystick
  28791. * @param leftJoystick defines that the joystick is for left hand (false by default)
  28792. */
  28793. constructor(leftJoystick?: boolean);
  28794. /**
  28795. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  28796. * @param newJoystickSensibility defines the new sensibility
  28797. */
  28798. setJoystickSensibility(newJoystickSensibility: number): void;
  28799. private _onPointerDown(e);
  28800. private _onPointerMove(e);
  28801. private _onPointerUp(e);
  28802. /**
  28803. * Change the color of the virtual joystick
  28804. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  28805. */
  28806. setJoystickColor(newColor: string): void;
  28807. /**
  28808. * Defines a callback to call when the joystick is touched
  28809. * @param action defines the callback
  28810. */
  28811. setActionOnTouch(action: () => any): void;
  28812. /**
  28813. * Defines which axis you'd like to control for left & right
  28814. * @param axis defines the axis to use
  28815. */
  28816. setAxisForLeftRight(axis: JoystickAxis): void;
  28817. /**
  28818. * Defines which axis you'd like to control for up & down
  28819. * @param axis defines the axis to use
  28820. */
  28821. setAxisForUpDown(axis: JoystickAxis): void;
  28822. private _drawVirtualJoystick();
  28823. /**
  28824. * Release internal HTML canvas
  28825. */
  28826. releaseCanvas(): void;
  28827. }
  28828. }
  28829. declare module BABYLON {
  28830. /**
  28831. * Helper class to push actions to a pool of workers.
  28832. */
  28833. class WorkerPool implements IDisposable {
  28834. private _workerInfos;
  28835. private _pendingActions;
  28836. /**
  28837. * Constructor
  28838. * @param workers Array of workers to use for actions
  28839. */
  28840. constructor(workers: Array<Worker>);
  28841. /**
  28842. * Terminates all workers and clears any pending actions.
  28843. */
  28844. dispose(): void;
  28845. /**
  28846. * Pushes an action to the worker pool. If all the workers are active, the action will be
  28847. * pended until a worker has completed its action.
  28848. * @param action The action to perform. Call onComplete when the action is complete.
  28849. */
  28850. push(action: (worker: Worker, onComplete: () => void) => void): void;
  28851. private _execute(workerInfo, action);
  28852. }
  28853. }
  28854. declare module BABYLON {
  28855. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  28856. readonly name: string;
  28857. private _zoomStopsAnimation;
  28858. private _idleRotationSpeed;
  28859. private _idleRotationWaitTime;
  28860. private _idleRotationSpinupTime;
  28861. /**
  28862. * Gets the flag that indicates if user zooming should stop animation.
  28863. */
  28864. /**
  28865. * Sets the flag that indicates if user zooming should stop animation.
  28866. */
  28867. zoomStopsAnimation: boolean;
  28868. /**
  28869. * Gets the default speed at which the camera rotates around the model.
  28870. */
  28871. /**
  28872. * Sets the default speed at which the camera rotates around the model.
  28873. */
  28874. idleRotationSpeed: number;
  28875. /**
  28876. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  28877. */
  28878. /**
  28879. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  28880. */
  28881. idleRotationWaitTime: number;
  28882. /**
  28883. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28884. */
  28885. /**
  28886. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28887. */
  28888. idleRotationSpinupTime: number;
  28889. /**
  28890. * Gets a value indicating if the camera is currently rotating because of this behavior
  28891. */
  28892. readonly rotationInProgress: boolean;
  28893. private _onPrePointerObservableObserver;
  28894. private _onAfterCheckInputsObserver;
  28895. private _attachedCamera;
  28896. private _isPointerDown;
  28897. private _lastFrameTime;
  28898. private _lastInteractionTime;
  28899. private _cameraRotationSpeed;
  28900. init(): void;
  28901. attach(camera: ArcRotateCamera): void;
  28902. detach(): void;
  28903. /**
  28904. * Returns true if user is scrolling.
  28905. * @return true if user is scrolling.
  28906. */
  28907. private _userIsZooming();
  28908. private _lastFrameRadius;
  28909. private _shouldAnimationStopForInteraction();
  28910. /**
  28911. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  28912. */
  28913. private _applyUserInteraction();
  28914. private _userIsMoving();
  28915. }
  28916. }
  28917. declare module BABYLON {
  28918. /**
  28919. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  28920. */
  28921. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  28922. readonly name: string;
  28923. /**
  28924. * The easing function used by animations
  28925. */
  28926. static EasingFunction: BackEase;
  28927. /**
  28928. * The easing mode used by animations
  28929. */
  28930. static EasingMode: number;
  28931. /**
  28932. * The duration of the animation, in milliseconds
  28933. */
  28934. transitionDuration: number;
  28935. /**
  28936. * Length of the distance animated by the transition when lower radius is reached
  28937. */
  28938. lowerRadiusTransitionRange: number;
  28939. /**
  28940. * Length of the distance animated by the transition when upper radius is reached
  28941. */
  28942. upperRadiusTransitionRange: number;
  28943. private _autoTransitionRange;
  28944. /**
  28945. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28946. */
  28947. /**
  28948. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28949. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  28950. */
  28951. autoTransitionRange: boolean;
  28952. private _attachedCamera;
  28953. private _onAfterCheckInputsObserver;
  28954. private _onMeshTargetChangedObserver;
  28955. init(): void;
  28956. attach(camera: ArcRotateCamera): void;
  28957. detach(): void;
  28958. private _radiusIsAnimating;
  28959. private _radiusBounceTransition;
  28960. private _animatables;
  28961. private _cachedWheelPrecision;
  28962. /**
  28963. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  28964. * @param radiusLimit The limit to check against.
  28965. * @return Bool to indicate if at limit.
  28966. */
  28967. private _isRadiusAtLimit(radiusLimit);
  28968. /**
  28969. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  28970. * @param radiusDelta The delta by which to animate to. Can be negative.
  28971. */
  28972. private _applyBoundRadiusAnimation(radiusDelta);
  28973. /**
  28974. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  28975. */
  28976. protected _clearAnimationLocks(): void;
  28977. /**
  28978. * Stops and removes all animations that have been applied to the camera
  28979. */
  28980. stopAllAnimations(): void;
  28981. }
  28982. }
  28983. declare module BABYLON {
  28984. class FramingBehavior implements Behavior<ArcRotateCamera> {
  28985. readonly name: string;
  28986. private _mode;
  28987. private _radiusScale;
  28988. private _positionScale;
  28989. private _defaultElevation;
  28990. private _elevationReturnTime;
  28991. private _elevationReturnWaitTime;
  28992. private _zoomStopsAnimation;
  28993. private _framingTime;
  28994. /**
  28995. * The easing function used by animations
  28996. */
  28997. static EasingFunction: ExponentialEase;
  28998. /**
  28999. * The easing mode used by animations
  29000. */
  29001. static EasingMode: number;
  29002. /**
  29003. * Gets current mode used by the behavior.
  29004. */
  29005. /**
  29006. * Sets the current mode used by the behavior
  29007. */
  29008. mode: number;
  29009. /**
  29010. * Gets the scale applied to the radius
  29011. */
  29012. /**
  29013. * Sets the scale applied to the radius (1 by default)
  29014. */
  29015. radiusScale: number;
  29016. /**
  29017. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29018. */
  29019. /**
  29020. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29021. */
  29022. positionScale: number;
  29023. /**
  29024. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29025. * behaviour is triggered, in radians.
  29026. */
  29027. /**
  29028. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29029. * behaviour is triggered, in radians.
  29030. */
  29031. defaultElevation: number;
  29032. /**
  29033. * Gets the time (in milliseconds) taken to return to the default beta position.
  29034. * Negative value indicates camera should not return to default.
  29035. */
  29036. /**
  29037. * Sets the time (in milliseconds) taken to return to the default beta position.
  29038. * Negative value indicates camera should not return to default.
  29039. */
  29040. elevationReturnTime: number;
  29041. /**
  29042. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29043. */
  29044. /**
  29045. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29046. */
  29047. elevationReturnWaitTime: number;
  29048. /**
  29049. * Gets the flag that indicates if user zooming should stop animation.
  29050. */
  29051. /**
  29052. * Sets the flag that indicates if user zooming should stop animation.
  29053. */
  29054. zoomStopsAnimation: boolean;
  29055. /**
  29056. * Gets the transition time when framing the mesh, in milliseconds
  29057. */
  29058. /**
  29059. * Sets the transition time when framing the mesh, in milliseconds
  29060. */
  29061. framingTime: number;
  29062. private _onPrePointerObservableObserver;
  29063. private _onAfterCheckInputsObserver;
  29064. private _onMeshTargetChangedObserver;
  29065. private _attachedCamera;
  29066. private _isPointerDown;
  29067. private _lastInteractionTime;
  29068. init(): void;
  29069. attach(camera: ArcRotateCamera): void;
  29070. detach(): void;
  29071. private _animatables;
  29072. private _betaIsAnimating;
  29073. private _betaTransition;
  29074. private _radiusTransition;
  29075. private _vectorTransition;
  29076. /**
  29077. * Targets the given mesh and updates zoom level accordingly.
  29078. * @param mesh The mesh to target.
  29079. * @param radius Optional. If a cached radius position already exists, overrides default.
  29080. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29081. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29082. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29083. */
  29084. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29085. /**
  29086. * Targets the given mesh with its children and updates zoom level accordingly.
  29087. * @param mesh The mesh to target.
  29088. * @param radius Optional. If a cached radius position already exists, overrides default.
  29089. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29090. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29091. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29092. */
  29093. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29094. /**
  29095. * Targets the given meshes with their children and updates zoom level accordingly.
  29096. * @param meshes The mesh to target.
  29097. * @param radius Optional. If a cached radius position already exists, overrides default.
  29098. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29099. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29100. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29101. */
  29102. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29103. /**
  29104. * Targets the given mesh and updates zoom level accordingly.
  29105. * @param mesh The mesh to target.
  29106. * @param radius Optional. If a cached radius position already exists, overrides default.
  29107. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29108. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29109. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29110. */
  29111. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29112. /**
  29113. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29114. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29115. * frustum width.
  29116. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29117. * to fully enclose the mesh in the viewing frustum.
  29118. */
  29119. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29120. /**
  29121. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29122. * is automatically returned to its default position (expected to be above ground plane).
  29123. */
  29124. private _maintainCameraAboveGround();
  29125. /**
  29126. * Returns the frustum slope based on the canvas ratio and camera FOV
  29127. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29128. */
  29129. private _getFrustumSlope();
  29130. /**
  29131. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29132. */
  29133. private _clearAnimationLocks();
  29134. /**
  29135. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29136. */
  29137. private _applyUserInteraction();
  29138. /**
  29139. * Stops and removes all animations that have been applied to the camera
  29140. */
  29141. stopAllAnimations(): void;
  29142. /**
  29143. * Gets a value indicating if the user is moving the camera
  29144. */
  29145. readonly isUserIsMoving: boolean;
  29146. /**
  29147. * The camera can move all the way towards the mesh.
  29148. */
  29149. static IgnoreBoundsSizeMode: number;
  29150. /**
  29151. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29152. */
  29153. static FitFrustumSidesMode: number;
  29154. }
  29155. }
  29156. declare module BABYLON {
  29157. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  29158. camera: ArcRotateCamera;
  29159. gamepad: Nullable<Gamepad>;
  29160. private _onGamepadConnectedObserver;
  29161. private _onGamepadDisconnectedObserver;
  29162. gamepadRotationSensibility: number;
  29163. gamepadMoveSensibility: number;
  29164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29165. detachControl(element: Nullable<HTMLElement>): void;
  29166. checkInputs(): void;
  29167. getClassName(): string;
  29168. getSimpleName(): string;
  29169. }
  29170. }
  29171. declare module BABYLON {
  29172. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  29173. camera: ArcRotateCamera;
  29174. private _keys;
  29175. keysUp: number[];
  29176. keysDown: number[];
  29177. keysLeft: number[];
  29178. keysRight: number[];
  29179. keysReset: number[];
  29180. panningSensibility: number;
  29181. zoomingSensibility: number;
  29182. useAltToZoom: boolean;
  29183. private _ctrlPressed;
  29184. private _altPressed;
  29185. private _onCanvasBlurObserver;
  29186. private _onKeyboardObserver;
  29187. private _engine;
  29188. private _scene;
  29189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29190. detachControl(element: Nullable<HTMLElement>): void;
  29191. checkInputs(): void;
  29192. getClassName(): string;
  29193. getSimpleName(): string;
  29194. }
  29195. }
  29196. declare module BABYLON {
  29197. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  29198. camera: ArcRotateCamera;
  29199. private _wheel;
  29200. private _observer;
  29201. wheelPrecision: number;
  29202. /**
  29203. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  29204. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  29205. */
  29206. wheelDeltaPercentage: number;
  29207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29208. detachControl(element: Nullable<HTMLElement>): void;
  29209. getClassName(): string;
  29210. getSimpleName(): string;
  29211. }
  29212. }
  29213. declare module BABYLON {
  29214. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  29215. camera: ArcRotateCamera;
  29216. buttons: number[];
  29217. angularSensibilityX: number;
  29218. angularSensibilityY: number;
  29219. pinchPrecision: number;
  29220. /**
  29221. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  29222. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  29223. */
  29224. pinchDeltaPercentage: number;
  29225. panningSensibility: number;
  29226. multiTouchPanning: boolean;
  29227. multiTouchPanAndZoom: boolean;
  29228. private _isPanClick;
  29229. pinchInwards: boolean;
  29230. private _pointerInput;
  29231. private _observer;
  29232. private _onMouseMove;
  29233. private _onGestureStart;
  29234. private _onGesture;
  29235. private _MSGestureHandler;
  29236. private _onLostFocus;
  29237. private _onContextMenu;
  29238. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29239. detachControl(element: Nullable<HTMLElement>): void;
  29240. getClassName(): string;
  29241. getSimpleName(): string;
  29242. }
  29243. }
  29244. declare module BABYLON {
  29245. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  29246. camera: ArcRotateCamera;
  29247. alphaCorrection: number;
  29248. betaCorrection: number;
  29249. gammaCorrection: number;
  29250. private _alpha;
  29251. private _gamma;
  29252. private _dirty;
  29253. private _deviceOrientationHandler;
  29254. constructor();
  29255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29256. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  29257. checkInputs(): void;
  29258. detachControl(element: Nullable<HTMLElement>): void;
  29259. getClassName(): string;
  29260. getSimpleName(): string;
  29261. }
  29262. }
  29263. declare module BABYLON {
  29264. /**
  29265. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  29266. * Screen rotation is taken into account.
  29267. */
  29268. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  29269. private _camera;
  29270. private _screenOrientationAngle;
  29271. private _constantTranform;
  29272. private _screenQuaternion;
  29273. private _alpha;
  29274. private _beta;
  29275. private _gamma;
  29276. constructor();
  29277. camera: FreeCamera;
  29278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29279. private _orientationChanged;
  29280. private _deviceOrientation;
  29281. detachControl(element: Nullable<HTMLElement>): void;
  29282. checkInputs(): void;
  29283. getClassName(): string;
  29284. getSimpleName(): string;
  29285. }
  29286. }
  29287. declare module BABYLON {
  29288. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  29289. camera: FreeCamera;
  29290. gamepad: Nullable<Gamepad>;
  29291. private _onGamepadConnectedObserver;
  29292. private _onGamepadDisconnectedObserver;
  29293. gamepadAngularSensibility: number;
  29294. gamepadMoveSensibility: number;
  29295. private _cameraTransform;
  29296. private _deltaTransform;
  29297. private _vector3;
  29298. private _vector2;
  29299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29300. detachControl(element: Nullable<HTMLElement>): void;
  29301. checkInputs(): void;
  29302. getClassName(): string;
  29303. getSimpleName(): string;
  29304. }
  29305. }
  29306. declare module BABYLON {
  29307. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  29308. camera: FreeCamera;
  29309. private _keys;
  29310. private _onCanvasBlurObserver;
  29311. private _onKeyboardObserver;
  29312. private _engine;
  29313. private _scene;
  29314. keysUp: number[];
  29315. keysDown: number[];
  29316. keysLeft: number[];
  29317. keysRight: number[];
  29318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29319. detachControl(element: Nullable<HTMLElement>): void;
  29320. checkInputs(): void;
  29321. getClassName(): string;
  29322. _onLostFocus(e: FocusEvent): void;
  29323. getSimpleName(): string;
  29324. }
  29325. }
  29326. declare module BABYLON {
  29327. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  29328. touchEnabled: boolean;
  29329. camera: FreeCamera;
  29330. buttons: number[];
  29331. angularSensibility: number;
  29332. private _pointerInput;
  29333. private _onMouseMove;
  29334. private _observer;
  29335. private previousPosition;
  29336. constructor(touchEnabled?: boolean);
  29337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29338. detachControl(element: Nullable<HTMLElement>): void;
  29339. getClassName(): string;
  29340. getSimpleName(): string;
  29341. }
  29342. }
  29343. declare module BABYLON {
  29344. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  29345. camera: FreeCamera;
  29346. private _offsetX;
  29347. private _offsetY;
  29348. private _pointerPressed;
  29349. private _pointerInput;
  29350. private _observer;
  29351. private _onLostFocus;
  29352. touchAngularSensibility: number;
  29353. touchMoveSensibility: number;
  29354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29355. detachControl(element: Nullable<HTMLElement>): void;
  29356. checkInputs(): void;
  29357. getClassName(): string;
  29358. getSimpleName(): string;
  29359. }
  29360. }
  29361. declare module BABYLON {
  29362. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29363. camera: FreeCamera;
  29364. private _leftjoystick;
  29365. private _rightjoystick;
  29366. getLeftJoystick(): VirtualJoystick;
  29367. getRightJoystick(): VirtualJoystick;
  29368. checkInputs(): void;
  29369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29370. detachControl(element: Nullable<HTMLElement>): void;
  29371. getClassName(): string;
  29372. getSimpleName(): string;
  29373. }
  29374. }
  29375. declare module BABYLON {
  29376. class VRCameraMetrics {
  29377. hResolution: number;
  29378. vResolution: number;
  29379. hScreenSize: number;
  29380. vScreenSize: number;
  29381. vScreenCenter: number;
  29382. eyeToScreenDistance: number;
  29383. lensSeparationDistance: number;
  29384. interpupillaryDistance: number;
  29385. distortionK: number[];
  29386. chromaAbCorrection: number[];
  29387. postProcessScaleFactor: number;
  29388. lensCenterOffset: number;
  29389. compensateDistortion: boolean;
  29390. readonly aspectRatio: number;
  29391. readonly aspectRatioFov: number;
  29392. readonly leftHMatrix: Matrix;
  29393. readonly rightHMatrix: Matrix;
  29394. readonly leftPreViewMatrix: Matrix;
  29395. readonly rightPreViewMatrix: Matrix;
  29396. static GetDefault(): VRCameraMetrics;
  29397. }
  29398. }
  29399. declare module BABYLON {
  29400. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29401. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29402. getClassName(): string;
  29403. }
  29404. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29405. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29406. getClassName(): string;
  29407. }
  29408. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29409. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29410. getClassName(): string;
  29411. }
  29412. }
  29413. declare module BABYLON {
  29414. /**
  29415. * Options to modify the vr teleportation behavior.
  29416. */
  29417. interface VRTeleportationOptions {
  29418. /**
  29419. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29420. */
  29421. floorMeshName?: string;
  29422. /**
  29423. * A list of meshes to be used as the teleportation floor. (default: empty)
  29424. */
  29425. floorMeshes?: Mesh[];
  29426. }
  29427. /**
  29428. * Options to modify the vr experience helper's behavior.
  29429. */
  29430. interface VRExperienceHelperOptions extends WebVROptions {
  29431. /**
  29432. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  29433. */
  29434. createDeviceOrientationCamera?: boolean;
  29435. /**
  29436. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  29437. */
  29438. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29439. }
  29440. /**
  29441. * Helps to quickly add VR support to an existing scene.
  29442. * See http://doc.babylonjs.com/how_to/webvr_helper
  29443. */
  29444. class VRExperienceHelper {
  29445. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29446. private _scene;
  29447. private _position;
  29448. private _btnVR;
  29449. private _btnVRDisplayed;
  29450. private _webVRsupported;
  29451. private _webVRready;
  29452. private _webVRrequesting;
  29453. private _webVRpresenting;
  29454. private _fullscreenVRpresenting;
  29455. private _canvas;
  29456. private _webVRCamera;
  29457. private _vrDeviceOrientationCamera;
  29458. private _deviceOrientationCamera;
  29459. private _existingCamera;
  29460. private _onKeyDown;
  29461. private _onVrDisplayPresentChange;
  29462. private _onVRDisplayChanged;
  29463. private _onVRRequestPresentStart;
  29464. private _onVRRequestPresentComplete;
  29465. /**
  29466. * Observable raised when entering VR.
  29467. */
  29468. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29469. /**
  29470. * Observable raised when exiting VR.
  29471. */
  29472. onExitingVRObservable: Observable<VRExperienceHelper>;
  29473. /**
  29474. * Observable raised when controller mesh is loaded.
  29475. */
  29476. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29477. /** Return this.onEnteringVRObservable
  29478. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29479. */
  29480. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29481. /** Return this.onExitingVRObservable
  29482. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29483. */
  29484. readonly onExitingVR: Observable<VRExperienceHelper>;
  29485. /** Return this.onControllerMeshLoadedObservable
  29486. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29487. */
  29488. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29489. private _rayLength;
  29490. private _useCustomVRButton;
  29491. private _teleportationRequested;
  29492. private _teleportActive;
  29493. private _floorMeshName;
  29494. private _floorMeshesCollection;
  29495. private _rotationAllowed;
  29496. private _teleportBackwardsVector;
  29497. private _teleportationTarget;
  29498. private _isDefaultTeleportationTarget;
  29499. private _postProcessMove;
  29500. private _teleportationFillColor;
  29501. private _teleportationBorderColor;
  29502. private _rotationAngle;
  29503. private _haloCenter;
  29504. private _cameraGazer;
  29505. private _padSensibilityUp;
  29506. private _padSensibilityDown;
  29507. private leftController;
  29508. private rightController;
  29509. /**
  29510. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29511. */
  29512. onNewMeshSelected: Observable<AbstractMesh>;
  29513. /**
  29514. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29515. */
  29516. onNewMeshPicked: Observable<PickingInfo>;
  29517. private _circleEase;
  29518. /**
  29519. * Observable raised before camera teleportation
  29520. */
  29521. onBeforeCameraTeleport: Observable<Vector3>;
  29522. /**
  29523. * Observable raised after camera teleportation
  29524. */
  29525. onAfterCameraTeleport: Observable<Vector3>;
  29526. /**
  29527. * Observable raised when current selected mesh gets unselected
  29528. */
  29529. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29530. private _raySelectionPredicate;
  29531. /**
  29532. * To be optionaly changed by user to define custom ray selection
  29533. */
  29534. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29535. /**
  29536. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29537. */
  29538. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29539. /**
  29540. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29541. */
  29542. teleportationEnabled: boolean;
  29543. private _defaultHeight;
  29544. private _teleportationInitialized;
  29545. private _interactionsEnabled;
  29546. private _interactionsRequested;
  29547. private _displayGaze;
  29548. private _displayLaserPointer;
  29549. /**
  29550. * The mesh used to display where the user is going to teleport.
  29551. */
  29552. /**
  29553. * Sets the mesh to be used to display where the user is going to teleport.
  29554. */
  29555. teleportationTarget: Mesh;
  29556. /**
  29557. * The mesh used to display where the user is selecting,
  29558. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29559. * See http://doc.babylonjs.com/resources/baking_transformations
  29560. */
  29561. gazeTrackerMesh: Mesh;
  29562. /**
  29563. * If the ray of the gaze should be displayed.
  29564. */
  29565. /**
  29566. * Sets if the ray of the gaze should be displayed.
  29567. */
  29568. displayGaze: boolean;
  29569. /**
  29570. * If the ray of the LaserPointer should be displayed.
  29571. */
  29572. /**
  29573. * Sets if the ray of the LaserPointer should be displayed.
  29574. */
  29575. displayLaserPointer: boolean;
  29576. /**
  29577. * The deviceOrientationCamera used as the camera when not in VR.
  29578. */
  29579. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29580. /**
  29581. * Based on the current WebVR support, returns the current VR camera used.
  29582. */
  29583. readonly currentVRCamera: Nullable<Camera>;
  29584. /**
  29585. * The webVRCamera which is used when in VR.
  29586. */
  29587. readonly webVRCamera: WebVRFreeCamera;
  29588. /**
  29589. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29590. */
  29591. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29592. private readonly _teleportationRequestInitiated;
  29593. /**
  29594. * Instantiates a VRExperienceHelper.
  29595. * Helps to quickly add VR support to an existing scene.
  29596. * @param scene The scene the VRExperienceHelper belongs to.
  29597. * @param webVROptions Options to modify the vr experience helper's behavior.
  29598. */
  29599. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29600. private _onDefaultMeshLoaded(webVRController);
  29601. private _onResize;
  29602. private _onFullscreenChange;
  29603. /**
  29604. * Gets a value indicating if we are currently in VR mode.
  29605. */
  29606. readonly isInVRMode: boolean;
  29607. private onVrDisplayPresentChange();
  29608. private onVRDisplayChanged(eventArgs);
  29609. private moveButtonToBottomRight();
  29610. private displayVRButton();
  29611. private updateButtonVisibility();
  29612. /**
  29613. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29614. * Otherwise, will use the fullscreen API.
  29615. */
  29616. enterVR(): void;
  29617. /**
  29618. * Attempt to exit VR, or fullscreen.
  29619. */
  29620. exitVR(): void;
  29621. /**
  29622. * The position of the vr experience helper.
  29623. */
  29624. /**
  29625. * Sets the position of the vr experience helper.
  29626. */
  29627. position: Vector3;
  29628. /**
  29629. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29630. */
  29631. enableInteractions(): void;
  29632. private beforeRender;
  29633. private _isTeleportationFloor(mesh);
  29634. /**
  29635. * Adds a floor mesh to be used for teleportation.
  29636. * @param floorMesh the mesh to be used for teleportation.
  29637. */
  29638. addFloorMesh(floorMesh: Mesh): void;
  29639. /**
  29640. * Removes a floor mesh from being used for teleportation.
  29641. * @param floorMesh the mesh to be removed.
  29642. */
  29643. removeFloorMesh(floorMesh: Mesh): void;
  29644. /**
  29645. * Enables interactions and teleportation using the VR controllers and gaze.
  29646. * @param vrTeleportationOptions options to modify teleportation behavior.
  29647. */
  29648. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29649. private _onNewGamepadConnected;
  29650. private _tryEnableInteractionOnController;
  29651. private _onNewGamepadDisconnected;
  29652. private _enableInteractionOnController(controller);
  29653. private _checkTeleportWithRay(stateObject, gazer);
  29654. private _checkRotate(stateObject, gazer);
  29655. private _checkTeleportBackwards(stateObject, gazer);
  29656. private _enableTeleportationOnController(controller);
  29657. private _createTeleportationCircles();
  29658. private _displayTeleportationTarget();
  29659. private _hideTeleportationTarget();
  29660. private _rotateCamera(right);
  29661. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29662. private _workingVector;
  29663. private _workingQuaternion;
  29664. private _workingMatrix;
  29665. private _teleportCamera(location);
  29666. private _convertNormalToDirectionOfRay(normal, ray);
  29667. private _castRayAndSelectObject(gazer);
  29668. private _notifySelectedMeshUnselected(mesh);
  29669. /**
  29670. * Sets the color of the laser ray from the vr controllers.
  29671. * @param color new color for the ray.
  29672. */
  29673. changeLaserColor(color: Color3): void;
  29674. /**
  29675. * Sets the color of the ray from the vr headsets gaze.
  29676. * @param color new color for the ray.
  29677. */
  29678. changeGazeColor(color: Color3): void;
  29679. /**
  29680. * Exits VR and disposes of the vr experience helper
  29681. */
  29682. dispose(): void;
  29683. /**
  29684. * Gets the name of the VRExperienceHelper class
  29685. * @returns "VRExperienceHelper"
  29686. */
  29687. getClassName(): string;
  29688. }
  29689. }
  29690. declare module BABYLON {
  29691. /**
  29692. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29693. * IMPORTANT!! The data is right-hand data.
  29694. * @export
  29695. * @interface DevicePose
  29696. */
  29697. interface DevicePose {
  29698. /**
  29699. * The position of the device, values in array are [x,y,z].
  29700. */
  29701. readonly position: Nullable<Float32Array>;
  29702. /**
  29703. * The linearVelocity of the device, values in array are [x,y,z].
  29704. */
  29705. readonly linearVelocity: Nullable<Float32Array>;
  29706. /**
  29707. * The linearAcceleration of the device, values in array are [x,y,z].
  29708. */
  29709. readonly linearAcceleration: Nullable<Float32Array>;
  29710. /**
  29711. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29712. */
  29713. readonly orientation: Nullable<Float32Array>;
  29714. /**
  29715. * The angularVelocity of the device, values in array are [x,y,z].
  29716. */
  29717. readonly angularVelocity: Nullable<Float32Array>;
  29718. /**
  29719. * The angularAcceleration of the device, values in array are [x,y,z].
  29720. */
  29721. readonly angularAcceleration: Nullable<Float32Array>;
  29722. }
  29723. /**
  29724. * Interface representing a pose controlled object in Babylon.
  29725. * A pose controlled object has both regular pose values as well as pose values
  29726. * from an external device such as a VR head mounted display
  29727. */
  29728. interface PoseControlled {
  29729. /**
  29730. * The position of the object in babylon space.
  29731. */
  29732. position: Vector3;
  29733. /**
  29734. * The rotation quaternion of the object in babylon space.
  29735. */
  29736. rotationQuaternion: Quaternion;
  29737. /**
  29738. * The position of the device in babylon space.
  29739. */
  29740. devicePosition?: Vector3;
  29741. /**
  29742. * The rotation quaternion of the device in babylon space.
  29743. */
  29744. deviceRotationQuaternion: Quaternion;
  29745. /**
  29746. * The raw pose coming from the device.
  29747. */
  29748. rawPose: Nullable<DevicePose>;
  29749. /**
  29750. * The scale of the device to be used when translating from device space to babylon space.
  29751. */
  29752. deviceScaleFactor: number;
  29753. /**
  29754. * Updates the poseControlled values based on the input device pose.
  29755. * @param poseData the pose data to update the object with
  29756. */
  29757. updateFromDevice(poseData: DevicePose): void;
  29758. }
  29759. /**
  29760. * Set of options to customize the webVRCamera
  29761. */
  29762. interface WebVROptions {
  29763. /**
  29764. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29765. */
  29766. trackPosition?: boolean;
  29767. /**
  29768. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29769. */
  29770. positionScale?: number;
  29771. /**
  29772. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29773. */
  29774. displayName?: string;
  29775. /**
  29776. * Should the native controller meshes be initialized. (default: true)
  29777. */
  29778. controllerMeshes?: boolean;
  29779. /**
  29780. * Creating a default HemiLight only on controllers. (default: true)
  29781. */
  29782. defaultLightingOnControllers?: boolean;
  29783. /**
  29784. * If you don't want to use the default VR button of the helper. (default: false)
  29785. */
  29786. useCustomVRButton?: boolean;
  29787. /**
  29788. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29789. */
  29790. customVRButton?: HTMLButtonElement;
  29791. /**
  29792. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29793. */
  29794. rayLength?: number;
  29795. /**
  29796. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29797. */
  29798. defaultHeight?: number;
  29799. }
  29800. /**
  29801. * This represents a WebVR camera.
  29802. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29803. * @example http://doc.babylonjs.com/how_to/webvr_camera
  29804. */
  29805. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29806. private webVROptions;
  29807. /**
  29808. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29809. */
  29810. _vrDevice: any;
  29811. /**
  29812. * The rawPose of the vrDevice.
  29813. */
  29814. rawPose: Nullable<DevicePose>;
  29815. private _onVREnabled;
  29816. private _specsVersion;
  29817. private _attached;
  29818. private _frameData;
  29819. protected _descendants: Array<Node>;
  29820. private _deviceRoomPosition;
  29821. private _deviceRoomRotationQuaternion;
  29822. private _standingMatrix;
  29823. /**
  29824. * Represents device position in babylon space.
  29825. */
  29826. devicePosition: Vector3;
  29827. /**
  29828. * Represents device rotation in babylon space.
  29829. */
  29830. deviceRotationQuaternion: Quaternion;
  29831. /**
  29832. * The scale of the device to be used when translating from device space to babylon space.
  29833. */
  29834. deviceScaleFactor: number;
  29835. private _deviceToWorld;
  29836. private _worldToDevice;
  29837. /**
  29838. * References to the webVR controllers for the vrDevice.
  29839. */
  29840. controllers: Array<WebVRController>;
  29841. /**
  29842. * Emits an event when a controller is attached.
  29843. */
  29844. onControllersAttachedObservable: Observable<WebVRController[]>;
  29845. /**
  29846. * Emits an event when a controller's mesh has been loaded;
  29847. */
  29848. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29849. /**
  29850. * If the rig cameras be used as parent instead of this camera.
  29851. */
  29852. rigParenting: boolean;
  29853. private _lightOnControllers;
  29854. private _defaultHeight?;
  29855. /**
  29856. * Instantiates a WebVRFreeCamera.
  29857. * @param name The name of the WebVRFreeCamera
  29858. * @param position The starting anchor position for the camera
  29859. * @param scene The scene the camera belongs to
  29860. * @param webVROptions a set of customizable options for the webVRCamera
  29861. */
  29862. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  29863. /**
  29864. * Gets the device distance from the ground in meters.
  29865. * @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.
  29866. */
  29867. deviceDistanceToRoomGround(): number;
  29868. /**
  29869. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29870. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  29871. */
  29872. useStandingMatrix(callback?: (bool: boolean) => void): void;
  29873. /**
  29874. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29875. * @returns A promise with a boolean set to if the standing matrix is supported.
  29876. */
  29877. useStandingMatrixAsync(): Promise<boolean>;
  29878. /**
  29879. * Disposes the camera
  29880. */
  29881. dispose(): void;
  29882. /**
  29883. * Gets a vrController by name.
  29884. * @param name The name of the controller to retreive
  29885. * @returns the controller matching the name specified or null if not found
  29886. */
  29887. getControllerByName(name: string): Nullable<WebVRController>;
  29888. private _leftController;
  29889. /**
  29890. * The controller corrisponding to the users left hand.
  29891. */
  29892. readonly leftController: Nullable<WebVRController>;
  29893. private _rightController;
  29894. /**
  29895. * The controller corrisponding to the users right hand.
  29896. */
  29897. readonly rightController: Nullable<WebVRController>;
  29898. /**
  29899. * Casts a ray forward from the vrCamera's gaze.
  29900. * @param length Length of the ray (default: 100)
  29901. * @returns the ray corrisponding to the gaze
  29902. */
  29903. getForwardRay(length?: number): Ray;
  29904. /**
  29905. * Updates the camera based on device's frame data
  29906. */
  29907. _checkInputs(): void;
  29908. /**
  29909. * Updates the poseControlled values based on the input device pose.
  29910. * @param poseData Pose coming from the device
  29911. */
  29912. updateFromDevice(poseData: DevicePose): void;
  29913. /**
  29914. * WebVR's attach control will start broadcasting frames to the device.
  29915. * Note that in certain browsers (chrome for example) this function must be called
  29916. * within a user-interaction callback. Example:
  29917. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  29918. *
  29919. * @param element html element to attach the vrDevice to
  29920. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  29921. */
  29922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29923. /**
  29924. * Detaches the camera from the html element and disables VR
  29925. *
  29926. * @param element html element to detach from
  29927. */
  29928. detachControl(element: HTMLElement): void;
  29929. /**
  29930. * @returns the name of this class
  29931. */
  29932. getClassName(): string;
  29933. /**
  29934. * Calls resetPose on the vrDisplay
  29935. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  29936. */
  29937. resetToCurrentRotation(): void;
  29938. /**
  29939. * Updates the rig cameras (left and right eye)
  29940. */
  29941. _updateRigCameras(): void;
  29942. private _workingVector;
  29943. private _oneVector;
  29944. private _workingMatrix;
  29945. private updateCacheCalled;
  29946. /**
  29947. * Updates the cached values of the camera
  29948. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  29949. */
  29950. _updateCache(ignoreParentClass?: boolean): void;
  29951. /**
  29952. * Updates the current device position and rotation in the babylon world
  29953. */
  29954. update(): void;
  29955. /**
  29956. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  29957. * @returns an identity matrix
  29958. */
  29959. _getViewMatrix(): Matrix;
  29960. /**
  29961. * This function is called by the two RIG cameras.
  29962. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  29963. */
  29964. protected _getWebVRViewMatrix(): Matrix;
  29965. protected _getWebVRProjectionMatrix(): Matrix;
  29966. private _onGamepadConnectedObserver;
  29967. private _onGamepadDisconnectedObserver;
  29968. /**
  29969. * Initializes the controllers and their meshes
  29970. */
  29971. initControllers(): void;
  29972. }
  29973. }
  29974. declare module BABYLON {
  29975. interface IOctreeContainer<T> {
  29976. blocks: Array<OctreeBlock<T>>;
  29977. }
  29978. class Octree<T> {
  29979. maxDepth: number;
  29980. blocks: Array<OctreeBlock<T>>;
  29981. dynamicContent: T[];
  29982. private _maxBlockCapacity;
  29983. private _selectionContent;
  29984. private _creationFunc;
  29985. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29986. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29987. addMesh(entry: T): void;
  29988. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29989. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29990. intersectsRay(ray: Ray): SmartArray<T>;
  29991. 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;
  29992. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29993. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29994. }
  29995. }
  29996. declare module BABYLON {
  29997. class OctreeBlock<T> {
  29998. entries: T[];
  29999. blocks: Array<OctreeBlock<T>>;
  30000. private _depth;
  30001. private _maxDepth;
  30002. private _capacity;
  30003. private _minPoint;
  30004. private _maxPoint;
  30005. private _boundingVectors;
  30006. private _creationFunc;
  30007. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  30008. readonly capacity: number;
  30009. readonly minPoint: Vector3;
  30010. readonly maxPoint: Vector3;
  30011. addEntry(entry: T): void;
  30012. addEntries(entries: T[]): void;
  30013. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30014. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30015. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  30016. createInnerBlocks(): void;
  30017. }
  30018. }
  30019. declare module BABYLON {
  30020. /**
  30021. * Google Daydream controller
  30022. */
  30023. class DaydreamController extends WebVRController {
  30024. /**
  30025. * Base Url for the controller model.
  30026. */
  30027. static MODEL_BASE_URL: string;
  30028. /**
  30029. * File name for the controller model.
  30030. */
  30031. static MODEL_FILENAME: string;
  30032. /**
  30033. * Gamepad Id prefix used to identify Daydream Controller.
  30034. */
  30035. static readonly GAMEPAD_ID_PREFIX: string;
  30036. /**
  30037. * Creates a new DaydreamController from a gamepad
  30038. * @param vrGamepad the gamepad that the controller should be created from
  30039. */
  30040. constructor(vrGamepad: any);
  30041. /**
  30042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30043. * @param scene scene in which to add meshes
  30044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30045. */
  30046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30047. /**
  30048. * Called once for each button that changed state since the last frame
  30049. * @param buttonIdx Which button index changed
  30050. * @param state New state of the button
  30051. * @param changes Which properties on the state changed since last frame
  30052. */
  30053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30054. }
  30055. }
  30056. declare module BABYLON {
  30057. /**
  30058. * Gear VR Controller
  30059. */
  30060. class GearVRController extends WebVRController {
  30061. /**
  30062. * Base Url for the controller model.
  30063. */
  30064. static MODEL_BASE_URL: string;
  30065. /**
  30066. * File name for the controller model.
  30067. */
  30068. static MODEL_FILENAME: string;
  30069. /**
  30070. * Gamepad Id prefix used to identify this controller.
  30071. */
  30072. static readonly GAMEPAD_ID_PREFIX: string;
  30073. private readonly _buttonIndexToObservableNameMap;
  30074. /**
  30075. * Creates a new GearVRController from a gamepad
  30076. * @param vrGamepad the gamepad that the controller should be created from
  30077. */
  30078. constructor(vrGamepad: any);
  30079. /**
  30080. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30081. * @param scene scene in which to add meshes
  30082. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30083. */
  30084. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30085. /**
  30086. * Called once for each button that changed state since the last frame
  30087. * @param buttonIdx Which button index changed
  30088. * @param state New state of the button
  30089. * @param changes Which properties on the state changed since last frame
  30090. */
  30091. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30092. }
  30093. }
  30094. declare module BABYLON {
  30095. /**
  30096. * Generic Controller
  30097. */
  30098. class GenericController extends WebVRController {
  30099. /**
  30100. * Base Url for the controller model.
  30101. */
  30102. static readonly MODEL_BASE_URL: string;
  30103. /**
  30104. * File name for the controller model.
  30105. */
  30106. static readonly MODEL_FILENAME: string;
  30107. /**
  30108. * Creates a new GenericController from a gamepad
  30109. * @param vrGamepad the gamepad that the controller should be created from
  30110. */
  30111. constructor(vrGamepad: any);
  30112. /**
  30113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30114. * @param scene scene in which to add meshes
  30115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30116. */
  30117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30118. /**
  30119. * Called once for each button that changed state since the last frame
  30120. * @param buttonIdx Which button index changed
  30121. * @param state New state of the button
  30122. * @param changes Which properties on the state changed since last frame
  30123. */
  30124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30125. }
  30126. }
  30127. declare module BABYLON {
  30128. /**
  30129. * Oculus Touch Controller
  30130. */
  30131. class OculusTouchController extends WebVRController {
  30132. /**
  30133. * Base Url for the controller model.
  30134. */
  30135. static MODEL_BASE_URL: string;
  30136. /**
  30137. * File name for the left controller model.
  30138. */
  30139. static MODEL_LEFT_FILENAME: string;
  30140. /**
  30141. * File name for the right controller model.
  30142. */
  30143. static MODEL_RIGHT_FILENAME: string;
  30144. /**
  30145. * Fired when the secondary trigger on this controller is modified
  30146. */
  30147. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30148. /**
  30149. * Fired when the thumb rest on this controller is modified
  30150. */
  30151. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30152. /**
  30153. * Creates a new OculusTouchController from a gamepad
  30154. * @param vrGamepad the gamepad that the controller should be created from
  30155. */
  30156. constructor(vrGamepad: any);
  30157. /**
  30158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30159. * @param scene scene in which to add meshes
  30160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30161. */
  30162. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30163. /**
  30164. * Fired when the A button on this controller is modified
  30165. */
  30166. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30167. /**
  30168. * Fired when the B button on this controller is modified
  30169. */
  30170. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30171. /**
  30172. * Fired when the X button on this controller is modified
  30173. */
  30174. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30175. /**
  30176. * Fired when the Y button on this controller is modified
  30177. */
  30178. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30179. /**
  30180. * Called once for each button that changed state since the last frame
  30181. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30182. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30183. * 2) secondary trigger (same)
  30184. * 3) A (right) X (left), touch, pressed = value
  30185. * 4) B / Y
  30186. * 5) thumb rest
  30187. * @param buttonIdx Which button index changed
  30188. * @param state New state of the button
  30189. * @param changes Which properties on the state changed since last frame
  30190. */
  30191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30192. }
  30193. }
  30194. declare module BABYLON {
  30195. /**
  30196. * Defines the types of pose enabled controllers that are supported
  30197. */
  30198. enum PoseEnabledControllerType {
  30199. /**
  30200. * HTC Vive
  30201. */
  30202. VIVE = 0,
  30203. /**
  30204. * Oculus Rift
  30205. */
  30206. OCULUS = 1,
  30207. /**
  30208. * Windows mixed reality
  30209. */
  30210. WINDOWS = 2,
  30211. /**
  30212. * Samsung gear VR
  30213. */
  30214. GEAR_VR = 3,
  30215. /**
  30216. * Google Daydream
  30217. */
  30218. DAYDREAM = 4,
  30219. /**
  30220. * Generic
  30221. */
  30222. GENERIC = 5,
  30223. }
  30224. /**
  30225. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30226. */
  30227. interface MutableGamepadButton {
  30228. /**
  30229. * Value of the button/trigger
  30230. */
  30231. value: number;
  30232. /**
  30233. * If the button/trigger is currently touched
  30234. */
  30235. touched: boolean;
  30236. /**
  30237. * If the button/trigger is currently pressed
  30238. */
  30239. pressed: boolean;
  30240. }
  30241. /**
  30242. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30243. * @hidden
  30244. */
  30245. interface ExtendedGamepadButton extends GamepadButton {
  30246. /**
  30247. * If the button/trigger is currently pressed
  30248. */
  30249. readonly pressed: boolean;
  30250. /**
  30251. * If the button/trigger is currently touched
  30252. */
  30253. readonly touched: boolean;
  30254. /**
  30255. * Value of the button/trigger
  30256. */
  30257. readonly value: number;
  30258. }
  30259. /**
  30260. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30261. */
  30262. class PoseEnabledControllerHelper {
  30263. /**
  30264. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30265. * @param vrGamepad the gamepad to initialized
  30266. * @returns a vr controller of the type the gamepad identified as
  30267. */
  30268. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30269. }
  30270. /**
  30271. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30272. */
  30273. class PoseEnabledController extends Gamepad implements PoseControlled {
  30274. private _deviceRoomPosition;
  30275. private _deviceRoomRotationQuaternion;
  30276. /**
  30277. * The device position in babylon space
  30278. */
  30279. devicePosition: Vector3;
  30280. /**
  30281. * The device rotation in babylon space
  30282. */
  30283. deviceRotationQuaternion: Quaternion;
  30284. /**
  30285. * The scale factor of the device in babylon space
  30286. */
  30287. deviceScaleFactor: number;
  30288. /**
  30289. * (Likely devicePosition should be used instead) The device position in its room space
  30290. */
  30291. position: Vector3;
  30292. /**
  30293. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30294. */
  30295. rotationQuaternion: Quaternion;
  30296. /**
  30297. * The type of controller (Eg. Windows mixed reality)
  30298. */
  30299. controllerType: PoseEnabledControllerType;
  30300. private _calculatedPosition;
  30301. private _calculatedRotation;
  30302. /**
  30303. * The raw pose from the device
  30304. */
  30305. rawPose: DevicePose;
  30306. /**
  30307. * Internal, the mesh attached to the controller
  30308. */
  30309. _mesh: Nullable<AbstractMesh>;
  30310. private _poseControlledCamera;
  30311. private _leftHandSystemQuaternion;
  30312. /**
  30313. * Internal, matrix used to convert room space to babylon space
  30314. */
  30315. _deviceToWorld: Matrix;
  30316. /**
  30317. * Node to be used when casting a ray from the controller
  30318. */
  30319. _pointingPoseNode: Nullable<AbstractMesh>;
  30320. /**
  30321. * Name of the child mesh that can be used to cast a ray from the controller
  30322. */
  30323. static readonly POINTING_POSE: string;
  30324. /**
  30325. * Creates a new PoseEnabledController from a gamepad
  30326. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30327. */
  30328. constructor(browserGamepad: any);
  30329. private _workingMatrix;
  30330. /**
  30331. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30332. */
  30333. update(): void;
  30334. /**
  30335. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30336. * @param poseData raw pose fromthe device
  30337. */
  30338. updateFromDevice(poseData: DevicePose): void;
  30339. /**
  30340. * @hidden
  30341. */
  30342. _meshAttachedObservable: Observable<AbstractMesh>;
  30343. /**
  30344. * Attaches a mesh to the controller
  30345. * @param mesh the mesh to be attached
  30346. */
  30347. attachToMesh(mesh: AbstractMesh): void;
  30348. /**
  30349. * Attaches the controllers mesh to a camera
  30350. * @param camera the camera the mesh should be attached to
  30351. */
  30352. attachToPoseControlledCamera(camera: TargetCamera): void;
  30353. /**
  30354. * Disposes of the controller
  30355. */
  30356. dispose(): void;
  30357. /**
  30358. * The mesh that is attached to the controller
  30359. */
  30360. readonly mesh: Nullable<AbstractMesh>;
  30361. /**
  30362. * Gets the ray of the controller in the direction the controller is pointing
  30363. * @param length the length the resulting ray should be
  30364. * @returns a ray in the direction the controller is pointing
  30365. */
  30366. getForwardRay(length?: number): Ray;
  30367. }
  30368. }
  30369. declare module BABYLON {
  30370. /**
  30371. * Vive Controller
  30372. */
  30373. class ViveController extends WebVRController {
  30374. /**
  30375. * Base Url for the controller model.
  30376. */
  30377. static MODEL_BASE_URL: string;
  30378. /**
  30379. * File name for the controller model.
  30380. */
  30381. static MODEL_FILENAME: string;
  30382. /**
  30383. * Creates a new ViveController from a gamepad
  30384. * @param vrGamepad the gamepad that the controller should be created from
  30385. */
  30386. constructor(vrGamepad: any);
  30387. /**
  30388. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30389. * @param scene scene in which to add meshes
  30390. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30391. */
  30392. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30393. /**
  30394. * Fired when the left button on this controller is modified
  30395. */
  30396. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30397. /**
  30398. * Fired when the right button on this controller is modified
  30399. */
  30400. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30401. /**
  30402. * Fired when the menu button on this controller is modified
  30403. */
  30404. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30405. /**
  30406. * Called once for each button that changed state since the last frame
  30407. * Vive mapping:
  30408. * 0: touchpad
  30409. * 1: trigger
  30410. * 2: left AND right buttons
  30411. * 3: menu button
  30412. * @param buttonIdx Which button index changed
  30413. * @param state New state of the button
  30414. * @param changes Which properties on the state changed since last frame
  30415. */
  30416. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30417. }
  30418. }
  30419. declare module BABYLON {
  30420. /**
  30421. * Defines the WebVRController object that represents controllers tracked in 3D space
  30422. */
  30423. abstract class WebVRController extends PoseEnabledController {
  30424. /**
  30425. * Internal, the default controller model for the controller
  30426. */
  30427. protected _defaultModel: AbstractMesh;
  30428. /**
  30429. * Fired when the trigger state has changed
  30430. */
  30431. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30432. /**
  30433. * Fired when the main button state has changed
  30434. */
  30435. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30436. /**
  30437. * Fired when the secondary button state has changed
  30438. */
  30439. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30440. /**
  30441. * Fired when the pad state has changed
  30442. */
  30443. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30444. /**
  30445. * Fired when controllers stick values have changed
  30446. */
  30447. onPadValuesChangedObservable: Observable<StickValues>;
  30448. /**
  30449. * Array of button availible on the controller
  30450. */
  30451. protected _buttons: Array<MutableGamepadButton>;
  30452. private _onButtonStateChange;
  30453. /**
  30454. * Fired when a controller button's state has changed
  30455. * @param callback the callback containing the button that was modified
  30456. */
  30457. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30458. /**
  30459. * X and Y axis corrisponding to the controllers joystick
  30460. */
  30461. pad: StickValues;
  30462. /**
  30463. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30464. */
  30465. hand: string;
  30466. /**
  30467. * The default controller model for the controller
  30468. */
  30469. readonly defaultModel: AbstractMesh;
  30470. /**
  30471. * Creates a new WebVRController from a gamepad
  30472. * @param vrGamepad the gamepad that the WebVRController should be created from
  30473. */
  30474. constructor(vrGamepad: any);
  30475. /**
  30476. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30477. */
  30478. update(): void;
  30479. /**
  30480. * Function to be called when a button is modified
  30481. */
  30482. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30483. /**
  30484. * Loads a mesh and attaches it to the controller
  30485. * @param scene the scene the mesh should be added to
  30486. * @param meshLoaded callback for when the mesh has been loaded
  30487. */
  30488. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30489. private _setButtonValue(newState, currentState, buttonIndex);
  30490. private _changes;
  30491. private _checkChanges(newState, currentState);
  30492. /**
  30493. * Disposes of th webVRCOntroller
  30494. */
  30495. dispose(): void;
  30496. }
  30497. }
  30498. declare module BABYLON {
  30499. /**
  30500. * Defines the WindowsMotionController object that the state of the windows motion controller
  30501. */
  30502. class WindowsMotionController extends WebVRController {
  30503. /**
  30504. * The base url used to load the left and right controller models
  30505. */
  30506. static MODEL_BASE_URL: string;
  30507. /**
  30508. * The name of the left controller model file
  30509. */
  30510. static MODEL_LEFT_FILENAME: string;
  30511. /**
  30512. * The name of the right controller model file
  30513. */
  30514. static MODEL_RIGHT_FILENAME: string;
  30515. /**
  30516. * The controller name prefix for this controller type
  30517. */
  30518. static readonly GAMEPAD_ID_PREFIX: string;
  30519. /**
  30520. * The controller id pattern for this controller type
  30521. */
  30522. private static readonly GAMEPAD_ID_PATTERN;
  30523. private _loadedMeshInfo;
  30524. private readonly _mapping;
  30525. /**
  30526. * Fired when the trackpad on this controller is clicked
  30527. */
  30528. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30529. /**
  30530. * Fired when the trackpad on this controller is modified
  30531. */
  30532. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30533. /**
  30534. * The current x and y values of this controller's trackpad
  30535. */
  30536. trackpad: StickValues;
  30537. /**
  30538. * Creates a new WindowsMotionController from a gamepad
  30539. * @param vrGamepad the gamepad that the controller should be created from
  30540. */
  30541. constructor(vrGamepad: any);
  30542. /**
  30543. * Fired when the trigger on this controller is modified
  30544. */
  30545. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30546. /**
  30547. * Fired when the menu button on this controller is modified
  30548. */
  30549. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30550. /**
  30551. * Fired when the grip button on this controller is modified
  30552. */
  30553. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30554. /**
  30555. * Fired when the thumbstick button on this controller is modified
  30556. */
  30557. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30558. /**
  30559. * Fired when the touchpad button on this controller is modified
  30560. */
  30561. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30562. /**
  30563. * Fired when the touchpad values on this controller are modified
  30564. */
  30565. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30566. /**
  30567. * Called once per frame by the engine.
  30568. */
  30569. update(): void;
  30570. /**
  30571. * Called once for each button that changed state since the last frame
  30572. * @param buttonIdx Which button index changed
  30573. * @param state New state of the button
  30574. * @param changes Which properties on the state changed since last frame
  30575. */
  30576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30577. /**
  30578. * Moves the buttons on the controller mesh based on their current state
  30579. * @param buttonName the name of the button to move
  30580. * @param buttonValue the value of the button which determines the buttons new position
  30581. */
  30582. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30583. /**
  30584. * Moves the axis on the controller mesh based on its current state
  30585. * @param axis the index of the axis
  30586. * @param axisValue the value of the axis which determines the meshes new position
  30587. * @hidden
  30588. */
  30589. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30590. /**
  30591. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30592. * @param scene scene in which to add meshes
  30593. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30594. */
  30595. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30596. /**
  30597. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30598. * can be transformed by button presses and axes values, based on this._mapping.
  30599. *
  30600. * @param scene scene in which the meshes exist
  30601. * @param meshes list of meshes that make up the controller model to process
  30602. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30603. */
  30604. private processModel(scene, meshes);
  30605. private createMeshInfo(rootNode);
  30606. /**
  30607. * Gets the ray of the controller in the direction the controller is pointing
  30608. * @param length the length the resulting ray should be
  30609. * @returns a ray in the direction the controller is pointing
  30610. */
  30611. getForwardRay(length?: number): Ray;
  30612. /**
  30613. * Disposes of the controller
  30614. */
  30615. dispose(): void;
  30616. }
  30617. }
  30618. declare module BABYLON {
  30619. /**
  30620. * Interface to implement to create a shadow generator compatible with BJS.
  30621. */
  30622. interface IShadowGenerator {
  30623. /**
  30624. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30625. * @returns The render target texture if present otherwise, null
  30626. */
  30627. getShadowMap(): Nullable<RenderTargetTexture>;
  30628. /**
  30629. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30630. * @returns The render target texture if the shadow map is present otherwise, null
  30631. */
  30632. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30633. /**
  30634. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30635. * @param subMesh The submesh we want to render in the shadow map
  30636. * @param useInstances Defines wether will draw in the map using instances
  30637. * @returns true if ready otherwise, false
  30638. */
  30639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30640. /**
  30641. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30642. * @param defines Defines of the material we want to update
  30643. * @param lightIndex Index of the light in the enabled light list of the material
  30644. */
  30645. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30646. /**
  30647. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30648. * defined in the generator but impacting the effect).
  30649. * It implies the unifroms available on the materials are the standard BJS ones.
  30650. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30651. * @param effect The effect we are binfing the information for
  30652. */
  30653. bindShadowLight(lightIndex: string, effect: Effect): void;
  30654. /**
  30655. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30656. * (eq to shadow prjection matrix * light transform matrix)
  30657. * @returns The transform matrix used to create the shadow map
  30658. */
  30659. getTransformMatrix(): Matrix;
  30660. /**
  30661. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30662. * Cube and 2D textures for instance.
  30663. */
  30664. recreateShadowMap(): void;
  30665. /**
  30666. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30667. * @param onCompiled Callback triggered at the and of the effects compilation
  30668. * @param options Sets of optional options forcing the compilation with different modes
  30669. */
  30670. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  30671. useInstances: boolean;
  30672. }>): void;
  30673. /**
  30674. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30675. * @param options Sets of optional options forcing the compilation with different modes
  30676. * @returns A promise that resolves when the compilation completes
  30677. */
  30678. forceCompilationAsync(options?: Partial<{
  30679. useInstances: boolean;
  30680. }>): Promise<void>;
  30681. /**
  30682. * Serializes the shadow generator setup to a json object.
  30683. * @returns The serialized JSON object
  30684. */
  30685. serialize(): any;
  30686. /**
  30687. * Disposes the Shadow map and related Textures and effects.
  30688. */
  30689. dispose(): void;
  30690. }
  30691. /**
  30692. * Default implementation IShadowGenerator.
  30693. * This is the main object responsible of generating shadows in the framework.
  30694. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30695. */
  30696. class ShadowGenerator implements IShadowGenerator {
  30697. /**
  30698. * Shadow generator mode None: no filtering applied.
  30699. */
  30700. static readonly FILTER_NONE: number;
  30701. /**
  30702. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30703. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30704. */
  30705. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30706. /**
  30707. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30708. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30709. */
  30710. static readonly FILTER_POISSONSAMPLING: number;
  30711. /**
  30712. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30713. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30714. */
  30715. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30716. /**
  30717. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30718. * edge artifacts on steep falloff.
  30719. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30720. */
  30721. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30722. /**
  30723. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30724. * edge artifacts on steep falloff.
  30725. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30726. */
  30727. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30728. /**
  30729. * Shadow generator mode PCF: Percentage Closer Filtering
  30730. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30731. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30732. */
  30733. static readonly FILTER_PCF: number;
  30734. /**
  30735. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30736. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30737. * Contact Hardening
  30738. */
  30739. static readonly FILTER_PCSS: number;
  30740. /**
  30741. * Reserved for PCF and PCSS
  30742. * Highest Quality.
  30743. *
  30744. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30745. *
  30746. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30747. */
  30748. static readonly QUALITY_HIGH: number;
  30749. /**
  30750. * Reserved for PCF and PCSS
  30751. * Good tradeoff for quality/perf cross devices
  30752. *
  30753. * Execute PCF on a 3*3 kernel.
  30754. *
  30755. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30756. */
  30757. static readonly QUALITY_MEDIUM: number;
  30758. /**
  30759. * Reserved for PCF and PCSS
  30760. * The lowest quality but the fastest.
  30761. *
  30762. * Execute PCF on a 1*1 kernel.
  30763. *
  30764. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30765. */
  30766. static readonly QUALITY_LOW: number;
  30767. private _bias;
  30768. /**
  30769. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30770. */
  30771. /**
  30772. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30773. */
  30774. bias: number;
  30775. private _normalBias;
  30776. /**
  30777. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30778. */
  30779. /**
  30780. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30781. */
  30782. normalBias: number;
  30783. private _blurBoxOffset;
  30784. /**
  30785. * Gets the blur box offset: offset applied during the blur pass.
  30786. * Only usefull if useKernelBlur = false
  30787. */
  30788. /**
  30789. * Sets the blur box offset: offset applied during the blur pass.
  30790. * Only usefull if useKernelBlur = false
  30791. */
  30792. blurBoxOffset: number;
  30793. private _blurScale;
  30794. /**
  30795. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30796. * 2 means half of the size.
  30797. */
  30798. /**
  30799. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30800. * 2 means half of the size.
  30801. */
  30802. blurScale: number;
  30803. private _blurKernel;
  30804. /**
  30805. * Gets the blur kernel: kernel size of the blur pass.
  30806. * Only usefull if useKernelBlur = true
  30807. */
  30808. /**
  30809. * Sets the blur kernel: kernel size of the blur pass.
  30810. * Only usefull if useKernelBlur = true
  30811. */
  30812. blurKernel: number;
  30813. private _useKernelBlur;
  30814. /**
  30815. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30816. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30817. */
  30818. /**
  30819. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30820. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30821. */
  30822. useKernelBlur: boolean;
  30823. private _depthScale;
  30824. /**
  30825. * Gets the depth scale used in ESM mode.
  30826. */
  30827. /**
  30828. * Sets the depth scale used in ESM mode.
  30829. * This can override the scale stored on the light.
  30830. */
  30831. depthScale: number;
  30832. private _filter;
  30833. /**
  30834. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30835. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30836. */
  30837. /**
  30838. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30839. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30840. */
  30841. filter: number;
  30842. /**
  30843. * Gets if the current filter is set to Poisson Sampling.
  30844. */
  30845. /**
  30846. * Sets the current filter to Poisson Sampling.
  30847. */
  30848. usePoissonSampling: boolean;
  30849. /**
  30850. * Gets if the current filter is set to VSM.
  30851. * DEPRECATED. Should use useExponentialShadowMap instead.
  30852. */
  30853. /**
  30854. * Sets the current filter is to VSM.
  30855. * DEPRECATED. Should use useExponentialShadowMap instead.
  30856. */
  30857. useVarianceShadowMap: boolean;
  30858. /**
  30859. * Gets if the current filter is set to blurred VSM.
  30860. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30861. */
  30862. /**
  30863. * Sets the current filter is to blurred VSM.
  30864. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30865. */
  30866. useBlurVarianceShadowMap: boolean;
  30867. /**
  30868. * Gets if the current filter is set to ESM.
  30869. */
  30870. /**
  30871. * Sets the current filter is to ESM.
  30872. */
  30873. useExponentialShadowMap: boolean;
  30874. /**
  30875. * Gets if the current filter is set to filtered ESM.
  30876. */
  30877. /**
  30878. * Gets if the current filter is set to filtered ESM.
  30879. */
  30880. useBlurExponentialShadowMap: boolean;
  30881. /**
  30882. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30883. * exponential to prevent steep falloff artifacts).
  30884. */
  30885. /**
  30886. * Sets the current filter to "close ESM" (using the inverse of the
  30887. * exponential to prevent steep falloff artifacts).
  30888. */
  30889. useCloseExponentialShadowMap: boolean;
  30890. /**
  30891. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30892. * exponential to prevent steep falloff artifacts).
  30893. */
  30894. /**
  30895. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30896. * exponential to prevent steep falloff artifacts).
  30897. */
  30898. useBlurCloseExponentialShadowMap: boolean;
  30899. /**
  30900. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30901. */
  30902. /**
  30903. * Sets the current filter to "PCF" (percentage closer filtering).
  30904. */
  30905. usePercentageCloserFiltering: boolean;
  30906. private _filteringQuality;
  30907. /**
  30908. * Gets the PCF or PCSS Quality.
  30909. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30910. */
  30911. /**
  30912. * Sets the PCF or PCSS Quality.
  30913. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30914. */
  30915. filteringQuality: number;
  30916. /**
  30917. * Gets if the current filter is set to "PCSS" (contact hardening).
  30918. */
  30919. /**
  30920. * Sets the current filter to "PCSS" (contact hardening).
  30921. */
  30922. useContactHardeningShadow: boolean;
  30923. private _contactHardeningLightSizeUVRatio;
  30924. /**
  30925. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30926. * Using a ratio helps keeping shape stability independently of the map size.
  30927. *
  30928. * It does not account for the light projection as it was having too much
  30929. * instability during the light setup or during light position changes.
  30930. *
  30931. * Only valid if useContactHardeningShadow is true.
  30932. */
  30933. /**
  30934. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30935. * Using a ratio helps keeping shape stability independently of the map size.
  30936. *
  30937. * It does not account for the light projection as it was having too much
  30938. * instability during the light setup or during light position changes.
  30939. *
  30940. * Only valid if useContactHardeningShadow is true.
  30941. */
  30942. contactHardeningLightSizeUVRatio: number;
  30943. private _darkness;
  30944. /**
  30945. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30946. * 0 means strongest and 1 would means no shadow.
  30947. * @returns the darkness.
  30948. */
  30949. getDarkness(): number;
  30950. /**
  30951. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30952. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30953. * @returns the shadow generator allowing fluent coding.
  30954. */
  30955. setDarkness(darkness: number): ShadowGenerator;
  30956. private _transparencyShadow;
  30957. /**
  30958. * Sets the ability to have transparent shadow (boolean).
  30959. * @param transparent True if transparent else False
  30960. * @returns the shadow generator allowing fluent coding
  30961. */
  30962. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30963. private _shadowMap;
  30964. private _shadowMap2;
  30965. /**
  30966. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30967. * @returns The render target texture if present otherwise, null
  30968. */
  30969. getShadowMap(): Nullable<RenderTargetTexture>;
  30970. /**
  30971. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30972. * @returns The render target texture if the shadow map is present otherwise, null
  30973. */
  30974. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30975. /**
  30976. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30977. * @param mesh Mesh to add
  30978. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30979. * @returns the Shadow Generator itself
  30980. */
  30981. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30982. /**
  30983. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30984. * @param mesh Mesh to remove
  30985. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30986. * @returns the Shadow Generator itself
  30987. */
  30988. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30989. /**
  30990. * Controls the extent to which the shadows fade out at the edge of the frustum
  30991. * Used only by directionals and spots
  30992. */
  30993. frustumEdgeFalloff: number;
  30994. private _light;
  30995. /**
  30996. * Returns the associated light object.
  30997. * @returns the light generating the shadow
  30998. */
  30999. getLight(): IShadowLight;
  31000. /**
  31001. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31002. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31003. * It might on the other hand introduce peter panning.
  31004. */
  31005. forceBackFacesOnly: boolean;
  31006. private _scene;
  31007. private _lightDirection;
  31008. private _effect;
  31009. private _viewMatrix;
  31010. private _projectionMatrix;
  31011. private _transformMatrix;
  31012. private _cachedPosition;
  31013. private _cachedDirection;
  31014. private _cachedDefines;
  31015. private _currentRenderID;
  31016. private _boxBlurPostprocess;
  31017. private _kernelBlurXPostprocess;
  31018. private _kernelBlurYPostprocess;
  31019. private _blurPostProcesses;
  31020. private _mapSize;
  31021. private _currentFaceIndex;
  31022. private _currentFaceIndexCache;
  31023. private _textureType;
  31024. private _defaultTextureMatrix;
  31025. /**
  31026. * Creates a ShadowGenerator object.
  31027. * A ShadowGenerator is the required tool to use the shadows.
  31028. * Each light casting shadows needs to use its own ShadowGenerator.
  31029. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31030. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31031. * @param light The light object generating the shadows.
  31032. * @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.
  31033. */
  31034. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31035. private _initializeGenerator();
  31036. private _initializeShadowMap();
  31037. private _initializeBlurRTTAndPostProcesses();
  31038. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31039. private _renderSubMeshForShadowMap(subMesh);
  31040. private _applyFilterValues();
  31041. /**
  31042. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31043. * @param onCompiled Callback triggered at the and of the effects compilation
  31044. * @param options Sets of optional options forcing the compilation with different modes
  31045. */
  31046. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31047. useInstances: boolean;
  31048. }>): void;
  31049. /**
  31050. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31051. * @param options Sets of optional options forcing the compilation with different modes
  31052. * @returns A promise that resolves when the compilation completes
  31053. */
  31054. forceCompilationAsync(options?: Partial<{
  31055. useInstances: boolean;
  31056. }>): Promise<void>;
  31057. /**
  31058. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31059. * @param subMesh The submesh we want to render in the shadow map
  31060. * @param useInstances Defines wether will draw in the map using instances
  31061. * @returns true if ready otherwise, false
  31062. */
  31063. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31064. /**
  31065. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31066. * @param defines Defines of the material we want to update
  31067. * @param lightIndex Index of the light in the enabled light list of the material
  31068. */
  31069. prepareDefines(defines: any, lightIndex: number): void;
  31070. /**
  31071. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31072. * defined in the generator but impacting the effect).
  31073. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31074. * @param effect The effect we are binfing the information for
  31075. */
  31076. bindShadowLight(lightIndex: string, effect: Effect): void;
  31077. /**
  31078. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31079. * (eq to shadow prjection matrix * light transform matrix)
  31080. * @returns The transform matrix used to create the shadow map
  31081. */
  31082. getTransformMatrix(): Matrix;
  31083. /**
  31084. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31085. * Cube and 2D textures for instance.
  31086. */
  31087. recreateShadowMap(): void;
  31088. private _disposeBlurPostProcesses();
  31089. private _disposeRTTandPostProcesses();
  31090. /**
  31091. * Disposes the ShadowGenerator.
  31092. * Returns nothing.
  31093. */
  31094. dispose(): void;
  31095. /**
  31096. * Serializes the shadow generator setup to a json object.
  31097. * @returns The serialized JSON object
  31098. */
  31099. serialize(): any;
  31100. /**
  31101. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31102. * @param parsedShadowGenerator The JSON object to parse
  31103. * @param scene The scene to create the shadow map for
  31104. * @returns The parsed shadow generator
  31105. */
  31106. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31107. }
  31108. }
  31109. declare module BABYLON {
  31110. }
  31111. declare module BABYLON {
  31112. /**
  31113. * Background material used to create an efficient environement around your scene.
  31114. */
  31115. class BackgroundMaterial extends PushMaterial {
  31116. /**
  31117. * Standard reflectance value at parallel view angle.
  31118. */
  31119. static StandardReflectance0: number;
  31120. /**
  31121. * Standard reflectance value at grazing angle.
  31122. */
  31123. static StandardReflectance90: number;
  31124. protected _primaryColor: Color3;
  31125. /**
  31126. * Key light Color (multiply against the environement texture)
  31127. */
  31128. primaryColor: Color3;
  31129. protected __perceptualColor: Nullable<Color3>;
  31130. /**
  31131. * Experimental Internal Use Only.
  31132. *
  31133. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31134. * This acts as a helper to set the primary color to a more "human friendly" value.
  31135. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31136. * output color as close as possible from the chosen value.
  31137. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31138. * part of lighting setup.)
  31139. */
  31140. _perceptualColor: Nullable<Color3>;
  31141. protected _primaryColorShadowLevel: float;
  31142. /**
  31143. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31144. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31145. */
  31146. primaryColorShadowLevel: float;
  31147. protected _primaryColorHighlightLevel: float;
  31148. /**
  31149. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31150. * The primary color is used at the level chosen to define what the white area would look.
  31151. */
  31152. primaryColorHighlightLevel: float;
  31153. protected _reflectionTexture: Nullable<BaseTexture>;
  31154. /**
  31155. * Reflection Texture used in the material.
  31156. * Should be author in a specific way for the best result (refer to the documentation).
  31157. */
  31158. reflectionTexture: Nullable<BaseTexture>;
  31159. protected _reflectionBlur: float;
  31160. /**
  31161. * Reflection Texture level of blur.
  31162. *
  31163. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31164. * texture twice.
  31165. */
  31166. reflectionBlur: float;
  31167. protected _diffuseTexture: Nullable<BaseTexture>;
  31168. /**
  31169. * Diffuse Texture used in the material.
  31170. * Should be author in a specific way for the best result (refer to the documentation).
  31171. */
  31172. diffuseTexture: Nullable<BaseTexture>;
  31173. protected _shadowLights: Nullable<IShadowLight[]>;
  31174. /**
  31175. * Specify the list of lights casting shadow on the material.
  31176. * All scene shadow lights will be included if null.
  31177. */
  31178. shadowLights: Nullable<IShadowLight[]>;
  31179. protected _shadowLevel: float;
  31180. /**
  31181. * Helps adjusting the shadow to a softer level if required.
  31182. * 0 means black shadows and 1 means no shadows.
  31183. */
  31184. shadowLevel: float;
  31185. protected _sceneCenter: Vector3;
  31186. /**
  31187. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31188. * It is usually zero but might be interesting to modify according to your setup.
  31189. */
  31190. sceneCenter: Vector3;
  31191. protected _opacityFresnel: boolean;
  31192. /**
  31193. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31194. * This helps ensuring a nice transition when the camera goes under the ground.
  31195. */
  31196. opacityFresnel: boolean;
  31197. protected _reflectionFresnel: boolean;
  31198. /**
  31199. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31200. * This helps adding a mirror texture on the ground.
  31201. */
  31202. reflectionFresnel: boolean;
  31203. protected _reflectionFalloffDistance: number;
  31204. /**
  31205. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31206. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31207. */
  31208. reflectionFalloffDistance: number;
  31209. protected _reflectionAmount: number;
  31210. /**
  31211. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31212. */
  31213. reflectionAmount: number;
  31214. protected _reflectionReflectance0: number;
  31215. /**
  31216. * This specifies the weight of the reflection at grazing angle.
  31217. */
  31218. reflectionReflectance0: number;
  31219. protected _reflectionReflectance90: number;
  31220. /**
  31221. * This specifies the weight of the reflection at a perpendicular point of view.
  31222. */
  31223. reflectionReflectance90: number;
  31224. /**
  31225. * Sets the reflection reflectance fresnel values according to the default standard
  31226. * empirically know to work well :-)
  31227. */
  31228. reflectionStandardFresnelWeight: number;
  31229. protected _useRGBColor: boolean;
  31230. /**
  31231. * Helps to directly use the maps channels instead of their level.
  31232. */
  31233. useRGBColor: boolean;
  31234. protected _enableNoise: boolean;
  31235. /**
  31236. * This helps reducing the banding effect that could occur on the background.
  31237. */
  31238. enableNoise: boolean;
  31239. /**
  31240. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31241. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31242. * Recommended to be keep at 1.0 except for special cases.
  31243. */
  31244. fovMultiplier: number;
  31245. private _fovMultiplier;
  31246. /**
  31247. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31248. */
  31249. useEquirectangularFOV: boolean;
  31250. private _maxSimultaneousLights;
  31251. /**
  31252. * Number of Simultaneous lights allowed on the material.
  31253. */
  31254. maxSimultaneousLights: int;
  31255. /**
  31256. * Default configuration related to image processing available in the Background Material.
  31257. */
  31258. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31259. /**
  31260. * Keep track of the image processing observer to allow dispose and replace.
  31261. */
  31262. private _imageProcessingObserver;
  31263. /**
  31264. * Attaches a new image processing configuration to the PBR Material.
  31265. * @param configuration (if null the scene configuration will be use)
  31266. */
  31267. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31268. /**
  31269. * Gets the image processing configuration used either in this material.
  31270. */
  31271. /**
  31272. * Sets the Default image processing configuration used either in the this material.
  31273. *
  31274. * If sets to null, the scene one is in use.
  31275. */
  31276. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31277. /**
  31278. * Gets wether the color curves effect is enabled.
  31279. */
  31280. /**
  31281. * Sets wether the color curves effect is enabled.
  31282. */
  31283. cameraColorCurvesEnabled: boolean;
  31284. /**
  31285. * Gets wether the color grading effect is enabled.
  31286. */
  31287. /**
  31288. * Gets wether the color grading effect is enabled.
  31289. */
  31290. cameraColorGradingEnabled: boolean;
  31291. /**
  31292. * Gets wether tonemapping is enabled or not.
  31293. */
  31294. /**
  31295. * Sets wether tonemapping is enabled or not
  31296. */
  31297. cameraToneMappingEnabled: boolean;
  31298. /**
  31299. * The camera exposure used on this material.
  31300. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31301. * This corresponds to a photographic exposure.
  31302. */
  31303. /**
  31304. * The camera exposure used on this material.
  31305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31306. * This corresponds to a photographic exposure.
  31307. */
  31308. cameraExposure: float;
  31309. /**
  31310. * Gets The camera contrast used on this material.
  31311. */
  31312. /**
  31313. * Sets The camera contrast used on this material.
  31314. */
  31315. cameraContrast: float;
  31316. /**
  31317. * Gets the Color Grading 2D Lookup Texture.
  31318. */
  31319. /**
  31320. * Sets the Color Grading 2D Lookup Texture.
  31321. */
  31322. cameraColorGradingTexture: Nullable<BaseTexture>;
  31323. /**
  31324. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31325. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31326. * 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;
  31327. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31328. */
  31329. /**
  31330. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31331. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31332. * 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;
  31333. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31334. */
  31335. cameraColorCurves: Nullable<ColorCurves>;
  31336. /**
  31337. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31338. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31339. */
  31340. switchToBGR: boolean;
  31341. private _renderTargets;
  31342. private _reflectionControls;
  31343. private _white;
  31344. private _primaryShadowColor;
  31345. private _primaryHighlightColor;
  31346. /**
  31347. * Instantiates a Background Material in the given scene
  31348. * @param name The friendly name of the material
  31349. * @param scene The scene to add the material to
  31350. */
  31351. constructor(name: string, scene: Scene);
  31352. /**
  31353. * The entire material has been created in order to prevent overdraw.
  31354. * @returns false
  31355. */
  31356. needAlphaTesting(): boolean;
  31357. /**
  31358. * The entire material has been created in order to prevent overdraw.
  31359. * @returns true if blending is enable
  31360. */
  31361. needAlphaBlending(): boolean;
  31362. /**
  31363. * Checks wether the material is ready to be rendered for a given mesh.
  31364. * @param mesh The mesh to render
  31365. * @param subMesh The submesh to check against
  31366. * @param useInstances Specify wether or not the material is used with instances
  31367. * @returns true if all the dependencies are ready (Textures, Effects...)
  31368. */
  31369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31370. /**
  31371. * Compute the primary color according to the chosen perceptual color.
  31372. */
  31373. private _computePrimaryColorFromPerceptualColor();
  31374. /**
  31375. * Compute the highlights and shadow colors according to their chosen levels.
  31376. */
  31377. private _computePrimaryColors();
  31378. /**
  31379. * Build the uniform buffer used in the material.
  31380. */
  31381. buildUniformLayout(): void;
  31382. /**
  31383. * Unbind the material.
  31384. */
  31385. unbind(): void;
  31386. /**
  31387. * Bind only the world matrix to the material.
  31388. * @param world The world matrix to bind.
  31389. */
  31390. bindOnlyWorldMatrix(world: Matrix): void;
  31391. /**
  31392. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31393. * @param world The world matrix to bind.
  31394. * @param subMesh The submesh to bind for.
  31395. */
  31396. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31397. /**
  31398. * Dispose the material.
  31399. * @param forceDisposeEffect Force disposal of the associated effect.
  31400. * @param forceDisposeTextures Force disposal of the associated textures.
  31401. */
  31402. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31403. /**
  31404. * Clones the material.
  31405. * @param name The cloned name.
  31406. * @returns The cloned material.
  31407. */
  31408. clone(name: string): BackgroundMaterial;
  31409. /**
  31410. * Serializes the current material to its JSON representation.
  31411. * @returns The JSON representation.
  31412. */
  31413. serialize(): any;
  31414. /**
  31415. * Gets the class name of the material
  31416. * @returns "BackgroundMaterial"
  31417. */
  31418. getClassName(): string;
  31419. /**
  31420. * Parse a JSON input to create back a background material.
  31421. * @param source The JSON data to parse
  31422. * @param scene The scene to create the parsed material in
  31423. * @param rootUrl The root url of the assets the material depends upon
  31424. * @returns the instantiated BackgroundMaterial.
  31425. */
  31426. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31427. }
  31428. }
  31429. declare module BABYLON {
  31430. /**
  31431. * The Physically based material base class of BJS.
  31432. *
  31433. * This offers the main features of a standard PBR material.
  31434. * For more information, please refer to the documentation :
  31435. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31436. */
  31437. abstract class PBRBaseMaterial extends PushMaterial {
  31438. /**
  31439. * Intensity of the direct lights e.g. the four lights available in your scene.
  31440. * This impacts both the direct diffuse and specular highlights.
  31441. */
  31442. protected _directIntensity: number;
  31443. /**
  31444. * Intensity of the emissive part of the material.
  31445. * This helps controlling the emissive effect without modifying the emissive color.
  31446. */
  31447. protected _emissiveIntensity: number;
  31448. /**
  31449. * Intensity of the environment e.g. how much the environment will light the object
  31450. * either through harmonics for rough material or through the refelction for shiny ones.
  31451. */
  31452. protected _environmentIntensity: number;
  31453. /**
  31454. * This is a special control allowing the reduction of the specular highlights coming from the
  31455. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31456. */
  31457. protected _specularIntensity: number;
  31458. /**
  31459. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31460. */
  31461. private _lightingInfos;
  31462. /**
  31463. * Debug Control allowing disabling the bump map on this material.
  31464. */
  31465. protected _disableBumpMap: boolean;
  31466. /**
  31467. * AKA Diffuse Texture in standard nomenclature.
  31468. */
  31469. protected _albedoTexture: BaseTexture;
  31470. /**
  31471. * AKA Occlusion Texture in other nomenclature.
  31472. */
  31473. protected _ambientTexture: BaseTexture;
  31474. /**
  31475. * AKA Occlusion Texture Intensity in other nomenclature.
  31476. */
  31477. protected _ambientTextureStrength: number;
  31478. /**
  31479. * Stores the alpha values in a texture.
  31480. */
  31481. protected _opacityTexture: BaseTexture;
  31482. /**
  31483. * Stores the reflection values in a texture.
  31484. */
  31485. protected _reflectionTexture: BaseTexture;
  31486. /**
  31487. * Stores the refraction values in a texture.
  31488. */
  31489. protected _refractionTexture: BaseTexture;
  31490. /**
  31491. * Stores the emissive values in a texture.
  31492. */
  31493. protected _emissiveTexture: BaseTexture;
  31494. /**
  31495. * AKA Specular texture in other nomenclature.
  31496. */
  31497. protected _reflectivityTexture: BaseTexture;
  31498. /**
  31499. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31500. */
  31501. protected _metallicTexture: BaseTexture;
  31502. /**
  31503. * Specifies the metallic scalar of the metallic/roughness workflow.
  31504. * Can also be used to scale the metalness values of the metallic texture.
  31505. */
  31506. protected _metallic: number;
  31507. /**
  31508. * Specifies the roughness scalar of the metallic/roughness workflow.
  31509. * Can also be used to scale the roughness values of the metallic texture.
  31510. */
  31511. protected _roughness: number;
  31512. /**
  31513. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  31514. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  31515. */
  31516. protected _microSurfaceTexture: BaseTexture;
  31517. /**
  31518. * Stores surface normal data used to displace a mesh in a texture.
  31519. */
  31520. protected _bumpTexture: BaseTexture;
  31521. /**
  31522. * Stores the pre-calculated light information of a mesh in a texture.
  31523. */
  31524. protected _lightmapTexture: BaseTexture;
  31525. /**
  31526. * The color of a material in ambient lighting.
  31527. */
  31528. protected _ambientColor: Color3;
  31529. /**
  31530. * AKA Diffuse Color in other nomenclature.
  31531. */
  31532. protected _albedoColor: Color3;
  31533. /**
  31534. * AKA Specular Color in other nomenclature.
  31535. */
  31536. protected _reflectivityColor: Color3;
  31537. /**
  31538. * The color applied when light is reflected from a material.
  31539. */
  31540. protected _reflectionColor: Color3;
  31541. /**
  31542. * The color applied when light is emitted from a material.
  31543. */
  31544. protected _emissiveColor: Color3;
  31545. /**
  31546. * AKA Glossiness in other nomenclature.
  31547. */
  31548. protected _microSurface: number;
  31549. /**
  31550. * source material index of refraction (IOR)' / 'destination material IOR.
  31551. */
  31552. protected _indexOfRefraction: number;
  31553. /**
  31554. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  31555. */
  31556. protected _invertRefractionY: boolean;
  31557. /**
  31558. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  31559. * Materials half opaque for instance using refraction could benefit from this control.
  31560. */
  31561. protected _linkRefractionWithTransparency: boolean;
  31562. /**
  31563. * Specifies that the material will use the light map as a show map.
  31564. */
  31565. protected _useLightmapAsShadowmap: boolean;
  31566. /**
  31567. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  31568. * makes the reflect vector face the model (under horizon).
  31569. */
  31570. protected _useHorizonOcclusion: boolean;
  31571. /**
  31572. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  31573. * too much the area relying on ambient texture to define their ambient occlusion.
  31574. */
  31575. protected _useRadianceOcclusion: boolean;
  31576. /**
  31577. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  31578. */
  31579. protected _useAlphaFromAlbedoTexture: boolean;
  31580. /**
  31581. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  31582. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31583. */
  31584. protected _useSpecularOverAlpha: boolean;
  31585. /**
  31586. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  31587. */
  31588. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  31589. /**
  31590. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  31591. */
  31592. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  31593. /**
  31594. * Specifies if the metallic texture contains the roughness information in its green channel.
  31595. */
  31596. protected _useRoughnessFromMetallicTextureGreen: boolean;
  31597. /**
  31598. * Specifies if the metallic texture contains the metallness information in its blue channel.
  31599. */
  31600. protected _useMetallnessFromMetallicTextureBlue: boolean;
  31601. /**
  31602. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  31603. */
  31604. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  31605. /**
  31606. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  31607. */
  31608. protected _useAmbientInGrayScale: boolean;
  31609. /**
  31610. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  31611. * The material will try to infer what glossiness each pixel should be.
  31612. */
  31613. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  31614. /**
  31615. * BJS is using an harcoded light falloff based on a manually sets up range.
  31616. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  31617. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  31618. */
  31619. protected _usePhysicalLightFalloff: boolean;
  31620. /**
  31621. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31622. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31623. */
  31624. protected _useRadianceOverAlpha: boolean;
  31625. /**
  31626. * Allows using an object space normal map (instead of tangent space).
  31627. */
  31628. protected _useObjectSpaceNormalMap: boolean;
  31629. /**
  31630. * Allows using the bump map in parallax mode.
  31631. */
  31632. protected _useParallax: boolean;
  31633. /**
  31634. * Allows using the bump map in parallax occlusion mode.
  31635. */
  31636. protected _useParallaxOcclusion: boolean;
  31637. /**
  31638. * Controls the scale bias of the parallax mode.
  31639. */
  31640. protected _parallaxScaleBias: number;
  31641. /**
  31642. * If sets to true, disables all the lights affecting the material.
  31643. */
  31644. protected _disableLighting: boolean;
  31645. /**
  31646. * Number of Simultaneous lights allowed on the material.
  31647. */
  31648. protected _maxSimultaneousLights: number;
  31649. /**
  31650. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  31651. */
  31652. protected _invertNormalMapX: boolean;
  31653. /**
  31654. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  31655. */
  31656. protected _invertNormalMapY: boolean;
  31657. /**
  31658. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31659. */
  31660. protected _twoSidedLighting: boolean;
  31661. /**
  31662. * Defines the alpha limits in alpha test mode.
  31663. */
  31664. protected _alphaCutOff: number;
  31665. /**
  31666. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31667. */
  31668. protected _forceAlphaTest: boolean;
  31669. /**
  31670. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31671. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  31672. */
  31673. protected _useAlphaFresnel: boolean;
  31674. /**
  31675. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31676. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  31677. */
  31678. protected _useLinearAlphaFresnel: boolean;
  31679. /**
  31680. * The transparency mode of the material.
  31681. */
  31682. protected _transparencyMode: Nullable<number>;
  31683. /**
  31684. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  31685. * from cos thetav and roughness:
  31686. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  31687. */
  31688. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  31689. /**
  31690. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  31691. */
  31692. protected _forceIrradianceInFragment: boolean;
  31693. /**
  31694. * Force normal to face away from face.
  31695. */
  31696. protected _forceNormalForward: boolean;
  31697. /**
  31698. * Enables specular anti aliasing in the PBR shader.
  31699. * It will both interacts on the Geometry for analytical and IBL lighting.
  31700. * It also prefilter the roughness map based on the bump values.
  31701. */
  31702. protected _enableSpecularAntiAliasing: boolean;
  31703. /**
  31704. * Default configuration related to image processing available in the PBR Material.
  31705. */
  31706. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31707. /**
  31708. * Keep track of the image processing observer to allow dispose and replace.
  31709. */
  31710. private _imageProcessingObserver;
  31711. /**
  31712. * Attaches a new image processing configuration to the PBR Material.
  31713. * @param configuration
  31714. */
  31715. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31716. /**
  31717. * Stores the available render targets.
  31718. */
  31719. private _renderTargets;
  31720. /**
  31721. * Sets the global ambient color for the material used in lighting calculations.
  31722. */
  31723. private _globalAmbientColor;
  31724. /**
  31725. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  31726. */
  31727. private _useLogarithmicDepth;
  31728. /**
  31729. * If set to true, no lighting calculations will be applied.
  31730. */
  31731. private _unlit;
  31732. /**
  31733. * Instantiates a new PBRMaterial instance.
  31734. *
  31735. * @param name The material name
  31736. * @param scene The scene the material will be use in.
  31737. */
  31738. constructor(name: string, scene: Scene);
  31739. /**
  31740. * Gets the name of the material class.
  31741. */
  31742. getClassName(): string;
  31743. /**
  31744. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31745. */
  31746. /**
  31747. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31748. */
  31749. useLogarithmicDepth: boolean;
  31750. /**
  31751. * Gets the current transparency mode.
  31752. */
  31753. /**
  31754. * Sets the transparency mode of the material.
  31755. */
  31756. transparencyMode: Nullable<number>;
  31757. /**
  31758. * Returns true if alpha blending should be disabled.
  31759. */
  31760. private readonly _disableAlphaBlending;
  31761. /**
  31762. * Specifies whether or not this material should be rendered in alpha blend mode.
  31763. */
  31764. needAlphaBlending(): boolean;
  31765. /**
  31766. * Specifies if the mesh will require alpha blending.
  31767. * @param mesh - BJS mesh.
  31768. */
  31769. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31770. /**
  31771. * Specifies whether or not this material should be rendered in alpha test mode.
  31772. */
  31773. needAlphaTesting(): boolean;
  31774. /**
  31775. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  31776. */
  31777. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  31778. /**
  31779. * Gets the texture used for the alpha test.
  31780. */
  31781. getAlphaTestTexture(): BaseTexture;
  31782. /**
  31783. * Stores the reflectivity values based on metallic roughness workflow.
  31784. */
  31785. private static _scaledReflectivity;
  31786. /**
  31787. * Specifies that the submesh is ready to be used.
  31788. * @param mesh - BJS mesh.
  31789. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  31790. * @param useInstances - Specifies that instances should be used.
  31791. * @returns - boolean indicating that the submesh is ready or not.
  31792. */
  31793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31794. /**
  31795. * Specifies if the material uses metallic roughness workflow.
  31796. * @returns boolean specifiying if the material uses metallic roughness workflow.
  31797. */
  31798. isMetallicWorkflow(): boolean;
  31799. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  31800. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  31801. /**
  31802. * Force shader compilation
  31803. */
  31804. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  31805. clipPlane: boolean;
  31806. }>): void;
  31807. /**
  31808. * Initializes the uniform buffer layout for the shader.
  31809. */
  31810. buildUniformLayout(): void;
  31811. /**
  31812. * Unbinds the textures.
  31813. */
  31814. unbind(): void;
  31815. /**
  31816. * Binds the submesh data.
  31817. * @param world - The world matrix.
  31818. * @param mesh - The BJS mesh.
  31819. * @param subMesh - A submesh of the BJS mesh.
  31820. */
  31821. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31822. /**
  31823. * Returns the animatable textures.
  31824. * @returns - Array of animatable textures.
  31825. */
  31826. getAnimatables(): IAnimatable[];
  31827. /**
  31828. * Returns the texture used for reflections.
  31829. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  31830. */
  31831. private _getReflectionTexture();
  31832. /**
  31833. * Returns the texture used for refraction or null if none is used.
  31834. * @returns - Refection texture if present. If no refraction texture and refraction
  31835. * is linked with transparency, returns environment texture. Otherwise, returns null.
  31836. */
  31837. private _getRefractionTexture();
  31838. /**
  31839. * Disposes the resources of the material.
  31840. * @param forceDisposeEffect - Forces the disposal of effects.
  31841. * @param forceDisposeTextures - Forces the disposal of all textures.
  31842. */
  31843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31844. }
  31845. }
  31846. declare module BABYLON {
  31847. /**
  31848. * The Physically based simple base material of BJS.
  31849. *
  31850. * This enables better naming and convention enforcements on top of the pbrMaterial.
  31851. * It is used as the base class for both the specGloss and metalRough conventions.
  31852. */
  31853. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  31854. /**
  31855. * Number of Simultaneous lights allowed on the material.
  31856. */
  31857. maxSimultaneousLights: number;
  31858. /**
  31859. * If sets to true, disables all the lights affecting the material.
  31860. */
  31861. disableLighting: boolean;
  31862. /**
  31863. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  31864. */
  31865. environmentTexture: BaseTexture;
  31866. /**
  31867. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31868. */
  31869. invertNormalMapX: boolean;
  31870. /**
  31871. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31872. */
  31873. invertNormalMapY: boolean;
  31874. /**
  31875. * Normal map used in the model.
  31876. */
  31877. normalTexture: BaseTexture;
  31878. /**
  31879. * Emissivie color used to self-illuminate the model.
  31880. */
  31881. emissiveColor: Color3;
  31882. /**
  31883. * Emissivie texture used to self-illuminate the model.
  31884. */
  31885. emissiveTexture: BaseTexture;
  31886. /**
  31887. * Occlusion Channel Strenght.
  31888. */
  31889. occlusionStrength: number;
  31890. /**
  31891. * Occlusion Texture of the material (adding extra occlusion effects).
  31892. */
  31893. occlusionTexture: BaseTexture;
  31894. /**
  31895. * Defines the alpha limits in alpha test mode.
  31896. */
  31897. alphaCutOff: number;
  31898. /**
  31899. * Gets the current double sided mode.
  31900. */
  31901. /**
  31902. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31903. */
  31904. doubleSided: boolean;
  31905. lightmapTexture: BaseTexture;
  31906. useLightmapAsShadowmap: boolean;
  31907. /**
  31908. * Return the active textures of the material.
  31909. */
  31910. getActiveTextures(): BaseTexture[];
  31911. hasTexture(texture: BaseTexture): boolean;
  31912. /**
  31913. * Instantiates a new PBRMaterial instance.
  31914. *
  31915. * @param name The material name
  31916. * @param scene The scene the material will be use in.
  31917. */
  31918. constructor(name: string, scene: Scene);
  31919. getClassName(): string;
  31920. }
  31921. }
  31922. declare module BABYLON {
  31923. /**
  31924. * The Physically based material of BJS.
  31925. *
  31926. * This offers the main features of a standard PBR material.
  31927. * For more information, please refer to the documentation :
  31928. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31929. */
  31930. class PBRMaterial extends PBRBaseMaterial {
  31931. private static _PBRMATERIAL_OPAQUE;
  31932. /**
  31933. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31934. */
  31935. static readonly PBRMATERIAL_OPAQUE: number;
  31936. /**
  31937. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31938. */
  31939. private static _PBRMATERIAL_ALPHATEST;
  31940. /**
  31941. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31942. */
  31943. static readonly PBRMATERIAL_ALPHATEST: number;
  31944. /**
  31945. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31946. */
  31947. private static _PBRMATERIAL_ALPHABLEND;
  31948. /**
  31949. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31950. */
  31951. static readonly PBRMATERIAL_ALPHABLEND: number;
  31952. /**
  31953. * 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.
  31954. * They are also discarded below the alpha cutoff threshold to improve performances.
  31955. */
  31956. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  31957. /**
  31958. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31959. * They are also discarded below the alpha cutoff threshold to improve performances.
  31960. */
  31961. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  31962. /**
  31963. * Intensity of the direct lights e.g. the four lights available in your scene.
  31964. * This impacts both the direct diffuse and specular highlights.
  31965. */
  31966. directIntensity: number;
  31967. /**
  31968. * Intensity of the emissive part of the material.
  31969. * This helps controlling the emissive effect without modifying the emissive color.
  31970. */
  31971. emissiveIntensity: number;
  31972. /**
  31973. * Intensity of the environment e.g. how much the environment will light the object
  31974. * either through harmonics for rough material or through the refelction for shiny ones.
  31975. */
  31976. environmentIntensity: number;
  31977. /**
  31978. * This is a special control allowing the reduction of the specular highlights coming from the
  31979. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31980. */
  31981. specularIntensity: number;
  31982. /**
  31983. * Debug Control allowing disabling the bump map on this material.
  31984. */
  31985. disableBumpMap: boolean;
  31986. /**
  31987. * AKA Diffuse Texture in standard nomenclature.
  31988. */
  31989. albedoTexture: BaseTexture;
  31990. /**
  31991. * AKA Occlusion Texture in other nomenclature.
  31992. */
  31993. ambientTexture: BaseTexture;
  31994. /**
  31995. * AKA Occlusion Texture Intensity in other nomenclature.
  31996. */
  31997. ambientTextureStrength: number;
  31998. /**
  31999. * Stores the alpha values in a texture.
  32000. */
  32001. opacityTexture: BaseTexture;
  32002. /**
  32003. * Stores the reflection values in a texture.
  32004. */
  32005. reflectionTexture: Nullable<BaseTexture>;
  32006. /**
  32007. * Stores the emissive values in a texture.
  32008. */
  32009. emissiveTexture: BaseTexture;
  32010. /**
  32011. * AKA Specular texture in other nomenclature.
  32012. */
  32013. reflectivityTexture: BaseTexture;
  32014. /**
  32015. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32016. */
  32017. metallicTexture: BaseTexture;
  32018. /**
  32019. * Specifies the metallic scalar of the metallic/roughness workflow.
  32020. * Can also be used to scale the metalness values of the metallic texture.
  32021. */
  32022. metallic: number;
  32023. /**
  32024. * Specifies the roughness scalar of the metallic/roughness workflow.
  32025. * Can also be used to scale the roughness values of the metallic texture.
  32026. */
  32027. roughness: number;
  32028. /**
  32029. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32030. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32031. */
  32032. microSurfaceTexture: BaseTexture;
  32033. /**
  32034. * Stores surface normal data used to displace a mesh in a texture.
  32035. */
  32036. bumpTexture: BaseTexture;
  32037. /**
  32038. * Stores the pre-calculated light information of a mesh in a texture.
  32039. */
  32040. lightmapTexture: BaseTexture;
  32041. /**
  32042. * Stores the refracted light information in a texture.
  32043. */
  32044. refractionTexture: BaseTexture;
  32045. /**
  32046. * The color of a material in ambient lighting.
  32047. */
  32048. ambientColor: Color3;
  32049. /**
  32050. * AKA Diffuse Color in other nomenclature.
  32051. */
  32052. albedoColor: Color3;
  32053. /**
  32054. * AKA Specular Color in other nomenclature.
  32055. */
  32056. reflectivityColor: Color3;
  32057. /**
  32058. * The color reflected from the material.
  32059. */
  32060. reflectionColor: Color3;
  32061. /**
  32062. * The color emitted from the material.
  32063. */
  32064. emissiveColor: Color3;
  32065. /**
  32066. * AKA Glossiness in other nomenclature.
  32067. */
  32068. microSurface: number;
  32069. /**
  32070. * source material index of refraction (IOR)' / 'destination material IOR.
  32071. */
  32072. indexOfRefraction: number;
  32073. /**
  32074. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32075. */
  32076. invertRefractionY: boolean;
  32077. /**
  32078. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32079. * Materials half opaque for instance using refraction could benefit from this control.
  32080. */
  32081. linkRefractionWithTransparency: boolean;
  32082. useLightmapAsShadowmap: boolean;
  32083. /**
  32084. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32085. */
  32086. useAlphaFromAlbedoTexture: boolean;
  32087. /**
  32088. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32089. */
  32090. forceAlphaTest: boolean;
  32091. /**
  32092. * Defines the alpha limits in alpha test mode.
  32093. */
  32094. alphaCutOff: number;
  32095. /**
  32096. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32097. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32098. */
  32099. useSpecularOverAlpha: boolean;
  32100. /**
  32101. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32102. */
  32103. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32104. /**
  32105. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32106. */
  32107. useRoughnessFromMetallicTextureAlpha: boolean;
  32108. /**
  32109. * Specifies if the metallic texture contains the roughness information in its green channel.
  32110. */
  32111. useRoughnessFromMetallicTextureGreen: boolean;
  32112. /**
  32113. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32114. */
  32115. useMetallnessFromMetallicTextureBlue: boolean;
  32116. /**
  32117. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32118. */
  32119. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32120. /**
  32121. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32122. */
  32123. useAmbientInGrayScale: boolean;
  32124. /**
  32125. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32126. * The material will try to infer what glossiness each pixel should be.
  32127. */
  32128. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32129. /**
  32130. * BJS is using an harcoded light falloff based on a manually sets up range.
  32131. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32132. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32133. */
  32134. usePhysicalLightFalloff: boolean;
  32135. /**
  32136. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32137. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32138. */
  32139. useRadianceOverAlpha: boolean;
  32140. /**
  32141. * Allows using an object space normal map (instead of tangent space).
  32142. */
  32143. useObjectSpaceNormalMap: boolean;
  32144. /**
  32145. * Allows using the bump map in parallax mode.
  32146. */
  32147. useParallax: boolean;
  32148. /**
  32149. * Allows using the bump map in parallax occlusion mode.
  32150. */
  32151. useParallaxOcclusion: boolean;
  32152. /**
  32153. * Controls the scale bias of the parallax mode.
  32154. */
  32155. parallaxScaleBias: number;
  32156. /**
  32157. * If sets to true, disables all the lights affecting the material.
  32158. */
  32159. disableLighting: boolean;
  32160. /**
  32161. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32162. */
  32163. forceIrradianceInFragment: boolean;
  32164. /**
  32165. * Number of Simultaneous lights allowed on the material.
  32166. */
  32167. maxSimultaneousLights: number;
  32168. /**
  32169. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32170. */
  32171. invertNormalMapX: boolean;
  32172. /**
  32173. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32174. */
  32175. invertNormalMapY: boolean;
  32176. /**
  32177. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32178. */
  32179. twoSidedLighting: boolean;
  32180. /**
  32181. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32182. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32183. */
  32184. useAlphaFresnel: boolean;
  32185. /**
  32186. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32187. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32188. */
  32189. useLinearAlphaFresnel: boolean;
  32190. /**
  32191. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32192. * And/Or occlude the blended part.
  32193. */
  32194. environmentBRDFTexture: Nullable<BaseTexture>;
  32195. /**
  32196. * Force normal to face away from face.
  32197. */
  32198. forceNormalForward: boolean;
  32199. /**
  32200. * Enables specular anti aliasing in the PBR shader.
  32201. * It will both interacts on the Geometry for analytical and IBL lighting.
  32202. * It also prefilter the roughness map based on the bump values.
  32203. */
  32204. enableSpecularAntiAliasing: boolean;
  32205. /**
  32206. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32207. * makes the reflect vector face the model (under horizon).
  32208. */
  32209. useHorizonOcclusion: boolean;
  32210. /**
  32211. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32212. * too much the area relying on ambient texture to define their ambient occlusion.
  32213. */
  32214. useRadianceOcclusion: boolean;
  32215. /**
  32216. * If set to true, no lighting calculations will be applied.
  32217. */
  32218. unlit: boolean;
  32219. /**
  32220. * Gets the image processing configuration used either in this material.
  32221. */
  32222. /**
  32223. * Sets the Default image processing configuration used either in the this material.
  32224. *
  32225. * If sets to null, the scene one is in use.
  32226. */
  32227. imageProcessingConfiguration: ImageProcessingConfiguration;
  32228. /**
  32229. * Gets wether the color curves effect is enabled.
  32230. */
  32231. /**
  32232. * Sets wether the color curves effect is enabled.
  32233. */
  32234. cameraColorCurvesEnabled: boolean;
  32235. /**
  32236. * Gets wether the color grading effect is enabled.
  32237. */
  32238. /**
  32239. * Gets wether the color grading effect is enabled.
  32240. */
  32241. cameraColorGradingEnabled: boolean;
  32242. /**
  32243. * Gets wether tonemapping is enabled or not.
  32244. */
  32245. /**
  32246. * Sets wether tonemapping is enabled or not
  32247. */
  32248. cameraToneMappingEnabled: boolean;
  32249. /**
  32250. * The camera exposure used on this material.
  32251. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32252. * This corresponds to a photographic exposure.
  32253. */
  32254. /**
  32255. * The camera exposure used on this material.
  32256. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32257. * This corresponds to a photographic exposure.
  32258. */
  32259. cameraExposure: number;
  32260. /**
  32261. * Gets The camera contrast used on this material.
  32262. */
  32263. /**
  32264. * Sets The camera contrast used on this material.
  32265. */
  32266. cameraContrast: number;
  32267. /**
  32268. * Gets the Color Grading 2D Lookup Texture.
  32269. */
  32270. /**
  32271. * Sets the Color Grading 2D Lookup Texture.
  32272. */
  32273. cameraColorGradingTexture: Nullable<BaseTexture>;
  32274. /**
  32275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32277. * 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;
  32278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32279. */
  32280. /**
  32281. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32282. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32283. * 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;
  32284. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32285. */
  32286. cameraColorCurves: Nullable<ColorCurves>;
  32287. /**
  32288. * Instantiates a new PBRMaterial instance.
  32289. *
  32290. * @param name The material name
  32291. * @param scene The scene the material will be use in.
  32292. */
  32293. constructor(name: string, scene: Scene);
  32294. /**
  32295. * Returns the name of this material class.
  32296. */
  32297. getClassName(): string;
  32298. /**
  32299. * Returns an array of the actively used textures.
  32300. * @returns - Array of BaseTextures
  32301. */
  32302. getActiveTextures(): BaseTexture[];
  32303. /**
  32304. * Checks to see if a texture is used in the material.
  32305. * @param texture - Base texture to use.
  32306. * @returns - Boolean specifying if a texture is used in the material.
  32307. */
  32308. hasTexture(texture: BaseTexture): boolean;
  32309. /**
  32310. * Makes a duplicate of the current material.
  32311. * @param name - name to use for the new material.
  32312. */
  32313. clone(name: string): PBRMaterial;
  32314. /**
  32315. * Serializes this PBR Material.
  32316. * @returns - An object with the serialized material.
  32317. */
  32318. serialize(): any;
  32319. /**
  32320. * Parses a PBR Material from a serialized object.
  32321. * @param source - Serialized object.
  32322. * @param scene - BJS scene instance.
  32323. * @param rootUrl - url for the scene object
  32324. * @returns - PBRMaterial
  32325. */
  32326. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32327. }
  32328. }
  32329. declare module BABYLON {
  32330. /**
  32331. * The PBR material of BJS following the metal roughness convention.
  32332. *
  32333. * This fits to the PBR convention in the GLTF definition:
  32334. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32335. */
  32336. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32337. /**
  32338. * The base color has two different interpretations depending on the value of metalness.
  32339. * When the material is a metal, the base color is the specific measured reflectance value
  32340. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32341. * of the material.
  32342. */
  32343. baseColor: Color3;
  32344. /**
  32345. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32346. * well as opacity information in the alpha channel.
  32347. */
  32348. baseTexture: BaseTexture;
  32349. /**
  32350. * Specifies the metallic scalar value of the material.
  32351. * Can also be used to scale the metalness values of the metallic texture.
  32352. */
  32353. metallic: number;
  32354. /**
  32355. * Specifies the roughness scalar value of the material.
  32356. * Can also be used to scale the roughness values of the metallic texture.
  32357. */
  32358. roughness: number;
  32359. /**
  32360. * Texture containing both the metallic value in the B channel and the
  32361. * roughness value in the G channel to keep better precision.
  32362. */
  32363. metallicRoughnessTexture: BaseTexture;
  32364. /**
  32365. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32366. *
  32367. * @param name The material name
  32368. * @param scene The scene the material will be use in.
  32369. */
  32370. constructor(name: string, scene: Scene);
  32371. /**
  32372. * Return the currrent class name of the material.
  32373. */
  32374. getClassName(): string;
  32375. /**
  32376. * Return the active textures of the material.
  32377. */
  32378. getActiveTextures(): BaseTexture[];
  32379. /**
  32380. * Checks to see if a texture is used in the material.
  32381. * @param texture - Base texture to use.
  32382. * @returns - Boolean specifying if a texture is used in the material.
  32383. */
  32384. hasTexture(texture: BaseTexture): boolean;
  32385. /**
  32386. * Makes a duplicate of the current material.
  32387. * @param name - name to use for the new material.
  32388. */
  32389. clone(name: string): PBRMetallicRoughnessMaterial;
  32390. /**
  32391. * Serialize the material to a parsable JSON object.
  32392. */
  32393. serialize(): any;
  32394. /**
  32395. * Parses a JSON object correponding to the serialize function.
  32396. */
  32397. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32398. }
  32399. }
  32400. declare module BABYLON {
  32401. /**
  32402. * The PBR material of BJS following the specular glossiness convention.
  32403. *
  32404. * This fits to the PBR convention in the GLTF definition:
  32405. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32406. */
  32407. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32408. /**
  32409. * Specifies the diffuse color of the material.
  32410. */
  32411. diffuseColor: Color3;
  32412. /**
  32413. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32414. * channel.
  32415. */
  32416. diffuseTexture: BaseTexture;
  32417. /**
  32418. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32419. */
  32420. specularColor: Color3;
  32421. /**
  32422. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32423. */
  32424. glossiness: number;
  32425. /**
  32426. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32427. */
  32428. specularGlossinessTexture: BaseTexture;
  32429. /**
  32430. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32431. *
  32432. * @param name The material name
  32433. * @param scene The scene the material will be use in.
  32434. */
  32435. constructor(name: string, scene: Scene);
  32436. /**
  32437. * Return the currrent class name of the material.
  32438. */
  32439. getClassName(): string;
  32440. /**
  32441. * Return the active textures of the material.
  32442. */
  32443. getActiveTextures(): BaseTexture[];
  32444. /**
  32445. * Checks to see if a texture is used in the material.
  32446. * @param texture - Base texture to use.
  32447. * @returns - Boolean specifying if a texture is used in the material.
  32448. */
  32449. hasTexture(texture: BaseTexture): boolean;
  32450. /**
  32451. * Makes a duplicate of the current material.
  32452. * @param name - name to use for the new material.
  32453. */
  32454. clone(name: string): PBRSpecularGlossinessMaterial;
  32455. /**
  32456. * Serialize the material to a parsable JSON object.
  32457. */
  32458. serialize(): any;
  32459. /**
  32460. * Parses a JSON object correponding to the serialize function.
  32461. */
  32462. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32463. }
  32464. }
  32465. declare module BABYLON {
  32466. class BaseTexture {
  32467. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32468. name: string;
  32469. private _hasAlpha;
  32470. hasAlpha: boolean;
  32471. getAlphaFromRGB: boolean;
  32472. level: number;
  32473. coordinatesIndex: number;
  32474. private _coordinatesMode;
  32475. /**
  32476. * How a texture is mapped.
  32477. *
  32478. * | Value | Type | Description |
  32479. * | ----- | ----------------------------------- | ----------- |
  32480. * | 0 | EXPLICIT_MODE | |
  32481. * | 1 | SPHERICAL_MODE | |
  32482. * | 2 | PLANAR_MODE | |
  32483. * | 3 | CUBIC_MODE | |
  32484. * | 4 | PROJECTION_MODE | |
  32485. * | 5 | SKYBOX_MODE | |
  32486. * | 6 | INVCUBIC_MODE | |
  32487. * | 7 | EQUIRECTANGULAR_MODE | |
  32488. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32489. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32490. */
  32491. coordinatesMode: number;
  32492. /**
  32493. * | Value | Type | Description |
  32494. * | ----- | ------------------ | ----------- |
  32495. * | 0 | CLAMP_ADDRESSMODE | |
  32496. * | 1 | WRAP_ADDRESSMODE | |
  32497. * | 2 | MIRROR_ADDRESSMODE | |
  32498. */
  32499. wrapU: number;
  32500. /**
  32501. * | Value | Type | Description |
  32502. * | ----- | ------------------ | ----------- |
  32503. * | 0 | CLAMP_ADDRESSMODE | |
  32504. * | 1 | WRAP_ADDRESSMODE | |
  32505. * | 2 | MIRROR_ADDRESSMODE | |
  32506. */
  32507. wrapV: number;
  32508. /**
  32509. * | Value | Type | Description |
  32510. * | ----- | ------------------ | ----------- |
  32511. * | 0 | CLAMP_ADDRESSMODE | |
  32512. * | 1 | WRAP_ADDRESSMODE | |
  32513. * | 2 | MIRROR_ADDRESSMODE | |
  32514. */
  32515. wrapR: number;
  32516. anisotropicFilteringLevel: number;
  32517. isCube: boolean;
  32518. is3D: boolean;
  32519. gammaSpace: boolean;
  32520. invertZ: boolean;
  32521. lodLevelInAlpha: boolean;
  32522. lodGenerationOffset: number;
  32523. lodGenerationScale: number;
  32524. isRenderTarget: boolean;
  32525. readonly uid: string;
  32526. toString(): string;
  32527. getClassName(): string;
  32528. animations: Animation[];
  32529. /**
  32530. * An event triggered when the texture is disposed.
  32531. */
  32532. onDisposeObservable: Observable<BaseTexture>;
  32533. private _onDisposeObserver;
  32534. onDispose: () => void;
  32535. delayLoadState: number;
  32536. private _scene;
  32537. _texture: Nullable<InternalTexture>;
  32538. private _uid;
  32539. readonly isBlocking: boolean;
  32540. constructor(scene: Nullable<Scene>);
  32541. getScene(): Nullable<Scene>;
  32542. getTextureMatrix(): Matrix;
  32543. getReflectionTextureMatrix(): Matrix;
  32544. getInternalTexture(): Nullable<InternalTexture>;
  32545. isReadyOrNotBlocking(): boolean;
  32546. isReady(): boolean;
  32547. getSize(): ISize;
  32548. getBaseSize(): ISize;
  32549. scale(ratio: number): void;
  32550. readonly canRescale: boolean;
  32551. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  32552. _rebuild(): void;
  32553. delayLoad(): void;
  32554. clone(): Nullable<BaseTexture>;
  32555. readonly textureType: number;
  32556. readonly textureFormat: number;
  32557. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  32558. releaseInternalTexture(): void;
  32559. sphericalPolynomial: Nullable<SphericalPolynomial>;
  32560. readonly _lodTextureHigh: Nullable<BaseTexture>;
  32561. readonly _lodTextureMid: Nullable<BaseTexture>;
  32562. readonly _lodTextureLow: Nullable<BaseTexture>;
  32563. dispose(): void;
  32564. serialize(): any;
  32565. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32566. }
  32567. }
  32568. declare module BABYLON {
  32569. /**
  32570. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  32571. * It can help converting any input color in a desired output one. This can then be used to create effects
  32572. * from sepia, black and white to sixties or futuristic rendering...
  32573. *
  32574. * The only supported format is currently 3dl.
  32575. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  32576. */
  32577. class ColorGradingTexture extends BaseTexture {
  32578. /**
  32579. * The current texture matrix. (will always be identity in color grading texture)
  32580. */
  32581. private _textureMatrix;
  32582. /**
  32583. * The texture URL.
  32584. */
  32585. url: string;
  32586. /**
  32587. * Empty line regex stored for GC.
  32588. */
  32589. private static _noneEmptyLineRegex;
  32590. private _engine;
  32591. /**
  32592. * Instantiates a ColorGradingTexture from the following parameters.
  32593. *
  32594. * @param url The location of the color gradind data (currently only supporting 3dl)
  32595. * @param scene The scene the texture will be used in
  32596. */
  32597. constructor(url: string, scene: Scene);
  32598. /**
  32599. * Returns the texture matrix used in most of the material.
  32600. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  32601. */
  32602. getTextureMatrix(): Matrix;
  32603. /**
  32604. * Occurs when the file being loaded is a .3dl LUT file.
  32605. */
  32606. private load3dlTexture();
  32607. /**
  32608. * Starts the loading process of the texture.
  32609. */
  32610. private loadTexture();
  32611. /**
  32612. * Clones the color gradind texture.
  32613. */
  32614. clone(): ColorGradingTexture;
  32615. /**
  32616. * Called during delayed load for textures.
  32617. */
  32618. delayLoad(): void;
  32619. /**
  32620. * Parses a color grading texture serialized by Babylon.
  32621. * @param parsedTexture The texture information being parsedTexture
  32622. * @param scene The scene to load the texture in
  32623. * @param rootUrl The root url of the data assets to load
  32624. * @return A color gradind texture
  32625. */
  32626. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  32627. /**
  32628. * Serializes the LUT texture to json format.
  32629. */
  32630. serialize(): any;
  32631. }
  32632. }
  32633. declare module BABYLON {
  32634. class CubeTexture extends BaseTexture {
  32635. url: string;
  32636. coordinatesMode: number;
  32637. /**
  32638. * Gets or sets the center of the bounding box associated with the cube texture
  32639. * It must define where the camera used to render the texture was set
  32640. */
  32641. boundingBoxPosition: Vector3;
  32642. private _boundingBoxSize;
  32643. /**
  32644. * Gets or sets the size of the bounding box associated with the cube texture
  32645. * When defined, the cubemap will switch to local mode
  32646. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32647. * @example https://www.babylonjs-playground.com/#RNASML
  32648. */
  32649. boundingBoxSize: Vector3;
  32650. protected _rotationY: number;
  32651. /**
  32652. * Gets texture matrix rotation angle around Y axis radians.
  32653. */
  32654. /**
  32655. * Sets texture matrix rotation angle around Y axis in radians.
  32656. */
  32657. rotationY: number;
  32658. private _noMipmap;
  32659. private _files;
  32660. private _extensions;
  32661. private _textureMatrix;
  32662. private _format;
  32663. private _prefiltered;
  32664. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  32665. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  32666. 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);
  32667. delayLoad(): void;
  32668. getReflectionTextureMatrix(): Matrix;
  32669. setReflectionTextureMatrix(value: Matrix): void;
  32670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  32671. clone(): CubeTexture;
  32672. }
  32673. }
  32674. declare module BABYLON {
  32675. /**
  32676. * A class extending {BABYLON.Texture} allowing drawing on a texture
  32677. * @see http://doc.babylonjs.com/how_to/dynamictexture
  32678. */
  32679. class DynamicTexture extends Texture {
  32680. private _generateMipMaps;
  32681. private _canvas;
  32682. private _context;
  32683. private _engine;
  32684. /**
  32685. * Creates a {BABYLON.DynamicTexture}
  32686. * @param name defines the name of the texture
  32687. * @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
  32688. * @param scene defines the scene where you want the texture
  32689. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  32690. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  32691. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  32692. */
  32693. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  32694. /**
  32695. * Gets the current state of canRescale
  32696. */
  32697. readonly canRescale: boolean;
  32698. private _recreate(textureSize);
  32699. /**
  32700. * Scales the texture
  32701. * @param ratio the scale factor to apply to both width and height
  32702. */
  32703. scale(ratio: number): void;
  32704. /**
  32705. * Resizes the texture
  32706. * @param width the new width
  32707. * @param height the new height
  32708. */
  32709. scaleTo(width: number, height: number): void;
  32710. /**
  32711. * Gets the context of the canvas used by the texture
  32712. * @returns the canvas context of the dynamic texture
  32713. */
  32714. getContext(): CanvasRenderingContext2D;
  32715. /**
  32716. * Clears the texture
  32717. */
  32718. clear(): void;
  32719. /**
  32720. * Updates the texture
  32721. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32722. */
  32723. update(invertY?: boolean): void;
  32724. /**
  32725. * Draws text onto the texture
  32726. * @param text defines the text to be drawn
  32727. * @param x defines the placement of the text from the left
  32728. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  32729. * @param font defines the font to be used with font-style, font-size, font-name
  32730. * @param color defines the color used for the text
  32731. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  32732. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32733. * @param update defines whether texture is immediately update (default is true)
  32734. */
  32735. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  32736. /**
  32737. * Clones the texture
  32738. * @returns the clone of the texture.
  32739. */
  32740. clone(): DynamicTexture;
  32741. /** @hidden */
  32742. _rebuild(): void;
  32743. }
  32744. }
  32745. declare module BABYLON {
  32746. /**
  32747. * This represents a texture coming from an HDR input.
  32748. *
  32749. * The only supported format is currently panorama picture stored in RGBE format.
  32750. * Example of such files can be found on HDRLib: http://hdrlib.com/
  32751. */
  32752. class HDRCubeTexture extends BaseTexture {
  32753. private static _facesMapping;
  32754. private _generateHarmonics;
  32755. private _noMipmap;
  32756. private _textureMatrix;
  32757. private _size;
  32758. private _onLoad;
  32759. private _onError;
  32760. /**
  32761. * The texture URL.
  32762. */
  32763. url: string;
  32764. /**
  32765. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  32766. */
  32767. coordinatesMode: number;
  32768. protected _isBlocking: boolean;
  32769. /**
  32770. * Gets wether or not the texture is blocking during loading.
  32771. */
  32772. /**
  32773. * Sets wether or not the texture is blocking during loading.
  32774. */
  32775. isBlocking: boolean;
  32776. protected _rotationY: number;
  32777. /**
  32778. * Gets texture matrix rotation angle around Y axis radians.
  32779. */
  32780. /**
  32781. * Sets texture matrix rotation angle around Y axis in radians.
  32782. */
  32783. rotationY: number;
  32784. /**
  32785. * Gets or sets the center of the bounding box associated with the cube texture
  32786. * It must define where the camera used to render the texture was set
  32787. */
  32788. boundingBoxPosition: Vector3;
  32789. private _boundingBoxSize;
  32790. /**
  32791. * Gets or sets the size of the bounding box associated with the cube texture
  32792. * When defined, the cubemap will switch to local mode
  32793. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32794. * @example https://www.babylonjs-playground.com/#RNASML
  32795. */
  32796. boundingBoxSize: Vector3;
  32797. /**
  32798. * Instantiates an HDRTexture from the following parameters.
  32799. *
  32800. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  32801. * @param scene The scene the texture will be used in
  32802. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  32803. * @param noMipmap Forces to not generate the mipmap if true
  32804. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  32805. * @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)
  32806. * @param reserved Reserved flag for internal use.
  32807. */
  32808. 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>);
  32809. /**
  32810. * Occurs when the file is raw .hdr file.
  32811. */
  32812. private loadTexture();
  32813. clone(): HDRCubeTexture;
  32814. delayLoad(): void;
  32815. getReflectionTextureMatrix(): Matrix;
  32816. setReflectionTextureMatrix(value: Matrix): void;
  32817. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  32818. serialize(): any;
  32819. }
  32820. }
  32821. declare module BABYLON {
  32822. /**
  32823. * Class used to store data associated with WebGL texture data for the engine
  32824. * This class should not be used directly
  32825. */
  32826. class InternalTexture implements IInternalTextureTracker {
  32827. /**
  32828. * The source of the texture data is unknown
  32829. */
  32830. static DATASOURCE_UNKNOWN: number;
  32831. /**
  32832. * Texture data comes from an URL
  32833. */
  32834. static DATASOURCE_URL: number;
  32835. /**
  32836. * Texture data is only used for temporary storage
  32837. */
  32838. static DATASOURCE_TEMP: number;
  32839. /**
  32840. * Texture data comes from raw data (ArrayBuffer)
  32841. */
  32842. static DATASOURCE_RAW: number;
  32843. /**
  32844. * Texture content is dynamic (video or dynamic texture)
  32845. */
  32846. static DATASOURCE_DYNAMIC: number;
  32847. /**
  32848. * Texture content is generated by rendering to it
  32849. */
  32850. static DATASOURCE_RENDERTARGET: number;
  32851. /**
  32852. * Texture content is part of a multi render target process
  32853. */
  32854. static DATASOURCE_MULTIRENDERTARGET: number;
  32855. /**
  32856. * Texture data comes from a cube data file
  32857. */
  32858. static DATASOURCE_CUBE: number;
  32859. /**
  32860. * Texture data comes from a raw cube data
  32861. */
  32862. static DATASOURCE_CUBERAW: number;
  32863. /**
  32864. * Texture data come from a prefiltered cube data file
  32865. */
  32866. static DATASOURCE_CUBEPREFILTERED: number;
  32867. /**
  32868. * Texture content is raw 3D data
  32869. */
  32870. static DATASOURCE_RAW3D: number;
  32871. /**
  32872. * Texture content is a depth texture
  32873. */
  32874. static DATASOURCE_DEPTHTEXTURE: number;
  32875. /**
  32876. * Defines if the texture is ready
  32877. */
  32878. isReady: boolean;
  32879. /**
  32880. * Defines if the texture is a cube texture
  32881. */
  32882. isCube: boolean;
  32883. /**
  32884. * Defines if the texture contains 3D data
  32885. */
  32886. is3D: boolean;
  32887. /**
  32888. * Gets the URL used to load this texture
  32889. */
  32890. url: string;
  32891. /**
  32892. * Gets the sampling mode of the texture
  32893. */
  32894. samplingMode: number;
  32895. /**
  32896. * Gets a boolean indicating if the texture needs mipmaps generation
  32897. */
  32898. generateMipMaps: boolean;
  32899. /**
  32900. * Gets the number of samples used by the texture (WebGL2+ only)
  32901. */
  32902. samples: number;
  32903. /**
  32904. * Gets the type of the texture
  32905. */
  32906. type: number;
  32907. /**
  32908. * Gets the format of the texture
  32909. */
  32910. format: number;
  32911. /**
  32912. * Observable called when the texture is loaded
  32913. */
  32914. onLoadedObservable: Observable<InternalTexture>;
  32915. /**
  32916. * Gets the width of the texture
  32917. */
  32918. width: number;
  32919. /**
  32920. * Gets the height of the texture
  32921. */
  32922. height: number;
  32923. /**
  32924. * Gets the depth of the texture
  32925. */
  32926. depth: number;
  32927. /**
  32928. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32929. */
  32930. baseWidth: number;
  32931. /**
  32932. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32933. */
  32934. baseHeight: number;
  32935. /**
  32936. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32937. */
  32938. baseDepth: number;
  32939. /**
  32940. * Gets a boolean indicating if the texture is inverted on Y axis
  32941. */
  32942. invertY: boolean;
  32943. /**
  32944. * Gets or set the previous tracker in the list
  32945. */
  32946. previous: Nullable<IInternalTextureTracker>;
  32947. /**
  32948. * Gets or set the next tracker in the list
  32949. */
  32950. next: Nullable<IInternalTextureTracker>;
  32951. /** @hidden */
  32952. _initialSlot: number;
  32953. /** @hidden */
  32954. _designatedSlot: number;
  32955. /** @hidden */
  32956. _dataSource: number;
  32957. /** @hidden */
  32958. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  32959. /** @hidden */
  32960. _bufferView: Nullable<ArrayBufferView>;
  32961. /** @hidden */
  32962. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32963. /** @hidden */
  32964. _size: number;
  32965. /** @hidden */
  32966. _extension: string;
  32967. /** @hidden */
  32968. _files: Nullable<string[]>;
  32969. /** @hidden */
  32970. _workingCanvas: HTMLCanvasElement;
  32971. /** @hidden */
  32972. _workingContext: CanvasRenderingContext2D;
  32973. /** @hidden */
  32974. _framebuffer: Nullable<WebGLFramebuffer>;
  32975. /** @hidden */
  32976. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32977. /** @hidden */
  32978. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32979. /** @hidden */
  32980. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32981. /** @hidden */
  32982. _attachments: Nullable<number[]>;
  32983. /** @hidden */
  32984. _cachedCoordinatesMode: Nullable<number>;
  32985. /** @hidden */
  32986. _cachedWrapU: Nullable<number>;
  32987. /** @hidden */
  32988. _cachedWrapV: Nullable<number>;
  32989. /** @hidden */
  32990. _cachedWrapR: Nullable<number>;
  32991. /** @hidden */
  32992. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32993. /** @hidden */
  32994. _isDisabled: boolean;
  32995. /** @hidden */
  32996. _compression: Nullable<string>;
  32997. /** @hidden */
  32998. _generateStencilBuffer: boolean;
  32999. /** @hidden */
  33000. _generateDepthBuffer: boolean;
  33001. /** @hidden */
  33002. _comparisonFunction: number;
  33003. /** @hidden */
  33004. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33005. /** @hidden */
  33006. _lodGenerationScale: number;
  33007. /** @hidden */
  33008. _lodGenerationOffset: number;
  33009. /** @hidden */
  33010. _lodTextureHigh: BaseTexture;
  33011. /** @hidden */
  33012. _lodTextureMid: BaseTexture;
  33013. /** @hidden */
  33014. _lodTextureLow: BaseTexture;
  33015. /** @hidden */
  33016. _webGLTexture: Nullable<WebGLTexture>;
  33017. /** @hidden */
  33018. _references: number;
  33019. private _engine;
  33020. /**
  33021. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33022. */
  33023. readonly dataSource: number;
  33024. /**
  33025. * Creates a new InternalTexture
  33026. * @param engine defines the engine to use
  33027. * @param dataSource defines the type of data that will be used
  33028. */
  33029. constructor(engine: Engine, dataSource: number);
  33030. /**
  33031. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33032. */
  33033. incrementReferences(): void;
  33034. /**
  33035. * Change the size of the texture (not the size of the content)
  33036. * @param width defines the new width
  33037. * @param height defines the new height
  33038. * @param depth defines the new depth (1 by default)
  33039. */
  33040. updateSize(width: int, height: int, depth?: int): void;
  33041. /** @hidden */
  33042. _rebuild(): void;
  33043. private _swapAndDie(target);
  33044. /**
  33045. * Dispose the current allocated resources
  33046. */
  33047. dispose(): void;
  33048. }
  33049. }
  33050. declare module BABYLON {
  33051. /**
  33052. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33053. */
  33054. interface IInternalTextureTracker {
  33055. /**
  33056. * Gets or set the previous tracker in the list
  33057. */
  33058. previous: Nullable<IInternalTextureTracker>;
  33059. /**
  33060. * Gets or set the next tracker in the list
  33061. */
  33062. next: Nullable<IInternalTextureTracker>;
  33063. }
  33064. /**
  33065. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33066. */
  33067. class DummyInternalTextureTracker {
  33068. /**
  33069. * Gets or set the previous tracker in the list
  33070. */
  33071. previous: Nullable<IInternalTextureTracker>;
  33072. /**
  33073. * Gets or set the next tracker in the list
  33074. */
  33075. next: Nullable<IInternalTextureTracker>;
  33076. }
  33077. }
  33078. declare module BABYLON {
  33079. class MirrorTexture extends RenderTargetTexture {
  33080. private scene;
  33081. mirrorPlane: Plane;
  33082. private _transformMatrix;
  33083. private _mirrorMatrix;
  33084. private _savedViewMatrix;
  33085. private _blurX;
  33086. private _blurY;
  33087. private _adaptiveBlurKernel;
  33088. private _blurKernelX;
  33089. private _blurKernelY;
  33090. private _blurRatio;
  33091. blurRatio: number;
  33092. adaptiveBlurKernel: number;
  33093. blurKernel: number;
  33094. blurKernelX: number;
  33095. blurKernelY: number;
  33096. private _autoComputeBlurKernel();
  33097. protected _onRatioRescale(): void;
  33098. private _updateGammaSpace();
  33099. private _imageProcessingConfigChangeObserver;
  33100. constructor(name: string, size: number | {
  33101. width: number;
  33102. height: number;
  33103. } | {
  33104. ratio: number;
  33105. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33106. private _preparePostProcesses();
  33107. clone(): MirrorTexture;
  33108. serialize(): any;
  33109. dispose(): void;
  33110. }
  33111. }
  33112. declare module BABYLON {
  33113. interface IMultiRenderTargetOptions {
  33114. generateMipMaps?: boolean;
  33115. types?: number[];
  33116. samplingModes?: number[];
  33117. generateDepthBuffer?: boolean;
  33118. generateStencilBuffer?: boolean;
  33119. generateDepthTexture?: boolean;
  33120. textureCount?: number;
  33121. doNotChangeAspectRatio?: boolean;
  33122. defaultType?: number;
  33123. }
  33124. class MultiRenderTarget extends RenderTargetTexture {
  33125. private _internalTextures;
  33126. private _textures;
  33127. readonly isSupported: boolean;
  33128. private _multiRenderTargetOptions;
  33129. readonly textures: Texture[];
  33130. readonly depthTexture: Texture;
  33131. wrapU: number;
  33132. wrapV: number;
  33133. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33134. _rebuild(): void;
  33135. private _createInternalTextures();
  33136. private _createTextures();
  33137. samples: number;
  33138. resize(size: any): void;
  33139. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33140. dispose(): void;
  33141. releaseInternalTextures(): void;
  33142. }
  33143. }
  33144. declare module BABYLON {
  33145. class RawTexture extends Texture {
  33146. format: number;
  33147. private _engine;
  33148. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33149. update(data: ArrayBufferView): void;
  33150. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33151. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33152. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33153. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33154. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33155. }
  33156. }
  33157. declare module BABYLON {
  33158. /**
  33159. * Class used to store 3D textures containing user data
  33160. */
  33161. class RawTexture3D extends Texture {
  33162. /** Gets or sets the texture format to use*/
  33163. format: number;
  33164. private _engine;
  33165. /**
  33166. * Create a new RawTexture3D
  33167. * @param data defines the data of the texture
  33168. * @param width defines the width of the texture
  33169. * @param height defines the height of the texture
  33170. * @param depth defines the depth of the texture
  33171. * @param format defines the texture format to use
  33172. * @param scene defines the hosting scene
  33173. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33174. * @param invertY defines if texture must be stored with Y axis inverted
  33175. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33176. */
  33177. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33178. /** Gets or sets the texture format to use*/
  33179. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  33180. /**
  33181. * Update the texture with new data
  33182. * @param data defines the data to store in the texture
  33183. */
  33184. update(data: ArrayBufferView): void;
  33185. }
  33186. }
  33187. declare module BABYLON {
  33188. /**
  33189. * Creates a refraction texture used by refraction channel of the standard material.
  33190. * @param name the texture name
  33191. * @param size size of the underlying texture
  33192. * @param scene root scene
  33193. */
  33194. class RefractionTexture extends RenderTargetTexture {
  33195. refractionPlane: Plane;
  33196. depth: number;
  33197. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33198. clone(): RefractionTexture;
  33199. serialize(): any;
  33200. }
  33201. }
  33202. declare module BABYLON {
  33203. class RenderTargetTexture extends Texture {
  33204. isCube: boolean;
  33205. static _REFRESHRATE_RENDER_ONCE: number;
  33206. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33207. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33208. static readonly REFRESHRATE_RENDER_ONCE: number;
  33209. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33210. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33211. /**
  33212. * Use this predicate to dynamically define the list of mesh you want to render.
  33213. * If set, the renderList property will be overwritten.
  33214. */
  33215. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33216. /**
  33217. * Use this list to define the list of mesh you want to render.
  33218. */
  33219. renderList: Nullable<Array<AbstractMesh>>;
  33220. renderParticles: boolean;
  33221. renderSprites: boolean;
  33222. coordinatesMode: number;
  33223. activeCamera: Nullable<Camera>;
  33224. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33225. useCameraPostProcesses: boolean;
  33226. ignoreCameraViewport: boolean;
  33227. private _postProcessManager;
  33228. private _postProcesses;
  33229. private _resizeObserver;
  33230. /**
  33231. * An event triggered when the texture is unbind.
  33232. */
  33233. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33234. /**
  33235. * An event triggered when the texture is unbind.
  33236. */
  33237. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33238. private _onAfterUnbindObserver;
  33239. onAfterUnbind: () => void;
  33240. /**
  33241. * An event triggered before rendering the texture
  33242. */
  33243. onBeforeRenderObservable: Observable<number>;
  33244. private _onBeforeRenderObserver;
  33245. onBeforeRender: (faceIndex: number) => void;
  33246. /**
  33247. * An event triggered after rendering the texture
  33248. */
  33249. onAfterRenderObservable: Observable<number>;
  33250. private _onAfterRenderObserver;
  33251. onAfterRender: (faceIndex: number) => void;
  33252. /**
  33253. * An event triggered after the texture clear
  33254. */
  33255. onClearObservable: Observable<Engine>;
  33256. private _onClearObserver;
  33257. onClear: (Engine: Engine) => void;
  33258. clearColor: Color4;
  33259. protected _size: number | {
  33260. width: number;
  33261. height: number;
  33262. };
  33263. protected _initialSizeParameter: number | {
  33264. width: number;
  33265. height: number;
  33266. } | {
  33267. ratio: number;
  33268. };
  33269. protected _sizeRatio: Nullable<number>;
  33270. _generateMipMaps: boolean;
  33271. protected _renderingManager: RenderingManager;
  33272. _waitingRenderList: string[];
  33273. protected _doNotChangeAspectRatio: boolean;
  33274. protected _currentRefreshId: number;
  33275. protected _refreshRate: number;
  33276. protected _textureMatrix: Matrix;
  33277. protected _samples: number;
  33278. protected _renderTargetOptions: RenderTargetCreationOptions;
  33279. readonly renderTargetOptions: RenderTargetCreationOptions;
  33280. protected _engine: Engine;
  33281. protected _onRatioRescale(): void;
  33282. /**
  33283. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33284. * It must define where the camera used to render the texture is set
  33285. */
  33286. boundingBoxPosition: Vector3;
  33287. private _boundingBoxSize;
  33288. /**
  33289. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33290. * When defined, the cubemap will switch to local mode
  33291. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33292. * @example https://www.babylonjs-playground.com/#RNASML
  33293. */
  33294. boundingBoxSize: Vector3;
  33295. /**
  33296. * In case the RTT has been created with a depth texture, get the associated
  33297. * depth texture.
  33298. * Otherwise, return null.
  33299. */
  33300. depthStencilTexture: Nullable<InternalTexture>;
  33301. /**
  33302. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33303. * or used a shadow, depth texture...
  33304. * @param name The friendly name of the texture
  33305. * @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)
  33306. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33307. * @param generateMipMaps True if mip maps need to be generated after render.
  33308. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33309. * @param type The type of the buffer in the RTT (int, half float, float...)
  33310. * @param isCube True if a cube texture needs to be created
  33311. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33312. * @param generateDepthBuffer True to generate a depth buffer
  33313. * @param generateStencilBuffer True to generate a stencil buffer
  33314. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33315. */
  33316. constructor(name: string, size: number | {
  33317. width: number;
  33318. height: number;
  33319. } | {
  33320. ratio: number;
  33321. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33322. /**
  33323. * Creates a depth stencil texture.
  33324. * This is only available in WebGL 2 or with the depth texture extension available.
  33325. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33326. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33327. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33328. */
  33329. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33330. private _processSizeParameter(size);
  33331. samples: number;
  33332. resetRefreshCounter(): void;
  33333. refreshRate: number;
  33334. addPostProcess(postProcess: PostProcess): void;
  33335. clearPostProcesses(dispose?: boolean): void;
  33336. removePostProcess(postProcess: PostProcess): void;
  33337. _shouldRender(): boolean;
  33338. getRenderSize(): number;
  33339. getRenderWidth(): number;
  33340. getRenderHeight(): number;
  33341. readonly canRescale: boolean;
  33342. scale(ratio: number): void;
  33343. getReflectionTextureMatrix(): Matrix;
  33344. resize(size: number | {
  33345. width: number;
  33346. height: number;
  33347. } | {
  33348. ratio: number;
  33349. }): void;
  33350. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33351. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33352. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33353. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33354. /**
  33355. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33356. * This allowed control for front to back rendering or reversly depending of the special needs.
  33357. *
  33358. * @param renderingGroupId The rendering group id corresponding to its index
  33359. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33360. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33361. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33362. */
  33363. 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;
  33364. /**
  33365. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33366. *
  33367. * @param renderingGroupId The rendering group id corresponding to its index
  33368. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33369. */
  33370. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33371. clone(): RenderTargetTexture;
  33372. serialize(): any;
  33373. disposeFramebufferObjects(): void;
  33374. dispose(): void;
  33375. _rebuild(): void;
  33376. /**
  33377. * Clear the info related to rendering groups preventing retention point in material dispose.
  33378. */
  33379. freeRenderingGroups(): void;
  33380. }
  33381. }
  33382. declare module BABYLON {
  33383. class Texture extends BaseTexture {
  33384. static NEAREST_SAMPLINGMODE: number;
  33385. static NEAREST_NEAREST_MIPLINEAR: number;
  33386. static BILINEAR_SAMPLINGMODE: number;
  33387. static LINEAR_LINEAR_MIPNEAREST: number;
  33388. static TRILINEAR_SAMPLINGMODE: number;
  33389. static LINEAR_LINEAR_MIPLINEAR: number;
  33390. static NEAREST_NEAREST_MIPNEAREST: number;
  33391. static NEAREST_LINEAR_MIPNEAREST: number;
  33392. static NEAREST_LINEAR_MIPLINEAR: number;
  33393. static NEAREST_LINEAR: number;
  33394. static NEAREST_NEAREST: number;
  33395. static LINEAR_NEAREST_MIPNEAREST: number;
  33396. static LINEAR_NEAREST_MIPLINEAR: number;
  33397. static LINEAR_LINEAR: number;
  33398. static LINEAR_NEAREST: number;
  33399. static EXPLICIT_MODE: number;
  33400. static SPHERICAL_MODE: number;
  33401. static PLANAR_MODE: number;
  33402. static CUBIC_MODE: number;
  33403. static PROJECTION_MODE: number;
  33404. static SKYBOX_MODE: number;
  33405. static INVCUBIC_MODE: number;
  33406. static EQUIRECTANGULAR_MODE: number;
  33407. static FIXED_EQUIRECTANGULAR_MODE: number;
  33408. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33409. static CLAMP_ADDRESSMODE: number;
  33410. static WRAP_ADDRESSMODE: number;
  33411. static MIRROR_ADDRESSMODE: number;
  33412. /**
  33413. * 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
  33414. */
  33415. static UseSerializedUrlIfAny: boolean;
  33416. url: Nullable<string>;
  33417. uOffset: number;
  33418. vOffset: number;
  33419. uScale: number;
  33420. vScale: number;
  33421. uAng: number;
  33422. vAng: number;
  33423. wAng: number;
  33424. readonly noMipmap: boolean;
  33425. private _noMipmap;
  33426. _invertY: boolean;
  33427. private _rowGenerationMatrix;
  33428. private _cachedTextureMatrix;
  33429. private _projectionModeMatrix;
  33430. private _t0;
  33431. private _t1;
  33432. private _t2;
  33433. private _cachedUOffset;
  33434. private _cachedVOffset;
  33435. private _cachedUScale;
  33436. private _cachedVScale;
  33437. private _cachedUAng;
  33438. private _cachedVAng;
  33439. private _cachedWAng;
  33440. private _cachedProjectionMatrixId;
  33441. private _cachedCoordinatesMode;
  33442. _samplingMode: number;
  33443. private _buffer;
  33444. private _deleteBuffer;
  33445. protected _format: Nullable<number>;
  33446. private _delayedOnLoad;
  33447. private _delayedOnError;
  33448. protected _onLoadObservable: Nullable<Observable<Texture>>;
  33449. protected _isBlocking: boolean;
  33450. isBlocking: boolean;
  33451. readonly samplingMode: number;
  33452. 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);
  33453. updateURL(url: string): void;
  33454. delayLoad(): void;
  33455. updateSamplingMode(samplingMode: number): void;
  33456. private _prepareRowForTextureGeneration(x, y, z, t);
  33457. getTextureMatrix(): Matrix;
  33458. getReflectionTextureMatrix(): Matrix;
  33459. clone(): Texture;
  33460. readonly onLoadObservable: Observable<Texture>;
  33461. serialize(): any;
  33462. getClassName(): string;
  33463. dispose(): void;
  33464. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  33465. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  33466. 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;
  33467. }
  33468. }
  33469. declare module BABYLON {
  33470. /**
  33471. * Settings for finer control over video usage
  33472. */
  33473. interface VideoTextureSettings {
  33474. /**
  33475. * Applies `autoplay` to video, if specified
  33476. */
  33477. autoPlay?: boolean;
  33478. /**
  33479. * Applies `loop` to video, if specified
  33480. */
  33481. loop?: boolean;
  33482. /**
  33483. * Automatically updates internal texture from video at every frame in the render loop
  33484. */
  33485. autoUpdateTexture: boolean;
  33486. }
  33487. class VideoTexture extends Texture {
  33488. /**
  33489. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33490. */
  33491. readonly autoUpdateTexture: boolean;
  33492. /**
  33493. * The video instance used by the texture internally
  33494. */
  33495. readonly video: HTMLVideoElement;
  33496. private _generateMipMaps;
  33497. private _engine;
  33498. private _stillImageCaptured;
  33499. /**
  33500. * Creates a video texture.
  33501. * Sample : https://doc.babylonjs.com/how_to/video_texture
  33502. * @param {string | null} name optional name, will detect from video source, if not defined
  33503. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  33504. * @param {BABYLON.Scene} scene is obviously the current scene.
  33505. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33506. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  33507. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33508. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  33509. */
  33510. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33511. private _getName(src);
  33512. private _getVideo(src);
  33513. private _createInternalTexture;
  33514. private reset;
  33515. /**
  33516. * Internal method to initiate `update`.
  33517. */
  33518. _rebuild(): void;
  33519. /**
  33520. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33521. */
  33522. update(): void;
  33523. /**
  33524. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33525. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33526. */
  33527. updateTexture(isVisible: boolean): void;
  33528. protected _updateInternalTexture: (e?: Event | undefined) => void;
  33529. /**
  33530. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33531. * @param url New url.
  33532. */
  33533. updateURL(url: string): void;
  33534. dispose(): void;
  33535. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33536. minWidth: number;
  33537. maxWidth: number;
  33538. minHeight: number;
  33539. maxHeight: number;
  33540. deviceId: string;
  33541. }): void;
  33542. }
  33543. }
  33544. declare var DracoDecoderModule: any;
  33545. declare var WebAssembly: any;
  33546. declare module BABYLON {
  33547. /**
  33548. * Configuration for Draco compression
  33549. */
  33550. interface IDracoCompressionConfiguration {
  33551. /**
  33552. * Configuration for the decoder.
  33553. */
  33554. decoder?: {
  33555. /**
  33556. * The url to the WebAssembly module.
  33557. */
  33558. wasmUrl?: string;
  33559. /**
  33560. * The url to the WebAssembly binary.
  33561. */
  33562. wasmBinaryUrl?: string;
  33563. /**
  33564. * The url to the fallback JavaScript module.
  33565. */
  33566. fallbackUrl?: string;
  33567. };
  33568. }
  33569. /**
  33570. * Draco compression (https://google.github.io/draco/)
  33571. */
  33572. class DracoCompression implements IDisposable {
  33573. private static _DecoderModulePromise;
  33574. /**
  33575. * The configuration.
  33576. */
  33577. static Configuration: IDracoCompressionConfiguration;
  33578. /**
  33579. * Returns true if the decoder is available.
  33580. */
  33581. static readonly DecoderAvailable: boolean;
  33582. /**
  33583. * Constructor
  33584. */
  33585. constructor();
  33586. /**
  33587. * Stop all async operations and release resources.
  33588. */
  33589. dispose(): void;
  33590. /**
  33591. * Decode Draco compressed mesh data to vertex data.
  33592. * @param data The array buffer view for the Draco compression data
  33593. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  33594. * @returns A promise that resolves with the decoded vertex data
  33595. */
  33596. decodeMeshAsync(data: ArrayBufferView, attributes: {
  33597. [kind: string]: number;
  33598. }): Promise<VertexData>;
  33599. private static _GetDecoderModule();
  33600. private static _LoadScriptAsync(url);
  33601. private static _LoadFileAsync(url);
  33602. }
  33603. }
  33604. declare module BABYLON {
  33605. /**
  33606. * Particle emitter emitting particles from the inside of a box.
  33607. * It emits the particles randomly between 2 given directions.
  33608. */
  33609. class BoxParticleEmitter implements IParticleEmitterType {
  33610. /**
  33611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33612. */
  33613. direction1: Vector3;
  33614. /**
  33615. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33616. */
  33617. direction2: Vector3;
  33618. /**
  33619. * 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.
  33620. */
  33621. minEmitBox: Vector3;
  33622. /**
  33623. * 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.
  33624. */
  33625. maxEmitBox: Vector3;
  33626. /**
  33627. * Creates a new instance BoxParticleEmitter
  33628. */
  33629. constructor();
  33630. /**
  33631. * Called by the particle System when the direction is computed for the created particle.
  33632. * @param emitPower is the power of the particle (speed)
  33633. * @param worldMatrix is the world matrix of the particle system
  33634. * @param directionToUpdate is the direction vector to update with the result
  33635. * @param particle is the particle we are computed the direction for
  33636. */
  33637. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33638. /**
  33639. * Called by the particle System when the position is computed for the created particle.
  33640. * @param worldMatrix is the world matrix of the particle system
  33641. * @param positionToUpdate is the position vector to update with the result
  33642. * @param particle is the particle we are computed the position for
  33643. */
  33644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33645. /**
  33646. * Clones the current emitter and returns a copy of it
  33647. * @returns the new emitter
  33648. */
  33649. clone(): BoxParticleEmitter;
  33650. /**
  33651. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33652. * @param effect defines the update shader
  33653. */
  33654. applyToShader(effect: Effect): void;
  33655. /**
  33656. * Returns a string to use to update the GPU particles update shader
  33657. * @returns a string containng the defines string
  33658. */
  33659. getEffectDefines(): string;
  33660. /**
  33661. * Returns the string "BoxEmitter"
  33662. * @returns a string containing the class name
  33663. */
  33664. getClassName(): string;
  33665. /**
  33666. * Serializes the particle system to a JSON object.
  33667. * @returns the JSON object
  33668. */
  33669. serialize(): any;
  33670. /**
  33671. * Parse properties from a JSON object
  33672. * @param serializationObject defines the JSON object
  33673. */
  33674. parse(serializationObject: any): void;
  33675. }
  33676. }
  33677. declare module BABYLON {
  33678. /**
  33679. * Particle emitter emitting particles from the inside of a cone.
  33680. * It emits the particles alongside the cone volume from the base to the particle.
  33681. * The emission direction might be randomized.
  33682. */
  33683. class ConeParticleEmitter implements IParticleEmitterType {
  33684. /**
  33685. * The radius of the emission cone.
  33686. */
  33687. angle: number;
  33688. /**
  33689. * The cone base angle.
  33690. */
  33691. directionRandomizer: number;
  33692. private _radius;
  33693. private _height;
  33694. /**
  33695. * Gets the radius of the emission cone.
  33696. */
  33697. /**
  33698. * Sets the radius of the emission cone.
  33699. */
  33700. radius: number;
  33701. /**
  33702. * Creates a new instance ConeParticleEmitter
  33703. * @param radius the radius of the emission cone (1 by default)
  33704. * @param angles the cone base angle (PI by default)
  33705. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33706. */
  33707. constructor(radius?: number,
  33708. /**
  33709. * The radius of the emission cone.
  33710. */
  33711. angle?: number,
  33712. /**
  33713. * The cone base angle.
  33714. */
  33715. directionRandomizer?: number);
  33716. /**
  33717. * Called by the particle System when the direction is computed for the created particle.
  33718. * @param emitPower is the power of the particle (speed)
  33719. * @param worldMatrix is the world matrix of the particle system
  33720. * @param directionToUpdate is the direction vector to update with the result
  33721. * @param particle is the particle we are computed the direction for
  33722. */
  33723. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33724. /**
  33725. * Called by the particle System when the position is computed for the created particle.
  33726. * @param worldMatrix is the world matrix of the particle system
  33727. * @param positionToUpdate is the position vector to update with the result
  33728. * @param particle is the particle we are computed the position for
  33729. */
  33730. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33731. /**
  33732. * Clones the current emitter and returns a copy of it
  33733. * @returns the new emitter
  33734. */
  33735. clone(): ConeParticleEmitter;
  33736. /**
  33737. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33738. * @param effect defines the update shader
  33739. */
  33740. applyToShader(effect: Effect): void;
  33741. /**
  33742. * Returns a string to use to update the GPU particles update shader
  33743. * @returns a string containng the defines string
  33744. */
  33745. getEffectDefines(): string;
  33746. /**
  33747. * Returns the string "BoxEmitter"
  33748. * @returns a string containing the class name
  33749. */
  33750. getClassName(): string;
  33751. /**
  33752. * Serializes the particle system to a JSON object.
  33753. * @returns the JSON object
  33754. */
  33755. serialize(): any;
  33756. /**
  33757. * Parse properties from a JSON object
  33758. * @param serializationObject defines the JSON object
  33759. */
  33760. parse(serializationObject: any): void;
  33761. }
  33762. }
  33763. declare module BABYLON {
  33764. /**
  33765. * Particle emitter represents a volume emitting particles.
  33766. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  33767. */
  33768. interface IParticleEmitterType {
  33769. /**
  33770. * Called by the particle System when the direction is computed for the created particle.
  33771. * @param emitPower is the power of the particle (speed)
  33772. * @param worldMatrix is the world matrix of the particle system
  33773. * @param directionToUpdate is the direction vector to update with the result
  33774. * @param particle is the particle we are computed the direction for
  33775. */
  33776. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33777. /**
  33778. * Called by the particle System when the position is computed for the created particle.
  33779. * @param worldMatrix is the world matrix of the particle system
  33780. * @param positionToUpdate is the position vector to update with the result
  33781. * @param particle is the particle we are computed the position for
  33782. */
  33783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33784. /**
  33785. * Clones the current emitter and returns a copy of it
  33786. * @returns the new emitter
  33787. */
  33788. clone(): IParticleEmitterType;
  33789. /**
  33790. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33791. * @param effect defines the update shader
  33792. */
  33793. applyToShader(effect: Effect): void;
  33794. /**
  33795. * Returns a string to use to update the GPU particles update shader
  33796. * @returns the effect defines string
  33797. */
  33798. getEffectDefines(): string;
  33799. /**
  33800. * Returns a string representing the class name
  33801. * @returns a string containing the class name
  33802. */
  33803. getClassName(): string;
  33804. /**
  33805. * Serializes the particle system to a JSON object.
  33806. * @returns the JSON object
  33807. */
  33808. serialize(): any;
  33809. /**
  33810. * Parse properties from a JSON object
  33811. * @param serializationObject defines the JSON object
  33812. */
  33813. parse(serializationObject: any): void;
  33814. }
  33815. }
  33816. declare module BABYLON {
  33817. /**
  33818. * Particle emitter emitting particles from the inside of a sphere.
  33819. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  33820. */
  33821. class SphereParticleEmitter implements IParticleEmitterType {
  33822. /**
  33823. * The radius of the emission sphere.
  33824. */
  33825. radius: number;
  33826. /**
  33827. * How much to randomize the particle direction [0-1].
  33828. */
  33829. directionRandomizer: number;
  33830. /**
  33831. * Creates a new instance SphereParticleEmitter
  33832. * @param radius the radius of the emission sphere (1 by default)
  33833. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33834. */
  33835. constructor(
  33836. /**
  33837. * The radius of the emission sphere.
  33838. */
  33839. radius?: number,
  33840. /**
  33841. * How much to randomize the particle direction [0-1].
  33842. */
  33843. directionRandomizer?: number);
  33844. /**
  33845. * Called by the particle System when the direction is computed for the created particle.
  33846. * @param emitPower is the power of the particle (speed)
  33847. * @param worldMatrix is the world matrix of the particle system
  33848. * @param directionToUpdate is the direction vector to update with the result
  33849. * @param particle is the particle we are computed the direction for
  33850. */
  33851. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33852. /**
  33853. * Called by the particle System when the position is computed for the created particle.
  33854. * @param worldMatrix is the world matrix of the particle system
  33855. * @param positionToUpdate is the position vector to update with the result
  33856. * @param particle is the particle we are computed the position for
  33857. */
  33858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33859. /**
  33860. * Clones the current emitter and returns a copy of it
  33861. * @returns the new emitter
  33862. */
  33863. clone(): SphereParticleEmitter;
  33864. /**
  33865. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33866. * @param effect defines the update shader
  33867. */
  33868. applyToShader(effect: Effect): void;
  33869. /**
  33870. * Returns a string to use to update the GPU particles update shader
  33871. * @returns a string containng the defines string
  33872. */
  33873. getEffectDefines(): string;
  33874. /**
  33875. * Returns the string "SphereParticleEmitter"
  33876. * @returns a string containing the class name
  33877. */
  33878. getClassName(): string;
  33879. /**
  33880. * Serializes the particle system to a JSON object.
  33881. * @returns the JSON object
  33882. */
  33883. serialize(): any;
  33884. /**
  33885. * Parse properties from a JSON object
  33886. * @param serializationObject defines the JSON object
  33887. */
  33888. parse(serializationObject: any): void;
  33889. }
  33890. /**
  33891. * Particle emitter emitting particles from the inside of a sphere.
  33892. * It emits the particles randomly between two vectors.
  33893. */
  33894. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  33895. /**
  33896. * The min limit of the emission direction.
  33897. */
  33898. direction1: Vector3;
  33899. /**
  33900. * The max limit of the emission direction.
  33901. */
  33902. direction2: Vector3;
  33903. /**
  33904. * Creates a new instance SphereDirectedParticleEmitter
  33905. * @param radius the radius of the emission sphere (1 by default)
  33906. * @param direction1 the min limit of the emission direction (up vector by default)
  33907. * @param direction2 the max limit of the emission direction (up vector by default)
  33908. */
  33909. constructor(radius?: number,
  33910. /**
  33911. * The min limit of the emission direction.
  33912. */
  33913. direction1?: Vector3,
  33914. /**
  33915. * The max limit of the emission direction.
  33916. */
  33917. direction2?: Vector3);
  33918. /**
  33919. * Called by the particle System when the direction is computed for the created particle.
  33920. * @param emitPower is the power of the particle (speed)
  33921. * @param worldMatrix is the world matrix of the particle system
  33922. * @param directionToUpdate is the direction vector to update with the result
  33923. * @param particle is the particle we are computed the direction for
  33924. */
  33925. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33926. /**
  33927. * Clones the current emitter and returns a copy of it
  33928. * @returns the new emitter
  33929. */
  33930. clone(): SphereDirectedParticleEmitter;
  33931. /**
  33932. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33933. * @param effect defines the update shader
  33934. */
  33935. applyToShader(effect: Effect): void;
  33936. /**
  33937. * Returns a string to use to update the GPU particles update shader
  33938. * @returns a string containng the defines string
  33939. */
  33940. getEffectDefines(): string;
  33941. /**
  33942. * Returns the string "SphereDirectedParticleEmitter"
  33943. * @returns a string containing the class name
  33944. */
  33945. getClassName(): string;
  33946. /**
  33947. * Serializes the particle system to a JSON object.
  33948. * @returns the JSON object
  33949. */
  33950. serialize(): any;
  33951. /**
  33952. * Parse properties from a JSON object
  33953. * @param serializationObject defines the JSON object
  33954. */
  33955. parse(serializationObject: any): void;
  33956. }
  33957. }
  33958. declare module BABYLON {
  33959. class CannonJSPlugin implements IPhysicsEnginePlugin {
  33960. private _useDeltaForWorldStep;
  33961. world: any;
  33962. name: string;
  33963. private _physicsMaterials;
  33964. private _fixedTimeStep;
  33965. BJSCANNON: any;
  33966. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  33967. setGravity(gravity: Vector3): void;
  33968. setTimeStep(timeStep: number): void;
  33969. getTimeStep(): number;
  33970. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33971. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33972. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33973. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33974. private _processChildMeshes(mainImpostor);
  33975. removePhysicsBody(impostor: PhysicsImpostor): void;
  33976. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  33977. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  33978. private _addMaterial(name, friction, restitution);
  33979. private _checkWithEpsilon(value);
  33980. private _createShape(impostor);
  33981. private _createHeightmap(object, pointDepth?);
  33982. private _minus90X;
  33983. private _plus90X;
  33984. private _tmpPosition;
  33985. private _tmpDeltaPosition;
  33986. private _tmpUnityRotation;
  33987. private _updatePhysicsBodyTransformation(impostor);
  33988. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33989. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33990. isSupported(): boolean;
  33991. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33992. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33993. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33994. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33995. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33996. getBodyMass(impostor: PhysicsImpostor): number;
  33997. getBodyFriction(impostor: PhysicsImpostor): number;
  33998. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33999. getBodyRestitution(impostor: PhysicsImpostor): number;
  34000. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34001. sleepBody(impostor: PhysicsImpostor): void;
  34002. wakeUpBody(impostor: PhysicsImpostor): void;
  34003. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34004. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34005. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34006. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34007. getRadius(impostor: PhysicsImpostor): number;
  34008. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34009. dispose(): void;
  34010. private _extendNamespace();
  34011. }
  34012. }
  34013. declare module BABYLON {
  34014. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34015. world: any;
  34016. name: string;
  34017. BJSOIMO: any;
  34018. constructor(iterations?: number);
  34019. setGravity(gravity: Vector3): void;
  34020. setTimeStep(timeStep: number): void;
  34021. getTimeStep(): number;
  34022. private _tmpImpostorsArray;
  34023. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34024. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34026. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34027. private _tmpPositionVector;
  34028. removePhysicsBody(impostor: PhysicsImpostor): void;
  34029. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34030. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34031. isSupported(): boolean;
  34032. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34033. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34034. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34035. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34036. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34037. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34038. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34039. getBodyMass(impostor: PhysicsImpostor): number;
  34040. getBodyFriction(impostor: PhysicsImpostor): number;
  34041. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34042. getBodyRestitution(impostor: PhysicsImpostor): number;
  34043. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34044. sleepBody(impostor: PhysicsImpostor): void;
  34045. wakeUpBody(impostor: PhysicsImpostor): void;
  34046. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34047. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34048. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34049. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34050. getRadius(impostor: PhysicsImpostor): number;
  34051. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34052. dispose(): void;
  34053. }
  34054. }
  34055. declare module BABYLON {
  34056. /**
  34057. * This represents a set of one or more post processes in Babylon.
  34058. * A post process can be used to apply a shader to a texture after it is rendered.
  34059. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34060. */
  34061. class PostProcessRenderEffect {
  34062. private _postProcesses;
  34063. private _getPostProcesses;
  34064. private _singleInstance;
  34065. private _cameras;
  34066. private _indicesForCamera;
  34067. /**
  34068. * Name of the effect
  34069. */
  34070. _name: string;
  34071. /**
  34072. * Instantiates a post process render effect.
  34073. * A post process can be used to apply a shader to a texture after it is rendered.
  34074. * @param engine The engine the effect is tied to
  34075. * @param name The name of the effect
  34076. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34077. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34078. */
  34079. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34080. /**
  34081. * Checks if all the post processes in the effect are supported.
  34082. */
  34083. readonly isSupported: boolean;
  34084. /**
  34085. * Updates the current state of the effect
  34086. */
  34087. _update(): void;
  34088. /**
  34089. * Attaches the effect on cameras
  34090. * @param cameras The camera to attach to.
  34091. */
  34092. _attachCameras(cameras: Camera): void;
  34093. /**
  34094. * Attaches the effect on cameras
  34095. * @param cameras The camera to attach to.
  34096. */
  34097. _attachCameras(cameras: Camera[]): void;
  34098. /**
  34099. * Detatches the effect on cameras
  34100. * @param cameras The camera to detatch from.
  34101. */
  34102. _detachCameras(cameras: Camera): void;
  34103. /**
  34104. * Detatches the effect on cameras
  34105. * @param cameras The camera to detatch from.
  34106. */
  34107. _detachCameras(cameras: Camera[]): void;
  34108. /**
  34109. * Enables the effect on given cameras
  34110. * @param cameras The camera to enable.
  34111. */
  34112. _enable(cameras: Camera): void;
  34113. /**
  34114. * Enables the effect on given cameras
  34115. * @param cameras The camera to enable.
  34116. */
  34117. _enable(cameras: Nullable<Camera[]>): void;
  34118. /**
  34119. * Disables the effect on the given cameras
  34120. * @param cameras The camera to disable.
  34121. */
  34122. _disable(cameras: Camera): void;
  34123. /**
  34124. * Disables the effect on the given cameras
  34125. * @param cameras The camera to disable.
  34126. */
  34127. _disable(cameras: Nullable<Camera[]>): void;
  34128. /**
  34129. * Gets a list of the post processes contained in the effect.
  34130. * @param camera The camera to get the post processes on.
  34131. * @returns The list of the post processes in the effect.
  34132. */
  34133. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34134. }
  34135. }
  34136. declare module BABYLON {
  34137. class PostProcessRenderPipeline {
  34138. private engine;
  34139. private _renderEffects;
  34140. private _renderEffectsForIsolatedPass;
  34141. protected _cameras: Camera[];
  34142. _name: string;
  34143. constructor(engine: Engine, name: string);
  34144. getClassName(): string;
  34145. readonly isSupported: boolean;
  34146. addEffect(renderEffect: PostProcessRenderEffect): void;
  34147. _rebuild(): void;
  34148. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34149. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34150. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34151. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34152. _attachCameras(cameras: Camera, unique: boolean): void;
  34153. _attachCameras(cameras: Camera[], unique: boolean): void;
  34154. _detachCameras(cameras: Camera): void;
  34155. _detachCameras(cameras: Nullable<Camera[]>): void;
  34156. _update(): void;
  34157. _reset(): void;
  34158. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34159. dispose(): void;
  34160. }
  34161. }
  34162. declare module BABYLON {
  34163. class PostProcessRenderPipelineManager {
  34164. private _renderPipelines;
  34165. constructor();
  34166. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34167. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34168. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34169. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34170. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34171. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34172. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34173. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34174. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34175. update(): void;
  34176. _rebuild(): void;
  34177. dispose(): void;
  34178. }
  34179. }
  34180. declare module BABYLON {
  34181. /**
  34182. * Helper class dealing with the extraction of spherical polynomial dataArray
  34183. * from a cube map.
  34184. */
  34185. class CubeMapToSphericalPolynomialTools {
  34186. private static FileFaces;
  34187. /**
  34188. * Converts a texture to the according Spherical Polynomial data.
  34189. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34190. *
  34191. * @param texture The texture to extract the information from.
  34192. * @return The Spherical Polynomial data.
  34193. */
  34194. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34195. /**
  34196. * Converts a cubemap to the according Spherical Polynomial data.
  34197. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34198. *
  34199. * @param cubeInfo The Cube map to extract the information from.
  34200. * @return The Spherical Polynomial data.
  34201. */
  34202. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34203. }
  34204. }
  34205. declare module BABYLON {
  34206. /**
  34207. * Header information of HDR texture files.
  34208. */
  34209. interface HDRInfo {
  34210. /**
  34211. * The height of the texture in pixels.
  34212. */
  34213. height: number;
  34214. /**
  34215. * The width of the texture in pixels.
  34216. */
  34217. width: number;
  34218. /**
  34219. * The index of the beginning of the data in the binary file.
  34220. */
  34221. dataPosition: number;
  34222. }
  34223. /**
  34224. * This groups tools to convert HDR texture to native colors array.
  34225. */
  34226. class HDRTools {
  34227. private static Ldexp(mantissa, exponent);
  34228. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34229. private static readStringLine(uint8array, startIndex);
  34230. /**
  34231. * Reads header information from an RGBE texture stored in a native array.
  34232. * More information on this format are available here:
  34233. * https://en.wikipedia.org/wiki/RGBE_image_format
  34234. *
  34235. * @param uint8array The binary file stored in native array.
  34236. * @return The header information.
  34237. */
  34238. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34239. /**
  34240. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34241. * This RGBE texture needs to store the information as a panorama.
  34242. *
  34243. * More information on this format are available here:
  34244. * https://en.wikipedia.org/wiki/RGBE_image_format
  34245. *
  34246. * @param buffer The binary file stored in an array buffer.
  34247. * @param size The expected size of the extracted cubemap.
  34248. * @return The Cube Map information.
  34249. */
  34250. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34251. /**
  34252. * Returns the pixels data extracted from an RGBE texture.
  34253. * This pixels will be stored left to right up to down in the R G B order in one array.
  34254. *
  34255. * More information on this format are available here:
  34256. * https://en.wikipedia.org/wiki/RGBE_image_format
  34257. *
  34258. * @param uint8array The binary file stored in an array buffer.
  34259. * @param hdrInfo The header information of the file.
  34260. * @return The pixels data in RGB right to left up to down order.
  34261. */
  34262. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34263. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34264. }
  34265. }
  34266. declare module BABYLON {
  34267. /**
  34268. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34269. */
  34270. interface CubeMapInfo {
  34271. /**
  34272. * The pixel array for the front face.
  34273. * This is stored in format, left to right, up to down format.
  34274. */
  34275. front: Nullable<ArrayBufferView>;
  34276. /**
  34277. * The pixel array for the back face.
  34278. * This is stored in format, left to right, up to down format.
  34279. */
  34280. back: Nullable<ArrayBufferView>;
  34281. /**
  34282. * The pixel array for the left face.
  34283. * This is stored in format, left to right, up to down format.
  34284. */
  34285. left: Nullable<ArrayBufferView>;
  34286. /**
  34287. * The pixel array for the right face.
  34288. * This is stored in format, left to right, up to down format.
  34289. */
  34290. right: Nullable<ArrayBufferView>;
  34291. /**
  34292. * The pixel array for the up face.
  34293. * This is stored in format, left to right, up to down format.
  34294. */
  34295. up: Nullable<ArrayBufferView>;
  34296. /**
  34297. * The pixel array for the down face.
  34298. * This is stored in format, left to right, up to down format.
  34299. */
  34300. down: Nullable<ArrayBufferView>;
  34301. /**
  34302. * The size of the cubemap stored.
  34303. *
  34304. * Each faces will be size * size pixels.
  34305. */
  34306. size: number;
  34307. /**
  34308. * The format of the texture.
  34309. *
  34310. * RGBA, RGB.
  34311. */
  34312. format: number;
  34313. /**
  34314. * The type of the texture data.
  34315. *
  34316. * UNSIGNED_INT, FLOAT.
  34317. */
  34318. type: number;
  34319. /**
  34320. * Specifies whether the texture is in gamma space.
  34321. */
  34322. gammaSpace: boolean;
  34323. }
  34324. /**
  34325. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34326. */
  34327. class PanoramaToCubeMapTools {
  34328. private static FACE_FRONT;
  34329. private static FACE_BACK;
  34330. private static FACE_RIGHT;
  34331. private static FACE_LEFT;
  34332. private static FACE_DOWN;
  34333. private static FACE_UP;
  34334. /**
  34335. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34336. *
  34337. * @param float32Array The source data.
  34338. * @param inputWidth The width of the input panorama.
  34339. * @param inputhHeight The height of the input panorama.
  34340. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34341. * @return The cubemap data
  34342. */
  34343. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34344. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34345. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34346. }
  34347. }
  34348. declare module BABYLON {
  34349. class CustomProceduralTexture extends ProceduralTexture {
  34350. private _animate;
  34351. private _time;
  34352. private _config;
  34353. private _texturePath;
  34354. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34355. private loadJson(jsonUrl);
  34356. isReady(): boolean;
  34357. render(useCameraPostProcess?: boolean): void;
  34358. updateTextures(): void;
  34359. updateShaderUniforms(): void;
  34360. animate: boolean;
  34361. }
  34362. }
  34363. declare module BABYLON {
  34364. class ProceduralTexture extends Texture {
  34365. isCube: boolean;
  34366. private _size;
  34367. _generateMipMaps: boolean;
  34368. isEnabled: boolean;
  34369. private _currentRefreshId;
  34370. private _refreshRate;
  34371. onGenerated: () => void;
  34372. private _vertexBuffers;
  34373. private _indexBuffer;
  34374. private _effect;
  34375. private _uniforms;
  34376. private _samplers;
  34377. private _fragment;
  34378. _textures: {
  34379. [key: string]: Texture;
  34380. };
  34381. private _floats;
  34382. private _floatsArrays;
  34383. private _colors3;
  34384. private _colors4;
  34385. private _vectors2;
  34386. private _vectors3;
  34387. private _matrices;
  34388. private _fallbackTexture;
  34389. private _fallbackTextureUsed;
  34390. private _engine;
  34391. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  34392. private _createIndexBuffer();
  34393. _rebuild(): void;
  34394. reset(): void;
  34395. isReady(): boolean;
  34396. resetRefreshCounter(): void;
  34397. setFragment(fragment: any): void;
  34398. refreshRate: number;
  34399. _shouldRender(): boolean;
  34400. getRenderSize(): number;
  34401. resize(size: number, generateMipMaps: boolean): void;
  34402. private _checkUniform(uniformName);
  34403. setTexture(name: string, texture: Texture): ProceduralTexture;
  34404. setFloat(name: string, value: number): ProceduralTexture;
  34405. setFloats(name: string, value: number[]): ProceduralTexture;
  34406. setColor3(name: string, value: Color3): ProceduralTexture;
  34407. setColor4(name: string, value: Color4): ProceduralTexture;
  34408. setVector2(name: string, value: Vector2): ProceduralTexture;
  34409. setVector3(name: string, value: Vector3): ProceduralTexture;
  34410. setMatrix(name: string, value: Matrix): ProceduralTexture;
  34411. render(useCameraPostProcess?: boolean): void;
  34412. clone(): ProceduralTexture;
  34413. dispose(): void;
  34414. }
  34415. }
  34416. declare module BABYLON {
  34417. /**
  34418. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  34419. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  34420. */
  34421. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34422. private _scene;
  34423. private _originalCameras;
  34424. /**
  34425. * ID of the sharpen post process,
  34426. */
  34427. private readonly SharpenPostProcessId;
  34428. /**
  34429. * ID of the image processing post process;
  34430. */
  34431. readonly ImageProcessingPostProcessId: string;
  34432. /**
  34433. * ID of the Fast Approximate Anti-Aliasing post process;
  34434. */
  34435. readonly FxaaPostProcessId: string;
  34436. /**
  34437. * ID of the chromatic aberration post process,
  34438. */
  34439. private readonly ChromaticAberrationPostProcessId;
  34440. /**
  34441. * ID of the grain post process
  34442. */
  34443. private readonly GrainPostProcessId;
  34444. /**
  34445. * Sharpen post process which will apply a sharpen convolution to enhance edges
  34446. */
  34447. sharpen: SharpenPostProcess;
  34448. private _sharpenEffect;
  34449. private bloom;
  34450. /**
  34451. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  34452. */
  34453. depthOfField: DepthOfFieldEffect;
  34454. /**
  34455. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  34456. */
  34457. fxaa: FxaaPostProcess;
  34458. /**
  34459. * Image post processing pass used to perform operations such as tone mapping or color grading.
  34460. */
  34461. imageProcessing: ImageProcessingPostProcess;
  34462. /**
  34463. * Chromatic aberration post process which will shift rgb colors in the image
  34464. */
  34465. chromaticAberration: ChromaticAberrationPostProcess;
  34466. private _chromaticAberrationEffect;
  34467. /**
  34468. * Grain post process which add noise to the image
  34469. */
  34470. grain: GrainPostProcess;
  34471. private _grainEffect;
  34472. /**
  34473. * Animations which can be used to tweak settings over a period of time
  34474. */
  34475. animations: Animation[];
  34476. private _imageProcessingConfigurationObserver;
  34477. private _sharpenEnabled;
  34478. private _bloomEnabled;
  34479. private _depthOfFieldEnabled;
  34480. private _depthOfFieldBlurLevel;
  34481. private _fxaaEnabled;
  34482. private _imageProcessingEnabled;
  34483. private _defaultPipelineTextureType;
  34484. private _bloomScale;
  34485. private _chromaticAberrationEnabled;
  34486. private _grainEnabled;
  34487. private _buildAllowed;
  34488. /**
  34489. * Enable or disable the sharpen process from the pipeline
  34490. */
  34491. sharpenEnabled: boolean;
  34492. private _resizeObserver;
  34493. private _hardwareScaleLevel;
  34494. private _bloomKernel;
  34495. /**
  34496. * Specifies the size of the bloom blur kernel, relative to the final output size
  34497. */
  34498. bloomKernel: number;
  34499. /**
  34500. * Specifies the weight of the bloom in the final rendering
  34501. */
  34502. private _bloomWeight;
  34503. /**
  34504. * Specifies the luma threshold for the area that will be blurred by the bloom
  34505. */
  34506. private _bloomThreshold;
  34507. private _hdr;
  34508. /**
  34509. * The strength of the bloom.
  34510. */
  34511. bloomWeight: number;
  34512. /**
  34513. * The strength of the bloom.
  34514. */
  34515. bloomThreshold: number;
  34516. /**
  34517. * The scale of the bloom, lower value will provide better performance.
  34518. */
  34519. bloomScale: number;
  34520. /**
  34521. * Enable or disable the bloom from the pipeline
  34522. */
  34523. bloomEnabled: boolean;
  34524. private _rebuildBloom();
  34525. /**
  34526. * If the depth of field is enabled.
  34527. */
  34528. depthOfFieldEnabled: boolean;
  34529. /**
  34530. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34531. */
  34532. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34533. /**
  34534. * If the anti aliasing is enabled.
  34535. */
  34536. fxaaEnabled: boolean;
  34537. private _samples;
  34538. /**
  34539. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34540. */
  34541. samples: number;
  34542. /**
  34543. * If image processing is enabled.
  34544. */
  34545. imageProcessingEnabled: boolean;
  34546. /**
  34547. * Enable or disable the chromaticAberration process from the pipeline
  34548. */
  34549. chromaticAberrationEnabled: boolean;
  34550. /**
  34551. * Enable or disable the grain process from the pipeline
  34552. */
  34553. grainEnabled: boolean;
  34554. /**
  34555. * @constructor
  34556. * @param {string} name - The rendering pipeline name
  34557. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34558. * @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)
  34559. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34560. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  34561. */
  34562. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34563. /**
  34564. * Force the compilation of the entire pipeline.
  34565. */
  34566. prepare(): void;
  34567. private _hasCleared;
  34568. private _prevPostProcess;
  34569. private _prevPrevPostProcess;
  34570. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34571. private _buildPipeline();
  34572. private _disposePostProcesses(disposeNonRecreated?);
  34573. /**
  34574. * Dispose of the pipeline and stop all post processes
  34575. */
  34576. dispose(): void;
  34577. /**
  34578. * Serialize the rendering pipeline (Used when exporting)
  34579. * @returns the serialized object
  34580. */
  34581. serialize(): any;
  34582. /**
  34583. * Parse the serialized pipeline
  34584. * @param source Source pipeline.
  34585. * @param scene The scene to load the pipeline to.
  34586. * @param rootUrl The URL of the serialized pipeline.
  34587. * @returns An instantiated pipeline from the serialized object.
  34588. */
  34589. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34590. }
  34591. }
  34592. declare module BABYLON {
  34593. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34594. /**
  34595. * The chromatic aberration PostProcess id in the pipeline
  34596. */
  34597. LensChromaticAberrationEffect: string;
  34598. /**
  34599. * The highlights enhancing PostProcess id in the pipeline
  34600. */
  34601. HighlightsEnhancingEffect: string;
  34602. /**
  34603. * The depth-of-field PostProcess id in the pipeline
  34604. */
  34605. LensDepthOfFieldEffect: string;
  34606. private _scene;
  34607. private _depthTexture;
  34608. private _grainTexture;
  34609. private _chromaticAberrationPostProcess;
  34610. private _highlightsPostProcess;
  34611. private _depthOfFieldPostProcess;
  34612. private _edgeBlur;
  34613. private _grainAmount;
  34614. private _chromaticAberration;
  34615. private _distortion;
  34616. private _highlightsGain;
  34617. private _highlightsThreshold;
  34618. private _dofDistance;
  34619. private _dofAperture;
  34620. private _dofDarken;
  34621. private _dofPentagon;
  34622. private _blurNoise;
  34623. /**
  34624. * @constructor
  34625. *
  34626. * Effect parameters are as follow:
  34627. * {
  34628. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34629. * edge_blur: number; // from 0 to x (1 for realism)
  34630. * distortion: number; // from 0 to x (1 for realism)
  34631. * grain_amount: number; // from 0 to 1
  34632. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34633. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34634. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34635. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34636. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34637. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34638. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34639. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34640. * }
  34641. * Note: if an effect parameter is unset, effect is disabled
  34642. *
  34643. * @param {string} name - The rendering pipeline name
  34644. * @param {object} parameters - An object containing all parameters (see above)
  34645. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34646. * @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)
  34647. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34648. */
  34649. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  34650. setEdgeBlur(amount: number): void;
  34651. disableEdgeBlur(): void;
  34652. setGrainAmount(amount: number): void;
  34653. disableGrain(): void;
  34654. setChromaticAberration(amount: number): void;
  34655. disableChromaticAberration(): void;
  34656. setEdgeDistortion(amount: number): void;
  34657. disableEdgeDistortion(): void;
  34658. setFocusDistance(amount: number): void;
  34659. disableDepthOfField(): void;
  34660. setAperture(amount: number): void;
  34661. setDarkenOutOfFocus(amount: number): void;
  34662. enablePentagonBokeh(): void;
  34663. disablePentagonBokeh(): void;
  34664. enableNoiseBlur(): void;
  34665. disableNoiseBlur(): void;
  34666. setHighlightsGain(amount: number): void;
  34667. setHighlightsThreshold(amount: number): void;
  34668. disableHighlights(): void;
  34669. /**
  34670. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  34671. */
  34672. dispose(disableDepthRender?: boolean): void;
  34673. private _createChromaticAberrationPostProcess(ratio);
  34674. private _createHighlightsPostProcess(ratio);
  34675. private _createDepthOfFieldPostProcess(ratio);
  34676. private _createGrainTexture();
  34677. }
  34678. }
  34679. declare module BABYLON {
  34680. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  34681. /**
  34682. * The PassPostProcess id in the pipeline that contains the original scene color
  34683. */
  34684. SSAOOriginalSceneColorEffect: string;
  34685. /**
  34686. * The SSAO PostProcess id in the pipeline
  34687. */
  34688. SSAORenderEffect: string;
  34689. /**
  34690. * The horizontal blur PostProcess id in the pipeline
  34691. */
  34692. SSAOBlurHRenderEffect: string;
  34693. /**
  34694. * The vertical blur PostProcess id in the pipeline
  34695. */
  34696. SSAOBlurVRenderEffect: string;
  34697. /**
  34698. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34699. */
  34700. SSAOCombineRenderEffect: string;
  34701. /**
  34702. * The output strength of the SSAO post-process. Default value is 1.0.
  34703. */
  34704. totalStrength: number;
  34705. /**
  34706. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  34707. */
  34708. maxZ: number;
  34709. /**
  34710. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  34711. */
  34712. minZAspect: number;
  34713. /**
  34714. * Number of samples used for the SSAO calculations. Default value is 8
  34715. */
  34716. private _samples;
  34717. /**
  34718. * Ratio object used for SSAO ratio and blur ratio
  34719. */
  34720. private _ratio;
  34721. /**
  34722. * Dynamically generated sphere sampler.
  34723. */
  34724. private _sampleSphere;
  34725. /**
  34726. * Blur filter offsets
  34727. */
  34728. private _samplerOffsets;
  34729. samples: number;
  34730. /**
  34731. * Are we using bilateral blur ?
  34732. */
  34733. private _expensiveBlur;
  34734. expensiveBlur: boolean;
  34735. /**
  34736. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  34737. */
  34738. radius: number;
  34739. /**
  34740. * The base color of the SSAO post-process
  34741. * The final result is "base + ssao" between [0, 1]
  34742. */
  34743. base: number;
  34744. /**
  34745. * Support test.
  34746. */
  34747. static readonly IsSupported: boolean;
  34748. private _scene;
  34749. private _depthTexture;
  34750. private _normalTexture;
  34751. private _randomTexture;
  34752. private _originalColorPostProcess;
  34753. private _ssaoPostProcess;
  34754. private _blurHPostProcess;
  34755. private _blurVPostProcess;
  34756. private _ssaoCombinePostProcess;
  34757. private _firstUpdate;
  34758. /**
  34759. * @constructor
  34760. * @param {string} name - The rendering pipeline name
  34761. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34762. * @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 }
  34763. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34764. */
  34765. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34766. /**
  34767. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34768. */
  34769. dispose(disableGeometryBufferRenderer?: boolean): void;
  34770. private _createBlurPostProcess(ssaoRatio, blurRatio);
  34771. _rebuild(): void;
  34772. private _generateHemisphere();
  34773. private _createSSAOPostProcess(ratio);
  34774. private _createSSAOCombinePostProcess(ratio);
  34775. private _createRandomTexture();
  34776. /**
  34777. * Serialize the rendering pipeline (Used when exporting)
  34778. * @returns the serialized object
  34779. */
  34780. serialize(): any;
  34781. /**
  34782. * Parse the serialized pipeline
  34783. * @param source Source pipeline.
  34784. * @param scene The scene to load the pipeline to.
  34785. * @param rootUrl The URL of the serialized pipeline.
  34786. * @returns An instantiated pipeline from the serialized object.
  34787. */
  34788. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  34789. }
  34790. }
  34791. declare module BABYLON {
  34792. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  34793. /**
  34794. * The PassPostProcess id in the pipeline that contains the original scene color
  34795. */
  34796. SSAOOriginalSceneColorEffect: string;
  34797. /**
  34798. * The SSAO PostProcess id in the pipeline
  34799. */
  34800. SSAORenderEffect: string;
  34801. /**
  34802. * The horizontal blur PostProcess id in the pipeline
  34803. */
  34804. SSAOBlurHRenderEffect: string;
  34805. /**
  34806. * The vertical blur PostProcess id in the pipeline
  34807. */
  34808. SSAOBlurVRenderEffect: string;
  34809. /**
  34810. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34811. */
  34812. SSAOCombineRenderEffect: string;
  34813. /**
  34814. * The output strength of the SSAO post-process. Default value is 1.0.
  34815. */
  34816. totalStrength: number;
  34817. /**
  34818. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  34819. */
  34820. radius: number;
  34821. /**
  34822. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  34823. * Must not be equal to fallOff and superior to fallOff.
  34824. * Default value is 0.975
  34825. */
  34826. area: number;
  34827. /**
  34828. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  34829. * Must not be equal to area and inferior to area.
  34830. * Default value is 0.0
  34831. */
  34832. fallOff: number;
  34833. /**
  34834. * The base color of the SSAO post-process
  34835. * The final result is "base + ssao" between [0, 1]
  34836. */
  34837. base: number;
  34838. private _scene;
  34839. private _depthTexture;
  34840. private _randomTexture;
  34841. private _originalColorPostProcess;
  34842. private _ssaoPostProcess;
  34843. private _blurHPostProcess;
  34844. private _blurVPostProcess;
  34845. private _ssaoCombinePostProcess;
  34846. private _firstUpdate;
  34847. /**
  34848. * @constructor
  34849. * @param {string} name - The rendering pipeline name
  34850. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34851. * @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 }
  34852. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34853. */
  34854. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34855. /**
  34856. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34857. */
  34858. dispose(disableDepthRender?: boolean): void;
  34859. private _createBlurPostProcess(ratio);
  34860. _rebuild(): void;
  34861. private _createSSAOPostProcess(ratio);
  34862. private _createSSAOCombinePostProcess(ratio);
  34863. private _createRandomTexture();
  34864. }
  34865. }
  34866. declare module BABYLON {
  34867. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34868. /**
  34869. * Public members
  34870. */
  34871. originalPostProcess: Nullable<PostProcess>;
  34872. downSampleX4PostProcess: Nullable<PostProcess>;
  34873. brightPassPostProcess: Nullable<PostProcess>;
  34874. blurHPostProcesses: PostProcess[];
  34875. blurVPostProcesses: PostProcess[];
  34876. textureAdderPostProcess: Nullable<PostProcess>;
  34877. volumetricLightPostProcess: Nullable<PostProcess>;
  34878. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  34879. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  34880. volumetricLightMergePostProces: Nullable<PostProcess>;
  34881. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  34882. luminancePostProcess: Nullable<PostProcess>;
  34883. luminanceDownSamplePostProcesses: PostProcess[];
  34884. hdrPostProcess: Nullable<PostProcess>;
  34885. textureAdderFinalPostProcess: Nullable<PostProcess>;
  34886. lensFlareFinalPostProcess: Nullable<PostProcess>;
  34887. hdrFinalPostProcess: Nullable<PostProcess>;
  34888. lensFlarePostProcess: Nullable<PostProcess>;
  34889. lensFlareComposePostProcess: Nullable<PostProcess>;
  34890. motionBlurPostProcess: Nullable<PostProcess>;
  34891. depthOfFieldPostProcess: Nullable<PostProcess>;
  34892. brightThreshold: number;
  34893. blurWidth: number;
  34894. horizontalBlur: boolean;
  34895. exposure: number;
  34896. lensTexture: Nullable<Texture>;
  34897. volumetricLightCoefficient: number;
  34898. volumetricLightPower: number;
  34899. volumetricLightBlurScale: number;
  34900. sourceLight: Nullable<SpotLight | DirectionalLight>;
  34901. hdrMinimumLuminance: number;
  34902. hdrDecreaseRate: number;
  34903. hdrIncreaseRate: number;
  34904. lensColorTexture: Nullable<Texture>;
  34905. lensFlareStrength: number;
  34906. lensFlareGhostDispersal: number;
  34907. lensFlareHaloWidth: number;
  34908. lensFlareDistortionStrength: number;
  34909. lensStarTexture: Nullable<Texture>;
  34910. lensFlareDirtTexture: Nullable<Texture>;
  34911. depthOfFieldDistance: number;
  34912. depthOfFieldBlurWidth: number;
  34913. motionStrength: number;
  34914. animations: Animation[];
  34915. /**
  34916. * Private members
  34917. */
  34918. private _scene;
  34919. private _currentDepthOfFieldSource;
  34920. private _basePostProcess;
  34921. private _hdrCurrentLuminance;
  34922. private _floatTextureType;
  34923. private _ratio;
  34924. private _bloomEnabled;
  34925. private _depthOfFieldEnabled;
  34926. private _vlsEnabled;
  34927. private _lensFlareEnabled;
  34928. private _hdrEnabled;
  34929. private _motionBlurEnabled;
  34930. private _motionBlurSamples;
  34931. private _volumetricLightStepsCount;
  34932. BloomEnabled: boolean;
  34933. DepthOfFieldEnabled: boolean;
  34934. LensFlareEnabled: boolean;
  34935. HDREnabled: boolean;
  34936. VLSEnabled: boolean;
  34937. MotionBlurEnabled: boolean;
  34938. volumetricLightStepsCount: number;
  34939. motionBlurSamples: number;
  34940. /**
  34941. * @constructor
  34942. * @param {string} name - The rendering pipeline name
  34943. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34944. * @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)
  34945. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  34946. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34947. */
  34948. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  34949. private _buildPipeline();
  34950. private _createDownSampleX4PostProcess(scene, ratio);
  34951. private _createBrightPassPostProcess(scene, ratio);
  34952. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  34953. private _createTextureAdderPostProcess(scene, ratio);
  34954. private _createVolumetricLightPostProcess(scene, ratio);
  34955. private _createLuminancePostProcesses(scene, textureType);
  34956. private _createHdrPostProcess(scene, ratio);
  34957. private _createLensFlarePostProcess(scene, ratio);
  34958. private _createDepthOfFieldPostProcess(scene, ratio);
  34959. private _createMotionBlurPostProcess(scene, ratio);
  34960. private _getDepthTexture();
  34961. private _disposePostProcesses();
  34962. /**
  34963. * Dispose of the pipeline and stop all post processes
  34964. */
  34965. dispose(): void;
  34966. /**
  34967. * Serialize the rendering pipeline (Used when exporting)
  34968. * @returns the serialized object
  34969. */
  34970. serialize(): any;
  34971. /**
  34972. * Parse the serialized pipeline
  34973. * @param source Source pipeline.
  34974. * @param scene The scene to load the pipeline to.
  34975. * @param rootUrl The URL of the serialized pipeline.
  34976. * @returns An instantiated pipeline from the serialized object.
  34977. */
  34978. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  34979. static LuminanceSteps: number;
  34980. }
  34981. }