babylon.d.ts 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410
  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. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  183. * @returns the root mesh
  184. */
  185. createRootMesh(): Mesh;
  186. }
  187. }
  188. interface Window {
  189. mozIndexedDB: IDBFactory;
  190. webkitIndexedDB: IDBFactory;
  191. msIndexedDB: IDBFactory;
  192. webkitURL: typeof URL;
  193. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  194. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  195. WebGLRenderingContext: WebGLRenderingContext;
  196. MSGesture: MSGesture;
  197. CANNON: any;
  198. AudioContext: AudioContext;
  199. webkitAudioContext: AudioContext;
  200. PointerEvent: any;
  201. Math: Math;
  202. Uint8Array: Uint8ArrayConstructor;
  203. Float32Array: Float32ArrayConstructor;
  204. mozURL: typeof URL;
  205. msURL: typeof URL;
  206. VRFrameData: any;
  207. DracoDecoderModule: any;
  208. }
  209. interface WebGLRenderingContext {
  210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  212. vertexAttribDivisor(index: number, divisor: number): void;
  213. createVertexArray(): any;
  214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  221. createQuery(): WebGLQuery;
  222. deleteQuery(query: WebGLQuery): void;
  223. beginQuery(target: number, query: WebGLQuery): void;
  224. endQuery(target: number): void;
  225. getQueryParameter(query: WebGLQuery, pname: number): any;
  226. getQuery(target: number, pname: number): any;
  227. MAX_SAMPLES: number;
  228. RGBA8: number;
  229. READ_FRAMEBUFFER: number;
  230. DRAW_FRAMEBUFFER: number;
  231. UNIFORM_BUFFER: number;
  232. HALF_FLOAT_OES: number;
  233. RGBA16F: number;
  234. RGBA32F: number;
  235. R32F: number;
  236. RG32F: number;
  237. RGB32F: number;
  238. R16F: number;
  239. RG16F: number;
  240. RGB16F: number;
  241. RED: number;
  242. RG: number;
  243. R8: number;
  244. RG8: number;
  245. UNSIGNED_INT_24_8: number;
  246. DEPTH24_STENCIL8: number;
  247. drawBuffers(buffers: number[]): void;
  248. readBuffer(src: number): void;
  249. readonly COLOR_ATTACHMENT0: number;
  250. readonly COLOR_ATTACHMENT1: number;
  251. readonly COLOR_ATTACHMENT2: number;
  252. readonly COLOR_ATTACHMENT3: number;
  253. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  254. ANY_SAMPLES_PASSED: number;
  255. QUERY_RESULT_AVAILABLE: number;
  256. QUERY_RESULT: number;
  257. }
  258. interface Document {
  259. mozCancelFullScreen(): void;
  260. msCancelFullScreen(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. fullscreen: boolean;
  264. mozPointerLockElement: HTMLElement;
  265. msPointerLockElement: HTMLElement;
  266. webkitPointerLockElement: HTMLElement;
  267. }
  268. interface HTMLCanvasElement {
  269. msRequestPointerLock?(): void;
  270. mozRequestPointerLock?(): void;
  271. webkitRequestPointerLock?(): void;
  272. }
  273. interface CanvasRenderingContext2D {
  274. msImageSmoothingEnabled: boolean;
  275. }
  276. interface WebGLBuffer {
  277. references: number;
  278. capacity: number;
  279. is32Bits: boolean;
  280. }
  281. interface WebGLProgram {
  282. transformFeedback?: WebGLTransformFeedback | null;
  283. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  284. }
  285. interface MouseEvent {
  286. mozMovementX: number;
  287. mozMovementY: number;
  288. webkitMovementX: number;
  289. webkitMovementY: number;
  290. msMovementX: number;
  291. msMovementY: number;
  292. }
  293. interface Navigator {
  294. mozGetVRDevices: (any: any) => any;
  295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. webkitGetGamepads(): Gamepad[];
  299. msGetGamepads(): Gamepad[];
  300. webkitGamepads(): Gamepad[];
  301. }
  302. interface HTMLVideoElement {
  303. mozSrcObject: any;
  304. }
  305. interface Screen {
  306. orientation: string;
  307. mozOrientation: string;
  308. }
  309. interface Math {
  310. fround(x: number): number;
  311. imul(a: number, b: number): number;
  312. }
  313. interface EXT_disjoint_timer_query {
  314. QUERY_COUNTER_BITS_EXT: number;
  315. TIME_ELAPSED_EXT: number;
  316. TIMESTAMP_EXT: number;
  317. GPU_DISJOINT_EXT: number;
  318. QUERY_RESULT_EXT: number;
  319. QUERY_RESULT_AVAILABLE_EXT: number;
  320. queryCounterEXT(query: WebGLQuery, target: number): void;
  321. createQueryEXT(): WebGLQuery;
  322. beginQueryEXT(target: number, query: WebGLQuery): void;
  323. endQueryEXT(target: number): void;
  324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  325. deleteQueryEXT(query: WebGLQuery): void;
  326. }
  327. interface WebGLUniformLocation {
  328. _currentState: any;
  329. }
  330. declare module BABYLON {
  331. /**
  332. * Node is the basic class for all scene objects (Mesh, Light Camera).
  333. */
  334. class Node implements IBehaviorAware<Node> {
  335. /**
  336. * Gets or sets the name of the node
  337. */
  338. name: string;
  339. /**
  340. * Gets or sets the id of the node
  341. */
  342. id: string;
  343. /**
  344. * Gets or sets the unique id of the node
  345. */
  346. uniqueId: number;
  347. /**
  348. * Gets or sets a string used to store user defined state for the node
  349. */
  350. state: string;
  351. /**
  352. * Gets or sets an object used to store user defined information for the node
  353. */
  354. metadata: any;
  355. /**
  356. * Gets or sets a boolean used to define if the node must be serialized
  357. */
  358. doNotSerialize: boolean;
  359. /** @hidden */
  360. _isDisposed: boolean;
  361. /**
  362. * Gets a list of Animations associated with the node
  363. */
  364. animations: Animation[];
  365. private _ranges;
  366. /**
  367. * Callback raised when the node is ready to be used
  368. */
  369. onReady: (node: Node) => void;
  370. private _isEnabled;
  371. private _isReady;
  372. /** @hidden */
  373. _currentRenderId: number;
  374. private _parentRenderId;
  375. protected _childRenderId: number;
  376. /** @hidden */
  377. _waitingParentId: Nullable<string>;
  378. private _scene;
  379. /** @hidden */
  380. _cache: any;
  381. private _parentNode;
  382. private _children;
  383. /**
  384. * Gets a boolean indicating if the node has been disposed
  385. * @returns true if the node was disposed
  386. */
  387. isDisposed(): boolean;
  388. /**
  389. * Gets or sets the parent of the node
  390. */
  391. parent: Nullable<Node>;
  392. private _animationPropertiesOverride;
  393. /**
  394. * Gets or sets the animation properties override
  395. */
  396. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  397. /**
  398. * Gets a string idenfifying the name of the class
  399. * @returns "Node" string
  400. */
  401. getClassName(): string;
  402. /**
  403. * An event triggered when the mesh is disposed
  404. */
  405. onDisposeObservable: Observable<Node>;
  406. private _onDisposeObserver;
  407. /**
  408. * Sets a callback that will be raised when the node will be disposed
  409. */
  410. onDispose: () => void;
  411. /**
  412. * Creates a new Node
  413. * @param {string} name - the name and id to be given to this node
  414. * @param {BABYLON.Scene} the scene this node will be added to
  415. */
  416. constructor(name: string, scene?: Nullable<Scene>);
  417. /**
  418. * Gets the scene of the node
  419. * @returns a {BABYLON.Scene}
  420. */
  421. getScene(): Scene;
  422. /**
  423. * Gets the engine of the node
  424. * @returns a {BABYLON.Engine}
  425. */
  426. getEngine(): Engine;
  427. private _behaviors;
  428. /**
  429. * Attach a behavior to the node
  430. * @see http://doc.babylonjs.com/features/behaviour
  431. * @param behavior defines the behavior to attach
  432. * @returns the current Node
  433. */
  434. addBehavior(behavior: Behavior<Node>): Node;
  435. /**
  436. * Remove an attached behavior
  437. * @see http://doc.babylonjs.com/features/behaviour
  438. * @param behavior defines the behavior to attach
  439. * @returns the current Node
  440. */
  441. removeBehavior(behavior: Behavior<Node>): Node;
  442. /**
  443. * Gets the list of attached behaviors
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. */
  446. readonly behaviors: Behavior<Node>[];
  447. /**
  448. * Gets an attached behavior by name
  449. * @param name defines the name of the behavior to look for
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. * @returns null if behavior was not found else the requested behavior
  452. */
  453. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  454. /**
  455. * Returns the world matrix of the node
  456. * @returns a matrix containing the node's world matrix
  457. */
  458. getWorldMatrix(): Matrix;
  459. /** @hidden */
  460. _getWorldMatrixDeterminant(): number;
  461. /** @hidden */
  462. _initCache(): void;
  463. /** @hidden */
  464. updateCache(force?: boolean): void;
  465. /** @hidden */
  466. _updateCache(ignoreParentClass?: boolean): void;
  467. /** @hidden */
  468. _isSynchronized(): boolean;
  469. /** @hidden */
  470. _markSyncedWithParent(): void;
  471. /** @hidden */
  472. isSynchronizedWithParent(): boolean;
  473. /** @hidden */
  474. isSynchronized(updateCache?: boolean): boolean;
  475. /** @hidden */
  476. hasNewParent(update?: boolean): boolean;
  477. /**
  478. * Is this node ready to be used/rendered
  479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  480. * @return true if the node is ready
  481. */
  482. isReady(completeCheck?: boolean): boolean;
  483. /**
  484. * Is this node enabled?
  485. * 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
  486. * @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
  487. * @return whether this node (and its parent) is enabled
  488. */
  489. isEnabled(checkAncestors?: boolean): boolean;
  490. /**
  491. * Set the enabled state of this node
  492. * @param value defines the new enabled state
  493. */
  494. setEnabled(value: boolean): void;
  495. /**
  496. * Is this node a descendant of the given node?
  497. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  498. * @param ancestor defines the parent node to inspect
  499. * @returns a boolean indicating if this node is a descendant of the given node
  500. */
  501. isDescendantOf(ancestor: Node): boolean;
  502. /** @hidden */
  503. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  504. /**
  505. * Will return all nodes that have this node as ascendant
  506. * @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
  507. * @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
  508. * @return all children nodes of all types
  509. */
  510. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  511. /**
  512. * Get all child-meshes of this node
  513. * @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
  514. * @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
  515. * @returns an array of {BABYLON.AbstractMesh}
  516. */
  517. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  518. /**
  519. * Get all child-transformNodes of this node
  520. * @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
  521. * @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
  522. * @returns an array of {BABYLON.TransformNode}
  523. */
  524. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  525. /**
  526. * Get all direct children of this node
  527. * @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
  528. * @returns an array of {BABYLON.Node}
  529. */
  530. getChildren(predicate?: (node: Node) => boolean): Node[];
  531. /** @hidden */
  532. _setReady(state: boolean): void;
  533. /**
  534. * Get an animation by name
  535. * @param name defines the name of the animation to look for
  536. * @returns null if not found else the requested animation
  537. */
  538. getAnimationByName(name: string): Nullable<Animation>;
  539. /**
  540. * Creates an animation range for this node
  541. * @param name defines the name of the range
  542. * @param from defines the starting key
  543. * @param to defines the end key
  544. */
  545. createAnimationRange(name: string, from: number, to: number): void;
  546. /**
  547. * Delete a specific animation range
  548. * @param name defines the name of the range to delete
  549. * @param deleteFrames defines if animation frames from the range must be deleted as well
  550. */
  551. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  552. /**
  553. * Get an animation range by name
  554. * @param name defines the name of the animation range to look for
  555. * @returns null if not found else the requested animation range
  556. */
  557. getAnimationRange(name: string): Nullable<AnimationRange>;
  558. /**
  559. * Will start the animation sequence
  560. * @param name defines the range frames for animation sequence
  561. * @param loop defines if the animation should loop (false by default)
  562. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  563. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  564. * @returns the object created for this animation. If range does not exist, it will return null
  565. */
  566. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  567. /**
  568. * Serialize animation ranges into a JSON compatible object
  569. * @returns serialization object
  570. */
  571. serializeAnimationRanges(): any;
  572. /**
  573. * Computes the world matrix of the node
  574. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  575. * @returns the world matrix
  576. */
  577. computeWorldMatrix(force?: boolean): Matrix;
  578. /**
  579. * Releases resources associated with this node.
  580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  582. */
  583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  584. /**
  585. * Parse animation range data from a serialization object and store them into a given node
  586. * @param node defines where to store the animation ranges
  587. * @param parsedNode defines the serialization object to read data from
  588. * @param scene defines the hosting scene
  589. */
  590. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  591. }
  592. }
  593. declare module BABYLON {
  594. /**
  595. * Define an interface for all classes that will hold resources
  596. */
  597. interface IDisposable {
  598. /**
  599. * Releases all held resources
  600. */
  601. dispose(): void;
  602. }
  603. /**
  604. * Interface used to let developers provide their own mesh selection mechanism
  605. */
  606. interface IActiveMeshCandidateProvider {
  607. /**
  608. * Return the list of active meshes
  609. * @param scene defines the current scene
  610. * @returns the list of active meshes
  611. */
  612. getMeshes(scene: Scene): AbstractMesh[];
  613. /**
  614. * Indicates if the meshes have been checked to make sure they are isEnabled()
  615. */
  616. readonly checksIsEnabled: boolean;
  617. }
  618. /**
  619. * This class is used by the onRenderingGroupObservable
  620. */
  621. class RenderingGroupInfo {
  622. /**
  623. * The Scene that being rendered
  624. */
  625. scene: Scene;
  626. /**
  627. * The camera currently used for the rendering pass
  628. */
  629. camera: Nullable<Camera>;
  630. /**
  631. * The ID of the renderingGroup being processed
  632. */
  633. renderingGroupId: number;
  634. /**
  635. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  636. */
  637. renderStage: number;
  638. /**
  639. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  640. * This stage will be fired no matter what
  641. */
  642. static STAGE_PRECLEAR: number;
  643. /**
  644. * Called before opaque object are rendered.
  645. * This stage will be fired only if there's 3D Opaque content to render
  646. */
  647. static STAGE_PREOPAQUE: number;
  648. /**
  649. * Called after the opaque objects are rendered and before the transparent ones
  650. * This stage will be fired only if there's 3D transparent content to render
  651. */
  652. static STAGE_PRETRANSPARENT: number;
  653. /**
  654. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  655. * This stage will be fired no matter what
  656. */
  657. static STAGE_POSTTRANSPARENT: number;
  658. }
  659. /**
  660. * Represents a scene to be rendered by the engine.
  661. * @see http://doc.babylonjs.com/features/scene
  662. */
  663. class Scene implements IAnimatable {
  664. private static _FOGMODE_NONE;
  665. private static _FOGMODE_EXP;
  666. private static _FOGMODE_EXP2;
  667. private static _FOGMODE_LINEAR;
  668. private static _uniqueIdCounter;
  669. /**
  670. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MinDeltaTime: number;
  674. /**
  675. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  677. */
  678. static MaxDeltaTime: number;
  679. /** The fog is deactivated */
  680. static readonly FOGMODE_NONE: number;
  681. /** The fog density is following an exponential function */
  682. static readonly FOGMODE_EXP: number;
  683. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  684. static readonly FOGMODE_EXP2: number;
  685. /** The fog density is following a linear function. */
  686. static readonly FOGMODE_LINEAR: number;
  687. /**
  688. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  689. */
  690. autoClear: boolean;
  691. /**
  692. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  693. */
  694. autoClearDepthAndStencil: boolean;
  695. /**
  696. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  697. */
  698. clearColor: Color4;
  699. /**
  700. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  701. */
  702. ambientColor: Color3;
  703. /** @hidden */
  704. _environmentBRDFTexture: BaseTexture;
  705. /** @hidden */
  706. protected _environmentTexture: BaseTexture;
  707. /**
  708. * Texture used in all pbr material as the reflection texture.
  709. * As in the majority of the scene they are the same (exception for multi room and so on),
  710. * this is easier to reference from here than from all the materials.
  711. */
  712. /**
  713. * Texture used in all pbr material as the reflection texture.
  714. * As in the majority of the scene they are the same (exception for multi room and so on),
  715. * this is easier to set here than in all the materials.
  716. */
  717. environmentTexture: BaseTexture;
  718. /** @hidden */
  719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  720. /**
  721. * Default image processing configuration used either in the rendering
  722. * Forward main pass or through the imageProcessingPostProcess if present.
  723. * As in the majority of the scene they are the same (exception for multi camera),
  724. * this is easier to reference from here than from all the materials and post process.
  725. *
  726. * No setter as we it is a shared configuration, you can set the values instead.
  727. */
  728. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  729. private _forceWireframe;
  730. /**
  731. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  732. */
  733. forceWireframe: boolean;
  734. private _forcePointsCloud;
  735. /**
  736. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  737. */
  738. forcePointsCloud: boolean;
  739. /**
  740. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  741. */
  742. forceShowBoundingBoxes: boolean;
  743. /**
  744. * Gets or sets the active clipplane
  745. */
  746. clipPlane: Nullable<Plane>;
  747. /**
  748. * Gets or sets a boolean indicating if animations are enabled
  749. */
  750. animationsEnabled: boolean;
  751. private _animationPropertiesOverride;
  752. /**
  753. * Gets or sets the animation properties override
  754. */
  755. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  756. /**
  757. * Gets or sets a boolean indicating if a constant deltatime has to be used
  758. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  759. */
  760. useConstantAnimationDeltaTime: boolean;
  761. /**
  762. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  763. * Please note that it requires to run a ray cast through the scene on every frame
  764. */
  765. constantlyUpdateMeshUnderPointer: boolean;
  766. /**
  767. * Defines the HTML cursor to use when hovering over interactive elements
  768. */
  769. hoverCursor: string;
  770. /**
  771. * Defines the HTML default cursor to use (empty by default)
  772. */
  773. defaultCursor: string;
  774. /**
  775. * This is used to call preventDefault() on pointer down
  776. * in order to block unwanted artifacts like system double clicks
  777. */
  778. preventDefaultOnPointerDown: boolean;
  779. /**
  780. * Gets or sets user defined metadata
  781. */
  782. metadata: any;
  783. /**
  784. * Gets the name of the plugin used to load this scene (null by default)
  785. */
  786. loadingPluginName: string;
  787. /**
  788. * Use this array to add regular expressions used to disable offline support for specific urls
  789. */
  790. disableOfflineSupportExceptionRules: RegExp[];
  791. private _spritePredicate;
  792. /**
  793. * An event triggered when the scene is disposed.
  794. */
  795. onDisposeObservable: Observable<Scene>;
  796. private _onDisposeObserver;
  797. /** Sets a function to be executed when this scene is disposed. */
  798. onDispose: () => void;
  799. /**
  800. * An event triggered before rendering the scene (right after animations and physics)
  801. */
  802. onBeforeRenderObservable: Observable<Scene>;
  803. private _onBeforeRenderObserver;
  804. /** Sets a function to be executed before rendering this scene */
  805. beforeRender: Nullable<() => void>;
  806. /**
  807. * An event triggered after rendering the scene
  808. */
  809. onAfterRenderObservable: Observable<Scene>;
  810. private _onAfterRenderObserver;
  811. /** Sets a function to be executed after rendering this scene */
  812. afterRender: Nullable<() => void>;
  813. /**
  814. * An event triggered before animating the scene
  815. */
  816. onBeforeAnimationsObservable: Observable<Scene>;
  817. /**
  818. * An event triggered after animations processing
  819. */
  820. onAfterAnimationsObservable: Observable<Scene>;
  821. /**
  822. * An event triggered before draw calls are ready to be sent
  823. */
  824. onBeforeDrawPhaseObservable: Observable<Scene>;
  825. /**
  826. * An event triggered after draw calls have been sent
  827. */
  828. onAfterDrawPhaseObservable: Observable<Scene>;
  829. /**
  830. * An event triggered when physic simulation is about to be run
  831. */
  832. onBeforePhysicsObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when physic simulation has been done
  835. */
  836. onAfterPhysicsObservable: Observable<Scene>;
  837. /**
  838. * An event triggered when the scene is ready
  839. */
  840. onReadyObservable: Observable<Scene>;
  841. /**
  842. * An event triggered before rendering a camera
  843. */
  844. onBeforeCameraRenderObservable: Observable<Camera>;
  845. private _onBeforeCameraRenderObserver;
  846. /** Sets a function to be executed before rendering a camera*/
  847. beforeCameraRender: () => void;
  848. /**
  849. * An event triggered after rendering a camera
  850. */
  851. onAfterCameraRenderObservable: Observable<Camera>;
  852. private _onAfterCameraRenderObserver;
  853. /** Sets a function to be executed after rendering a camera*/
  854. afterCameraRender: () => void;
  855. /**
  856. * An event triggered when active meshes evaluation is about to start
  857. */
  858. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when active meshes evaluation is done
  861. */
  862. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when particles rendering is about to start
  865. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  866. */
  867. onBeforeParticlesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when particles rendering is done
  870. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  871. */
  872. onAfterParticlesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when sprites rendering is about to start
  875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  876. */
  877. onBeforeSpritesRenderingObservable: Observable<Scene>;
  878. /**
  879. * An event triggered when sprites rendering is done
  880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  881. */
  882. onAfterSpritesRenderingObservable: Observable<Scene>;
  883. /**
  884. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  885. */
  886. onDataLoadedObservable: Observable<Scene>;
  887. /**
  888. * An event triggered when a camera is created
  889. */
  890. onNewCameraAddedObservable: Observable<Camera>;
  891. /**
  892. * An event triggered when a camera is removed
  893. */
  894. onCameraRemovedObservable: Observable<Camera>;
  895. /**
  896. * An event triggered when a light is created
  897. */
  898. onNewLightAddedObservable: Observable<Light>;
  899. /**
  900. * An event triggered when a light is removed
  901. */
  902. onLightRemovedObservable: Observable<Light>;
  903. /**
  904. * An event triggered when a geometry is created
  905. */
  906. onNewGeometryAddedObservable: Observable<Geometry>;
  907. /**
  908. * An event triggered when a geometry is removed
  909. */
  910. onGeometryRemovedObservable: Observable<Geometry>;
  911. /**
  912. * An event triggered when a transform node is created
  913. */
  914. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  915. /**
  916. * An event triggered when a transform node is removed
  917. */
  918. onTransformNodeRemovedObservable: Observable<TransformNode>;
  919. /**
  920. * An event triggered when a mesh is created
  921. */
  922. onNewMeshAddedObservable: Observable<AbstractMesh>;
  923. /**
  924. * An event triggered when a mesh is removed
  925. */
  926. onMeshRemovedObservable: Observable<AbstractMesh>;
  927. /**
  928. * An event triggered when render targets are about to be rendered
  929. * Can happen multiple times per frame.
  930. */
  931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  932. /**
  933. * An event triggered when render targets were rendered.
  934. * Can happen multiple times per frame.
  935. */
  936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  937. /**
  938. * An event triggered before calculating deterministic simulation step
  939. */
  940. onBeforeStepObservable: Observable<Scene>;
  941. /**
  942. * An event triggered after calculating deterministic simulation step
  943. */
  944. onAfterStepObservable: Observable<Scene>;
  945. /**
  946. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  948. * 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)
  949. */
  950. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  951. /**
  952. * Gets a list of Animations associated with the scene
  953. */
  954. animations: Animation[];
  955. private _registeredForLateAnimationBindings;
  956. /**
  957. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  958. */
  959. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  960. /**
  961. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  962. */
  963. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  964. /**
  965. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  966. */
  967. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  968. private _onPointerMove;
  969. private _onPointerDown;
  970. private _onPointerUp;
  971. /** Deprecated. Use onPointerObservable instead */
  972. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  973. /** Deprecated. Use onPointerObservable instead */
  974. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  975. /** Deprecated. Use onPointerObservable instead */
  976. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  977. /** Deprecated. Use onPointerObservable instead */
  978. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  979. private _gamepadManager;
  980. /**
  981. * Gets the gamepad manager associated with the scene
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  983. */
  984. readonly gamepadManager: GamepadManager;
  985. /**
  986. * 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).
  987. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  988. */
  989. onPrePointerObservable: Observable<PointerInfoPre>;
  990. /**
  991. * Observable event triggered each time an input event is received from the rendering canvas
  992. */
  993. onPointerObservable: Observable<PointerInfo>;
  994. /**
  995. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  996. */
  997. readonly unTranslatedPointer: Vector2;
  998. /** The distance in pixel that you have to move to prevent some events */
  999. static DragMovementThreshold: number;
  1000. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1001. static LongPressDelay: number;
  1002. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1003. static DoubleClickDelay: number;
  1004. /** If you need to check double click without raising a single click at first click, enable this flag */
  1005. static ExclusiveDoubleClickMode: boolean;
  1006. private _initClickEvent;
  1007. private _initActionManager;
  1008. private _delayedSimpleClick;
  1009. private _delayedSimpleClickTimeout;
  1010. private _previousDelayedSimpleClickTimeout;
  1011. private _meshPickProceed;
  1012. private _previousButtonPressed;
  1013. private _currentPickResult;
  1014. private _previousPickResult;
  1015. private _totalPointersPressed;
  1016. private _doubleClickOccured;
  1017. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1018. cameraToUseForPointers: Nullable<Camera>;
  1019. private _pointerX;
  1020. private _pointerY;
  1021. private _unTranslatedPointerX;
  1022. private _unTranslatedPointerY;
  1023. private _startingPointerPosition;
  1024. private _previousStartingPointerPosition;
  1025. private _startingPointerTime;
  1026. private _previousStartingPointerTime;
  1027. private _pointerCaptures;
  1028. private _timeAccumulator;
  1029. private _currentStepId;
  1030. private _currentInternalStep;
  1031. /** @hidden */
  1032. _mirroredCameraPosition: Nullable<Vector3>;
  1033. /**
  1034. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1035. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1036. */
  1037. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1038. /**
  1039. * Observable event triggered each time an keyboard event is received from the hosting window
  1040. */
  1041. onKeyboardObservable: Observable<KeyboardInfo>;
  1042. private _onKeyDown;
  1043. private _onKeyUp;
  1044. private _onCanvasFocusObserver;
  1045. private _onCanvasBlurObserver;
  1046. private _useRightHandedSystem;
  1047. /**
  1048. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1049. */
  1050. useRightHandedSystem: boolean;
  1051. /**
  1052. * Sets the step Id used by deterministic lock step
  1053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1054. * @param newStepId defines the step Id
  1055. */
  1056. setStepId(newStepId: number): void;
  1057. /**
  1058. * Gets the step Id used by deterministic lock step
  1059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1060. * @returns the step Id
  1061. */
  1062. getStepId(): number;
  1063. /**
  1064. * Gets the internal step used by deterministic lock step
  1065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1066. * @returns the internal step
  1067. */
  1068. getInternalStep(): number;
  1069. private _fogEnabled;
  1070. /**
  1071. * Gets or sets a boolean indicating if fog is enabled on this scene
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogEnabled: boolean;
  1075. private _fogMode;
  1076. /**
  1077. * Gets or sets the fog mode to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogMode: number;
  1081. /**
  1082. * Gets or sets the fog color to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogColor: Color3;
  1086. /**
  1087. * Gets or sets the fog density to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogDensity: number;
  1091. /**
  1092. * Gets or sets the fog start distance to use
  1093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1094. */
  1095. fogStart: number;
  1096. /**
  1097. * Gets or sets the fog end distance to use
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. */
  1100. fogEnd: number;
  1101. private _shadowsEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1104. */
  1105. shadowsEnabled: boolean;
  1106. private _lightsEnabled;
  1107. /**
  1108. * Gets or sets a boolean indicating if lights are enabled on this scene
  1109. */
  1110. lightsEnabled: boolean;
  1111. /**
  1112. * All of the lights added to this scene
  1113. * @see http://doc.babylonjs.com/babylon101/lights
  1114. */
  1115. lights: Light[];
  1116. /** All of the cameras added to this scene.
  1117. * @see http://doc.babylonjs.com/babylon101/cameras
  1118. */
  1119. cameras: Camera[];
  1120. /** All of the active cameras added to this scene. */
  1121. activeCameras: Camera[];
  1122. /** The current active camera */
  1123. activeCamera: Nullable<Camera>;
  1124. /**
  1125. * All of the tranform nodes added to this scene
  1126. * @see http://doc.babylonjs.com/how_to/transformnode
  1127. */
  1128. transformNodes: TransformNode[];
  1129. /**
  1130. * All of the (abstract) meshes added to this scene
  1131. */
  1132. meshes: AbstractMesh[];
  1133. /**
  1134. * All of the animation groups added to this scene
  1135. * @see http://doc.babylonjs.com/how_to/group
  1136. */
  1137. animationGroups: AnimationGroup[];
  1138. private _geometries;
  1139. /**
  1140. * All of the materials added to this scene
  1141. * @see http://doc.babylonjs.com/babylon101/materials
  1142. */
  1143. materials: Material[];
  1144. /**
  1145. * All of the multi-materials added to this scene
  1146. * @see http://doc.babylonjs.com/how_to/multi_materials
  1147. */
  1148. multiMaterials: MultiMaterial[];
  1149. private _defaultMaterial;
  1150. /** The default material used on meshes when no material is affected */
  1151. /** The default material used on meshes when no material is affected */
  1152. defaultMaterial: Material;
  1153. private _texturesEnabled;
  1154. /**
  1155. * Gets or sets a boolean indicating if textures are enabled on this scene
  1156. */
  1157. texturesEnabled: boolean;
  1158. /**
  1159. * All of the textures added to this scene
  1160. */
  1161. textures: BaseTexture[];
  1162. /**
  1163. * Gets or sets a boolean indicating if particles are enabled on this scene
  1164. */
  1165. particlesEnabled: boolean;
  1166. /**
  1167. * All of the particle systems added to this scene
  1168. * @see http://doc.babylonjs.com/babylon101/particles
  1169. */
  1170. particleSystems: IParticleSystem[];
  1171. /**
  1172. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1173. */
  1174. spritesEnabled: boolean;
  1175. /**
  1176. * All of the sprite managers added to this scene
  1177. * @see http://doc.babylonjs.com/babylon101/sprites
  1178. */
  1179. spriteManagers: SpriteManager[];
  1180. /**
  1181. * The list of layers (background and foreground) of the scene
  1182. */
  1183. layers: Layer[];
  1184. /**
  1185. * The list of effect layers (highlights/glow) added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1187. * @see http://doc.babylonjs.com/how_to/glow_layer
  1188. */
  1189. effectLayers: EffectLayer[];
  1190. private _skeletonsEnabled;
  1191. /**
  1192. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1193. */
  1194. skeletonsEnabled: boolean;
  1195. /**
  1196. * The list of skeletons added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1198. */
  1199. skeletons: Skeleton[];
  1200. /**
  1201. * The list of morph target managers added to the scene
  1202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1203. */
  1204. morphTargetManagers: MorphTargetManager[];
  1205. /**
  1206. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1207. */
  1208. lensFlaresEnabled: boolean;
  1209. /**
  1210. * The list of lens flare system added to the scene
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1212. */
  1213. lensFlareSystems: LensFlareSystem[];
  1214. /**
  1215. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1217. */
  1218. collisionsEnabled: boolean;
  1219. private _workerCollisions;
  1220. /** @hidden */
  1221. collisionCoordinator: ICollisionCoordinator;
  1222. /**
  1223. * Defines the gravity applied to this scene (used only for collisions)
  1224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1225. */
  1226. gravity: Vector3;
  1227. /**
  1228. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1229. */
  1230. postProcessesEnabled: boolean;
  1231. /**
  1232. * The list of postprocesses added to the scene
  1233. */
  1234. postProcesses: PostProcess[];
  1235. /**
  1236. * Gets the current postprocess manager
  1237. */
  1238. postProcessManager: PostProcessManager;
  1239. private _postProcessRenderPipelineManager;
  1240. /**
  1241. * Gets the postprocess render pipeline manager
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1243. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1244. */
  1245. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1246. /**
  1247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1248. */
  1249. renderTargetsEnabled: boolean;
  1250. /**
  1251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1253. */
  1254. dumpNextRenderTargets: boolean;
  1255. /**
  1256. * The list of user defined render targets added to the scene
  1257. */
  1258. customRenderTargets: RenderTargetTexture[];
  1259. /**
  1260. * Defines if texture loading must be delayed
  1261. * If true, textures will only be loaded when they need to be rendered
  1262. */
  1263. useDelayedTextureLoading: boolean;
  1264. /**
  1265. * Gets the list of meshes imported to the scene through SceneLoader
  1266. */
  1267. importedMeshesFiles: String[];
  1268. /**
  1269. * Gets or sets a boolean indicating if probes are enabled on this scene
  1270. */
  1271. probesEnabled: boolean;
  1272. /**
  1273. * The list of reflection probes added to the scene
  1274. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1275. */
  1276. reflectionProbes: ReflectionProbe[];
  1277. /**
  1278. * @hidden
  1279. */
  1280. database: Database;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. /** @hidden */
  1287. _actionManagers: ActionManager[];
  1288. private _meshesForIntersections;
  1289. /**
  1290. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1291. */
  1292. proceduralTexturesEnabled: boolean;
  1293. /**
  1294. * The list of procedural textures added to the scene
  1295. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1296. */
  1297. proceduralTextures: ProceduralTexture[];
  1298. private _mainSoundTrack;
  1299. /**
  1300. * The list of sound tracks added to the scene
  1301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1302. */
  1303. soundTracks: SoundTrack[];
  1304. private _audioEnabled;
  1305. private _headphone;
  1306. /**
  1307. * Gets the main soundtrack associated with the scene
  1308. */
  1309. readonly mainSoundTrack: SoundTrack;
  1310. /**
  1311. * Gets or sets the VRExperienceHelper attached to the scene
  1312. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1313. * @ignorenaming
  1314. */
  1315. VRHelper: VRExperienceHelper;
  1316. /**
  1317. * Gets or sets the simplification queue attached to the scene
  1318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1319. */
  1320. simplificationQueue: SimplificationQueue;
  1321. private _engine;
  1322. private _totalVertices;
  1323. /** @hidden */
  1324. _activeIndices: PerfCounter;
  1325. /** @hidden */
  1326. _activeParticles: PerfCounter;
  1327. /** @hidden */
  1328. _activeBones: PerfCounter;
  1329. private _animationRatio;
  1330. private _animationTimeLast;
  1331. private _animationTime;
  1332. /**
  1333. * Gets or sets a general scale for animation speed
  1334. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1335. */
  1336. animationTimeScale: number;
  1337. /** @hidden */
  1338. _cachedMaterial: Nullable<Material>;
  1339. /** @hidden */
  1340. _cachedEffect: Nullable<Effect>;
  1341. /** @hidden */
  1342. _cachedVisibility: Nullable<number>;
  1343. private _renderId;
  1344. private _executeWhenReadyTimeoutId;
  1345. private _intermediateRendering;
  1346. private _viewUpdateFlag;
  1347. private _projectionUpdateFlag;
  1348. private _alternateViewUpdateFlag;
  1349. private _alternateProjectionUpdateFlag;
  1350. /** @hidden */
  1351. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1352. private _activeRequests;
  1353. private _pendingData;
  1354. private _isDisposed;
  1355. /**
  1356. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1357. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1358. */
  1359. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1360. private _activeMeshes;
  1361. private _processedMaterials;
  1362. private _renderTargets;
  1363. /** @hidden */
  1364. _activeParticleSystems: SmartArray<IParticleSystem>;
  1365. private _activeSkeletons;
  1366. private _softwareSkinnedMeshes;
  1367. private _renderingManager;
  1368. private _physicsEngine;
  1369. /** @hidden */
  1370. _activeAnimatables: Animatable[];
  1371. private _transformMatrix;
  1372. private _sceneUbo;
  1373. private _alternateSceneUbo;
  1374. private _pickWithRayInverseMatrix;
  1375. private _boundingBoxRenderer;
  1376. private _outlineRenderer;
  1377. private _viewMatrix;
  1378. private _projectionMatrix;
  1379. private _alternateViewMatrix;
  1380. private _alternateProjectionMatrix;
  1381. private _alternateTransformMatrix;
  1382. private _useAlternateCameraConfiguration;
  1383. private _alternateRendering;
  1384. /** @hidden */
  1385. _forcedViewPosition: Nullable<Vector3>;
  1386. /** @hidden */
  1387. readonly _isAlternateRenderingEnabled: boolean;
  1388. private _frustumPlanes;
  1389. /**
  1390. * Gets the list of frustum planes (built from the active camera)
  1391. */
  1392. readonly frustumPlanes: Plane[];
  1393. /**
  1394. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1395. * This is useful if there are more lights that the maximum simulteanous authorized
  1396. */
  1397. requireLightSorting: boolean;
  1398. private _selectionOctree;
  1399. private _pointerOverMesh;
  1400. private _pointerOverSprite;
  1401. private _debugLayer;
  1402. private _depthRenderer;
  1403. private _geometryBufferRenderer;
  1404. /**
  1405. * Gets the current geometry buffer associated to the scene.
  1406. */
  1407. /**
  1408. * Sets the current geometry buffer for the scene.
  1409. */
  1410. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1411. private _pickedDownMesh;
  1412. private _pickedUpMesh;
  1413. private _pickedDownSprite;
  1414. private _externalData;
  1415. private _uid;
  1416. /**
  1417. * Creates a new Scene
  1418. * @param engine defines the engine to use to render this scene
  1419. */
  1420. constructor(engine: Engine);
  1421. /**
  1422. * Gets the debug layer (aka Inspector) associated with the scene
  1423. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1424. */
  1425. readonly debugLayer: DebugLayer;
  1426. /**
  1427. * Gets a boolean indicating if collisions are processed on a web worker
  1428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1429. */
  1430. workerCollisions: boolean;
  1431. /**
  1432. * Gets the octree used to boost mesh selection (picking)
  1433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1434. */
  1435. readonly selectionOctree: Octree<AbstractMesh>;
  1436. /**
  1437. * Gets the mesh that is currently under the pointer
  1438. */
  1439. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1440. /**
  1441. * Gets the current on-screen X position of the pointer
  1442. */
  1443. readonly pointerX: number;
  1444. /**
  1445. * Gets the current on-screen Y position of the pointer
  1446. */
  1447. readonly pointerY: number;
  1448. /**
  1449. * Gets the cached material (ie. the latest rendered one)
  1450. * @returns the cached material
  1451. */
  1452. getCachedMaterial(): Nullable<Material>;
  1453. /**
  1454. * Gets the cached effect (ie. the latest rendered one)
  1455. * @returns the cached effect
  1456. */
  1457. getCachedEffect(): Nullable<Effect>;
  1458. /**
  1459. * Gets the cached visibility state (ie. the latest rendered one)
  1460. * @returns the cached visibility state
  1461. */
  1462. getCachedVisibility(): Nullable<number>;
  1463. /**
  1464. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1465. * @param material defines the current material
  1466. * @param effect defines the current effect
  1467. * @param visibility defines the current visibility state
  1468. * @returns true if one parameter is not cached
  1469. */
  1470. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1471. /**
  1472. * Gets the bounding box renderer associated with the scene
  1473. * @returns a BoundingBoxRenderer
  1474. */
  1475. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1476. /**
  1477. * Gets the outline renderer associated with the scene
  1478. * @returns a OutlineRenderer
  1479. */
  1480. getOutlineRenderer(): OutlineRenderer;
  1481. /**
  1482. * Gets the engine associated with the scene
  1483. * @returns an Engine
  1484. */
  1485. getEngine(): Engine;
  1486. /**
  1487. * Gets the total number of vertices rendered per frame
  1488. * @returns the total number of vertices rendered per frame
  1489. */
  1490. getTotalVertices(): number;
  1491. /**
  1492. * Gets the performance counter for total vertices
  1493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1494. */
  1495. readonly totalVerticesPerfCounter: PerfCounter;
  1496. /**
  1497. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1498. * @returns the total number of active indices rendered per frame
  1499. */
  1500. getActiveIndices(): number;
  1501. /**
  1502. * Gets the performance counter for active indices
  1503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1504. */
  1505. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1506. /**
  1507. * Gets the total number of active particles rendered per frame
  1508. * @returns the total number of active particles rendered per frame
  1509. */
  1510. getActiveParticles(): number;
  1511. /**
  1512. * Gets the performance counter for active particles
  1513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1514. */
  1515. readonly activeParticlesPerfCounter: PerfCounter;
  1516. /**
  1517. * Gets the total number of active bones rendered per frame
  1518. * @returns the total number of active bones rendered per frame
  1519. */
  1520. getActiveBones(): number;
  1521. /**
  1522. * Gets the performance counter for active bones
  1523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1524. */
  1525. readonly activeBonesPerfCounter: PerfCounter;
  1526. /** @hidden */
  1527. getInterFramePerfCounter(): number;
  1528. /** @hidden */
  1529. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1530. /** @hidden */
  1531. getLastFrameDuration(): number;
  1532. /** @hidden */
  1533. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1534. /** @hidden */
  1535. getEvaluateActiveMeshesDuration(): number;
  1536. /** @hidden */
  1537. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1538. /**
  1539. * Gets the array of active meshes
  1540. * @returns an array of AbstractMesh
  1541. */
  1542. getActiveMeshes(): SmartArray<AbstractMesh>;
  1543. /** @hidden */
  1544. getRenderTargetsDuration(): number;
  1545. /** @hidden */
  1546. getRenderDuration(): number;
  1547. /** @hidden */
  1548. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1549. /** @hidden */
  1550. getParticlesDuration(): number;
  1551. /** @hidden */
  1552. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1553. /** @hidden */
  1554. getSpritesDuration(): number;
  1555. /** @hidden */
  1556. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1557. /**
  1558. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1559. * @returns a number
  1560. */
  1561. getAnimationRatio(): number;
  1562. /**
  1563. * Gets an unique Id for the current frame
  1564. * @returns a number
  1565. */
  1566. getRenderId(): number;
  1567. /** Call this function if you want to manually increment the render Id*/
  1568. incrementRenderId(): void;
  1569. private _updatePointerPosition(evt);
  1570. private _createUbo();
  1571. private _createAlternateUbo();
  1572. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1573. private _setRayOnPointerInfo(pointerInfo);
  1574. /**
  1575. * Use this method to simulate a pointer move on a mesh
  1576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1579. * @returns the current scene
  1580. */
  1581. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1582. private _processPointerMove(pickResult, evt);
  1583. private _checkPrePointerObservable(pickResult, evt, type);
  1584. /**
  1585. * Use this method to simulate a pointer down on a mesh
  1586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1589. * @returns the current scene
  1590. */
  1591. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1592. private _processPointerDown(pickResult, evt);
  1593. /**
  1594. * Use this method to simulate a pointer up on a mesh
  1595. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1596. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1597. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1598. * @returns the current scene
  1599. */
  1600. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1601. private _processPointerUp(pickResult, evt, clickInfo);
  1602. /**
  1603. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1604. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1605. * @returns true if the pointer was captured
  1606. */
  1607. isPointerCaptured(pointerId?: number): boolean;
  1608. /**
  1609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1610. * @param attachUp defines if you want to attach events to pointerup
  1611. * @param attachDown defines if you want to attach events to pointerdown
  1612. * @param attachMove defines if you want to attach events to pointermove
  1613. */
  1614. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1615. /** Detaches all event handlers*/
  1616. detachControl(): void;
  1617. /**
  1618. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1619. * Delay loaded resources are not taking in account
  1620. * @return true if all required resources are ready
  1621. */
  1622. isReady(): boolean;
  1623. /** Resets all cached information relative to material (including effect and visibility) */
  1624. resetCachedMaterial(): void;
  1625. /**
  1626. * Registers a function to be called before every frame render
  1627. * @param func defines the function to register
  1628. */
  1629. registerBeforeRender(func: () => void): void;
  1630. /**
  1631. * Unregisters a function called before every frame render
  1632. * @param func defines the function to unregister
  1633. */
  1634. unregisterBeforeRender(func: () => void): void;
  1635. /**
  1636. * Registers a function to be called after every frame render
  1637. * @param func defines the function to register
  1638. */
  1639. registerAfterRender(func: () => void): void;
  1640. /**
  1641. * Unregisters a function called after every frame render
  1642. * @param func defines the function to unregister
  1643. */
  1644. unregisterAfterRender(func: () => void): void;
  1645. private _executeOnceBeforeRender(func);
  1646. /**
  1647. * The provided function will run before render once and will be disposed afterwards.
  1648. * A timeout delay can be provided so that the function will be executed in N ms.
  1649. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1650. * @param func The function to be executed.
  1651. * @param timeout optional delay in ms
  1652. */
  1653. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1654. /** @hidden */
  1655. _addPendingData(data: any): void;
  1656. /** @hidden */
  1657. _removePendingData(data: any): void;
  1658. /**
  1659. * Returns the number of items waiting to be loaded
  1660. * @returns the number of items waiting to be loaded
  1661. */
  1662. getWaitingItemsCount(): number;
  1663. /**
  1664. * Returns a boolean indicating if the scene is still loading data
  1665. */
  1666. readonly isLoading: boolean;
  1667. /**
  1668. * Registers a function to be executed when the scene is ready
  1669. * @param {Function} func - the function to be executed
  1670. */
  1671. executeWhenReady(func: () => void): void;
  1672. /**
  1673. * Returns a promise that resolves when the scene is ready
  1674. * @returns A promise that resolves when the scene is ready
  1675. */
  1676. whenReadyAsync(): Promise<void>;
  1677. /** @hidden */
  1678. _checkIsReady(): void;
  1679. /**
  1680. * Will start the animation sequence of a given target
  1681. * @param target defines the target
  1682. * @param from defines from which frame should animation start
  1683. * @param to defines until which frame should animation run.
  1684. * @param weight defines the weight to apply to the animation (1.0 by default)
  1685. * @param loop defines if the animation loops
  1686. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1687. * @param onAnimationEnd defines the function to be executed when the animation ends
  1688. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1689. * @returns the animatable object created for this animation
  1690. */
  1691. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1692. /**
  1693. * Will start the animation sequence of a given target
  1694. * @param target defines the target
  1695. * @param from defines from which frame should animation start
  1696. * @param to defines until which frame should animation run.
  1697. * @param loop defines if the animation loops
  1698. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1699. * @param onAnimationEnd defines the function to be executed when the animation ends
  1700. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1701. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1702. * @returns the animatable object created for this animation
  1703. */
  1704. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1705. /**
  1706. * Begin a new animation on a given node
  1707. * @param target defines the target where the animation will take place
  1708. * @param animations defines the list of animations to start
  1709. * @param from defines the initial value
  1710. * @param to defines the final value
  1711. * @param loop defines if you want animation to loop (off by default)
  1712. * @param speedRatio defines the speed ratio to apply to all animations
  1713. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1714. * @returns the list of created animatables
  1715. */
  1716. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1717. /**
  1718. * Begin a new animation on a given node and its hierarchy
  1719. * @param target defines the root node where the animation will take place
  1720. * @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.
  1721. * @param animations defines the list of animations to start
  1722. * @param from defines the initial value
  1723. * @param to defines the final value
  1724. * @param loop defines if you want animation to loop (off by default)
  1725. * @param speedRatio defines the speed ratio to apply to all animations
  1726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1727. * @returns the list of animatables created for all nodes
  1728. */
  1729. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1730. /**
  1731. * Gets the animatable associated with a specific target
  1732. * @param target defines the target of the animatable
  1733. * @returns the required animatable if found
  1734. */
  1735. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1736. /**
  1737. * Gets all animatables associated with a given target
  1738. * @param target defines the target to look animatables for
  1739. * @returns an array of Animatables
  1740. */
  1741. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1742. /**
  1743. * Gets all animatable attached to the scene
  1744. */
  1745. readonly animatables: Animatable[];
  1746. /**
  1747. * Will stop the animation of the given target
  1748. * @param target - the target
  1749. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1750. */
  1751. stopAnimation(target: any, animationName?: string): void;
  1752. /**
  1753. * Stops and removes all animations that have been applied to the scene
  1754. */
  1755. stopAllAnimations(): void;
  1756. private _animate();
  1757. /** @hidden */
  1758. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1759. private _processLateAnimationBindingsForMatrices(holder);
  1760. private _processLateAnimationBindingsForQuaternions(holder);
  1761. private _processLateAnimationBindings();
  1762. /** @hidden */
  1763. _switchToAlternateCameraConfiguration(active: boolean): void;
  1764. /**
  1765. * Gets the current view matrix
  1766. * @returns a Matrix
  1767. */
  1768. getViewMatrix(): Matrix;
  1769. /**
  1770. * Gets the current projection matrix
  1771. * @returns a Matrix
  1772. */
  1773. getProjectionMatrix(): Matrix;
  1774. /**
  1775. * Gets the current transform matrix
  1776. * @returns a Matrix made of View * Projection
  1777. */
  1778. getTransformMatrix(): Matrix;
  1779. /**
  1780. * Sets the current transform matrix
  1781. * @param view defines the View matrix to use
  1782. * @param projection defines the Projection matrix to use
  1783. */
  1784. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1785. /** @hidden */
  1786. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1787. /**
  1788. * Gets the uniform buffer used to store scene data
  1789. * @returns a UniformBuffer
  1790. */
  1791. getSceneUniformBuffer(): UniformBuffer;
  1792. /**
  1793. * Gets an unique (relatively to the current scene) Id
  1794. * @returns an unique number for the scene
  1795. */
  1796. getUniqueId(): number;
  1797. /**
  1798. * Add a mesh to the list of scene's meshes
  1799. * @param newMesh defines the mesh to add
  1800. * @param recursive if all child meshes should also be added to the scene
  1801. */
  1802. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1803. /**
  1804. * Remove a mesh for the list of scene's meshes
  1805. * @param toRemove defines the mesh to remove
  1806. * @param recursive if all child meshes should also be removed from the scene
  1807. * @returns the index where the mesh was in the mesh list
  1808. */
  1809. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1810. /**
  1811. * Add a transform node to the list of scene's transform nodes
  1812. * @param newTransformNode defines the transform node to add
  1813. */
  1814. addTransformNode(newTransformNode: TransformNode): void;
  1815. /**
  1816. * Remove a transform node for the list of scene's transform nodes
  1817. * @param toRemove defines the transform node to remove
  1818. * @returns the index where the transform node was in the transform node list
  1819. */
  1820. removeTransformNode(toRemove: TransformNode): number;
  1821. /**
  1822. * Remove a skeleton for the list of scene's skeletons
  1823. * @param toRemove defines the skeleton to remove
  1824. * @returns the index where the skeleton was in the skeleton list
  1825. */
  1826. removeSkeleton(toRemove: Skeleton): number;
  1827. /**
  1828. * Remove a morph target for the list of scene's morph targets
  1829. * @param toRemove defines the morph target to remove
  1830. * @returns the index where the morph target was in the morph target list
  1831. */
  1832. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1833. /**
  1834. * Remove a light for the list of scene's lights
  1835. * @param toRemove defines the light to remove
  1836. * @returns the index where the light was in the light list
  1837. */
  1838. removeLight(toRemove: Light): number;
  1839. /**
  1840. * Remove a camera for the list of scene's cameras
  1841. * @param toRemove defines the camera to remove
  1842. * @returns the index where the camera was in the camera list
  1843. */
  1844. removeCamera(toRemove: Camera): number;
  1845. /**
  1846. * Remove a particle system for the list of scene's particle systems
  1847. * @param toRemove defines the particle system to remove
  1848. * @returns the index where the particle system was in the particle system list
  1849. */
  1850. removeParticleSystem(toRemove: IParticleSystem): number;
  1851. /**
  1852. * Remove a animation for the list of scene's animations
  1853. * @param toRemove defines the animation to remove
  1854. * @returns the index where the animation was in the animation list
  1855. */
  1856. removeAnimation(toRemove: Animation): number;
  1857. /**
  1858. * Removes the given animation group from this scene.
  1859. * @param toRemove The animation group to remove
  1860. * @returns The index of the removed animation group
  1861. */
  1862. removeAnimationGroup(toRemove: AnimationGroup): number;
  1863. /**
  1864. * Removes the given multi-material from this scene.
  1865. * @param toRemove The multi-material to remove
  1866. * @returns The index of the removed multi-material
  1867. */
  1868. removeMultiMaterial(toRemove: MultiMaterial): number;
  1869. /**
  1870. * Removes the given material from this scene.
  1871. * @param toRemove The material to remove
  1872. * @returns The index of the removed material
  1873. */
  1874. removeMaterial(toRemove: Material): number;
  1875. /**
  1876. * Removes the given lens flare system from this scene.
  1877. * @param toRemove The lens flare system to remove
  1878. * @returns The index of the removed lens flare system
  1879. */
  1880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1881. /**
  1882. * Removes the given action manager from this scene.
  1883. * @param toRemove The action manager to remove
  1884. * @returns The index of the removed action manager
  1885. */
  1886. removeActionManager(toRemove: ActionManager): number;
  1887. /**
  1888. * Removes the given effect layer from this scene.
  1889. * @param toRemove defines the effect layer to remove
  1890. * @returns the index of the removed effect layer
  1891. */
  1892. removeEffectLayer(toRemove: EffectLayer): number;
  1893. /**
  1894. * Removes the given texture from this scene.
  1895. * @param toRemove The texture to remove
  1896. * @returns The index of the removed texture
  1897. */
  1898. removeTexture(toRemove: BaseTexture): number;
  1899. /**
  1900. * Adds the given light to this scene
  1901. * @param newLight The light to add
  1902. */
  1903. addLight(newLight: Light): void;
  1904. /**
  1905. * Sorts the list list based on light priorities
  1906. */
  1907. sortLightsByPriority(): void;
  1908. /**
  1909. * Adds the given camera to this scene
  1910. * @param newCamera The camera to add
  1911. */
  1912. addCamera(newCamera: Camera): void;
  1913. /**
  1914. * Adds the given skeleton to this scene
  1915. * @param newSkeleton The skeleton to add
  1916. */
  1917. addSkeleton(newSkeleton: Skeleton): void;
  1918. /**
  1919. * Adds the given particle system to this scene
  1920. * @param newParticleSystem The particle system to add
  1921. */
  1922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1923. /**
  1924. * Adds the given animation to this scene
  1925. * @param newAnimation The animation to add
  1926. */
  1927. addAnimation(newAnimation: Animation): void;
  1928. /**
  1929. * Adds the given animation group to this scene.
  1930. * @param newAnimationGroup The animation group to add
  1931. */
  1932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1933. /**
  1934. * Adds the given multi-material to this scene
  1935. * @param newMultiMaterial The multi-material to add
  1936. */
  1937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1938. /**
  1939. * Adds the given material to this scene
  1940. * @param newMaterial The material to add
  1941. */
  1942. addMaterial(newMaterial: Material): void;
  1943. /**
  1944. * Adds the given morph target to this scene
  1945. * @param newMorphTargetManager The morph target to add
  1946. */
  1947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1948. /**
  1949. * Adds the given geometry to this scene
  1950. * @param newGeometry The geometry to add
  1951. */
  1952. addGeometry(newGeometry: Geometry): void;
  1953. /**
  1954. * Adds the given lens flare system to this scene
  1955. * @param newLensFlareSystem The lens flare system to add
  1956. */
  1957. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1958. /**
  1959. * Adds the given effect layer to this scene
  1960. * @param newEffectLayer defines the effect layer to add
  1961. */
  1962. addEffectLayer(newEffectLayer: EffectLayer): void;
  1963. /**
  1964. * Adds the given action manager to this scene
  1965. * @param newActionManager The action manager to add
  1966. */
  1967. addActionManager(newActionManager: ActionManager): void;
  1968. /**
  1969. * Adds the given texture to this scene.
  1970. * @param newTexture The texture to add
  1971. */
  1972. addTexture(newTexture: BaseTexture): void;
  1973. /**
  1974. * Switch active camera
  1975. * @param newCamera defines the new active camera
  1976. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1977. */
  1978. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1979. /**
  1980. * sets the active camera of the scene using its ID
  1981. * @param id defines the camera's ID
  1982. * @return the new active camera or null if none found.
  1983. */
  1984. setActiveCameraByID(id: string): Nullable<Camera>;
  1985. /**
  1986. * sets the active camera of the scene using its name
  1987. * @param name defines the camera's name
  1988. * @returns the new active camera or null if none found.
  1989. */
  1990. setActiveCameraByName(name: string): Nullable<Camera>;
  1991. /**
  1992. * get an animation group using its name
  1993. * @param name defines the material's name
  1994. * @return the animation group or null if none found.
  1995. */
  1996. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1997. /**
  1998. * get a material using its id
  1999. * @param id defines the material's ID
  2000. * @return the material or null if none found.
  2001. */
  2002. getMaterialByID(id: string): Nullable<Material>;
  2003. /**
  2004. * Gets a material using its name
  2005. * @param name defines the material's name
  2006. * @return the material or null if none found.
  2007. */
  2008. getMaterialByName(name: string): Nullable<Material>;
  2009. /**
  2010. * Gets a lens flare system using its name
  2011. * @param name defines the name to look for
  2012. * @returns the lens flare system or null if not found
  2013. */
  2014. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2015. /**
  2016. * Gets a lens flare system using its id
  2017. * @param id defines the id to look for
  2018. * @returns the lens flare system or null if not found
  2019. */
  2020. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2021. /**
  2022. * Gets a camera using its id
  2023. * @param id defines the id to look for
  2024. * @returns the camera or null if not found
  2025. */
  2026. getCameraByID(id: string): Nullable<Camera>;
  2027. /**
  2028. * Gets a camera using its unique id
  2029. * @param uniqueId defines the unique id to look for
  2030. * @returns the camera or null if not found
  2031. */
  2032. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2033. /**
  2034. * Gets a camera using its name
  2035. * @param name defines the camera's name
  2036. * @return the camera or null if none found.
  2037. */
  2038. getCameraByName(name: string): Nullable<Camera>;
  2039. /**
  2040. * Gets a bone using its id
  2041. * @param id defines the bone's id
  2042. * @return the bone or null if not found
  2043. */
  2044. getBoneByID(id: string): Nullable<Bone>;
  2045. /**
  2046. * Gets a bone using its id
  2047. * @param name defines the bone's name
  2048. * @return the bone or null if not found
  2049. */
  2050. getBoneByName(name: string): Nullable<Bone>;
  2051. /**
  2052. * Gets a light node using its name
  2053. * @param name defines the the light's name
  2054. * @return the light or null if none found.
  2055. */
  2056. getLightByName(name: string): Nullable<Light>;
  2057. /**
  2058. * Gets a light node using its id
  2059. * @param id defines the light's id
  2060. * @return the light or null if none found.
  2061. */
  2062. getLightByID(id: string): Nullable<Light>;
  2063. /**
  2064. * Gets a light node using its scene-generated unique ID
  2065. * @param uniqueId defines the light's unique id
  2066. * @return the light or null if none found.
  2067. */
  2068. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2069. /**
  2070. * Gets a particle system by id
  2071. * @param id defines the particle system id
  2072. * @return the corresponding system or null if none found
  2073. */
  2074. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2075. /**
  2076. * Gets a geometry using its ID
  2077. * @param id defines the geometry's id
  2078. * @return the geometry or null if none found.
  2079. */
  2080. getGeometryByID(id: string): Nullable<Geometry>;
  2081. /**
  2082. * Add a new geometry to this scene
  2083. * @param geometry defines the geometry to be added to the scene.
  2084. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2085. * @return a boolean defining if the geometry was added or not
  2086. */
  2087. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2088. /**
  2089. * Removes an existing geometry
  2090. * @param geometry defines the geometry to be removed from the scene
  2091. * @return a boolean defining if the geometry was removed or not
  2092. */
  2093. removeGeometry(geometry: Geometry): boolean;
  2094. /**
  2095. * Gets the list of geometries attached to the scene
  2096. * @returns an array of Geometry
  2097. */
  2098. getGeometries(): Geometry[];
  2099. /**
  2100. * Gets the first added mesh found of a given ID
  2101. * @param id defines the id to search for
  2102. * @return the mesh found or null if not found at all
  2103. */
  2104. getMeshByID(id: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a list of meshes using their id
  2107. * @param id defines the id to search for
  2108. * @returns a list of meshes
  2109. */
  2110. getMeshesByID(id: string): Array<AbstractMesh>;
  2111. /**
  2112. * Gets the first added transform node found of a given ID
  2113. * @param id defines the id to search for
  2114. * @return the found transform node or null if not found at all.
  2115. */
  2116. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2117. /**
  2118. * Gets a list of transform nodes using their id
  2119. * @param id defines the id to search for
  2120. * @returns a list of transform nodes
  2121. */
  2122. getTransformNodesByID(id: string): Array<TransformNode>;
  2123. /**
  2124. * Gets a mesh with its auto-generated unique id
  2125. * @param uniqueId defines the unique id to search for
  2126. * @return the found mesh or null if not found at all.
  2127. */
  2128. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2129. /**
  2130. * Gets a the last added mesh using a given id
  2131. * @param id defines the id to search for
  2132. * @return the found mesh or null if not found at all.
  2133. */
  2134. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2135. /**
  2136. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2137. * @param id defines the id to search for
  2138. * @return the found node or null if not found at all
  2139. */
  2140. getLastEntryByID(id: string): Nullable<Node>;
  2141. /**
  2142. * Gets a node (Mesh, Camera, Light) using a given id
  2143. * @param id defines the id to search for
  2144. * @return the found node or null if not found at all
  2145. */
  2146. getNodeByID(id: string): Nullable<Node>;
  2147. /**
  2148. * Gets a node (Mesh, Camera, Light) using a given name
  2149. * @param name defines the name to search for
  2150. * @return the found node or null if not found at all.
  2151. */
  2152. getNodeByName(name: string): Nullable<Node>;
  2153. /**
  2154. * Gets a mesh using a given name
  2155. * @param name defines the name to search for
  2156. * @return the found mesh or null if not found at all.
  2157. */
  2158. getMeshByName(name: string): Nullable<AbstractMesh>;
  2159. /**
  2160. * Gets a transform node using a given name
  2161. * @param name defines the name to search for
  2162. * @return the found transform node or null if not found at all.
  2163. */
  2164. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2165. /**
  2166. * Gets a sound using a given name
  2167. * @param name defines the name to search for
  2168. * @return the found sound or null if not found at all.
  2169. */
  2170. getSoundByName(name: string): Nullable<Sound>;
  2171. /**
  2172. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2173. * @param id defines the id to search for
  2174. * @return the found skeleton or null if not found at all.
  2175. */
  2176. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2177. /**
  2178. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2179. * @param id defines the id to search for
  2180. * @return the found skeleton or null if not found at all.
  2181. */
  2182. getSkeletonById(id: string): Nullable<Skeleton>;
  2183. /**
  2184. * Gets a skeleton using a given name
  2185. * @param name defines the name to search for
  2186. * @return the found skeleton or null if not found at all.
  2187. */
  2188. getSkeletonByName(name: string): Nullable<Skeleton>;
  2189. /**
  2190. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2191. * @param id defines the id to search for
  2192. * @return the found morph target manager or null if not found at all.
  2193. */
  2194. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2195. /**
  2196. * Gets a boolean indicating if the given mesh is active
  2197. * @param mesh defines the mesh to look for
  2198. * @returns true if the mesh is in the active list
  2199. */
  2200. isActiveMesh(mesh: AbstractMesh): boolean;
  2201. /**
  2202. * Return a the first highlight layer of the scene with a given name.
  2203. * @param name The name of the highlight layer to look for.
  2204. * @return The highlight layer if found otherwise null.
  2205. */
  2206. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2207. /**
  2208. * Return a the first highlight layer of the scene with a given name.
  2209. * @param name The name of the highlight layer to look for.
  2210. * @return The highlight layer if found otherwise null.
  2211. */
  2212. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2213. /**
  2214. * Return a unique id as a string which can serve as an identifier for the scene
  2215. */
  2216. readonly uid: string;
  2217. /**
  2218. * Add an externaly attached data from its key.
  2219. * This method call will fail and return false, if such key already exists.
  2220. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2221. * @param key the unique key that identifies the data
  2222. * @param data the data object to associate to the key for this Engine instance
  2223. * @return true if no such key were already present and the data was added successfully, false otherwise
  2224. */
  2225. addExternalData<T>(key: string, data: T): boolean;
  2226. /**
  2227. * Get an externaly attached data from its key
  2228. * @param key the unique key that identifies the data
  2229. * @return the associated data, if present (can be null), or undefined if not present
  2230. */
  2231. getExternalData<T>(key: string): Nullable<T>;
  2232. /**
  2233. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2234. * @param key the unique key that identifies the data
  2235. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2236. * @return the associated data, can be null if the factory returned null.
  2237. */
  2238. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2239. /**
  2240. * Remove an externaly attached data from the Engine instance
  2241. * @param key the unique key that identifies the data
  2242. * @return true if the data was successfully removed, false if it doesn't exist
  2243. */
  2244. removeExternalData(key: string): boolean;
  2245. private _evaluateSubMesh(subMesh, mesh);
  2246. /**
  2247. * Clear the processed materials smart array preventing retention point in material dispose.
  2248. */
  2249. freeProcessedMaterials(): void;
  2250. /**
  2251. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2252. */
  2253. freeActiveMeshes(): void;
  2254. /**
  2255. * Clear the info related to rendering groups preventing retention points during dispose.
  2256. */
  2257. freeRenderingGroups(): void;
  2258. /** @hidden */
  2259. _isInIntermediateRendering(): boolean;
  2260. private _activeMeshCandidateProvider;
  2261. /**
  2262. * Defines the current active mesh candidate provider
  2263. * @param provider defines the provider to use
  2264. */
  2265. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2266. /**
  2267. * Gets the current active mesh candidate provider
  2268. * @returns the current active mesh candidate provider
  2269. */
  2270. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2271. private _activeMeshesFrozen;
  2272. /**
  2273. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2274. * @returns the current scene
  2275. */
  2276. freezeActiveMeshes(): Scene;
  2277. /**
  2278. * Use this function to restart evaluating active meshes on every frame
  2279. * @returns the current scene
  2280. */
  2281. unfreezeActiveMeshes(): Scene;
  2282. private _evaluateActiveMeshes();
  2283. private _activeMesh(sourceMesh, mesh);
  2284. /**
  2285. * Update the transform matrix to update from the current active camera
  2286. * @param force defines a boolean used to force the update even if cache is up to date
  2287. */
  2288. updateTransformMatrix(force?: boolean): void;
  2289. /**
  2290. * 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)
  2291. * @param alternateCamera defines the camera to use
  2292. */
  2293. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2294. private _renderForCamera(camera, rigParent?);
  2295. private _processSubCameras(camera);
  2296. private _checkIntersections();
  2297. /**
  2298. * Render the scene
  2299. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2300. */
  2301. render(updateCameras?: boolean): void;
  2302. private _updateAudioParameters();
  2303. /**
  2304. * Gets or sets if audio support is enabled
  2305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2306. */
  2307. audioEnabled: boolean;
  2308. private _disableAudio();
  2309. private _enableAudio();
  2310. /**
  2311. * Gets or sets if audio will be output to headphones
  2312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2313. */
  2314. headphone: boolean;
  2315. private _switchAudioModeForHeadphones();
  2316. private _switchAudioModeForNormalSpeakers();
  2317. /**
  2318. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2319. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2320. * @returns the created depth renderer
  2321. */
  2322. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2323. /**
  2324. * Disables a depth renderer for a given camera
  2325. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2326. */
  2327. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2328. /**
  2329. * Enables a GeometryBufferRender and associates it with the scene
  2330. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2331. * @returns the GeometryBufferRenderer
  2332. */
  2333. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2334. /**
  2335. * Disables the GeometryBufferRender associated with the scene
  2336. */
  2337. disableGeometryBufferRenderer(): void;
  2338. /**
  2339. * Freeze all materials
  2340. * A frozen material will not be updatable but should be faster to render
  2341. */
  2342. freezeMaterials(): void;
  2343. /**
  2344. * Unfreeze all materials
  2345. * A frozen material will not be updatable but should be faster to render
  2346. */
  2347. unfreezeMaterials(): void;
  2348. /**
  2349. * Releases all held ressources
  2350. */
  2351. dispose(): void;
  2352. /**
  2353. * Gets if the scene is already disposed
  2354. */
  2355. readonly isDisposed: boolean;
  2356. /**
  2357. * Releases sounds & soundtracks
  2358. */
  2359. disposeSounds(): void;
  2360. /**
  2361. * Call this function to reduce memory footprint of the scene.
  2362. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2363. */
  2364. clearCachedVertexData(): void;
  2365. /**
  2366. * This function will remove the local cached buffer data from texture.
  2367. * It will save memory but will prevent the texture from being rebuilt
  2368. */
  2369. cleanCachedTextureBuffer(): void;
  2370. /**
  2371. * Get the world extend vectors with an optional filter
  2372. *
  2373. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2374. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2375. */
  2376. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2377. min: Vector3;
  2378. max: Vector3;
  2379. };
  2380. /**
  2381. * Creates or updates the octree used to boost selection (picking)
  2382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2383. * @param maxCapacity defines the maximum capacity per leaf
  2384. * @param maxDepth defines the maximum depth of the octree
  2385. * @returns an octree of AbstractMesh
  2386. */
  2387. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2388. /**
  2389. * Creates a ray that can be used to pick in the scene
  2390. * @param x defines the x coordinate of the origin (on-screen)
  2391. * @param y defines the y coordinate of the origin (on-screen)
  2392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2393. * @param camera defines the camera to use for the picking
  2394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2395. * @returns a Ray
  2396. */
  2397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2398. /**
  2399. * Creates a ray that can be used to pick in the scene
  2400. * @param x defines the x coordinate of the origin (on-screen)
  2401. * @param y defines the y coordinate of the origin (on-screen)
  2402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2403. * @param result defines the ray where to store the picking ray
  2404. * @param camera defines the camera to use for the picking
  2405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2406. * @returns the current scene
  2407. */
  2408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2409. /**
  2410. * Creates a ray that can be used to pick in the scene
  2411. * @param x defines the x coordinate of the origin (on-screen)
  2412. * @param y defines the y coordinate of the origin (on-screen)
  2413. * @param camera defines the camera to use for the picking
  2414. * @returns a Ray
  2415. */
  2416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2417. /**
  2418. * Creates a ray that can be used to pick in the scene
  2419. * @param x defines the x coordinate of the origin (on-screen)
  2420. * @param y defines the y coordinate of the origin (on-screen)
  2421. * @param result defines the ray where to store the picking ray
  2422. * @param camera defines the camera to use for the picking
  2423. * @returns the current scene
  2424. */
  2425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2426. private _internalPick(rayFunction, predicate?, fastCheck?);
  2427. private _internalMultiPick(rayFunction, predicate?);
  2428. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2429. private _tempPickingRay;
  2430. /** Launch a ray to try to pick a mesh in the scene
  2431. * @param x position on screen
  2432. * @param y position on screen
  2433. * @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
  2434. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2435. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2436. * @returns a PickingInfo
  2437. */
  2438. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2439. /** Launch a ray to try to pick a sprite in the scene
  2440. * @param x position on screen
  2441. * @param y position on screen
  2442. * @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
  2443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2445. * @returns a PickingInfo
  2446. */
  2447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2448. private _cachedRayForTransform;
  2449. /** Use the given ray to pick a mesh in the scene
  2450. * @param ray The ray to use to pick meshes
  2451. * @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
  2452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2453. * @returns a PickingInfo
  2454. */
  2455. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2456. /**
  2457. * Launch a ray to try to pick a mesh in the scene
  2458. * @param x X position on screen
  2459. * @param y Y position on screen
  2460. * @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
  2461. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2462. * @returns an array of PickingInfo
  2463. */
  2464. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2465. /**
  2466. * Launch a ray to try to pick a mesh in the scene
  2467. * @param ray Ray to use
  2468. * @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
  2469. * @returns an array of PickingInfo
  2470. */
  2471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2472. /**
  2473. * Force the value of meshUnderPointer
  2474. * @param mesh defines the mesh to use
  2475. */
  2476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2477. /**
  2478. * Gets the mesh under the pointer
  2479. * @returns a Mesh or null if no mesh is under the pointer
  2480. */
  2481. getPointerOverMesh(): Nullable<AbstractMesh>;
  2482. /**
  2483. * Force the sprite under the pointer
  2484. * @param sprite defines the sprite to use
  2485. */
  2486. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2487. /**
  2488. * Gets the sprite under the pointer
  2489. * @returns a Sprite or null if no sprite is under the pointer
  2490. */
  2491. getPointerOverSprite(): Nullable<Sprite>;
  2492. /**
  2493. * Gets the current physics engine
  2494. * @returns a PhysicsEngine or null if none attached
  2495. */
  2496. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2497. /**
  2498. * Enables physics to the current scene
  2499. * @param gravity defines the scene's gravity for the physics engine
  2500. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2501. * @return a boolean indicating if the physics engine was initialized
  2502. */
  2503. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2504. /**
  2505. * Disables and disposes the physics engine associated with the scene
  2506. */
  2507. disablePhysicsEngine(): void;
  2508. /**
  2509. * Gets a boolean indicating if there is an active physics engine
  2510. * @returns a boolean indicating if there is an active physics engine
  2511. */
  2512. isPhysicsEnabled(): boolean;
  2513. /**
  2514. * Deletes a physics compound impostor
  2515. * @param compound defines the compound to delete
  2516. */
  2517. deleteCompoundImpostor(compound: any): void;
  2518. /** @hidden */
  2519. _rebuildGeometries(): void;
  2520. /** @hidden */
  2521. _rebuildTextures(): void;
  2522. /**
  2523. * Creates a default light for the scene.
  2524. * @param replace Whether to replace the existing lights in the scene.
  2525. */
  2526. createDefaultLight(replace?: boolean): void;
  2527. /**
  2528. * Creates a default camera for the scene.
  2529. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2530. * @param replace Whether to replace the existing active camera in the scene.
  2531. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2532. */
  2533. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2534. /**
  2535. * Creates a default camera and a default light
  2536. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2537. * @param replace defines if the camera and/or light will replace the existing ones
  2538. * @param attachCameraControls defines if attachControl will be called on the new camera
  2539. */
  2540. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2541. /**
  2542. * Creates a new sky box
  2543. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2544. * @param environmentTexture defines the texture to use as environment texture
  2545. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2546. * @param scale defines the overall scale of the skybox
  2547. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2548. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2549. * @returns a new mesh holding the sky box
  2550. */
  2551. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2552. /**
  2553. * Creates a new environment
  2554. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2555. * @param options defines the options you can use to configure the environment
  2556. * @returns the new EnvironmentHelper
  2557. */
  2558. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2559. /**
  2560. * Creates a new VREXperienceHelper
  2561. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2562. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2563. * @returns a new VREXperienceHelper
  2564. */
  2565. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2566. private _getByTags(list, tagsQuery, forEach?);
  2567. /**
  2568. * Get a list of meshes by tags
  2569. * @param tagsQuery defines the tags query to use
  2570. * @param forEach defines a predicate used to filter results
  2571. * @returns an array of Mesh
  2572. */
  2573. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2574. /**
  2575. * Get a list of cameras by tags
  2576. * @param tagsQuery defines the tags query to use
  2577. * @param forEach defines a predicate used to filter results
  2578. * @returns an array of Camera
  2579. */
  2580. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2581. /**
  2582. * Get a list of lights by tags
  2583. * @param tagsQuery defines the tags query to use
  2584. * @param forEach defines a predicate used to filter results
  2585. * @returns an array of Light
  2586. */
  2587. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2588. /**
  2589. * Get a list of materials by tags
  2590. * @param tagsQuery defines the tags query to use
  2591. * @param forEach defines a predicate used to filter results
  2592. * @returns an array of Material
  2593. */
  2594. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2595. /**
  2596. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2597. * This allowed control for front to back rendering or reversly depending of the special needs.
  2598. *
  2599. * @param renderingGroupId The rendering group id corresponding to its index
  2600. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2601. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2602. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2603. */
  2604. 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;
  2605. /**
  2606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2607. *
  2608. * @param renderingGroupId The rendering group id corresponding to its index
  2609. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2610. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2611. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2612. */
  2613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2614. /**
  2615. * Will flag all materials as dirty to trigger new shader compilation
  2616. * @param flag defines the flag used to specify which material part must be marked as dirty
  2617. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2618. */
  2619. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2620. /** @hidden */
  2621. _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;
  2622. /** @hidden */
  2623. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2624. }
  2625. }
  2626. declare module BABYLON {
  2627. type Nullable<T> = T | null;
  2628. type float = number;
  2629. type double = number;
  2630. type int = number;
  2631. type FloatArray = number[] | Float32Array;
  2632. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2633. /**
  2634. * Alias for types that can be used by a Buffer or VertexBuffer.
  2635. */
  2636. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2637. }
  2638. declare module BABYLON {
  2639. /**
  2640. * The action to be carried out following a trigger
  2641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2642. */
  2643. class Action {
  2644. /** the trigger, with or without parameters, for the action */
  2645. triggerOptions: any;
  2646. /**
  2647. * Trigger for the action
  2648. */
  2649. trigger: number;
  2650. /**
  2651. * Internal only - manager for action
  2652. * @hidden
  2653. */
  2654. _actionManager: ActionManager;
  2655. private _nextActiveAction;
  2656. private _child;
  2657. private _condition?;
  2658. private _triggerParameter;
  2659. /**
  2660. * An event triggered prior to action being executed.
  2661. */
  2662. onBeforeExecuteObservable: Observable<Action>;
  2663. /**
  2664. * Creates a new Action
  2665. * @param triggerOptions the trigger, with or without parameters, for the action
  2666. * @param condition an optional determinant of action
  2667. */
  2668. constructor(
  2669. /** the trigger, with or without parameters, for the action */
  2670. triggerOptions: any, condition?: Condition);
  2671. /**
  2672. * Internal only
  2673. * @hidden
  2674. */
  2675. _prepare(): void;
  2676. /**
  2677. * Gets the trigger parameters
  2678. * @returns the trigger parameters
  2679. */
  2680. getTriggerParameter(): any;
  2681. /**
  2682. * Internal only - executes current action event
  2683. * @hidden
  2684. */
  2685. _executeCurrent(evt?: ActionEvent): void;
  2686. /**
  2687. * Execute placeholder for child classes
  2688. * @param evt optional action event
  2689. */
  2690. execute(evt?: ActionEvent): void;
  2691. /**
  2692. * Skips to next active action
  2693. */
  2694. skipToNextActiveAction(): void;
  2695. /**
  2696. * Adds action to chain of actions, may be a DoNothingAction
  2697. * @param action defines the next action to execute
  2698. * @returns The action passed in
  2699. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2700. */
  2701. then(action: Action): Action;
  2702. /**
  2703. * Internal only
  2704. * @hidden
  2705. */
  2706. _getProperty(propertyPath: string): string;
  2707. /**
  2708. * Internal only
  2709. * @hidden
  2710. */
  2711. _getEffectiveTarget(target: any, propertyPath: string): any;
  2712. /**
  2713. * Serialize placeholder for child classes
  2714. * @param parent of child
  2715. * @returns the serialized object
  2716. */
  2717. serialize(parent: any): any;
  2718. /**
  2719. * Internal only called by serialize
  2720. * @hidden
  2721. */
  2722. protected _serialize(serializedAction: any, parent?: any): any;
  2723. /**
  2724. * Internal only
  2725. * @hidden
  2726. */
  2727. static _SerializeValueAsString: (value: any) => string;
  2728. /**
  2729. * Internal only
  2730. * @hidden
  2731. */
  2732. static _GetTargetProperty: (target: Scene | Node) => {
  2733. name: string;
  2734. targetType: string;
  2735. value: string;
  2736. };
  2737. }
  2738. }
  2739. declare module BABYLON {
  2740. /**
  2741. * ActionEvent is the event being sent when an action is triggered.
  2742. */
  2743. class ActionEvent {
  2744. /** The mesh or sprite that triggered the action */
  2745. source: any;
  2746. /** The X mouse cursor position at the time of the event */
  2747. pointerX: number;
  2748. /** The Y mouse cursor position at the time of the event */
  2749. pointerY: number;
  2750. /** The mesh that is currently pointed at (can be null) */
  2751. meshUnderPointer: Nullable<AbstractMesh>;
  2752. /** the original (browser) event that triggered the ActionEvent */
  2753. sourceEvent: any;
  2754. /** additional data for the event */
  2755. additionalData: any;
  2756. /**
  2757. * Creates a new ActionEvent
  2758. * @param source The mesh or sprite that triggered the action
  2759. * @param pointerX The X mouse cursor position at the time of the event
  2760. * @param pointerY The Y mouse cursor position at the time of the event
  2761. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2762. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2763. * @param additionalData additional data for the event
  2764. */
  2765. constructor(
  2766. /** The mesh or sprite that triggered the action */
  2767. source: any,
  2768. /** The X mouse cursor position at the time of the event */
  2769. pointerX: number,
  2770. /** The Y mouse cursor position at the time of the event */
  2771. pointerY: number,
  2772. /** The mesh that is currently pointed at (can be null) */
  2773. meshUnderPointer: Nullable<AbstractMesh>,
  2774. /** the original (browser) event that triggered the ActionEvent */
  2775. sourceEvent?: any,
  2776. /** additional data for the event */
  2777. additionalData?: any);
  2778. /**
  2779. * Helper function to auto-create an ActionEvent from a source mesh.
  2780. * @param source The source mesh that triggered the event
  2781. * @param evt The original (browser) event
  2782. * @param additionalData additional data for the event
  2783. * @returns the new ActionEvent
  2784. */
  2785. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2786. /**
  2787. * Helper function to auto-create an ActionEvent from a source sprite
  2788. * @param source The source sprite that triggered the event
  2789. * @param scene Scene associated with the sprite
  2790. * @param evt The original (browser) event
  2791. * @param additionalData additional data for the event
  2792. * @returns the new ActionEvent
  2793. */
  2794. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2795. /**
  2796. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2797. * @param scene the scene where the event occurred
  2798. * @param evt The original (browser) event
  2799. * @returns the new ActionEvent
  2800. */
  2801. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2802. /**
  2803. * Helper function to auto-create an ActionEvent from a primitive
  2804. * @param prim defines the target primitive
  2805. * @param pointerPos defines the pointer position
  2806. * @param evt The original (browser) event
  2807. * @param additionalData additional data for the event
  2808. * @returns the new ActionEvent
  2809. */
  2810. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2811. }
  2812. /**
  2813. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2814. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2816. */
  2817. class ActionManager {
  2818. private static _NothingTrigger;
  2819. private static _OnPickTrigger;
  2820. private static _OnLeftPickTrigger;
  2821. private static _OnRightPickTrigger;
  2822. private static _OnCenterPickTrigger;
  2823. private static _OnPickDownTrigger;
  2824. private static _OnDoublePickTrigger;
  2825. private static _OnPickUpTrigger;
  2826. private static _OnLongPressTrigger;
  2827. private static _OnPointerOverTrigger;
  2828. private static _OnPointerOutTrigger;
  2829. private static _OnEveryFrameTrigger;
  2830. private static _OnIntersectionEnterTrigger;
  2831. private static _OnIntersectionExitTrigger;
  2832. private static _OnKeyDownTrigger;
  2833. private static _OnKeyUpTrigger;
  2834. private static _OnPickOutTrigger;
  2835. /**
  2836. * Nothing
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly NothingTrigger: number;
  2840. /**
  2841. * On pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnPickTrigger: number;
  2845. /**
  2846. * On left pick
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnLeftPickTrigger: number;
  2850. /**
  2851. * On right pick
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnRightPickTrigger: number;
  2855. /**
  2856. * On center pick
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnCenterPickTrigger: number;
  2860. /**
  2861. * On pick down
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnPickDownTrigger: number;
  2865. /**
  2866. * On double pick
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnDoublePickTrigger: number;
  2870. /**
  2871. * On pick up
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnPickUpTrigger: number;
  2875. /**
  2876. * On pick out.
  2877. * This trigger will only be raised if you also declared a OnPickDown
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnPickOutTrigger: number;
  2881. /**
  2882. * On long press
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnLongPressTrigger: number;
  2886. /**
  2887. * On pointer over
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnPointerOverTrigger: number;
  2891. /**
  2892. * On pointer out
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnPointerOutTrigger: number;
  2896. /**
  2897. * On every frame
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly OnEveryFrameTrigger: number;
  2901. /**
  2902. * On intersection enter
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnIntersectionEnterTrigger: number;
  2906. /**
  2907. * On intersection exit
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnIntersectionExitTrigger: number;
  2911. /**
  2912. * On key down
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnKeyDownTrigger: number;
  2916. /**
  2917. * On key up
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnKeyUpTrigger: number;
  2921. /** Gets the list of active triggers */
  2922. static Triggers: {
  2923. [key: string]: number;
  2924. };
  2925. /** Gets the list of actions */
  2926. actions: Action[];
  2927. /** Gets the cursor to use when hovering items */
  2928. hoverCursor: string;
  2929. private _scene;
  2930. /**
  2931. * Creates a new action manager
  2932. * @param scene defines the hosting scene
  2933. */
  2934. constructor(scene: Scene);
  2935. /**
  2936. * Releases all associated resources
  2937. */
  2938. dispose(): void;
  2939. /**
  2940. * Gets hosting scene
  2941. * @returns the hosting scene
  2942. */
  2943. getScene(): Scene;
  2944. /**
  2945. * Does this action manager handles actions of any of the given triggers
  2946. * @param triggers defines the triggers to be tested
  2947. * @return a boolean indicating whether one (or more) of the triggers is handled
  2948. */
  2949. hasSpecificTriggers(triggers: number[]): boolean;
  2950. /**
  2951. * Does this action manager handles actions of a given trigger
  2952. * @param trigger defines the trigger to be tested
  2953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2954. * @return whether the trigger is handled
  2955. */
  2956. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2957. /**
  2958. * Does this action manager has pointer triggers
  2959. */
  2960. readonly hasPointerTriggers: boolean;
  2961. /**
  2962. * Does this action manager has pick triggers
  2963. */
  2964. readonly hasPickTriggers: boolean;
  2965. /**
  2966. * Does exist one action manager with at least one trigger
  2967. **/
  2968. static readonly HasTriggers: boolean;
  2969. /**
  2970. * Does exist one action manager with at least one pick trigger
  2971. **/
  2972. static readonly HasPickTriggers: boolean;
  2973. /**
  2974. * Does exist one action manager that handles actions of a given trigger
  2975. * @param trigger defines the trigger to be tested
  2976. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2977. **/
  2978. static HasSpecificTrigger(trigger: number): boolean;
  2979. /**
  2980. * Registers an action to this action manager
  2981. * @param action defines the action to be registered
  2982. * @return the action amended (prepared) after registration
  2983. */
  2984. registerAction(action: Action): Nullable<Action>;
  2985. /**
  2986. * Unregisters an action to this action manager
  2987. * @param action defines the action to be unregistered
  2988. * @return a boolean indicating whether the action has been unregistered
  2989. */
  2990. unregisterAction(action: Action): Boolean;
  2991. /**
  2992. * Process a specific trigger
  2993. * @param trigger defines the trigger to process
  2994. * @param evt defines the event details to be processed
  2995. */
  2996. processTrigger(trigger: number, evt?: ActionEvent): void;
  2997. /** @hidden */
  2998. _getEffectiveTarget(target: any, propertyPath: string): any;
  2999. /** @hidden */
  3000. _getProperty(propertyPath: string): string;
  3001. /**
  3002. * Serialize this manager to a JSON object
  3003. * @param name defines the property name to store this manager
  3004. * @returns a JSON representation of this manager
  3005. */
  3006. serialize(name: string): any;
  3007. /**
  3008. * Creates a new ActionManager from a JSON data
  3009. * @param parsedActions defines the JSON data to read from
  3010. * @param object defines the hosting mesh
  3011. * @param scene defines the hosting scene
  3012. */
  3013. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3014. /**
  3015. * Get a trigger name by index
  3016. * @param trigger defines the trigger index
  3017. * @returns a trigger name
  3018. */
  3019. static GetTriggerName(trigger: number): string;
  3020. }
  3021. }
  3022. declare module BABYLON {
  3023. /**
  3024. * A Condition applied to an Action
  3025. */
  3026. class Condition {
  3027. /**
  3028. * Internal only - manager for action
  3029. * @hidden
  3030. */
  3031. _actionManager: ActionManager;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _evaluationId: number;
  3037. /**
  3038. * Internal only
  3039. * @hidden
  3040. */
  3041. _currentResult: boolean;
  3042. /**
  3043. * Creates a new Condition
  3044. * @param actionManager the manager of the action the condition is applied to
  3045. */
  3046. constructor(actionManager: ActionManager);
  3047. /**
  3048. * Check if the current condition is valid
  3049. * @returns a boolean
  3050. */
  3051. isValid(): boolean;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getProperty(propertyPath: string): string;
  3057. /**
  3058. * Internal only
  3059. * @hidden
  3060. */
  3061. _getEffectiveTarget(target: any, propertyPath: string): any;
  3062. /**
  3063. * Serialize placeholder for child classes
  3064. * @returns the serialized object
  3065. */
  3066. serialize(): any;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. protected _serialize(serializedCondition: any): any;
  3072. }
  3073. /**
  3074. * Defines specific conditional operators as extensions of Condition
  3075. */
  3076. class ValueCondition extends Condition {
  3077. /** path to specify the property of the target the conditional operator uses */
  3078. propertyPath: string;
  3079. /** the value compared by the conditional operator against the current value of the property */
  3080. value: any;
  3081. /** the conditional operator, default ValueCondition.IsEqual */
  3082. operator: number;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsEqual;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsDifferent;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsGreater;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private static _IsLesser;
  3103. /**
  3104. * returns the number for IsEqual
  3105. */
  3106. static readonly IsEqual: number;
  3107. /**
  3108. * Returns the number for IsDifferent
  3109. */
  3110. static readonly IsDifferent: number;
  3111. /**
  3112. * Returns the number for IsGreater
  3113. */
  3114. static readonly IsGreater: number;
  3115. /**
  3116. * Returns the number for IsLesser
  3117. */
  3118. static readonly IsLesser: number;
  3119. /**
  3120. * Internal only The action manager for the condition
  3121. * @hidden
  3122. */
  3123. _actionManager: ActionManager;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _target;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _effectiveTarget;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. private _property;
  3139. /**
  3140. * Creates a new ValueCondition
  3141. * @param actionManager manager for the action the condition applies to
  3142. * @param target for the action
  3143. * @param propertyPath path to specify the property of the target the conditional operator uses
  3144. * @param value the value compared by the conditional operator against the current value of the property
  3145. * @param operator the conditional operator, default ValueCondition.IsEqual
  3146. */
  3147. constructor(actionManager: ActionManager, target: any,
  3148. /** path to specify the property of the target the conditional operator uses */
  3149. propertyPath: string,
  3150. /** the value compared by the conditional operator against the current value of the property */
  3151. value: any,
  3152. /** the conditional operator, default ValueCondition.IsEqual */
  3153. operator?: number);
  3154. /**
  3155. * Compares the given value with the property value for the specified conditional operator
  3156. * @returns the result of the comparison
  3157. */
  3158. isValid(): boolean;
  3159. /**
  3160. * Serialize the ValueCondition into a JSON compatible object
  3161. * @returns serialization object
  3162. */
  3163. serialize(): any;
  3164. /**
  3165. * Gets the name of the conditional operator for the ValueCondition
  3166. * @param operator the conditional operator
  3167. * @returns the name
  3168. */
  3169. static GetOperatorName(operator: number): string;
  3170. }
  3171. /**
  3172. * Defines a predicate condition as an extension of Condition
  3173. */
  3174. class PredicateCondition extends Condition {
  3175. /** defines the predicate function used to validate the condition */
  3176. predicate: () => boolean;
  3177. /**
  3178. * Internal only - manager for action
  3179. * @hidden
  3180. */
  3181. _actionManager: ActionManager;
  3182. /**
  3183. * Creates a new PredicateCondition
  3184. * @param actionManager manager for the action the condition applies to
  3185. * @param predicate defines the predicate function used to validate the condition
  3186. */
  3187. constructor(actionManager: ActionManager,
  3188. /** defines the predicate function used to validate the condition */
  3189. predicate: () => boolean);
  3190. /**
  3191. * @returns the validity of the predicate condition
  3192. */
  3193. isValid(): boolean;
  3194. }
  3195. /**
  3196. * Defines a state condition as an extension of Condition
  3197. */
  3198. class StateCondition extends Condition {
  3199. value: string;
  3200. /**
  3201. * Internal only - manager for action
  3202. * @hidden
  3203. */
  3204. _actionManager: ActionManager;
  3205. /**
  3206. * Internal only
  3207. * @hidden
  3208. */
  3209. private _target;
  3210. /**
  3211. * Creates a new StateCondition
  3212. * @param actionManager manager for the action the condition applies to
  3213. * @param target of the condition
  3214. * @param value to compare with target state
  3215. */
  3216. constructor(actionManager: ActionManager, target: any, value: string);
  3217. /**
  3218. * @returns the validity of the state
  3219. */
  3220. isValid(): boolean;
  3221. /**
  3222. * Serialize the StateCondition into a JSON compatible object
  3223. * @returns serialization object
  3224. */
  3225. serialize(): any;
  3226. }
  3227. }
  3228. declare module BABYLON {
  3229. class SwitchBooleanAction extends Action {
  3230. propertyPath: string;
  3231. private _target;
  3232. private _effectiveTarget;
  3233. private _property;
  3234. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3235. _prepare(): void;
  3236. execute(): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class SetStateAction extends Action {
  3240. value: string;
  3241. private _target;
  3242. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3243. execute(): void;
  3244. serialize(parent: any): any;
  3245. }
  3246. class SetValueAction extends Action {
  3247. propertyPath: string;
  3248. value: any;
  3249. private _target;
  3250. private _effectiveTarget;
  3251. private _property;
  3252. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3253. _prepare(): void;
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class IncrementValueAction extends Action {
  3258. propertyPath: string;
  3259. value: any;
  3260. private _target;
  3261. private _effectiveTarget;
  3262. private _property;
  3263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3264. _prepare(): void;
  3265. execute(): void;
  3266. serialize(parent: any): any;
  3267. }
  3268. class PlayAnimationAction extends Action {
  3269. from: number;
  3270. to: number;
  3271. loop: boolean | undefined;
  3272. private _target;
  3273. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3274. _prepare(): void;
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class StopAnimationAction extends Action {
  3279. private _target;
  3280. constructor(triggerOptions: any, target: any, condition?: Condition);
  3281. _prepare(): void;
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class DoNothingAction extends Action {
  3286. constructor(triggerOptions?: any, condition?: Condition);
  3287. execute(): void;
  3288. serialize(parent: any): any;
  3289. }
  3290. class CombineAction extends Action {
  3291. children: Action[];
  3292. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3293. _prepare(): void;
  3294. execute(evt: ActionEvent): void;
  3295. serialize(parent: any): any;
  3296. }
  3297. class ExecuteCodeAction extends Action {
  3298. func: (evt: ActionEvent) => void;
  3299. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3300. execute(evt: ActionEvent): void;
  3301. }
  3302. class SetParentAction extends Action {
  3303. private _parent;
  3304. private _target;
  3305. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3306. _prepare(): void;
  3307. execute(): void;
  3308. serialize(parent: any): any;
  3309. }
  3310. class PlaySoundAction extends Action {
  3311. private _sound;
  3312. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3313. _prepare(): void;
  3314. execute(): void;
  3315. serialize(parent: any): any;
  3316. }
  3317. class StopSoundAction extends Action {
  3318. private _sound;
  3319. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3320. _prepare(): void;
  3321. execute(): void;
  3322. serialize(parent: any): any;
  3323. }
  3324. }
  3325. declare module BABYLON {
  3326. class InterpolateValueAction extends Action {
  3327. propertyPath: string;
  3328. value: any;
  3329. duration: number;
  3330. stopOtherAnimations: boolean | undefined;
  3331. onInterpolationDone: (() => void) | undefined;
  3332. private _target;
  3333. private _effectiveTarget;
  3334. private _property;
  3335. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3337. _prepare(): void;
  3338. execute(): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. }
  3342. declare module BABYLON {
  3343. class Animatable {
  3344. target: any;
  3345. fromFrame: number;
  3346. toFrame: number;
  3347. loopAnimation: boolean;
  3348. onAnimationEnd: (() => void) | null | undefined;
  3349. private _localDelayOffset;
  3350. private _pausedDelay;
  3351. private _runtimeAnimations;
  3352. private _paused;
  3353. private _scene;
  3354. private _speedRatio;
  3355. private _weight;
  3356. private _syncRoot;
  3357. animationStarted: boolean;
  3358. /**
  3359. * Observer raised when the animation ends
  3360. */
  3361. onAnimationEndObservable: Observable<Animatable>;
  3362. /**
  3363. * Gets the root Animatable used to synchronize and normalize animations
  3364. */
  3365. readonly syncRoot: Animatable;
  3366. /**
  3367. * Gets the current frame of the first RuntimeAnimation
  3368. * Used to synchronize Animatables
  3369. */
  3370. readonly masterFrame: number;
  3371. /**
  3372. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3373. */
  3374. weight: number;
  3375. /**
  3376. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3377. */
  3378. speedRatio: number;
  3379. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3380. /**
  3381. * Synchronize and normalize current Animatable with a source Animatable
  3382. * This is useful when using animation weights and when animations are not of the same length
  3383. * @param root defines the root Animatable to synchronize with
  3384. * @returns the current Animatable
  3385. */
  3386. syncWith(root: Animatable): Animatable;
  3387. getAnimations(): RuntimeAnimation[];
  3388. appendAnimations(target: any, animations: Animation[]): void;
  3389. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3390. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3391. reset(): void;
  3392. enableBlending(blendingSpeed: number): void;
  3393. disableBlending(): void;
  3394. goToFrame(frame: number): void;
  3395. pause(): void;
  3396. restart(): void;
  3397. private _raiseOnAnimationEnd();
  3398. stop(animationName?: string): void;
  3399. /**
  3400. * Wait asynchronously for the animation to end
  3401. * @returns a promise which will be fullfilled when the animation ends
  3402. */
  3403. waitAsync(): Promise<Animatable>;
  3404. /** @hidden */
  3405. _animate(delay: number): boolean;
  3406. }
  3407. }
  3408. declare module BABYLON {
  3409. /**
  3410. * Represents the range of an animation
  3411. */
  3412. class AnimationRange {
  3413. /**The name of the animation range**/
  3414. name: string;
  3415. /**The starting frame of the animation */
  3416. from: number;
  3417. /**The ending frame of the animation*/
  3418. to: number;
  3419. /**
  3420. * Initializes the range of an animation
  3421. * @param name The name of the animation range
  3422. * @param from The starting frame of the animation
  3423. * @param to The ending frame of the animation
  3424. */
  3425. constructor(
  3426. /**The name of the animation range**/
  3427. name: string,
  3428. /**The starting frame of the animation */
  3429. from: number,
  3430. /**The ending frame of the animation*/
  3431. to: number);
  3432. /**
  3433. * Makes a copy of the animation range
  3434. * @returns A copy of the animation range
  3435. */
  3436. clone(): AnimationRange;
  3437. }
  3438. /**
  3439. * Composed of a frame, and an action function
  3440. */
  3441. class AnimationEvent {
  3442. /** The frame for which the event is triggered **/
  3443. frame: number;
  3444. /** The event to perform when triggered **/
  3445. action: () => void;
  3446. /** Specifies if the event should be triggered only once**/
  3447. onlyOnce: boolean | undefined;
  3448. /**
  3449. * Specifies if the animation event is done
  3450. */
  3451. isDone: boolean;
  3452. /**
  3453. * Initializes the animation event
  3454. * @param frame The frame for which the event is triggered
  3455. * @param action The event to perform when triggered
  3456. * @param onlyOnce Specifies if the event should be triggered only once
  3457. */
  3458. constructor(
  3459. /** The frame for which the event is triggered **/
  3460. frame: number,
  3461. /** The event to perform when triggered **/
  3462. action: () => void,
  3463. /** Specifies if the event should be triggered only once**/
  3464. onlyOnce?: boolean | undefined);
  3465. /** @hidden */
  3466. _clone(): AnimationEvent;
  3467. }
  3468. /**
  3469. * A cursor which tracks a point on a path
  3470. */
  3471. class PathCursor {
  3472. private path;
  3473. /**
  3474. * Stores path cursor callbacks for when an onchange event is triggered
  3475. */
  3476. private _onchange;
  3477. /**
  3478. * The value of the path cursor
  3479. */
  3480. value: number;
  3481. /**
  3482. * The animation array of the path cursor
  3483. */
  3484. animations: Animation[];
  3485. /**
  3486. * Initializes the path cursor
  3487. * @param path The path to track
  3488. */
  3489. constructor(path: Path2);
  3490. /**
  3491. * Gets the cursor point on the path
  3492. * @returns A point on the path cursor at the cursor location
  3493. */
  3494. getPoint(): Vector3;
  3495. /**
  3496. * Moves the cursor ahead by the step amount
  3497. * @param step The amount to move the cursor forward
  3498. * @returns This path cursor
  3499. */
  3500. moveAhead(step?: number): PathCursor;
  3501. /**
  3502. * Moves the cursor behind by the step amount
  3503. * @param step The amount to move the cursor back
  3504. * @returns This path cursor
  3505. */
  3506. moveBack(step?: number): PathCursor;
  3507. /**
  3508. * Moves the cursor by the step amount
  3509. * If the step amount is greater than one, an exception is thrown
  3510. * @param step The amount to move the cursor
  3511. * @returns This path cursor
  3512. */
  3513. move(step: number): PathCursor;
  3514. /**
  3515. * Ensures that the value is limited between zero and one
  3516. * @returns This path cursor
  3517. */
  3518. private ensureLimits();
  3519. /**
  3520. * Runs onchange callbacks on change (used by the animation engine)
  3521. * @returns This path cursor
  3522. */
  3523. private raiseOnChange();
  3524. /**
  3525. * Executes a function on change
  3526. * @param f A path cursor onchange callback
  3527. * @returns This path cursor
  3528. */
  3529. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3530. }
  3531. /**
  3532. * Defines an interface which represents an animation key frame
  3533. */
  3534. interface IAnimationKey {
  3535. /**
  3536. * Frame of the key frame
  3537. */
  3538. frame: number;
  3539. /**
  3540. * Value at the specifies key frame
  3541. */
  3542. value: any;
  3543. /**
  3544. * The input tangent for the cubic hermite spline
  3545. */
  3546. inTangent?: any;
  3547. /**
  3548. * The output tangent for the cubic hermite spline
  3549. */
  3550. outTangent?: any;
  3551. /**
  3552. * The animation interpolation type
  3553. */
  3554. interpolation?: AnimationKeyInterpolation;
  3555. }
  3556. /**
  3557. * Enum for the animation key frame interpolation type
  3558. */
  3559. enum AnimationKeyInterpolation {
  3560. /**
  3561. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3562. */
  3563. STEP = 1,
  3564. }
  3565. /**
  3566. * Class used to store any kind of animation
  3567. */
  3568. class Animation {
  3569. /**Name of the animation */
  3570. name: string;
  3571. /**Property to animate */
  3572. targetProperty: string;
  3573. /**The frames per second of the animation */
  3574. framePerSecond: number;
  3575. /**The data type of the animation */
  3576. dataType: number;
  3577. /**The loop mode of the animation */
  3578. loopMode: number | undefined;
  3579. /**Specifies if blending should be enabled */
  3580. enableBlending: boolean | undefined;
  3581. /**
  3582. * Use matrix interpolation instead of using direct key value when animating matrices
  3583. */
  3584. static AllowMatricesInterpolation: boolean;
  3585. /**
  3586. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3587. */
  3588. static AllowMatrixDecomposeForInterpolation: boolean;
  3589. /**
  3590. * Stores the key frames of the animation
  3591. */
  3592. private _keys;
  3593. /**
  3594. * Stores the easing function of the animation
  3595. */
  3596. private _easingFunction;
  3597. /**
  3598. * @hidden Internal use only
  3599. */
  3600. _runtimeAnimations: RuntimeAnimation[];
  3601. /**
  3602. * The set of event that will be linked to this animation
  3603. */
  3604. private _events;
  3605. /**
  3606. * Stores an array of target property paths
  3607. */
  3608. targetPropertyPath: string[];
  3609. /**
  3610. * Stores the blending speed of the animation
  3611. */
  3612. blendingSpeed: number;
  3613. /**
  3614. * Stores the animation ranges for the animation
  3615. */
  3616. private _ranges;
  3617. /**
  3618. * @hidden Internal use
  3619. */
  3620. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3621. /**
  3622. * Sets up an animation
  3623. * @param property The property to animate
  3624. * @param animationType The animation type to apply
  3625. * @param framePerSecond The frames per second of the animation
  3626. * @param easingFunction The easing function used in the animation
  3627. * @returns The created animation
  3628. */
  3629. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3630. /**
  3631. * Create and start an animation on a node
  3632. * @param name defines the name of the global animation that will be run on all nodes
  3633. * @param node defines the root node where the animation will take place
  3634. * @param targetProperty defines property to animate
  3635. * @param framePerSecond defines the number of frame per second yo use
  3636. * @param totalFrame defines the number of frames in total
  3637. * @param from defines the initial value
  3638. * @param to defines the final value
  3639. * @param loopMode defines which loop mode you want to use (off by default)
  3640. * @param easingFunction defines the easing function to use (linear by default)
  3641. * @param onAnimationEnd defines the callback to call when animation end
  3642. * @returns the animatable created for this animation
  3643. */
  3644. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3645. /**
  3646. * Create and start an animation on a node and its descendants
  3647. * @param name defines the name of the global animation that will be run on all nodes
  3648. * @param node defines the root node where the animation will take place
  3649. * @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
  3650. * @param targetProperty defines property to animate
  3651. * @param framePerSecond defines the number of frame per second to use
  3652. * @param totalFrame defines the number of frames in total
  3653. * @param from defines the initial value
  3654. * @param to defines the final value
  3655. * @param loopMode defines which loop mode you want to use (off by default)
  3656. * @param easingFunction defines the easing function to use (linear by default)
  3657. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3658. * @returns the list of animatables created for all nodes
  3659. * @example https://www.babylonjs-playground.com/#MH0VLI
  3660. */
  3661. 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[]>;
  3662. /**
  3663. * Creates a new animation, merges it with the existing animations and starts it
  3664. * @param name Name of the animation
  3665. * @param node Node which contains the scene that begins the animations
  3666. * @param targetProperty Specifies which property to animate
  3667. * @param framePerSecond The frames per second of the animation
  3668. * @param totalFrame The total number of frames
  3669. * @param from The frame at the beginning of the animation
  3670. * @param to The frame at the end of the animation
  3671. * @param loopMode Specifies the loop mode of the animation
  3672. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3673. * @param onAnimationEnd Callback to run once the animation is complete
  3674. * @returns Nullable animation
  3675. */
  3676. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3677. /**
  3678. * Transition property of an host to the target Value
  3679. * @param property The property to transition
  3680. * @param targetValue The target Value of the property
  3681. * @param host The object where the property to animate belongs
  3682. * @param scene Scene used to run the animation
  3683. * @param frameRate Framerate (in frame/s) to use
  3684. * @param transition The transition type we want to use
  3685. * @param duration The duration of the animation, in milliseconds
  3686. * @param onAnimationEnd Callback trigger at the end of the animation
  3687. * @returns Nullable animation
  3688. */
  3689. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3690. /**
  3691. * Return the array of runtime animations currently using this animation
  3692. */
  3693. readonly runtimeAnimations: RuntimeAnimation[];
  3694. /**
  3695. * Specifies if any of the runtime animations are currently running
  3696. */
  3697. readonly hasRunningRuntimeAnimations: boolean;
  3698. /**
  3699. * Initializes the animation
  3700. * @param name Name of the animation
  3701. * @param targetProperty Property to animate
  3702. * @param framePerSecond The frames per second of the animation
  3703. * @param dataType The data type of the animation
  3704. * @param loopMode The loop mode of the animation
  3705. * @param enableBlendings Specifies if blending should be enabled
  3706. */
  3707. constructor(
  3708. /**Name of the animation */
  3709. name: string,
  3710. /**Property to animate */
  3711. targetProperty: string,
  3712. /**The frames per second of the animation */
  3713. framePerSecond: number,
  3714. /**The data type of the animation */
  3715. dataType: number,
  3716. /**The loop mode of the animation */
  3717. loopMode?: number | undefined,
  3718. /**Specifies if blending should be enabled */
  3719. enableBlending?: boolean | undefined);
  3720. /**
  3721. * Converts the animation to a string
  3722. * @param fullDetails support for multiple levels of logging within scene loading
  3723. * @returns String form of the animation
  3724. */
  3725. toString(fullDetails?: boolean): string;
  3726. /**
  3727. * Add an event to this animation
  3728. * @param event Event to add
  3729. */
  3730. addEvent(event: AnimationEvent): void;
  3731. /**
  3732. * Remove all events found at the given frame
  3733. * @param frame The frame to remove events from
  3734. */
  3735. removeEvents(frame: number): void;
  3736. /**
  3737. * Retrieves all the events from the animation
  3738. * @returns Events from the animation
  3739. */
  3740. getEvents(): AnimationEvent[];
  3741. /**
  3742. * Creates an animation range
  3743. * @param name Name of the animation range
  3744. * @param from Starting frame of the animation range
  3745. * @param to Ending frame of the animation
  3746. */
  3747. createRange(name: string, from: number, to: number): void;
  3748. /**
  3749. * Deletes an animation range by name
  3750. * @param name Name of the animation range to delete
  3751. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3752. */
  3753. deleteRange(name: string, deleteFrames?: boolean): void;
  3754. /**
  3755. * Gets the animation range by name, or null if not defined
  3756. * @param name Name of the animation range
  3757. * @returns Nullable animation range
  3758. */
  3759. getRange(name: string): Nullable<AnimationRange>;
  3760. /**
  3761. * Gets the key frames from the animation
  3762. * @returns The key frames of the animation
  3763. */
  3764. getKeys(): Array<IAnimationKey>;
  3765. /**
  3766. * Gets the highest frame rate of the animation
  3767. * @returns Highest frame rate of the animation
  3768. */
  3769. getHighestFrame(): number;
  3770. /**
  3771. * Gets the easing function of the animation
  3772. * @returns Easing function of the animation
  3773. */
  3774. getEasingFunction(): IEasingFunction;
  3775. /**
  3776. * Sets the easing function of the animation
  3777. * @param easingFunction A custom mathematical formula for animation
  3778. */
  3779. setEasingFunction(easingFunction: EasingFunction): void;
  3780. /**
  3781. * Interpolates a scalar linearly
  3782. * @param startValue Start value of the animation curve
  3783. * @param endValue End value of the animation curve
  3784. * @param gradient Scalar amount to interpolate
  3785. * @returns Interpolated scalar value
  3786. */
  3787. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3788. /**
  3789. * Interpolates a scalar cubically
  3790. * @param startValue Start value of the animation curve
  3791. * @param outTangent End tangent of the animation
  3792. * @param endValue End value of the animation curve
  3793. * @param inTangent Start tangent of the animation curve
  3794. * @param gradient Scalar amount to interpolate
  3795. * @returns Interpolated scalar value
  3796. */
  3797. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3798. /**
  3799. * Interpolates a quaternion using a spherical linear interpolation
  3800. * @param startValue Start value of the animation curve
  3801. * @param endValue End value of the animation curve
  3802. * @param gradient Scalar amount to interpolate
  3803. * @returns Interpolated quaternion value
  3804. */
  3805. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3806. /**
  3807. * Interpolates a quaternion cubically
  3808. * @param startValue Start value of the animation curve
  3809. * @param outTangent End tangent of the animation curve
  3810. * @param endValue End value of the animation curve
  3811. * @param inTangent Start tangent of the animation curve
  3812. * @param gradient Scalar amount to interpolate
  3813. * @returns Interpolated quaternion value
  3814. */
  3815. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3816. /**
  3817. * Interpolates a Vector3 linearl
  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 scalar value
  3822. */
  3823. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3824. /**
  3825. * Interpolates a Vector3 cubically
  3826. * @param startValue Start value of the animation curve
  3827. * @param outTangent End tangent of the animation
  3828. * @param endValue End value of the animation curve
  3829. * @param inTangent Start tangent of the animation curve
  3830. * @param gradient Scalar amount to interpolate
  3831. * @returns InterpolatedVector3 value
  3832. */
  3833. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3834. /**
  3835. * Interpolates a Vector2 linearly
  3836. * @param startValue Start value of the animation curve
  3837. * @param endValue End value of the animation curve
  3838. * @param gradient Scalar amount to interpolate
  3839. * @returns Interpolated Vector2 value
  3840. */
  3841. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3842. /**
  3843. * Interpolates a Vector2 cubically
  3844. * @param startValue Start value of the animation curve
  3845. * @param outTangent End tangent of the animation
  3846. * @param endValue End value of the animation curve
  3847. * @param inTangent Start tangent of the animation curve
  3848. * @param gradient Scalar amount to interpolate
  3849. * @returns Interpolated Vector2 value
  3850. */
  3851. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3852. /**
  3853. * Interpolates a size linearly
  3854. * @param startValue Start value of the animation curve
  3855. * @param endValue End value of the animation curve
  3856. * @param gradient Scalar amount to interpolate
  3857. * @returns Interpolated Size value
  3858. */
  3859. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3860. /**
  3861. * Interpolates a Color3 linearly
  3862. * @param startValue Start value of the animation curve
  3863. * @param endValue End value of the animation curve
  3864. * @param gradient Scalar amount to interpolate
  3865. * @returns Interpolated Color3 value
  3866. */
  3867. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3868. /**
  3869. * @hidden Internal use only
  3870. */
  3871. _getKeyValue(value: any): any;
  3872. /**
  3873. * @hidden Internal use only
  3874. */
  3875. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3876. /**
  3877. * Defines the function to use to interpolate matrices
  3878. * @param startValue defines the start matrix
  3879. * @param endValue defines the end matrix
  3880. * @param gradient defines the gradient between both matrices
  3881. * @param result defines an optional target matrix where to store the interpolation
  3882. * @returns the interpolated matrix
  3883. */
  3884. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3885. /**
  3886. * Makes a copy of the animation
  3887. * @returns Cloned animation
  3888. */
  3889. clone(): Animation;
  3890. /**
  3891. * Sets the key frames of the animation
  3892. * @param values The animation key frames to set
  3893. */
  3894. setKeys(values: Array<IAnimationKey>): void;
  3895. /**
  3896. * Serializes the animation to an object
  3897. * @returns Serialized object
  3898. */
  3899. serialize(): any;
  3900. /**
  3901. * Float animation type
  3902. */
  3903. private static _ANIMATIONTYPE_FLOAT;
  3904. /**
  3905. * Vector3 animation type
  3906. */
  3907. private static _ANIMATIONTYPE_VECTOR3;
  3908. /**
  3909. * Quaternion animation type
  3910. */
  3911. private static _ANIMATIONTYPE_QUATERNION;
  3912. /**
  3913. * Matrix animation type
  3914. */
  3915. private static _ANIMATIONTYPE_MATRIX;
  3916. /**
  3917. * Color3 animation type
  3918. */
  3919. private static _ANIMATIONTYPE_COLOR3;
  3920. /**
  3921. * Vector2 animation type
  3922. */
  3923. private static _ANIMATIONTYPE_VECTOR2;
  3924. /**
  3925. * Size animation type
  3926. */
  3927. private static _ANIMATIONTYPE_SIZE;
  3928. /**
  3929. * Relative Loop Mode
  3930. */
  3931. private static _ANIMATIONLOOPMODE_RELATIVE;
  3932. /**
  3933. * Cycle Loop Mode
  3934. */
  3935. private static _ANIMATIONLOOPMODE_CYCLE;
  3936. /**
  3937. * Constant Loop Mode
  3938. */
  3939. private static _ANIMATIONLOOPMODE_CONSTANT;
  3940. /**
  3941. * Get the float animation type
  3942. */
  3943. static readonly ANIMATIONTYPE_FLOAT: number;
  3944. /**
  3945. * Get the Vector3 animation type
  3946. */
  3947. static readonly ANIMATIONTYPE_VECTOR3: number;
  3948. /**
  3949. * Get the Vectpr2 animation type
  3950. */
  3951. static readonly ANIMATIONTYPE_VECTOR2: number;
  3952. /**
  3953. * Get the Size animation type
  3954. */
  3955. static readonly ANIMATIONTYPE_SIZE: number;
  3956. /**
  3957. * Get the Quaternion animation type
  3958. */
  3959. static readonly ANIMATIONTYPE_QUATERNION: number;
  3960. /**
  3961. * Get the Matrix animation type
  3962. */
  3963. static readonly ANIMATIONTYPE_MATRIX: number;
  3964. /**
  3965. * Get the Color3 animation type
  3966. */
  3967. static readonly ANIMATIONTYPE_COLOR3: number;
  3968. /**
  3969. * Get the Relative Loop Mode
  3970. */
  3971. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3972. /**
  3973. * Get the Cycle Loop Mode
  3974. */
  3975. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3976. /**
  3977. * Get the Constant Loop Mode
  3978. */
  3979. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3980. /** @hidden */
  3981. static _UniversalLerp(left: any, right: any, amount: number): any;
  3982. /**
  3983. * Parses an animation object and creates an animation
  3984. * @param parsedAnimation Parsed animation object
  3985. * @returns Animation object
  3986. */
  3987. static Parse(parsedAnimation: any): Animation;
  3988. /**
  3989. * Appends the serialized animations from the source animations
  3990. * @param source Source containing the animations
  3991. * @param destination Target to store the animations
  3992. */
  3993. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3994. }
  3995. }
  3996. declare module BABYLON {
  3997. /**
  3998. * This class defines the direct association between an animation and a target
  3999. */
  4000. class TargetedAnimation {
  4001. animation: Animation;
  4002. target: any;
  4003. }
  4004. /**
  4005. * Use this class to create coordinated animations on multiple targets
  4006. */
  4007. class AnimationGroup implements IDisposable {
  4008. name: string;
  4009. private _scene;
  4010. private _targetedAnimations;
  4011. private _animatables;
  4012. private _from;
  4013. private _to;
  4014. private _isStarted;
  4015. private _speedRatio;
  4016. onAnimationEndObservable: Observable<TargetedAnimation>;
  4017. /**
  4018. * This observable will notify when all animations have ended.
  4019. */
  4020. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4021. /**
  4022. * Gets the first frame
  4023. */
  4024. readonly from: number;
  4025. /**
  4026. * Gets the last frame
  4027. */
  4028. readonly to: number;
  4029. /**
  4030. * Define if the animations are started
  4031. */
  4032. readonly isStarted: boolean;
  4033. /**
  4034. * Gets or sets the speed ratio to use for all animations
  4035. */
  4036. /**
  4037. * Gets or sets the speed ratio to use for all animations
  4038. */
  4039. speedRatio: number;
  4040. /**
  4041. * Gets the targeted animations for this animation group
  4042. */
  4043. readonly targetedAnimations: Array<TargetedAnimation>;
  4044. /**
  4045. * returning the list of animatables controlled by this animation group.
  4046. */
  4047. readonly animatables: Array<Animatable>;
  4048. constructor(name: string, scene?: Nullable<Scene>);
  4049. /**
  4050. * Add an animation (with its target) in the group
  4051. * @param animation defines the animation we want to add
  4052. * @param target defines the target of the animation
  4053. * @returns the {BABYLON.TargetedAnimation} object
  4054. */
  4055. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4056. /**
  4057. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4058. * It can add constant keys at begin or end
  4059. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4060. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4061. */
  4062. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4063. /**
  4064. * Start all animations on given targets
  4065. * @param loop defines if animations must loop
  4066. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4067. * @param from defines the from key (optional)
  4068. * @param to defines the to key (optional)
  4069. * @returns the current animation group
  4070. */
  4071. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4072. /**
  4073. * Pause all animations
  4074. */
  4075. pause(): AnimationGroup;
  4076. /**
  4077. * Play all animations to initial state
  4078. * This function will start() the animations if they were not started or will restart() them if they were paused
  4079. * @param loop defines if animations must loop
  4080. */
  4081. play(loop?: boolean): AnimationGroup;
  4082. /**
  4083. * Reset all animations to initial state
  4084. */
  4085. reset(): AnimationGroup;
  4086. /**
  4087. * Restart animations from key 0
  4088. */
  4089. restart(): AnimationGroup;
  4090. /**
  4091. * Stop all animations
  4092. */
  4093. stop(): AnimationGroup;
  4094. /**
  4095. * Set animation weight for all animatables
  4096. * @param weight defines the weight to use
  4097. * @return the animationGroup
  4098. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4099. */
  4100. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4101. /**
  4102. * Synchronize and normalize all animatables with a source animatable
  4103. * @param root defines the root animatable to synchronize with
  4104. * @return the animationGroup
  4105. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4106. */
  4107. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4108. /**
  4109. * Goes to a specific frame in this animation group
  4110. * @param frame the frame number to go to
  4111. * @return the animationGroup
  4112. */
  4113. goToFrame(frame: number): AnimationGroup;
  4114. /**
  4115. * Dispose all associated resources
  4116. */
  4117. dispose(): void;
  4118. private _checkAnimationGroupEnded(animatable);
  4119. }
  4120. }
  4121. declare module BABYLON {
  4122. /**
  4123. * Class used to override all child animations of a given target
  4124. */
  4125. class AnimationPropertiesOverride {
  4126. /**
  4127. * Gets or sets a value indicating if animation blending must be used
  4128. */
  4129. enableBlending: boolean;
  4130. /**
  4131. * Gets or sets the blending speed to use when enableBlending is true
  4132. */
  4133. blendingSpeed: number;
  4134. /**
  4135. * Gets or sets the default loop mode to use
  4136. */
  4137. loopMode: number;
  4138. }
  4139. }
  4140. declare module BABYLON {
  4141. interface IEasingFunction {
  4142. ease(gradient: number): number;
  4143. }
  4144. class EasingFunction implements IEasingFunction {
  4145. private static _EASINGMODE_EASEIN;
  4146. private static _EASINGMODE_EASEOUT;
  4147. private static _EASINGMODE_EASEINOUT;
  4148. static readonly EASINGMODE_EASEIN: number;
  4149. static readonly EASINGMODE_EASEOUT: number;
  4150. static readonly EASINGMODE_EASEINOUT: number;
  4151. private _easingMode;
  4152. setEasingMode(easingMode: number): void;
  4153. getEasingMode(): number;
  4154. easeInCore(gradient: number): number;
  4155. ease(gradient: number): number;
  4156. }
  4157. class CircleEase extends EasingFunction implements IEasingFunction {
  4158. easeInCore(gradient: number): number;
  4159. }
  4160. class BackEase extends EasingFunction implements IEasingFunction {
  4161. amplitude: number;
  4162. constructor(amplitude?: number);
  4163. easeInCore(gradient: number): number;
  4164. }
  4165. class BounceEase extends EasingFunction implements IEasingFunction {
  4166. bounces: number;
  4167. bounciness: number;
  4168. constructor(bounces?: number, bounciness?: number);
  4169. easeInCore(gradient: number): number;
  4170. }
  4171. class CubicEase extends EasingFunction implements IEasingFunction {
  4172. easeInCore(gradient: number): number;
  4173. }
  4174. class ElasticEase extends EasingFunction implements IEasingFunction {
  4175. oscillations: number;
  4176. springiness: number;
  4177. constructor(oscillations?: number, springiness?: number);
  4178. easeInCore(gradient: number): number;
  4179. }
  4180. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4181. exponent: number;
  4182. constructor(exponent?: number);
  4183. easeInCore(gradient: number): number;
  4184. }
  4185. class PowerEase extends EasingFunction implements IEasingFunction {
  4186. power: number;
  4187. constructor(power?: number);
  4188. easeInCore(gradient: number): number;
  4189. }
  4190. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4191. easeInCore(gradient: number): number;
  4192. }
  4193. class QuarticEase extends EasingFunction implements IEasingFunction {
  4194. easeInCore(gradient: number): number;
  4195. }
  4196. class QuinticEase extends EasingFunction implements IEasingFunction {
  4197. easeInCore(gradient: number): number;
  4198. }
  4199. class SineEase extends EasingFunction implements IEasingFunction {
  4200. easeInCore(gradient: number): number;
  4201. }
  4202. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4203. x1: number;
  4204. y1: number;
  4205. x2: number;
  4206. y2: number;
  4207. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4208. easeInCore(gradient: number): number;
  4209. }
  4210. }
  4211. declare module BABYLON {
  4212. /**
  4213. * Defines a runtime animation
  4214. */
  4215. class RuntimeAnimation {
  4216. private _events;
  4217. /**
  4218. * The current frame of the runtime animation
  4219. */
  4220. private _currentFrame;
  4221. /**
  4222. * The animation used by the runtime animation
  4223. */
  4224. private _animation;
  4225. /**
  4226. * The target of the runtime animation
  4227. */
  4228. private _target;
  4229. /**
  4230. * The initiating animatable
  4231. */
  4232. private _host;
  4233. /**
  4234. * The original value of the runtime animation
  4235. */
  4236. private _originalValue;
  4237. /**
  4238. * The original blend value of the runtime animation
  4239. */
  4240. private _originalBlendValue;
  4241. /**
  4242. * The offsets cache of the runtime animation
  4243. */
  4244. private _offsetsCache;
  4245. /**
  4246. * The high limits cache of the runtime animation
  4247. */
  4248. private _highLimitsCache;
  4249. /**
  4250. * Specifies if the runtime animation has been stopped
  4251. */
  4252. private _stopped;
  4253. /**
  4254. * The blending factor of the runtime animation
  4255. */
  4256. private _blendingFactor;
  4257. /**
  4258. * The BabylonJS scene
  4259. */
  4260. private _scene;
  4261. /**
  4262. * The current value of the runtime animation
  4263. */
  4264. private _currentValue;
  4265. /** @hidden */
  4266. _workValue: any;
  4267. /**
  4268. * The active target of the runtime animation
  4269. */
  4270. private _activeTarget;
  4271. /**
  4272. * The target path of the runtime animation
  4273. */
  4274. private _targetPath;
  4275. /**
  4276. * The weight of the runtime animation
  4277. */
  4278. private _weight;
  4279. /**
  4280. * The ratio offset of the runtime animation
  4281. */
  4282. private _ratioOffset;
  4283. /**
  4284. * The previous delay of the runtime animation
  4285. */
  4286. private _previousDelay;
  4287. /**
  4288. * The previous ratio of the runtime animation
  4289. */
  4290. private _previousRatio;
  4291. /**
  4292. * Gets the current frame of the runtime animation
  4293. */
  4294. readonly currentFrame: number;
  4295. /**
  4296. * Gets the weight of the runtime animation
  4297. */
  4298. readonly weight: number;
  4299. /**
  4300. * Gets the current value of the runtime animation
  4301. */
  4302. readonly currentValue: any;
  4303. /**
  4304. * Gets the target path of the runtime animation
  4305. */
  4306. readonly targetPath: string;
  4307. /**
  4308. * Gets the actual target of the runtime animation
  4309. */
  4310. readonly target: any;
  4311. /**
  4312. * Create a new RuntimeAnimation object
  4313. * @param target defines the target of the animation
  4314. * @param animation defines the source animation object
  4315. * @param scene defines the hosting scene
  4316. * @param host defines the initiating Animatable
  4317. */
  4318. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4319. /**
  4320. * Gets the animation from the runtime animation
  4321. */
  4322. readonly animation: Animation;
  4323. /**
  4324. * Resets the runtime animation to the beginning
  4325. * @param restoreOriginal defines whether to restore the target property to the original value
  4326. */
  4327. reset(restoreOriginal?: boolean): void;
  4328. /**
  4329. * Specifies if the runtime animation is stopped
  4330. * @returns Boolean specifying if the runtime animation is stopped
  4331. */
  4332. isStopped(): boolean;
  4333. /**
  4334. * Disposes of the runtime animation
  4335. */
  4336. dispose(): void;
  4337. /**
  4338. * Interpolates the animation from the current frame
  4339. * @param currentFrame The frame to interpolate the animation to
  4340. * @param repeatCount The number of times that the animation should loop
  4341. * @param loopMode The type of looping mode to use
  4342. * @param offsetValue Animation offset value
  4343. * @param highLimitValue The high limit value
  4344. * @returns The interpolated value
  4345. */
  4346. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4347. /**
  4348. * Apply the interpolated value to the target
  4349. * @param currentValue defines the value computed by the animation
  4350. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4351. */
  4352. setValue(currentValue: any, weight?: number): void;
  4353. private _setValue(target, currentValue, weight, targetIndex?);
  4354. /**
  4355. * Gets the loop pmode of the runtime animation
  4356. * @returns Loop Mode
  4357. */
  4358. private _getCorrectLoopMode();
  4359. /**
  4360. * Move the current animation to a given frame
  4361. * @param frame defines the frame to move to
  4362. */
  4363. goToFrame(frame: number): void;
  4364. /**
  4365. * @hidden Internal use only
  4366. */
  4367. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4368. /**
  4369. * Execute the current animation
  4370. * @param delay defines the delay to add to the current frame
  4371. * @param from defines the lower bound of the animation range
  4372. * @param to defines the upper bound of the animation range
  4373. * @param loop defines if the current animation must loop
  4374. * @param speedRatio defines the current speed ratio
  4375. * @param weight defines the weight of the animation (default is -1 so no weight)
  4376. * @returns a boolean indicating if the animation has ended
  4377. */
  4378. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4379. }
  4380. }
  4381. declare module BABYLON {
  4382. /**
  4383. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4385. */
  4386. class Analyser {
  4387. /**
  4388. * Gets or sets the smoothing
  4389. * @ignorenaming
  4390. */
  4391. SMOOTHING: number;
  4392. /**
  4393. * Gets or sets the FFT table size
  4394. * @ignorenaming
  4395. */
  4396. FFT_SIZE: number;
  4397. /**
  4398. * Gets or sets the bar graph amplitude
  4399. * @ignorenaming
  4400. */
  4401. BARGRAPHAMPLITUDE: number;
  4402. /**
  4403. * Gets or sets the position of the debug canvas
  4404. * @ignorenaming
  4405. */
  4406. DEBUGCANVASPOS: {
  4407. x: number;
  4408. y: number;
  4409. };
  4410. /**
  4411. * Gets or sets the debug canvas size
  4412. * @ignorenaming
  4413. */
  4414. DEBUGCANVASSIZE: {
  4415. width: number;
  4416. height: number;
  4417. };
  4418. private _byteFreqs;
  4419. private _byteTime;
  4420. private _floatFreqs;
  4421. private _webAudioAnalyser;
  4422. private _debugCanvas;
  4423. private _debugCanvasContext;
  4424. private _scene;
  4425. private _registerFunc;
  4426. private _audioEngine;
  4427. /**
  4428. * Creates a new analyser
  4429. * @param scene defines hosting scene
  4430. */
  4431. constructor(scene: Scene);
  4432. /**
  4433. * Get the number of data values you will have to play with for the visualization
  4434. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4435. * @returns a number
  4436. */
  4437. getFrequencyBinCount(): number;
  4438. /**
  4439. * Gets the current frequency data as a byte array
  4440. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4441. * @returns a Uint8Array
  4442. */
  4443. getByteFrequencyData(): Uint8Array;
  4444. /**
  4445. * Gets the current waveform as a byte array
  4446. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4447. * @returns a Uint8Array
  4448. */
  4449. getByteTimeDomainData(): Uint8Array;
  4450. /**
  4451. * Gets the current frequency data as a float array
  4452. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4453. * @returns a Float32Array
  4454. */
  4455. getFloatFrequencyData(): Float32Array;
  4456. /**
  4457. * Renders the debug canvas
  4458. */
  4459. drawDebugCanvas(): void;
  4460. /**
  4461. * Stops rendering the debug canvas and removes it
  4462. */
  4463. stopDebugCanvas(): void;
  4464. /**
  4465. * Connects two audio nodes
  4466. * @param inputAudioNode defines first node to connect
  4467. * @param outputAudioNode defines second node to connect
  4468. */
  4469. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4470. /**
  4471. * Releases all associated resources
  4472. */
  4473. dispose(): void;
  4474. }
  4475. }
  4476. declare module BABYLON {
  4477. class AudioEngine {
  4478. private _audioContext;
  4479. private _audioContextInitialized;
  4480. canUseWebAudio: boolean;
  4481. masterGain: GainNode;
  4482. private _connectedAnalyser;
  4483. WarnedWebAudioUnsupported: boolean;
  4484. unlocked: boolean;
  4485. onAudioUnlocked: () => any;
  4486. isMP3supported: boolean;
  4487. isOGGsupported: boolean;
  4488. readonly audioContext: Nullable<AudioContext>;
  4489. constructor();
  4490. private _unlockiOSaudio();
  4491. private _initializeAudioContext();
  4492. dispose(): void;
  4493. getGlobalVolume(): number;
  4494. setGlobalVolume(newVolume: number): void;
  4495. connectToAnalyser(analyser: Analyser): void;
  4496. }
  4497. }
  4498. declare module BABYLON {
  4499. class Sound {
  4500. name: string;
  4501. autoplay: boolean;
  4502. loop: boolean;
  4503. useCustomAttenuation: boolean;
  4504. soundTrackId: number;
  4505. spatialSound: boolean;
  4506. refDistance: number;
  4507. rolloffFactor: number;
  4508. maxDistance: number;
  4509. distanceModel: string;
  4510. private _panningModel;
  4511. onended: () => any;
  4512. private _playbackRate;
  4513. private _streaming;
  4514. private _startTime;
  4515. private _startOffset;
  4516. private _position;
  4517. private _localDirection;
  4518. private _volume;
  4519. private _isReadyToPlay;
  4520. isPlaying: boolean;
  4521. isPaused: boolean;
  4522. private _isDirectional;
  4523. private _readyToPlayCallback;
  4524. private _audioBuffer;
  4525. private _soundSource;
  4526. private _streamingSource;
  4527. private _soundPanner;
  4528. private _soundGain;
  4529. private _inputAudioNode;
  4530. private _ouputAudioNode;
  4531. private _coneInnerAngle;
  4532. private _coneOuterAngle;
  4533. private _coneOuterGain;
  4534. private _scene;
  4535. private _connectedMesh;
  4536. private _customAttenuationFunction;
  4537. private _registerFunc;
  4538. private _isOutputConnected;
  4539. private _htmlAudioElement;
  4540. private _urlType;
  4541. /**
  4542. * Create a sound and attach it to a scene
  4543. * @param name Name of your sound
  4544. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4545. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4546. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4547. */
  4548. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4549. dispose(): void;
  4550. isReady(): boolean;
  4551. private _soundLoaded(audioData);
  4552. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4553. updateOptions(options: any): void;
  4554. private _createSpatialParameters();
  4555. private _updateSpatialParameters();
  4556. switchPanningModelToHRTF(): void;
  4557. switchPanningModelToEqualPower(): void;
  4558. private _switchPanningModel();
  4559. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4560. /**
  4561. * Transform this sound into a directional source
  4562. * @param coneInnerAngle Size of the inner cone in degree
  4563. * @param coneOuterAngle Size of the outer cone in degree
  4564. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4565. */
  4566. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4567. setPosition(newPosition: Vector3): void;
  4568. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4569. private _updateDirection();
  4570. updateDistanceFromListener(): void;
  4571. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4572. /**
  4573. * Play the sound
  4574. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4575. * @param offset (optional) Start the sound setting it at a specific time
  4576. */
  4577. play(time?: number, offset?: number): void;
  4578. private _onended();
  4579. /**
  4580. * Stop the sound
  4581. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4582. */
  4583. stop(time?: number): void;
  4584. pause(): void;
  4585. setVolume(newVolume: number, time?: number): void;
  4586. setPlaybackRate(newPlaybackRate: number): void;
  4587. getVolume(): number;
  4588. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4589. detachFromMesh(): void;
  4590. private _onRegisterAfterWorldMatrixUpdate(node);
  4591. clone(): Nullable<Sound>;
  4592. getAudioBuffer(): AudioBuffer | null;
  4593. serialize(): any;
  4594. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4595. }
  4596. }
  4597. declare module BABYLON {
  4598. class SoundTrack {
  4599. private _outputAudioNode;
  4600. private _scene;
  4601. id: number;
  4602. soundCollection: Array<Sound>;
  4603. private _isMainTrack;
  4604. private _connectedAnalyser;
  4605. private _options;
  4606. private _isInitialized;
  4607. constructor(scene: Scene, options?: any);
  4608. private _initializeSoundTrackAudioGraph();
  4609. dispose(): void;
  4610. AddSound(sound: Sound): void;
  4611. RemoveSound(sound: Sound): void;
  4612. setVolume(newVolume: number): void;
  4613. switchPanningModelToHRTF(): void;
  4614. switchPanningModelToEqualPower(): void;
  4615. connectToAnalyser(analyser: Analyser): void;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * Interface used to define a behavior
  4621. */
  4622. interface Behavior<T> {
  4623. /** gets or sets behavior's name */
  4624. name: string;
  4625. /**
  4626. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4627. */
  4628. init(): void;
  4629. /**
  4630. * Called when the behavior is attached to a target
  4631. * @param target defines the target where the behavior is attached to
  4632. */
  4633. attach(target: T): void;
  4634. /**
  4635. * Called when the behavior is detached from its target
  4636. */
  4637. detach(): void;
  4638. }
  4639. /**
  4640. * Interface implemented by classes supporting behaviors
  4641. */
  4642. interface IBehaviorAware<T> {
  4643. /**
  4644. * Attach a behavior
  4645. * @param behavior defines the behavior to attach
  4646. * @returns the current host
  4647. */
  4648. addBehavior(behavior: Behavior<T>): T;
  4649. /**
  4650. * Remove a behavior from the current object
  4651. * @param behavior defines the behavior to detach
  4652. * @returns the current host
  4653. */
  4654. removeBehavior(behavior: Behavior<T>): T;
  4655. /**
  4656. * Gets a behavior using its name to search
  4657. * @param name defines the name to search
  4658. * @returns the behavior or null if not found
  4659. */
  4660. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4661. }
  4662. }
  4663. declare module BABYLON {
  4664. class ArcRotateCamera extends TargetCamera {
  4665. alpha: number;
  4666. beta: number;
  4667. radius: number;
  4668. protected _target: Vector3;
  4669. protected _targetHost: Nullable<AbstractMesh>;
  4670. target: Vector3;
  4671. inertialAlphaOffset: number;
  4672. inertialBetaOffset: number;
  4673. inertialRadiusOffset: number;
  4674. lowerAlphaLimit: Nullable<number>;
  4675. upperAlphaLimit: Nullable<number>;
  4676. lowerBetaLimit: number;
  4677. upperBetaLimit: number;
  4678. lowerRadiusLimit: Nullable<number>;
  4679. upperRadiusLimit: Nullable<number>;
  4680. inertialPanningX: number;
  4681. inertialPanningY: number;
  4682. pinchToPanMaxDistance: number;
  4683. panningDistanceLimit: Nullable<number>;
  4684. panningOriginTarget: Vector3;
  4685. panningInertia: number;
  4686. angularSensibilityX: number;
  4687. angularSensibilityY: number;
  4688. pinchPrecision: number;
  4689. pinchDeltaPercentage: number;
  4690. panningSensibility: number;
  4691. keysUp: number[];
  4692. keysDown: number[];
  4693. keysLeft: number[];
  4694. keysRight: number[];
  4695. wheelPrecision: number;
  4696. wheelDeltaPercentage: number;
  4697. zoomOnFactor: number;
  4698. targetScreenOffset: Vector2;
  4699. allowUpsideDown: boolean;
  4700. _viewMatrix: Matrix;
  4701. _useCtrlForPanning: boolean;
  4702. _panningMouseButton: number;
  4703. inputs: ArcRotateCameraInputsManager;
  4704. _reset: () => void;
  4705. panningAxis: Vector3;
  4706. protected _localDirection: Vector3;
  4707. protected _transformedDirection: Vector3;
  4708. private _bouncingBehavior;
  4709. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  4710. useBouncingBehavior: boolean;
  4711. private _framingBehavior;
  4712. readonly framingBehavior: Nullable<FramingBehavior>;
  4713. useFramingBehavior: boolean;
  4714. private _autoRotationBehavior;
  4715. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  4716. useAutoRotationBehavior: boolean;
  4717. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  4718. onCollide: (collidedMesh: AbstractMesh) => void;
  4719. checkCollisions: boolean;
  4720. collisionRadius: Vector3;
  4721. protected _collider: Collider;
  4722. protected _previousPosition: Vector3;
  4723. protected _collisionVelocity: Vector3;
  4724. protected _newPosition: Vector3;
  4725. protected _previousAlpha: number;
  4726. protected _previousBeta: number;
  4727. protected _previousRadius: number;
  4728. protected _collisionTriggered: boolean;
  4729. protected _targetBoundingCenter: Nullable<Vector3>;
  4730. private _computationVector;
  4731. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  4732. _initCache(): void;
  4733. _updateCache(ignoreParentClass?: boolean): void;
  4734. protected _getTargetPosition(): Vector3;
  4735. /**
  4736. * Store current camera state (fov, position, etc..)
  4737. */
  4738. private _storedAlpha;
  4739. private _storedBeta;
  4740. private _storedRadius;
  4741. private _storedTarget;
  4742. storeState(): Camera;
  4743. /**
  4744. * Restored camera state. You must call storeState() first
  4745. */
  4746. _restoreStateValues(): boolean;
  4747. _isSynchronizedViewMatrix(): boolean;
  4748. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  4749. detachControl(element: HTMLElement): void;
  4750. _checkInputs(): void;
  4751. protected _checkLimits(): void;
  4752. rebuildAnglesAndRadius(): void;
  4753. setPosition(position: Vector3): void;
  4754. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  4755. _getViewMatrix(): Matrix;
  4756. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  4757. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  4758. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  4759. min: Vector3;
  4760. max: Vector3;
  4761. distance: number;
  4762. }, doNotUpdateMaxZ?: boolean): void;
  4763. /**
  4764. * @override
  4765. * Override Camera.createRigCamera
  4766. */
  4767. createRigCamera(name: string, cameraIndex: number): Camera;
  4768. /**
  4769. * @override
  4770. * Override Camera._updateRigCameras
  4771. */
  4772. _updateRigCameras(): void;
  4773. dispose(): void;
  4774. getClassName(): string;
  4775. }
  4776. }
  4777. declare module BABYLON {
  4778. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  4779. constructor(camera: ArcRotateCamera);
  4780. addMouseWheel(): ArcRotateCameraInputsManager;
  4781. addPointers(): ArcRotateCameraInputsManager;
  4782. addKeyboard(): ArcRotateCameraInputsManager;
  4783. addGamepad(): ArcRotateCameraInputsManager;
  4784. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  4785. }
  4786. }
  4787. declare module BABYLON {
  4788. class Camera extends Node {
  4789. inputs: CameraInputsManager<Camera>;
  4790. private static _PERSPECTIVE_CAMERA;
  4791. private static _ORTHOGRAPHIC_CAMERA;
  4792. private static _FOVMODE_VERTICAL_FIXED;
  4793. private static _FOVMODE_HORIZONTAL_FIXED;
  4794. private static _RIG_MODE_NONE;
  4795. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  4796. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  4797. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  4798. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  4799. private static _RIG_MODE_VR;
  4800. private static _RIG_MODE_WEBVR;
  4801. static readonly PERSPECTIVE_CAMERA: number;
  4802. static readonly ORTHOGRAPHIC_CAMERA: number;
  4803. /**
  4804. * This is the default FOV mode for perspective cameras.
  4805. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  4806. *
  4807. */
  4808. static readonly FOVMODE_VERTICAL_FIXED: number;
  4809. /**
  4810. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  4811. *
  4812. */
  4813. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  4814. static readonly RIG_MODE_NONE: number;
  4815. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  4816. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  4817. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  4818. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  4819. static readonly RIG_MODE_VR: number;
  4820. static readonly RIG_MODE_WEBVR: number;
  4821. static ForceAttachControlToAlwaysPreventDefault: boolean;
  4822. static UseAlternateWebVRRendering: boolean;
  4823. position: Vector3;
  4824. /**
  4825. * The vector the camera should consider as up.
  4826. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  4827. */
  4828. upVector: Vector3;
  4829. orthoLeft: Nullable<number>;
  4830. orthoRight: Nullable<number>;
  4831. orthoBottom: Nullable<number>;
  4832. orthoTop: Nullable<number>;
  4833. /**
  4834. * FOV is set in Radians. (default is 0.8)
  4835. */
  4836. fov: number;
  4837. minZ: number;
  4838. maxZ: number;
  4839. inertia: number;
  4840. mode: number;
  4841. isIntermediate: boolean;
  4842. viewport: Viewport;
  4843. /**
  4844. * Restricts the camera to viewing objects with the same layerMask.
  4845. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  4846. */
  4847. layerMask: number;
  4848. /**
  4849. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  4850. */
  4851. fovMode: number;
  4852. cameraRigMode: number;
  4853. interaxialDistance: number;
  4854. isStereoscopicSideBySide: boolean;
  4855. _cameraRigParams: any;
  4856. _rigCameras: Camera[];
  4857. _rigPostProcess: Nullable<PostProcess>;
  4858. protected _webvrViewMatrix: Matrix;
  4859. _skipRendering: boolean;
  4860. _alternateCamera: Camera;
  4861. customRenderTargets: RenderTargetTexture[];
  4862. onViewMatrixChangedObservable: Observable<Camera>;
  4863. onProjectionMatrixChangedObservable: Observable<Camera>;
  4864. onAfterCheckInputsObservable: Observable<Camera>;
  4865. onRestoreStateObservable: Observable<Camera>;
  4866. private _computedViewMatrix;
  4867. _projectionMatrix: Matrix;
  4868. private _doNotComputeProjectionMatrix;
  4869. private _worldMatrix;
  4870. _postProcesses: Nullable<PostProcess>[];
  4871. private _transformMatrix;
  4872. _activeMeshes: SmartArray<AbstractMesh>;
  4873. protected _globalPosition: Vector3;
  4874. private _frustumPlanes;
  4875. private _refreshFrustumPlanes;
  4876. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  4877. private _storedFov;
  4878. private _stateStored;
  4879. /**
  4880. * Store current camera state (fov, position, etc..)
  4881. */
  4882. storeState(): Camera;
  4883. /**
  4884. * Restores the camera state values if it has been stored. You must call storeState() first
  4885. */
  4886. protected _restoreStateValues(): boolean;
  4887. /**
  4888. * Restored camera state. You must call storeState() first
  4889. */
  4890. restoreState(): boolean;
  4891. getClassName(): string;
  4892. /**
  4893. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  4894. */
  4895. toString(fullDetails?: boolean): string;
  4896. readonly globalPosition: Vector3;
  4897. getActiveMeshes(): SmartArray<AbstractMesh>;
  4898. isActiveMesh(mesh: Mesh): boolean;
  4899. /**
  4900. * Is this camera ready to be used/rendered
  4901. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  4902. * @return true if the camera is ready
  4903. */
  4904. isReady(completeCheck?: boolean): boolean;
  4905. _initCache(): void;
  4906. _updateCache(ignoreParentClass?: boolean): void;
  4907. _isSynchronized(): boolean;
  4908. _isSynchronizedViewMatrix(): boolean;
  4909. _isSynchronizedProjectionMatrix(): boolean;
  4910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  4911. detachControl(element: HTMLElement): void;
  4912. update(): void;
  4913. _checkInputs(): void;
  4914. readonly rigCameras: Camera[];
  4915. readonly rigPostProcess: Nullable<PostProcess>;
  4916. /**
  4917. * Internal, gets the first post proces.
  4918. * @returns the first post process to be run on this camera.
  4919. */
  4920. _getFirstPostProcess(): Nullable<PostProcess>;
  4921. private _cascadePostProcessesToRigCams();
  4922. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  4923. detachPostProcess(postProcess: PostProcess): void;
  4924. getWorldMatrix(): Matrix;
  4925. _getViewMatrix(): Matrix;
  4926. getViewMatrix(force?: boolean): Matrix;
  4927. freezeProjectionMatrix(projection?: Matrix): void;
  4928. unfreezeProjectionMatrix(): void;
  4929. getProjectionMatrix(force?: boolean): Matrix;
  4930. getTranformationMatrix(): Matrix;
  4931. private updateFrustumPlanes();
  4932. isInFrustum(target: ICullable): boolean;
  4933. isCompletelyInFrustum(target: ICullable): boolean;
  4934. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  4935. /**
  4936. * Releases resources associated with this node.
  4937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  4938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  4939. */
  4940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  4941. readonly leftCamera: Nullable<FreeCamera>;
  4942. readonly rightCamera: Nullable<FreeCamera>;
  4943. getLeftTarget(): Nullable<Vector3>;
  4944. getRightTarget(): Nullable<Vector3>;
  4945. setCameraRigMode(mode: number, rigParams: any): void;
  4946. private _getVRProjectionMatrix();
  4947. protected _updateCameraRotationMatrix(): void;
  4948. protected _updateWebVRCameraRotationMatrix(): void;
  4949. /**
  4950. * This function MUST be overwritten by the different WebVR cameras available.
  4951. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4952. */
  4953. protected _getWebVRProjectionMatrix(): Matrix;
  4954. /**
  4955. * This function MUST be overwritten by the different WebVR cameras available.
  4956. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4957. */
  4958. protected _getWebVRViewMatrix(): Matrix;
  4959. setCameraRigParameter(name: string, value: any): void;
  4960. /**
  4961. * needs to be overridden by children so sub has required properties to be copied
  4962. */
  4963. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  4964. /**
  4965. * May need to be overridden by children
  4966. */
  4967. _updateRigCameras(): void;
  4968. _setupInputs(): void;
  4969. serialize(): any;
  4970. clone(name: string): Camera;
  4971. getDirection(localAxis: Vector3): Vector3;
  4972. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  4973. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  4974. computeWorldMatrix(): Matrix;
  4975. static Parse(parsedCamera: any, scene: Scene): Camera;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. var CameraInputTypes: {};
  4980. interface ICameraInput<TCamera extends Camera> {
  4981. camera: Nullable<TCamera>;
  4982. getClassName(): string;
  4983. getSimpleName(): string;
  4984. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  4985. detachControl: (element: Nullable<HTMLElement>) => void;
  4986. checkInputs?: () => void;
  4987. }
  4988. interface CameraInputsMap<TCamera extends Camera> {
  4989. [name: string]: ICameraInput<TCamera>;
  4990. [idx: number]: ICameraInput<TCamera>;
  4991. }
  4992. class CameraInputsManager<TCamera extends Camera> {
  4993. attached: CameraInputsMap<TCamera>;
  4994. attachedElement: Nullable<HTMLElement>;
  4995. noPreventDefault: boolean;
  4996. camera: TCamera;
  4997. checkInputs: () => void;
  4998. constructor(camera: TCamera);
  4999. /**
  5000. * Add an input method to a camera.
  5001. * builtin inputs example: camera.inputs.addGamepad();
  5002. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5003. * @param input camera input method
  5004. */
  5005. add(input: ICameraInput<TCamera>): void;
  5006. /**
  5007. * Remove a specific input method from a camera
  5008. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5009. * @param inputToRemove camera input method
  5010. */
  5011. remove(inputToRemove: ICameraInput<TCamera>): void;
  5012. removeByType(inputType: string): void;
  5013. private _addCheckInputs(fn);
  5014. attachInput(input: ICameraInput<TCamera>): void;
  5015. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5016. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5017. rebuildInputCheck(): void;
  5018. /**
  5019. * Remove all attached input methods from a camera
  5020. */
  5021. clear(): void;
  5022. serialize(serializedCamera: any): void;
  5023. parse(parsedCamera: any): void;
  5024. }
  5025. }
  5026. declare module BABYLON {
  5027. /**
  5028. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5029. * being tilted forward or back and left or right.
  5030. */
  5031. class DeviceOrientationCamera extends FreeCamera {
  5032. private _initialQuaternion;
  5033. private _quaternionCache;
  5034. /**
  5035. * Creates a new device orientation camera
  5036. * @param name The name of the camera
  5037. * @param position The start position camera
  5038. * @param scene The scene the camera belongs to
  5039. */
  5040. constructor(name: string, position: Vector3, scene: Scene);
  5041. /**
  5042. * Gets the current instance class name ("DeviceOrientationCamera").
  5043. * This helps avoiding instanceof at run time.
  5044. * @returns the class name
  5045. */
  5046. getClassName(): string;
  5047. /**
  5048. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5049. */
  5050. _checkInputs(): void;
  5051. /**
  5052. * Reset the camera to its default orientation on the specified axis only.
  5053. * @param axis The axis to reset
  5054. */
  5055. resetToCurrentRotation(axis?: Axis): void;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. class FollowCamera extends TargetCamera {
  5060. radius: number;
  5061. rotationOffset: number;
  5062. heightOffset: number;
  5063. cameraAcceleration: number;
  5064. maxCameraSpeed: number;
  5065. lockedTarget: Nullable<AbstractMesh>;
  5066. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5067. private getRadians(degrees);
  5068. private follow(cameraTarget);
  5069. _checkInputs(): void;
  5070. getClassName(): string;
  5071. }
  5072. class ArcFollowCamera extends TargetCamera {
  5073. alpha: number;
  5074. beta: number;
  5075. radius: number;
  5076. target: Nullable<AbstractMesh>;
  5077. private _cartesianCoordinates;
  5078. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5079. private follow();
  5080. _checkInputs(): void;
  5081. getClassName(): string;
  5082. }
  5083. }
  5084. declare module BABYLON {
  5085. class FreeCamera extends TargetCamera {
  5086. ellipsoid: Vector3;
  5087. ellipsoidOffset: Vector3;
  5088. checkCollisions: boolean;
  5089. applyGravity: boolean;
  5090. inputs: FreeCameraInputsManager;
  5091. /**
  5092. * Gets the input sensibility for a mouse input. (default is 2000.0)
  5093. * Higher values reduce sensitivity.
  5094. */
  5095. /**
  5096. * Sets the input sensibility for a mouse input. (default is 2000.0)
  5097. * Higher values reduce sensitivity.
  5098. */
  5099. angularSensibility: number;
  5100. keysUp: number[];
  5101. keysDown: number[];
  5102. keysLeft: number[];
  5103. keysRight: number[];
  5104. onCollide: (collidedMesh: AbstractMesh) => void;
  5105. private _collider;
  5106. private _needMoveForGravity;
  5107. private _oldPosition;
  5108. private _diffPosition;
  5109. private _newPosition;
  5110. _localDirection: Vector3;
  5111. _transformedDirection: Vector3;
  5112. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5114. detachControl(element: HTMLElement): void;
  5115. private _collisionMask;
  5116. collisionMask: number;
  5117. _collideWithWorld(displacement: Vector3): void;
  5118. private _onCollisionPositionChange;
  5119. _checkInputs(): void;
  5120. _decideIfNeedsToMove(): boolean;
  5121. _updatePosition(): void;
  5122. dispose(): void;
  5123. getClassName(): string;
  5124. }
  5125. }
  5126. declare module BABYLON {
  5127. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  5128. constructor(camera: FreeCamera);
  5129. addKeyboard(): FreeCameraInputsManager;
  5130. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  5131. addGamepad(): FreeCameraInputsManager;
  5132. addDeviceOrientation(): FreeCameraInputsManager;
  5133. addTouch(): FreeCameraInputsManager;
  5134. addVirtualJoystick(): FreeCameraInputsManager;
  5135. }
  5136. }
  5137. declare module BABYLON {
  5138. class GamepadCamera extends UniversalCamera {
  5139. gamepadAngularSensibility: number;
  5140. gamepadMoveSensibility: number;
  5141. constructor(name: string, position: Vector3, scene: Scene);
  5142. getClassName(): string;
  5143. }
  5144. }
  5145. declare module BABYLON {
  5146. /**
  5147. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  5148. */
  5149. class AnaglyphFreeCamera extends FreeCamera {
  5150. /**
  5151. * Creates a new AnaglyphFreeCamera
  5152. * @param name defines camera name
  5153. * @param position defines initial position
  5154. * @param interaxialDistance defines distance between each color axis
  5155. * @param scene defines the hosting scene
  5156. */
  5157. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5158. /**
  5159. * Gets camera class name
  5160. * @returns AnaglyphFreeCamera
  5161. */
  5162. getClassName(): string;
  5163. }
  5164. /**
  5165. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  5166. */
  5167. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  5168. /**
  5169. * Creates a new AnaglyphArcRotateCamera
  5170. * @param name defines camera name
  5171. * @param alpha defines alpha angle (in radians)
  5172. * @param beta defines beta angle (in radians)
  5173. * @param radius defines radius
  5174. * @param target defines camera target
  5175. * @param interaxialDistance defines distance between each color axis
  5176. * @param scene defines the hosting scene
  5177. */
  5178. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  5179. /**
  5180. * Gets camera class name
  5181. * @returns AnaglyphArcRotateCamera
  5182. */
  5183. getClassName(): string;
  5184. }
  5185. /**
  5186. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  5187. */
  5188. class AnaglyphGamepadCamera extends GamepadCamera {
  5189. /**
  5190. * Creates a new AnaglyphGamepadCamera
  5191. * @param name defines camera name
  5192. * @param position defines initial position
  5193. * @param interaxialDistance defines distance between each color axis
  5194. * @param scene defines the hosting scene
  5195. */
  5196. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5197. /**
  5198. * Gets camera class name
  5199. * @returns AnaglyphGamepadCamera
  5200. */
  5201. getClassName(): string;
  5202. }
  5203. /**
  5204. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  5205. */
  5206. class AnaglyphUniversalCamera extends UniversalCamera {
  5207. /**
  5208. * Creates a new AnaglyphUniversalCamera
  5209. * @param name defines camera name
  5210. * @param position defines initial position
  5211. * @param interaxialDistance defines distance between each color axis
  5212. * @param scene defines the hosting scene
  5213. */
  5214. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5215. /**
  5216. * Gets camera class name
  5217. * @returns AnaglyphUniversalCamera
  5218. */
  5219. getClassName(): string;
  5220. }
  5221. /**
  5222. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  5223. */
  5224. class StereoscopicFreeCamera extends FreeCamera {
  5225. /**
  5226. * Creates a new StereoscopicFreeCamera
  5227. * @param name defines camera name
  5228. * @param position defines initial position
  5229. * @param interaxialDistance defines distance between each color axis
  5230. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  5231. * @param scene defines the hosting scene
  5232. */
  5233. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5234. /**
  5235. * Gets camera class name
  5236. * @returns StereoscopicFreeCamera
  5237. */
  5238. getClassName(): string;
  5239. }
  5240. /**
  5241. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  5242. */
  5243. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  5244. /**
  5245. * Creates a new StereoscopicArcRotateCamera
  5246. * @param name defines camera name
  5247. * @param alpha defines alpha angle (in radians)
  5248. * @param beta defines beta angle (in radians)
  5249. * @param radius defines radius
  5250. * @param target defines camera target
  5251. * @param interaxialDistance defines distance between each color axis
  5252. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  5253. * @param scene defines the hosting scene
  5254. */
  5255. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5256. /**
  5257. * Gets camera class name
  5258. * @returns StereoscopicArcRotateCamera
  5259. */
  5260. getClassName(): string;
  5261. }
  5262. /**
  5263. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  5264. */
  5265. class StereoscopicGamepadCamera extends GamepadCamera {
  5266. /**
  5267. * Creates a new StereoscopicGamepadCamera
  5268. * @param name defines camera name
  5269. * @param position defines initial position
  5270. * @param interaxialDistance defines distance between each color axis
  5271. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  5272. * @param scene defines the hosting scene
  5273. */
  5274. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5275. /**
  5276. * Gets camera class name
  5277. * @returns StereoscopicGamepadCamera
  5278. */
  5279. getClassName(): string;
  5280. }
  5281. /**
  5282. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  5283. */
  5284. class StereoscopicUniversalCamera extends UniversalCamera {
  5285. /**
  5286. * Creates a new StereoscopicUniversalCamera
  5287. * @param name defines camera name
  5288. * @param position defines initial position
  5289. * @param interaxialDistance defines distance between each color axis
  5290. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  5291. * @param scene defines the hosting scene
  5292. */
  5293. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5294. /**
  5295. * Gets camera class name
  5296. * @returns StereoscopicUniversalCamera
  5297. */
  5298. getClassName(): string;
  5299. }
  5300. }
  5301. declare module BABYLON {
  5302. class TargetCamera extends Camera {
  5303. cameraDirection: Vector3;
  5304. cameraRotation: Vector2;
  5305. rotation: Vector3;
  5306. rotationQuaternion: Quaternion;
  5307. speed: number;
  5308. noRotationConstraint: boolean;
  5309. lockedTarget: any;
  5310. _currentTarget: Vector3;
  5311. _viewMatrix: Matrix;
  5312. _camMatrix: Matrix;
  5313. _cameraTransformMatrix: Matrix;
  5314. _cameraRotationMatrix: Matrix;
  5315. private _rigCamTransformMatrix;
  5316. _referencePoint: Vector3;
  5317. private _currentUpVector;
  5318. _transformedReferencePoint: Vector3;
  5319. protected _globalCurrentTarget: Vector3;
  5320. protected _globalCurrentUpVector: Vector3;
  5321. _reset: () => void;
  5322. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5323. getFrontPosition(distance: number): Vector3;
  5324. _getLockedTargetPosition(): Nullable<Vector3>;
  5325. /**
  5326. * Store current camera state (fov, position, etc..)
  5327. */
  5328. private _storedPosition;
  5329. private _storedRotation;
  5330. private _storedRotationQuaternion;
  5331. storeState(): Camera;
  5332. /**
  5333. * Restored camera state. You must call storeState() first
  5334. */
  5335. _restoreStateValues(): boolean;
  5336. _initCache(): void;
  5337. _updateCache(ignoreParentClass?: boolean): void;
  5338. _isSynchronizedViewMatrix(): boolean;
  5339. _computeLocalCameraSpeed(): number;
  5340. setTarget(target: Vector3): void;
  5341. /**
  5342. * Return the current target position of the camera. This value is expressed in local space.
  5343. */
  5344. getTarget(): Vector3;
  5345. _decideIfNeedsToMove(): boolean;
  5346. _updatePosition(): void;
  5347. _checkInputs(): void;
  5348. protected _updateCameraRotationMatrix(): void;
  5349. _getViewMatrix(): Matrix;
  5350. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  5351. /**
  5352. * @override
  5353. * Override Camera.createRigCamera
  5354. */
  5355. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5356. /**
  5357. * @override
  5358. * Override Camera._updateRigCameras
  5359. */
  5360. _updateRigCameras(): void;
  5361. private _getRigCamPosition(halfSpace, result);
  5362. getClassName(): string;
  5363. }
  5364. }
  5365. declare module BABYLON {
  5366. class TouchCamera extends FreeCamera {
  5367. touchAngularSensibility: number;
  5368. touchMoveSensibility: number;
  5369. constructor(name: string, position: Vector3, scene: Scene);
  5370. getClassName(): string;
  5371. _setupInputs(): void;
  5372. }
  5373. }
  5374. declare module BABYLON {
  5375. class UniversalCamera extends TouchCamera {
  5376. gamepadAngularSensibility: number;
  5377. gamepadMoveSensibility: number;
  5378. constructor(name: string, position: Vector3, scene: Scene);
  5379. getClassName(): string;
  5380. }
  5381. }
  5382. declare module BABYLON {
  5383. class VirtualJoysticksCamera extends FreeCamera {
  5384. constructor(name: string, position: Vector3, scene: Scene);
  5385. getClassName(): string;
  5386. }
  5387. }
  5388. interface VRDisplay extends EventTarget {
  5389. /**
  5390. * Dictionary of capabilities describing the VRDisplay.
  5391. */
  5392. readonly capabilities: VRDisplayCapabilities;
  5393. /**
  5394. * z-depth defining the far plane of the eye view frustum
  5395. * enables mapping of values in the render target depth
  5396. * attachment to scene coordinates. Initially set to 10000.0.
  5397. */
  5398. depthFar: number;
  5399. /**
  5400. * z-depth defining the near plane of the eye view frustum
  5401. * enables mapping of values in the render target depth
  5402. * attachment to scene coordinates. Initially set to 0.01.
  5403. */
  5404. depthNear: number;
  5405. /**
  5406. * An identifier for this distinct VRDisplay. Used as an
  5407. * association point in the Gamepad API.
  5408. */
  5409. readonly displayId: number;
  5410. /**
  5411. * A display name, a user-readable name identifying it.
  5412. */
  5413. readonly displayName: string;
  5414. readonly isConnected: boolean;
  5415. readonly isPresenting: boolean;
  5416. /**
  5417. * If this VRDisplay supports room-scale experiences, the optional
  5418. * stage attribute contains details on the room-scale parameters.
  5419. */
  5420. readonly stageParameters: VRStageParameters | null;
  5421. /**
  5422. * Passing the value returned by `requestAnimationFrame` to
  5423. * `cancelAnimationFrame` will unregister the callback.
  5424. */
  5425. cancelAnimationFrame(handle: number): void;
  5426. /**
  5427. * Stops presenting to the VRDisplay.
  5428. */
  5429. exitPresent(): Promise<void>;
  5430. getEyeParameters(whichEye: string): VREyeParameters;
  5431. /**
  5432. * Populates the passed VRFrameData with the information required to render
  5433. * the current frame.
  5434. */
  5435. getFrameData(frameData: VRFrameData): boolean;
  5436. /**
  5437. * Get the layers currently being presented.
  5438. */
  5439. getLayers(): VRLayer[];
  5440. /**
  5441. * Return a VRPose containing the future predicted pose of the VRDisplay
  5442. * when the current frame will be presented. The value returned will not
  5443. * change until JavaScript has returned control to the browser.
  5444. *
  5445. * The VRPose will contain the position, orientation, velocity,
  5446. * and acceleration of each of these properties.
  5447. */
  5448. getPose(): VRPose;
  5449. /**
  5450. * Return the current instantaneous pose of the VRDisplay, with no
  5451. * prediction applied.
  5452. */
  5453. getImmediatePose(): VRPose;
  5454. /**
  5455. * The callback passed to `requestAnimationFrame` will be called
  5456. * any time a new frame should be rendered. When the VRDisplay is
  5457. * presenting the callback will be called at the native refresh
  5458. * rate of the HMD. When not presenting this function acts
  5459. * identically to how window.requestAnimationFrame acts. Content should
  5460. * make no assumptions of frame rate or vsync behavior as the HMD runs
  5461. * asynchronously from other displays and at differing refresh rates.
  5462. */
  5463. requestAnimationFrame(callback: FrameRequestCallback): number;
  5464. /**
  5465. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  5466. * Repeat calls while already presenting will update the VRLayers being displayed.
  5467. */
  5468. requestPresent(layers: VRLayer[]): Promise<void>;
  5469. /**
  5470. * Reset the pose for this display, treating its current position and
  5471. * orientation as the "origin/zero" values. VRPose.position,
  5472. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  5473. * updated when calling resetPose(). This should be called in only
  5474. * sitting-space experiences.
  5475. */
  5476. resetPose(): void;
  5477. /**
  5478. * The VRLayer provided to the VRDisplay will be captured and presented
  5479. * in the HMD. Calling this function has the same effect on the source
  5480. * canvas as any other operation that uses its source image, and canvases
  5481. * created without preserveDrawingBuffer set to true will be cleared.
  5482. */
  5483. submitFrame(pose?: VRPose): void;
  5484. }
  5485. declare var VRDisplay: {
  5486. prototype: VRDisplay;
  5487. new (): VRDisplay;
  5488. };
  5489. interface VRLayer {
  5490. leftBounds?: number[] | null;
  5491. rightBounds?: number[] | null;
  5492. source?: HTMLCanvasElement | null;
  5493. }
  5494. interface VRDisplayCapabilities {
  5495. readonly canPresent: boolean;
  5496. readonly hasExternalDisplay: boolean;
  5497. readonly hasOrientation: boolean;
  5498. readonly hasPosition: boolean;
  5499. readonly maxLayers: number;
  5500. }
  5501. interface VREyeParameters {
  5502. /** @deprecated */
  5503. readonly fieldOfView: VRFieldOfView;
  5504. readonly offset: Float32Array;
  5505. readonly renderHeight: number;
  5506. readonly renderWidth: number;
  5507. }
  5508. interface VRFieldOfView {
  5509. readonly downDegrees: number;
  5510. readonly leftDegrees: number;
  5511. readonly rightDegrees: number;
  5512. readonly upDegrees: number;
  5513. }
  5514. interface VRFrameData {
  5515. readonly leftProjectionMatrix: Float32Array;
  5516. readonly leftViewMatrix: Float32Array;
  5517. readonly pose: VRPose;
  5518. readonly rightProjectionMatrix: Float32Array;
  5519. readonly rightViewMatrix: Float32Array;
  5520. readonly timestamp: number;
  5521. }
  5522. interface VRPose {
  5523. readonly angularAcceleration: Float32Array | null;
  5524. readonly angularVelocity: Float32Array | null;
  5525. readonly linearAcceleration: Float32Array | null;
  5526. readonly linearVelocity: Float32Array | null;
  5527. readonly orientation: Float32Array | null;
  5528. readonly position: Float32Array | null;
  5529. readonly timestamp: number;
  5530. }
  5531. interface VRStageParameters {
  5532. sittingToStandingTransform?: Float32Array;
  5533. sizeX?: number;
  5534. sizeY?: number;
  5535. }
  5536. interface Navigator {
  5537. getVRDisplays(): Promise<VRDisplay[]>;
  5538. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  5539. }
  5540. interface Window {
  5541. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  5542. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  5543. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  5544. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5545. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5546. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  5547. }
  5548. interface Gamepad {
  5549. readonly displayId: number;
  5550. }
  5551. declare module BABYLON {
  5552. class Collider {
  5553. /** Define if a collision was found */
  5554. collisionFound: boolean;
  5555. /**
  5556. * Define last intersection point in local space
  5557. */
  5558. intersectionPoint: Vector3;
  5559. /**
  5560. * Define last collided mesh
  5561. */
  5562. collidedMesh: Nullable<AbstractMesh>;
  5563. private _collisionPoint;
  5564. private _planeIntersectionPoint;
  5565. private _tempVector;
  5566. private _tempVector2;
  5567. private _tempVector3;
  5568. private _tempVector4;
  5569. private _edge;
  5570. private _baseToVertex;
  5571. private _destinationPoint;
  5572. private _slidePlaneNormal;
  5573. private _displacementVector;
  5574. _radius: Vector3;
  5575. _retry: number;
  5576. private _velocity;
  5577. private _basePoint;
  5578. private _epsilon;
  5579. _velocityWorldLength: number;
  5580. _basePointWorld: Vector3;
  5581. private _velocityWorld;
  5582. private _normalizedVelocity;
  5583. _initialVelocity: Vector3;
  5584. _initialPosition: Vector3;
  5585. private _nearestDistance;
  5586. private _collisionMask;
  5587. collisionMask: number;
  5588. /**
  5589. * Gets the plane normal used to compute the sliding response (in local space)
  5590. */
  5591. readonly slidePlaneNormal: Vector3;
  5592. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5593. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5594. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5595. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5596. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5597. _getResponse(pos: Vector3, vel: Vector3): void;
  5598. }
  5599. }
  5600. declare module BABYLON {
  5601. var CollisionWorker: string;
  5602. interface ICollisionCoordinator {
  5603. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5604. init(scene: Scene): void;
  5605. destroy(): void;
  5606. onMeshAdded(mesh: AbstractMesh): void;
  5607. onMeshUpdated(mesh: AbstractMesh): void;
  5608. onMeshRemoved(mesh: AbstractMesh): void;
  5609. onGeometryAdded(geometry: Geometry): void;
  5610. onGeometryUpdated(geometry: Geometry): void;
  5611. onGeometryDeleted(geometry: Geometry): void;
  5612. }
  5613. interface SerializedMesh {
  5614. id: string;
  5615. name: string;
  5616. uniqueId: number;
  5617. geometryId: Nullable<string>;
  5618. sphereCenter: Array<number>;
  5619. sphereRadius: number;
  5620. boxMinimum: Array<number>;
  5621. boxMaximum: Array<number>;
  5622. worldMatrixFromCache: any;
  5623. subMeshes: Array<SerializedSubMesh>;
  5624. checkCollisions: boolean;
  5625. }
  5626. interface SerializedSubMesh {
  5627. position: number;
  5628. verticesStart: number;
  5629. verticesCount: number;
  5630. indexStart: number;
  5631. indexCount: number;
  5632. hasMaterial: boolean;
  5633. sphereCenter: Array<number>;
  5634. sphereRadius: number;
  5635. boxMinimum: Array<number>;
  5636. boxMaximum: Array<number>;
  5637. }
  5638. /**
  5639. * Interface describing the value associated with a geometry
  5640. */
  5641. interface SerializedGeometry {
  5642. /**
  5643. * Defines the unique ID of the geometry
  5644. */
  5645. id: string;
  5646. /**
  5647. * Defines the array containing the positions
  5648. */
  5649. positions: Float32Array;
  5650. /**
  5651. * Defines the array containing the indices
  5652. */
  5653. indices: Uint32Array;
  5654. /**
  5655. * Defines the array containing the normals
  5656. */
  5657. normals: Float32Array;
  5658. }
  5659. interface BabylonMessage {
  5660. taskType: WorkerTaskType;
  5661. payload: InitPayload | CollidePayload | UpdatePayload;
  5662. }
  5663. interface SerializedColliderToWorker {
  5664. position: Array<number>;
  5665. velocity: Array<number>;
  5666. radius: Array<number>;
  5667. }
  5668. /** Defines supported task for worker process */
  5669. enum WorkerTaskType {
  5670. /** Initialization */
  5671. INIT = 0,
  5672. /** Update of geometry */
  5673. UPDATE = 1,
  5674. /** Evaluate collision */
  5675. COLLIDE = 2,
  5676. }
  5677. interface WorkerReply {
  5678. error: WorkerReplyType;
  5679. taskType: WorkerTaskType;
  5680. payload?: any;
  5681. }
  5682. interface CollisionReplyPayload {
  5683. newPosition: Array<number>;
  5684. collisionId: number;
  5685. collidedMeshUniqueId: number;
  5686. }
  5687. interface InitPayload {
  5688. }
  5689. interface CollidePayload {
  5690. collisionId: number;
  5691. collider: SerializedColliderToWorker;
  5692. maximumRetry: number;
  5693. excludedMeshUniqueId: Nullable<number>;
  5694. }
  5695. interface UpdatePayload {
  5696. updatedMeshes: {
  5697. [n: number]: SerializedMesh;
  5698. };
  5699. updatedGeometries: {
  5700. [s: string]: SerializedGeometry;
  5701. };
  5702. removedMeshes: Array<number>;
  5703. removedGeometries: Array<string>;
  5704. }
  5705. /** Defines kind of replies returned by worker */
  5706. enum WorkerReplyType {
  5707. /** Success */
  5708. SUCCESS = 0,
  5709. /** Unkown error */
  5710. UNKNOWN_ERROR = 1,
  5711. }
  5712. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5713. private _scene;
  5714. private _scaledPosition;
  5715. private _scaledVelocity;
  5716. private _collisionsCallbackArray;
  5717. private _init;
  5718. private _runningUpdated;
  5719. private _worker;
  5720. private _addUpdateMeshesList;
  5721. private _addUpdateGeometriesList;
  5722. private _toRemoveMeshesArray;
  5723. private _toRemoveGeometryArray;
  5724. constructor();
  5725. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5726. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5727. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5728. init(scene: Scene): void;
  5729. destroy(): void;
  5730. onMeshAdded(mesh: AbstractMesh): void;
  5731. onMeshUpdated: (transformNode: TransformNode) => void;
  5732. onMeshRemoved(mesh: AbstractMesh): void;
  5733. onGeometryAdded(geometry: Geometry): void;
  5734. onGeometryUpdated: (geometry: Geometry) => void;
  5735. onGeometryDeleted(geometry: Geometry): void;
  5736. private _afterRender;
  5737. private _onMessageFromWorker;
  5738. }
  5739. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5740. private _scene;
  5741. private _scaledPosition;
  5742. private _scaledVelocity;
  5743. private _finalPosition;
  5744. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5745. init(scene: Scene): void;
  5746. destroy(): void;
  5747. onMeshAdded(mesh: AbstractMesh): void;
  5748. onMeshUpdated(mesh: AbstractMesh): void;
  5749. onMeshRemoved(mesh: AbstractMesh): void;
  5750. onGeometryAdded(geometry: Geometry): void;
  5751. onGeometryUpdated(geometry: Geometry): void;
  5752. onGeometryDeleted(geometry: Geometry): void;
  5753. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5754. }
  5755. }
  5756. declare function importScripts(...urls: string[]): void;
  5757. declare const safePostMessage: any;
  5758. declare module BABYLON {
  5759. var WorkerIncluded: boolean;
  5760. class CollisionCache {
  5761. private _meshes;
  5762. private _geometries;
  5763. getMeshes(): {
  5764. [n: number]: SerializedMesh;
  5765. };
  5766. getGeometries(): {
  5767. [s: number]: SerializedGeometry;
  5768. };
  5769. getMesh(id: any): SerializedMesh;
  5770. addMesh(mesh: SerializedMesh): void;
  5771. removeMesh(uniqueId: number): void;
  5772. getGeometry(id: string): SerializedGeometry;
  5773. addGeometry(geometry: SerializedGeometry): void;
  5774. removeGeometry(id: string): void;
  5775. }
  5776. class CollideWorker {
  5777. collider: Collider;
  5778. private _collisionCache;
  5779. private finalPosition;
  5780. private collisionsScalingMatrix;
  5781. private collisionTranformationMatrix;
  5782. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5783. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5784. private checkCollision(mesh);
  5785. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5786. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5787. private checkSubmeshCollision(subMesh);
  5788. }
  5789. interface ICollisionDetector {
  5790. onInit(payload: InitPayload): void;
  5791. onUpdate(payload: UpdatePayload): void;
  5792. onCollision(payload: CollidePayload): void;
  5793. }
  5794. class CollisionDetectorTransferable implements ICollisionDetector {
  5795. private _collisionCache;
  5796. onInit(payload: InitPayload): void;
  5797. onUpdate(payload: UpdatePayload): void;
  5798. onCollision(payload: CollidePayload): void;
  5799. }
  5800. }
  5801. declare module BABYLON {
  5802. class IntersectionInfo {
  5803. bu: Nullable<number>;
  5804. bv: Nullable<number>;
  5805. distance: number;
  5806. faceId: number;
  5807. subMeshId: number;
  5808. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5809. }
  5810. /**
  5811. * Information about the result of picking within a scene
  5812. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5813. */
  5814. class PickingInfo {
  5815. /**
  5816. * If the pick collided with an object
  5817. */
  5818. hit: boolean;
  5819. /**
  5820. * Distance away where the pick collided
  5821. */
  5822. distance: number;
  5823. /**
  5824. * The location of pick collision
  5825. */
  5826. pickedPoint: Nullable<Vector3>;
  5827. /**
  5828. * The mesh corrisponding the the pick collision
  5829. */
  5830. pickedMesh: Nullable<AbstractMesh>;
  5831. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5832. bu: number;
  5833. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5834. bv: number;
  5835. /** The id of the face on the mesh that was picked */
  5836. faceId: number;
  5837. /** Id of the the submesh that was picked */
  5838. subMeshId: number;
  5839. /** If a sprite was picked, this will be the sprite the pick collided with */
  5840. pickedSprite: Nullable<Sprite>;
  5841. /**
  5842. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5843. */
  5844. originMesh: Nullable<AbstractMesh>;
  5845. /**
  5846. * The ray that was used to perform the picking.
  5847. */
  5848. ray: Nullable<Ray>;
  5849. /**
  5850. * Gets the normal corrispodning to the face the pick collided with
  5851. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5852. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5853. * @returns The normal corrispodning to the face the pick collided with
  5854. */
  5855. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5856. /**
  5857. * Gets the texture coordinates of where the pick occured
  5858. * @returns the vector containing the coordnates of the texture
  5859. */
  5860. getTextureCoordinates(): Nullable<Vector2>;
  5861. }
  5862. }
  5863. declare module BABYLON {
  5864. class BoundingBox implements ICullable {
  5865. vectors: Vector3[];
  5866. center: Vector3;
  5867. centerWorld: Vector3;
  5868. extendSize: Vector3;
  5869. extendSizeWorld: Vector3;
  5870. directions: Vector3[];
  5871. vectorsWorld: Vector3[];
  5872. minimumWorld: Vector3;
  5873. maximumWorld: Vector3;
  5874. minimum: Vector3;
  5875. maximum: Vector3;
  5876. private _worldMatrix;
  5877. /**
  5878. * Creates a new bounding box
  5879. * @param min defines the minimum vector (in local space)
  5880. * @param max defines the maximum vector (in local space)
  5881. */
  5882. constructor(min: Vector3, max: Vector3);
  5883. /**
  5884. * Recreates the entire bounding box from scratch
  5885. * @param min defines the new minimum vector (in local space)
  5886. * @param max defines the new maximum vector (in local space)
  5887. */
  5888. reConstruct(min: Vector3, max: Vector3): void;
  5889. getWorldMatrix(): Matrix;
  5890. setWorldMatrix(matrix: Matrix): BoundingBox;
  5891. _update(world: Matrix): void;
  5892. isInFrustum(frustumPlanes: Plane[]): boolean;
  5893. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5894. intersectsPoint(point: Vector3): boolean;
  5895. intersectsSphere(sphere: BoundingSphere): boolean;
  5896. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5897. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5898. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5899. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5900. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. interface ICullable {
  5905. isInFrustum(frustumPlanes: Plane[]): boolean;
  5906. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5907. }
  5908. class BoundingInfo implements ICullable {
  5909. minimum: Vector3;
  5910. maximum: Vector3;
  5911. boundingBox: BoundingBox;
  5912. boundingSphere: BoundingSphere;
  5913. private _isLocked;
  5914. constructor(minimum: Vector3, maximum: Vector3);
  5915. isLocked: boolean;
  5916. update(world: Matrix): void;
  5917. /**
  5918. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5919. * @param center New center of the bounding info
  5920. * @param extend New extend of the bounding info
  5921. */
  5922. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5923. isInFrustum(frustumPlanes: Plane[]): boolean;
  5924. /**
  5925. * Gets the world distance between the min and max points of the bounding box
  5926. */
  5927. readonly diagonalLength: number;
  5928. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5929. _checkCollision(collider: Collider): boolean;
  5930. intersectsPoint(point: Vector3): boolean;
  5931. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5932. }
  5933. }
  5934. declare module BABYLON {
  5935. class BoundingSphere {
  5936. center: Vector3;
  5937. radius: number;
  5938. centerWorld: Vector3;
  5939. radiusWorld: number;
  5940. minimum: Vector3;
  5941. maximum: Vector3;
  5942. private _tempRadiusVector;
  5943. /**
  5944. * Creates a new bounding sphere
  5945. * @param min defines the minimum vector (in local space)
  5946. * @param max defines the maximum vector (in local space)
  5947. */
  5948. constructor(min: Vector3, max: Vector3);
  5949. /**
  5950. * Recreates the entire bounding sphere from scratch
  5951. * @param min defines the new minimum vector (in local space)
  5952. * @param max defines the new maximum vector (in local space)
  5953. */
  5954. reConstruct(min: Vector3, max: Vector3): void;
  5955. _update(world: Matrix): void;
  5956. isInFrustum(frustumPlanes: Plane[]): boolean;
  5957. intersectsPoint(point: Vector3): boolean;
  5958. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5959. }
  5960. }
  5961. declare module BABYLON {
  5962. class Ray {
  5963. origin: Vector3;
  5964. direction: Vector3;
  5965. length: number;
  5966. private _edge1;
  5967. private _edge2;
  5968. private _pvec;
  5969. private _tvec;
  5970. private _qvec;
  5971. private _tmpRay;
  5972. constructor(origin: Vector3, direction: Vector3, length?: number);
  5973. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5974. intersectsBox(box: BoundingBox): boolean;
  5975. intersectsSphere(sphere: BoundingSphere): boolean;
  5976. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5977. intersectsPlane(plane: Plane): Nullable<number>;
  5978. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5979. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5980. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5981. private static smallnum;
  5982. private static rayl;
  5983. /**
  5984. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5985. * @param sega the first point of the segment to test the intersection against
  5986. * @param segb the second point of the segment to test the intersection against
  5987. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5988. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5989. */
  5990. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5991. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5992. static Zero(): Ray;
  5993. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5994. /**
  5995. * 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
  5996. * transformed to the given world matrix.
  5997. * @param origin The origin point
  5998. * @param end The end point
  5999. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6000. */
  6001. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6002. static Transform(ray: Ray, matrix: Matrix): Ray;
  6003. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6004. }
  6005. }
  6006. /**
  6007. * Module Debug contains the (visual) components to debug a scene correctly
  6008. */
  6009. declare module BABYLON.Debug {
  6010. /**
  6011. * The Axes viewer will show 3 axes in a specific point in space
  6012. */
  6013. class AxesViewer {
  6014. private _xline;
  6015. private _yline;
  6016. private _zline;
  6017. private _xmesh;
  6018. private _ymesh;
  6019. private _zmesh;
  6020. /**
  6021. * Gets the hosting scene
  6022. */
  6023. scene: Nullable<Scene>;
  6024. /**
  6025. * Gets or sets a number used to scale line length
  6026. */
  6027. scaleLines: number;
  6028. /**
  6029. * Creates a new AxesViewer
  6030. * @param scene defines the hosting scene
  6031. * @param scaleLines defines a number used to scale line length (1 by default)
  6032. */
  6033. constructor(scene: Scene, scaleLines?: number);
  6034. /**
  6035. * Force the viewer to update
  6036. * @param position defines the position of the viewer
  6037. * @param xaxis defines the x axis of the viewer
  6038. * @param yaxis defines the y axis of the viewer
  6039. * @param zaxis defines the z axis of the viewer
  6040. */
  6041. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6042. /** Releases resources */
  6043. dispose(): void;
  6044. }
  6045. }
  6046. declare module BABYLON.Debug {
  6047. /**
  6048. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6049. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6050. */
  6051. class BoneAxesViewer extends AxesViewer {
  6052. /**
  6053. * Gets or sets the target mesh where to display the axes viewer
  6054. */
  6055. mesh: Nullable<Mesh>;
  6056. /**
  6057. * Gets or sets the target bone where to display the axes viewer
  6058. */
  6059. bone: Nullable<Bone>;
  6060. /** Gets current position */
  6061. pos: Vector3;
  6062. /** Gets direction of X axis */
  6063. xaxis: Vector3;
  6064. /** Gets direction of Y axis */
  6065. yaxis: Vector3;
  6066. /** Gets direction of Z axis */
  6067. zaxis: Vector3;
  6068. /**
  6069. * Creates a new BoneAxesViewer
  6070. * @param scene defines the hosting scene
  6071. * @param bone defines the target bone
  6072. * @param mesh defines the target mesh
  6073. * @param scaleLines defines a scaling factor for line length (1 by default)
  6074. */
  6075. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6076. /**
  6077. * Force the viewer to update
  6078. */
  6079. update(): void;
  6080. /** Releases resources */
  6081. dispose(): void;
  6082. }
  6083. }
  6084. declare module BABYLON {
  6085. class DebugLayer {
  6086. private _scene;
  6087. static InspectorURL: string;
  6088. private _inspector;
  6089. private BJSINSPECTOR;
  6090. constructor(scene: Scene);
  6091. /** Creates the inspector window. */
  6092. private _createInspector(config?);
  6093. isVisible(): boolean;
  6094. hide(): void;
  6095. /**
  6096. *
  6097. * Launch the debugLayer.
  6098. *
  6099. * initialTab:
  6100. * | Value | Tab Name |
  6101. * | --- | --- |
  6102. * | 0 | Scene |
  6103. * | 1 | Console |
  6104. * | 2 | Stats |
  6105. * | 3 | Textures |
  6106. * | 4 | Mesh |
  6107. * | 5 | Light |
  6108. * | 6 | Material |
  6109. * | 7 | GLTF |
  6110. * | 8 | GUI |
  6111. * | 9 | Physics |
  6112. * | 10 | Camera |
  6113. * | 11 | Audio |
  6114. *
  6115. */
  6116. show(config?: {
  6117. popup?: boolean;
  6118. initialTab?: number;
  6119. parentElement?: HTMLElement;
  6120. newColors?: {
  6121. backgroundColor?: string;
  6122. backgroundColorLighter?: string;
  6123. backgroundColorLighter2?: string;
  6124. backgroundColorLighter3?: string;
  6125. color?: string;
  6126. colorTop?: string;
  6127. colorBot?: string;
  6128. };
  6129. }): void;
  6130. /**
  6131. * Gets the active tab
  6132. * @return the index of the active tab or -1 if the inspector is hidden
  6133. */
  6134. getActiveTab(): number;
  6135. }
  6136. }
  6137. declare module BABYLON.Debug {
  6138. /**
  6139. * Used to show the physics impostor around the specific mesh
  6140. */
  6141. class PhysicsViewer {
  6142. /** @hidden */
  6143. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6144. /** @hidden */
  6145. protected _meshes: Array<Nullable<AbstractMesh>>;
  6146. /** @hidden */
  6147. protected _scene: Nullable<Scene>;
  6148. /** @hidden */
  6149. protected _numMeshes: number;
  6150. /** @hidden */
  6151. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6152. private _renderFunction;
  6153. private _debugBoxMesh;
  6154. private _debugSphereMesh;
  6155. private _debugMaterial;
  6156. /**
  6157. * Creates a new PhysicsViewer
  6158. * @param scene defines the hosting scene
  6159. */
  6160. constructor(scene: Scene);
  6161. /** @hidden */
  6162. protected _updateDebugMeshes(): void;
  6163. /**
  6164. * Renders a specified physic impostor
  6165. * @param impostor defines the impostor to render
  6166. */
  6167. showImpostor(impostor: PhysicsImpostor): void;
  6168. /**
  6169. * Hides a specified physic impostor
  6170. * @param impostor defines the impostor to hide
  6171. */
  6172. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6173. private _getDebugMaterial(scene);
  6174. private _getDebugBoxMesh(scene);
  6175. private _getDebugSphereMesh(scene);
  6176. private _getDebugMesh(impostor, scene);
  6177. /** Releases all resources */
  6178. dispose(): void;
  6179. }
  6180. }
  6181. declare module BABYLON {
  6182. class RayHelper {
  6183. ray: Nullable<Ray>;
  6184. private _renderPoints;
  6185. private _renderLine;
  6186. private _renderFunction;
  6187. private _scene;
  6188. private _updateToMeshFunction;
  6189. private _attachedToMesh;
  6190. private _meshSpaceDirection;
  6191. private _meshSpaceOrigin;
  6192. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6193. constructor(ray: Ray);
  6194. show(scene: Scene, color: Color3): void;
  6195. hide(): void;
  6196. private _render();
  6197. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6198. detachFromMesh(): void;
  6199. private _updateToMesh();
  6200. dispose(): void;
  6201. }
  6202. }
  6203. declare module BABYLON.Debug {
  6204. /**
  6205. * Class used to render a debug view of a given skeleton
  6206. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6207. */
  6208. class SkeletonViewer {
  6209. /** defines the skeleton to render */
  6210. skeleton: Skeleton;
  6211. /** defines the mesh attached to the skeleton */
  6212. mesh: AbstractMesh;
  6213. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6214. autoUpdateBonesMatrices: boolean;
  6215. /** defines the rendering group id to use with the viewer */
  6216. renderingGroupId: number;
  6217. /** Gets or sets the color used to render the skeleton */
  6218. color: Color3;
  6219. private _scene;
  6220. private _debugLines;
  6221. private _debugMesh;
  6222. private _isEnabled;
  6223. private _renderFunction;
  6224. /**
  6225. * Creates a new SkeletonViewer
  6226. * @param skeleton defines the skeleton to render
  6227. * @param mesh defines the mesh attached to the skeleton
  6228. * @param scene defines the hosting scene
  6229. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6230. * @param renderingGroupId defines the rendering group id to use with the viewer
  6231. */
  6232. constructor(
  6233. /** defines the skeleton to render */
  6234. skeleton: Skeleton,
  6235. /** defines the mesh attached to the skeleton */
  6236. mesh: AbstractMesh, scene: Scene,
  6237. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6238. autoUpdateBonesMatrices?: boolean,
  6239. /** defines the rendering group id to use with the viewer */
  6240. renderingGroupId?: number);
  6241. /** Gets or sets a boolean indicating if the viewer is enabled */
  6242. isEnabled: boolean;
  6243. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  6244. private _getLinesForBonesWithLength(bones, meshMat);
  6245. private _getLinesForBonesNoLength(bones, meshMat);
  6246. /** Update the viewer to sync with current skeleton state */
  6247. update(): void;
  6248. /** Release associated resources */
  6249. dispose(): void;
  6250. }
  6251. }
  6252. declare module BABYLON {
  6253. /**
  6254. * Interface for attribute information associated with buffer instanciation
  6255. */
  6256. class InstancingAttributeInfo {
  6257. /**
  6258. * Index/offset of the attribute in the vertex shader
  6259. */
  6260. index: number;
  6261. /**
  6262. * size of the attribute, 1, 2, 3 or 4
  6263. */
  6264. attributeSize: number;
  6265. /**
  6266. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6267. * default is FLOAT
  6268. */
  6269. attribyteType: number;
  6270. /**
  6271. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6272. */
  6273. normalized: boolean;
  6274. /**
  6275. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6276. */
  6277. offset: number;
  6278. /**
  6279. * Name of the GLSL attribute, for debugging purpose only
  6280. */
  6281. attributeName: string;
  6282. }
  6283. /**
  6284. * Define options used to create a render target texture
  6285. */
  6286. class RenderTargetCreationOptions {
  6287. /**
  6288. * Specifies is mipmaps must be generated
  6289. */
  6290. generateMipMaps?: boolean;
  6291. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6292. generateDepthBuffer?: boolean;
  6293. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6294. generateStencilBuffer?: boolean;
  6295. /** Defines texture type (int by default) */
  6296. type?: number;
  6297. /** Defines sampling mode (trilinear by default) */
  6298. samplingMode?: number;
  6299. /** Defines format (RGBA by default) */
  6300. format?: number;
  6301. }
  6302. /**
  6303. * Define options used to create a depth texture
  6304. */
  6305. class DepthTextureCreationOptions {
  6306. /** Specifies whether or not a stencil should be allocated in the texture */
  6307. generateStencil?: boolean;
  6308. /** Specifies whether or not bilinear filtering is enable on the texture */
  6309. bilinearFiltering?: boolean;
  6310. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6311. comparisonFunction?: number;
  6312. /** Specifies if the created texture is a cube texture */
  6313. isCube?: boolean;
  6314. }
  6315. /**
  6316. * Class used to describe the capabilities of the engine relatively to the current browser
  6317. */
  6318. class EngineCapabilities {
  6319. /** Maximum textures units per fragment shader */
  6320. maxTexturesImageUnits: number;
  6321. /** Maximum texture units per vertex shader */
  6322. maxVertexTextureImageUnits: number;
  6323. /** Maximum textures units in the entire pipeline */
  6324. maxCombinedTexturesImageUnits: number;
  6325. /** Maximum texture size */
  6326. maxTextureSize: number;
  6327. /** Maximum cube texture size */
  6328. maxCubemapTextureSize: number;
  6329. /** Maximum render texture size */
  6330. maxRenderTextureSize: number;
  6331. /** Maximum number of vertex attributes */
  6332. maxVertexAttribs: number;
  6333. /** Maximum number of varyings */
  6334. maxVaryingVectors: number;
  6335. /** Maximum number of uniforms per vertex shader */
  6336. maxVertexUniformVectors: number;
  6337. /** Maximum number of uniforms per fragment shader */
  6338. maxFragmentUniformVectors: number;
  6339. /** Defines if standard derivates (dx/dy) are supported */
  6340. standardDerivatives: boolean;
  6341. /** Defines if s3tc texture compression is supported */
  6342. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6343. /** Defines if pvrtc texture compression is supported */
  6344. pvrtc: any;
  6345. /** Defines if etc1 texture compression is supported */
  6346. etc1: any;
  6347. /** Defines if etc2 texture compression is supported */
  6348. etc2: any;
  6349. /** Defines if astc texture compression is supported */
  6350. astc: any;
  6351. /** Defines if float textures are supported */
  6352. textureFloat: boolean;
  6353. /** Defines if vertex array objects are supported */
  6354. vertexArrayObject: boolean;
  6355. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6356. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6357. /** Gets the maximum level of anisotropy supported */
  6358. maxAnisotropy: number;
  6359. /** Defines if instancing is supported */
  6360. instancedArrays: boolean;
  6361. /** Defines if 32 bits indices are supported */
  6362. uintIndices: boolean;
  6363. /** Defines if high precision shaders are supported */
  6364. highPrecisionShaderSupported: boolean;
  6365. /** Defines if depth reading in the fragment shader is supported */
  6366. fragmentDepthSupported: boolean;
  6367. /** Defines if float texture linear filtering is supported*/
  6368. textureFloatLinearFiltering: boolean;
  6369. /** Defines if rendering to float textures is supported */
  6370. textureFloatRender: boolean;
  6371. /** Defines if half float textures are supported*/
  6372. textureHalfFloat: boolean;
  6373. /** Defines if half float texture linear filtering is supported*/
  6374. textureHalfFloatLinearFiltering: boolean;
  6375. /** Defines if rendering to half float textures is supported */
  6376. textureHalfFloatRender: boolean;
  6377. /** Defines if textureLOD shader command is supported */
  6378. textureLOD: boolean;
  6379. /** Defines if draw buffers extension is supported */
  6380. drawBuffersExtension: boolean;
  6381. /** Defines if depth textures are supported */
  6382. depthTextureExtension: boolean;
  6383. /** Defines if float color buffer are supported */
  6384. colorBufferFloat: boolean;
  6385. /** Gets disjoint timer query extension (null if not supported) */
  6386. timerQuery: EXT_disjoint_timer_query;
  6387. /** Defines if timestamp can be used with timer query */
  6388. canUseTimestampForTimerQuery: boolean;
  6389. }
  6390. /** Interface defining initialization parameters for Engine class */
  6391. interface EngineOptions extends WebGLContextAttributes {
  6392. /**
  6393. * Defines if the engine should no exceed a specified device ratio
  6394. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6395. */
  6396. limitDeviceRatio?: number;
  6397. /**
  6398. * Defines if webvr should be enabled automatically
  6399. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6400. */
  6401. autoEnableWebVR?: boolean;
  6402. /**
  6403. * Defines if webgl2 should be turned off even if supported
  6404. * @see http://doc.babylonjs.com/features/webgl2
  6405. */
  6406. disableWebGL2Support?: boolean;
  6407. /**
  6408. * Defines if webaudio should be initialized as well
  6409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6410. */
  6411. audioEngine?: boolean;
  6412. /**
  6413. * Defines if animations should run using a deterministic lock step
  6414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6415. */
  6416. deterministicLockstep?: boolean;
  6417. /** Defines the maximum steps to use with deterministic lock step mode */
  6418. lockstepMaxSteps?: number;
  6419. /**
  6420. * Defines that engine should ignore context lost events
  6421. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6422. */
  6423. doNotHandleContextLost?: boolean;
  6424. }
  6425. /**
  6426. * Defines the interface used by display changed events
  6427. */
  6428. interface IDisplayChangedEventArgs {
  6429. /** Gets the vrDisplay object (if any) */
  6430. vrDisplay: Nullable<any>;
  6431. /** Gets a boolean indicating if webVR is supported */
  6432. vrSupported: boolean;
  6433. }
  6434. /**
  6435. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6436. */
  6437. class Engine {
  6438. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6439. static ExceptionList: ({
  6440. key: string;
  6441. capture: string;
  6442. captureConstraint: number;
  6443. targets: string[];
  6444. } | {
  6445. key: string;
  6446. capture: null;
  6447. captureConstraint: null;
  6448. targets: string[];
  6449. })[];
  6450. /** Gets the list of created engines */
  6451. static Instances: Engine[];
  6452. /**
  6453. * Gets the latest created engine
  6454. */
  6455. static readonly LastCreatedEngine: Nullable<Engine>;
  6456. /**
  6457. * Gets the latest created scene
  6458. */
  6459. static readonly LastCreatedScene: Nullable<Scene>;
  6460. /**
  6461. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6462. * @param flag defines which part of the materials must be marked as dirty
  6463. * @param predicate defines a predicate used to filter which materials should be affected
  6464. */
  6465. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6466. private static _ALPHA_DISABLE;
  6467. private static _ALPHA_ADD;
  6468. private static _ALPHA_COMBINE;
  6469. private static _ALPHA_SUBTRACT;
  6470. private static _ALPHA_MULTIPLY;
  6471. private static _ALPHA_MAXIMIZED;
  6472. private static _ALPHA_ONEONE;
  6473. private static _ALPHA_PREMULTIPLIED;
  6474. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6475. private static _ALPHA_INTERPOLATE;
  6476. private static _ALPHA_SCREENMODE;
  6477. private static _DELAYLOADSTATE_NONE;
  6478. private static _DELAYLOADSTATE_LOADED;
  6479. private static _DELAYLOADSTATE_LOADING;
  6480. private static _DELAYLOADSTATE_NOTLOADED;
  6481. private static _TEXTUREFORMAT_ALPHA;
  6482. private static _TEXTUREFORMAT_LUMINANCE;
  6483. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6484. private static _TEXTUREFORMAT_RGB;
  6485. private static _TEXTUREFORMAT_RGBA;
  6486. private static _TEXTUREFORMAT_R;
  6487. private static _TEXTUREFORMAT_RG;
  6488. private static _TEXTURETYPE_UNSIGNED_INT;
  6489. private static _TEXTURETYPE_FLOAT;
  6490. private static _TEXTURETYPE_HALF_FLOAT;
  6491. private static _NEVER;
  6492. private static _ALWAYS;
  6493. private static _LESS;
  6494. private static _EQUAL;
  6495. private static _LEQUAL;
  6496. private static _GREATER;
  6497. private static _GEQUAL;
  6498. private static _NOTEQUAL;
  6499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6500. static readonly NEVER: number;
  6501. /** 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 */
  6502. static readonly ALWAYS: number;
  6503. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6504. static readonly LESS: number;
  6505. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6506. static readonly EQUAL: number;
  6507. /** 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 */
  6508. static readonly LEQUAL: number;
  6509. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6510. static readonly GREATER: number;
  6511. /** 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 */
  6512. static readonly GEQUAL: number;
  6513. /** 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 */
  6514. static readonly NOTEQUAL: number;
  6515. private static _KEEP;
  6516. private static _REPLACE;
  6517. private static _INCR;
  6518. private static _DECR;
  6519. private static _INVERT;
  6520. private static _INCR_WRAP;
  6521. private static _DECR_WRAP;
  6522. /** Passed to stencilOperation to specify that stencil value must be kept */
  6523. static readonly KEEP: number;
  6524. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6525. static readonly REPLACE: number;
  6526. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6527. static readonly INCR: number;
  6528. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6529. static readonly DECR: number;
  6530. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6531. static readonly INVERT: number;
  6532. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6533. static readonly INCR_WRAP: number;
  6534. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6535. static readonly DECR_WRAP: number;
  6536. /** Defines that alpha blending is disabled */
  6537. static readonly ALPHA_DISABLE: number;
  6538. /** Defines that alpha blending to SRC + DEST */
  6539. static readonly ALPHA_ONEONE: number;
  6540. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6541. static readonly ALPHA_ADD: number;
  6542. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6543. static readonly ALPHA_COMBINE: number;
  6544. /** Defines that alpha blending to DEST - SRC * DEST */
  6545. static readonly ALPHA_SUBTRACT: number;
  6546. /** Defines that alpha blending to SRC * DEST */
  6547. static readonly ALPHA_MULTIPLY: number;
  6548. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6549. static readonly ALPHA_MAXIMIZED: number;
  6550. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6551. static readonly ALPHA_PREMULTIPLIED: number;
  6552. /**
  6553. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6554. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6555. */
  6556. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6557. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6558. static readonly ALPHA_INTERPOLATE: number;
  6559. /**
  6560. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6561. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6562. */
  6563. static readonly ALPHA_SCREENMODE: number;
  6564. /** Defines that the ressource is not delayed*/
  6565. static readonly DELAYLOADSTATE_NONE: number;
  6566. /** Defines that the ressource was successfully delay loaded */
  6567. static readonly DELAYLOADSTATE_LOADED: number;
  6568. /** Defines that the ressource is currently delay loading */
  6569. static readonly DELAYLOADSTATE_LOADING: number;
  6570. /** Defines that the ressource is delayed and has not started loading */
  6571. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6572. /** ALPHA */
  6573. static readonly TEXTUREFORMAT_ALPHA: number;
  6574. /** LUMINANCE */
  6575. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6576. /**
  6577. * R
  6578. */
  6579. static readonly TEXTUREFORMAT_R: number;
  6580. /**
  6581. * RG
  6582. */
  6583. static readonly TEXTUREFORMAT_RG: number;
  6584. /** LUMINANCE_ALPHA */
  6585. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6586. /** RGB */
  6587. static readonly TEXTUREFORMAT_RGB: number;
  6588. /** RGBA */
  6589. static readonly TEXTUREFORMAT_RGBA: number;
  6590. /** UNSIGNED_INT */
  6591. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6592. /** FLOAT */
  6593. static readonly TEXTURETYPE_FLOAT: number;
  6594. /** HALF_FLOAT */
  6595. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6596. private static _SCALEMODE_FLOOR;
  6597. private static _SCALEMODE_NEAREST;
  6598. private static _SCALEMODE_CEILING;
  6599. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6600. static readonly SCALEMODE_FLOOR: number;
  6601. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6602. static readonly SCALEMODE_NEAREST: number;
  6603. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6604. static readonly SCALEMODE_CEILING: number;
  6605. /**
  6606. * Returns the current version of the framework
  6607. */
  6608. static readonly Version: string;
  6609. /**
  6610. * Gets or sets the epsilon value used by collision engine
  6611. */
  6612. static CollisionsEpsilon: number;
  6613. /**
  6614. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6615. */
  6616. static CodeRepository: string;
  6617. /**
  6618. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6619. */
  6620. static ShadersRepository: string;
  6621. /**
  6622. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6623. */
  6624. forcePOTTextures: boolean;
  6625. /**
  6626. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6627. */
  6628. isFullscreen: boolean;
  6629. /**
  6630. * Gets a boolean indicating if the pointer is currently locked
  6631. */
  6632. isPointerLock: boolean;
  6633. /**
  6634. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6635. */
  6636. cullBackFaces: boolean;
  6637. /**
  6638. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6639. */
  6640. renderEvenInBackground: boolean;
  6641. /**
  6642. * Gets or sets a boolean indicating that cache can be kept between frames
  6643. */
  6644. preventCacheWipeBetweenFrames: boolean;
  6645. /**
  6646. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6647. **/
  6648. enableOfflineSupport: boolean;
  6649. /**
  6650. * 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)
  6651. **/
  6652. disableManifestCheck: boolean;
  6653. /**
  6654. * Gets the list of created scenes
  6655. */
  6656. scenes: Scene[];
  6657. /**
  6658. * Gets the list of created postprocesses
  6659. */
  6660. postProcesses: PostProcess[];
  6661. /**
  6662. * Observable event triggered each time the rendering canvas is resized
  6663. */
  6664. onResizeObservable: Observable<Engine>;
  6665. /**
  6666. * Observable event triggered each time the canvas loses focus
  6667. */
  6668. onCanvasBlurObservable: Observable<Engine>;
  6669. /**
  6670. * Observable event triggered each time the canvas gains focus
  6671. */
  6672. onCanvasFocusObservable: Observable<Engine>;
  6673. /**
  6674. * Observable event triggered each time the canvas receives pointerout event
  6675. */
  6676. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6677. /**
  6678. * Observable event triggered before each texture is initialized
  6679. */
  6680. onBeforeTextureInitObservable: Observable<Texture>;
  6681. private _vrDisplay;
  6682. private _vrSupported;
  6683. private _oldSize;
  6684. private _oldHardwareScaleFactor;
  6685. private _vrExclusivePointerMode;
  6686. private _webVRInitPromise;
  6687. /**
  6688. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6689. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6690. */
  6691. readonly isInVRExclusivePointerMode: boolean;
  6692. /**
  6693. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6694. */
  6695. disableUniformBuffers: boolean;
  6696. /** @hidden */
  6697. _uniformBuffers: UniformBuffer[];
  6698. /**
  6699. * Gets a boolean indicating that the engine supports uniform buffers
  6700. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6701. */
  6702. readonly supportsUniformBuffers: boolean;
  6703. /**
  6704. * Observable raised when the engine begins a new frame
  6705. */
  6706. onBeginFrameObservable: Observable<Engine>;
  6707. /**
  6708. * Observable raised when the engine ends the current frame
  6709. */
  6710. onEndFrameObservable: Observable<Engine>;
  6711. /**
  6712. * Observable raised when the engine is about to compile a shader
  6713. */
  6714. onBeforeShaderCompilationObservable: Observable<Engine>;
  6715. /**
  6716. * Observable raised when the engine has jsut compiled a shader
  6717. */
  6718. onAfterShaderCompilationObservable: Observable<Engine>;
  6719. private _gl;
  6720. private _renderingCanvas;
  6721. private _windowIsBackground;
  6722. private _webGLVersion;
  6723. /**
  6724. * Gets a boolean indicating that only power of 2 textures are supported
  6725. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6726. */
  6727. readonly needPOTTextures: boolean;
  6728. /** @hidden */
  6729. _badOS: boolean;
  6730. /** @hidden */
  6731. _badDesktopOS: boolean;
  6732. /**
  6733. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6734. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6735. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6736. */
  6737. disableTextureBindingOptimization: boolean;
  6738. /**
  6739. * Gets the audio engine
  6740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6741. * @ignorenaming
  6742. */
  6743. static audioEngine: AudioEngine;
  6744. private _onFocus;
  6745. private _onBlur;
  6746. private _onCanvasPointerOut;
  6747. private _onCanvasBlur;
  6748. private _onCanvasFocus;
  6749. private _onFullscreenChange;
  6750. private _onPointerLockChange;
  6751. private _onVRDisplayPointerRestricted;
  6752. private _onVRDisplayPointerUnrestricted;
  6753. private _onVrDisplayConnect;
  6754. private _onVrDisplayDisconnect;
  6755. private _onVrDisplayPresentChange;
  6756. /**
  6757. * Observable signaled when VR display mode changes
  6758. */
  6759. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6760. /**
  6761. * Observable signaled when VR request present is complete
  6762. */
  6763. onVRRequestPresentComplete: Observable<boolean>;
  6764. /**
  6765. * Observable signaled when VR request present starts
  6766. */
  6767. onVRRequestPresentStart: Observable<Engine>;
  6768. private _hardwareScalingLevel;
  6769. /** @hidden */
  6770. protected _caps: EngineCapabilities;
  6771. private _pointerLockRequested;
  6772. private _isStencilEnable;
  6773. private _colorWrite;
  6774. private _loadingScreen;
  6775. /** @hidden */
  6776. _drawCalls: PerfCounter;
  6777. /** @hidden */
  6778. _textureCollisions: PerfCounter;
  6779. private _glVersion;
  6780. private _glRenderer;
  6781. private _glVendor;
  6782. private _videoTextureSupported;
  6783. private _renderingQueueLaunched;
  6784. private _activeRenderLoops;
  6785. private _deterministicLockstep;
  6786. private _lockstepMaxSteps;
  6787. /**
  6788. * Observable signaled when a context lost event is raised
  6789. */
  6790. onContextLostObservable: Observable<Engine>;
  6791. /**
  6792. * Observable signaled when a context restored event is raised
  6793. */
  6794. onContextRestoredObservable: Observable<Engine>;
  6795. private _onContextLost;
  6796. private _onContextRestored;
  6797. private _contextWasLost;
  6798. private _doNotHandleContextLost;
  6799. /**
  6800. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  6801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  6802. */
  6803. doNotHandleContextLost: boolean;
  6804. private _performanceMonitor;
  6805. private _fps;
  6806. private _deltaTime;
  6807. /**
  6808. * Turn this value on if you want to pause FPS computation when in background
  6809. */
  6810. disablePerformanceMonitorInBackground: boolean;
  6811. /**
  6812. * Gets the performance monitor attached to this engine
  6813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  6814. */
  6815. readonly performanceMonitor: PerformanceMonitor;
  6816. /** @hidden */
  6817. protected _depthCullingState: _DepthCullingState;
  6818. /** @hidden */
  6819. protected _stencilState: _StencilState;
  6820. /** @hidden */
  6821. protected _alphaState: _AlphaState;
  6822. /** @hidden */
  6823. protected _alphaMode: number;
  6824. protected _internalTexturesCache: InternalTexture[];
  6825. /** @hidden */
  6826. protected _activeChannel: number;
  6827. private _currentTextureChannel;
  6828. /** @hidden */
  6829. protected _boundTexturesCache: {
  6830. [key: string]: Nullable<InternalTexture>;
  6831. };
  6832. /** @hidden */
  6833. protected _currentEffect: Nullable<Effect>;
  6834. /** @hidden */
  6835. protected _currentProgram: Nullable<WebGLProgram>;
  6836. private _compiledEffects;
  6837. private _vertexAttribArraysEnabled;
  6838. /** @hidden */
  6839. protected _cachedViewport: Nullable<Viewport>;
  6840. private _cachedVertexArrayObject;
  6841. /** @hidden */
  6842. protected _cachedVertexBuffers: any;
  6843. /** @hidden */
  6844. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6845. /** @hidden */
  6846. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6847. /** @hidden */
  6848. protected _currentRenderTarget: Nullable<InternalTexture>;
  6849. private _uintIndicesCurrentlySet;
  6850. private _currentBoundBuffer;
  6851. /** @hidden */
  6852. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6853. private _currentBufferPointers;
  6854. private _currentInstanceLocations;
  6855. private _currentInstanceBuffers;
  6856. private _textureUnits;
  6857. private _firstBoundInternalTextureTracker;
  6858. private _lastBoundInternalTextureTracker;
  6859. private _workingCanvas;
  6860. private _workingContext;
  6861. private _rescalePostProcess;
  6862. private _dummyFramebuffer;
  6863. private _externalData;
  6864. private _bindedRenderFunction;
  6865. private _vaoRecordInProgress;
  6866. private _mustWipeVertexAttributes;
  6867. private _emptyTexture;
  6868. private _emptyCubeTexture;
  6869. private _emptyTexture3D;
  6870. private _frameHandler;
  6871. private _nextFreeTextureSlots;
  6872. private _maxSimultaneousTextures;
  6873. private _activeRequests;
  6874. private _texturesSupported;
  6875. private _textureFormatInUse;
  6876. /**
  6877. * Gets the list of texture formats supported
  6878. */
  6879. readonly texturesSupported: Array<string>;
  6880. /**
  6881. * Gets the list of texture formats in use
  6882. */
  6883. readonly textureFormatInUse: Nullable<string>;
  6884. /**
  6885. * Gets the current viewport
  6886. */
  6887. readonly currentViewport: Nullable<Viewport>;
  6888. /**
  6889. * Gets the default empty texture
  6890. */
  6891. readonly emptyTexture: InternalTexture;
  6892. /**
  6893. * Gets the default empty 3D texture
  6894. */
  6895. readonly emptyTexture3D: InternalTexture;
  6896. /**
  6897. * Gets the default empty cube texture
  6898. */
  6899. readonly emptyCubeTexture: InternalTexture;
  6900. /**
  6901. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  6902. */
  6903. readonly premultipliedAlpha: boolean;
  6904. /**
  6905. * Creates a new engine
  6906. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6907. * @param antialias defines enable antialiasing (default: false)
  6908. * @param options defines further options to be sent to the getContext() function
  6909. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6910. */
  6911. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6912. private _rebuildInternalTextures();
  6913. private _rebuildEffects();
  6914. private _rebuildBuffers();
  6915. private _initGLContext();
  6916. /**
  6917. * Gets version of the current webGL context
  6918. */
  6919. readonly webGLVersion: number;
  6920. /**
  6921. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6922. */
  6923. readonly isStencilEnable: boolean;
  6924. private _prepareWorkingCanvas();
  6925. /**
  6926. * Reset the texture cache to empty state
  6927. */
  6928. resetTextureCache(): void;
  6929. /**
  6930. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  6931. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6932. * @returns true if engine is in deterministic lock step mode
  6933. */
  6934. isDeterministicLockStep(): boolean;
  6935. /**
  6936. * Gets the max steps when engine is running in deterministic lock step
  6937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6938. * @returns the max steps
  6939. */
  6940. getLockstepMaxSteps(): number;
  6941. /**
  6942. * Gets an object containing information about the current webGL context
  6943. * @returns an object containing the vender, the renderer and the version of the current webGL context
  6944. */
  6945. getGlInfo(): {
  6946. vendor: string;
  6947. renderer: string;
  6948. version: string;
  6949. };
  6950. /**
  6951. * Gets current aspect ratio
  6952. * @param camera defines the camera to use to get the aspect ratio
  6953. * @param useScreen defines if screen size must be used (or the current render target if any)
  6954. * @returns a number defining the aspect ratio
  6955. */
  6956. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6957. /**
  6958. * Gets current screen aspect ratio
  6959. * @returns a number defining the aspect ratio
  6960. */
  6961. getScreenAspectRatio(): number;
  6962. /**
  6963. * Gets the current render width
  6964. * @param useScreen defines if screen size must be used (or the current render target if any)
  6965. * @returns a number defining the current render width
  6966. */
  6967. getRenderWidth(useScreen?: boolean): number;
  6968. /**
  6969. * Gets the current render height
  6970. * @param useScreen defines if screen size must be used (or the current render target if any)
  6971. * @returns a number defining the current render height
  6972. */
  6973. getRenderHeight(useScreen?: boolean): number;
  6974. /**
  6975. * Gets the HTML canvas attached with the current webGL context
  6976. * @returns a HTML canvas
  6977. */
  6978. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6979. /**
  6980. * Gets the client rect of the HTML canvas attached with the current webGL context
  6981. * @returns a client rectanglee
  6982. */
  6983. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6984. /**
  6985. * Defines the hardware scaling level.
  6986. * By default the hardware scaling level is computed from the window device ratio.
  6987. * 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.
  6988. * @param level defines the level to use
  6989. */
  6990. setHardwareScalingLevel(level: number): void;
  6991. /**
  6992. * Gets the current hardware scaling level.
  6993. * By default the hardware scaling level is computed from the window device ratio.
  6994. * 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.
  6995. * @returns a number indicating the current hardware scaling level
  6996. */
  6997. getHardwareScalingLevel(): number;
  6998. /**
  6999. * Gets the list of loaded textures
  7000. * @returns an array containing all loaded textures
  7001. */
  7002. getLoadedTexturesCache(): InternalTexture[];
  7003. /**
  7004. * Gets the object containing all engine capabilities
  7005. * @returns the EngineCapabilities object
  7006. */
  7007. getCaps(): EngineCapabilities;
  7008. /** @hidden */
  7009. readonly drawCalls: number;
  7010. /** @hidden */
  7011. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7012. /**
  7013. * Gets the current depth function
  7014. * @returns a number defining the depth function
  7015. */
  7016. getDepthFunction(): Nullable<number>;
  7017. /**
  7018. * Sets the current depth function
  7019. * @param depthFunc defines the function to use
  7020. */
  7021. setDepthFunction(depthFunc: number): void;
  7022. /**
  7023. * Sets the current depth function to GREATER
  7024. */
  7025. setDepthFunctionToGreater(): void;
  7026. /**
  7027. * Sets the current depth function to GEQUAL
  7028. */
  7029. setDepthFunctionToGreaterOrEqual(): void;
  7030. /**
  7031. * Sets the current depth function to LESS
  7032. */
  7033. setDepthFunctionToLess(): void;
  7034. /**
  7035. * Sets the current depth function to LEQUAL
  7036. */
  7037. setDepthFunctionToLessOrEqual(): void;
  7038. /**
  7039. * Gets a boolean indicating if stencil buffer is enabled
  7040. * @returns the current stencil buffer state
  7041. */
  7042. getStencilBuffer(): boolean;
  7043. /**
  7044. * Enable or disable the stencil buffer
  7045. * @param enable defines if the stencil buffer must be enabled or disabled
  7046. */
  7047. setStencilBuffer(enable: boolean): void;
  7048. /**
  7049. * Gets the current stencil mask
  7050. * @returns a number defining the new stencil mask to use
  7051. */
  7052. getStencilMask(): number;
  7053. /**
  7054. * Sets the current stencil mask
  7055. * @param mask defines the new stencil mask to use
  7056. */
  7057. setStencilMask(mask: number): void;
  7058. /**
  7059. * Gets the current stencil function
  7060. * @returns a number defining the stencil function to use
  7061. */
  7062. getStencilFunction(): number;
  7063. /**
  7064. * Gets the current stencil reference value
  7065. * @returns a number defining the stencil reference value to use
  7066. */
  7067. getStencilFunctionReference(): number;
  7068. /**
  7069. * Gets the current stencil mask
  7070. * @returns a number defining the stencil mask to use
  7071. */
  7072. getStencilFunctionMask(): number;
  7073. /**
  7074. * Sets the current stencil function
  7075. * @param stencilFunc defines the new stencil function to use
  7076. */
  7077. setStencilFunction(stencilFunc: number): void;
  7078. /**
  7079. * Sets the current stencil reference
  7080. * @param reference defines the new stencil reference to use
  7081. */
  7082. setStencilFunctionReference(reference: number): void;
  7083. /**
  7084. * Sets the current stencil mask
  7085. * @param mask defines the new stencil mask to use
  7086. */
  7087. setStencilFunctionMask(mask: number): void;
  7088. /**
  7089. * Gets the current stencil operation when stencil fails
  7090. * @returns a number defining stencil operation to use when stencil fails
  7091. */
  7092. getStencilOperationFail(): number;
  7093. /**
  7094. * Gets the current stencil operation when depth fails
  7095. * @returns a number defining stencil operation to use when depth fails
  7096. */
  7097. getStencilOperationDepthFail(): number;
  7098. /**
  7099. * Gets the current stencil operation when stencil passes
  7100. * @returns a number defining stencil operation to use when stencil passes
  7101. */
  7102. getStencilOperationPass(): number;
  7103. /**
  7104. * Sets the stencil operation to use when stencil fails
  7105. * @param operation defines the stencil operation to use when stencil fails
  7106. */
  7107. setStencilOperationFail(operation: number): void;
  7108. /**
  7109. * Sets the stencil operation to use when depth fails
  7110. * @param operation defines the stencil operation to use when depth fails
  7111. */
  7112. setStencilOperationDepthFail(operation: number): void;
  7113. /**
  7114. * Sets the stencil operation to use when stencil passes
  7115. * @param operation defines the stencil operation to use when stencil passes
  7116. */
  7117. setStencilOperationPass(operation: number): void;
  7118. /**
  7119. * Sets a boolean indicating if the dithering state is enabled or disabled
  7120. * @param value defines the dithering state
  7121. */
  7122. setDitheringState(value: boolean): void;
  7123. /**
  7124. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7125. * @param value defines the rasterizer state
  7126. */
  7127. setRasterizerState(value: boolean): void;
  7128. /**
  7129. * stop executing a render loop function and remove it from the execution array
  7130. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7131. */
  7132. stopRenderLoop(renderFunction?: () => void): void;
  7133. /** @hidden */
  7134. _renderLoop(): void;
  7135. /**
  7136. * Register and execute a render loop. The engine can have more than one render function
  7137. * @param renderFunction defines the function to continuously execute
  7138. */
  7139. runRenderLoop(renderFunction: () => void): void;
  7140. /**
  7141. * Toggle full screen mode
  7142. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7143. * @param options defines an option object to be sent to the requestFullscreen function
  7144. */
  7145. switchFullscreen(requestPointerLock: boolean): void;
  7146. /**
  7147. * Clear the current render buffer or the current render target (if any is set up)
  7148. * @param color defines the color to use
  7149. * @param backBuffer defines if the back buffer must be cleared
  7150. * @param depth defines if the depth buffer must be cleared
  7151. * @param stencil defines if the stencil buffer must be cleared
  7152. */
  7153. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7154. /**
  7155. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7156. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7157. * @param y defines the y-coordinate of the corner of the clear rectangle
  7158. * @param width defines the width of the clear rectangle
  7159. * @param height defines the height of the clear rectangle
  7160. * @param clearColor defines the clear color
  7161. */
  7162. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7163. /**
  7164. * Set the WebGL's viewport
  7165. * @param viewport defines the viewport element to be used
  7166. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7167. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7168. */
  7169. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7170. /**
  7171. * Directly set the WebGL Viewport
  7172. * @param x defines the x coordinate of the viewport (in screen space)
  7173. * @param y defines the y coordinate of the viewport (in screen space)
  7174. * @param width defines the width of the viewport (in screen space)
  7175. * @param height defines the height of the viewport (in screen space)
  7176. * @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
  7177. */
  7178. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7179. /**
  7180. * Begin a new frame
  7181. */
  7182. beginFrame(): void;
  7183. /**
  7184. * Enf the current frame
  7185. */
  7186. endFrame(): void;
  7187. /**
  7188. * Resize the view according to the canvas' size
  7189. */
  7190. resize(): void;
  7191. /**
  7192. * Force a specific size of the canvas
  7193. * @param width defines the new canvas' width
  7194. * @param height defines the new canvas' height
  7195. */
  7196. setSize(width: number, height: number): void;
  7197. /**
  7198. * Gets a boolean indicating if a webVR device was detected
  7199. * @returns true if a webVR device was detected
  7200. */
  7201. isVRDevicePresent(): boolean;
  7202. /**
  7203. * Gets the current webVR device
  7204. * @returns the current webVR device (or null)
  7205. */
  7206. getVRDevice(): any;
  7207. /**
  7208. * Initializes a webVR display and starts listening to display change events
  7209. * The onVRDisplayChangedObservable will be notified upon these changes
  7210. * @returns The onVRDisplayChangedObservable
  7211. */
  7212. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7213. /**
  7214. * Initializes a webVR display and starts listening to display change events
  7215. * The onVRDisplayChangedObservable will be notified upon these changes
  7216. * @returns A promise containing a VRDisplay and if vr is supported
  7217. */
  7218. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7219. /**
  7220. * Call this function to switch to webVR mode
  7221. * Will do nothing if webVR is not supported or if there is no webVR device
  7222. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7223. */
  7224. enableVR(): void;
  7225. /**
  7226. * Call this function to leave webVR mode
  7227. * Will do nothing if webVR is not supported or if there is no webVR device
  7228. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7229. */
  7230. disableVR(): void;
  7231. private _onVRFullScreenTriggered;
  7232. private _getVRDisplaysAsync();
  7233. /**
  7234. * Binds the frame buffer to the specified texture.
  7235. * @param texture The texture to render to or null for the default canvas
  7236. * @param faceIndex The face of the texture to render to in case of cube texture
  7237. * @param requiredWidth The width of the target to render to
  7238. * @param requiredHeight The height of the target to render to
  7239. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7240. * @param depthStencilTexture The depth stencil texture to use to render
  7241. * @param lodLevel defines le lod level to bind to the frame buffer
  7242. */
  7243. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  7244. private bindUnboundFramebuffer(framebuffer);
  7245. /**
  7246. * Unbind the current render target texture from the webGL context
  7247. * @param texture defines the render target texture to unbind
  7248. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7249. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7250. */
  7251. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7252. /**
  7253. * Unbind a list of render target textures from the webGL context
  7254. * This is used only when drawBuffer extension or webGL2 are active
  7255. * @param textures defines the render target textures to unbind
  7256. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7257. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7258. */
  7259. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7260. /**
  7261. * Force the mipmap generation for the given render target texture
  7262. * @param texture defines the render target texture to use
  7263. */
  7264. generateMipMapsForCubemap(texture: InternalTexture): void;
  7265. /**
  7266. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7267. */
  7268. flushFramebuffer(): void;
  7269. /**
  7270. * Unbind the current render target and bind the default framebuffer
  7271. */
  7272. restoreDefaultFramebuffer(): void;
  7273. /**
  7274. * Create an uniform buffer
  7275. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7276. * @param elements defines the content of the uniform buffer
  7277. * @returns the webGL uniform buffer
  7278. */
  7279. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7280. /**
  7281. * Create a dynamic uniform buffer
  7282. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7283. * @param elements defines the content of the uniform buffer
  7284. * @returns the webGL uniform buffer
  7285. */
  7286. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7287. /**
  7288. * Update an existing uniform buffer
  7289. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7290. * @param uniformBuffer defines the target uniform buffer
  7291. * @param elements defines the content to update
  7292. * @param offset defines the offset in the uniform buffer where update should start
  7293. * @param count defines the size of the data to update
  7294. */
  7295. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7296. private _resetVertexBufferBinding();
  7297. /**
  7298. * Creates a vertex buffer
  7299. * @param data the data for the vertex buffer
  7300. * @returns the new WebGL static buffer
  7301. */
  7302. createVertexBuffer(data: DataArray): WebGLBuffer;
  7303. /**
  7304. * Creates a dynamic vertex buffer
  7305. * @param data the data for the dynamic vertex buffer
  7306. * @returns the new WebGL dynamic buffer
  7307. */
  7308. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7309. /**
  7310. * Update a dynamic index buffer
  7311. * @param indexBuffer defines the target index buffer
  7312. * @param indices defines the data to update
  7313. * @param offset defines the offset in the target index buffer where update should start
  7314. */
  7315. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7316. /**
  7317. * Updates a dynamic vertex buffer.
  7318. * @param vertexBuffer the vertex buffer to update
  7319. * @param data the data used to update the vertex buffer
  7320. * @param byteOffset the byte offset of the data
  7321. * @param byteLength the byte length of the data
  7322. */
  7323. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7324. private _resetIndexBufferBinding();
  7325. /**
  7326. * Creates a new index buffer
  7327. * @param indices defines the content of the index buffer
  7328. * @param updatable defines if the index buffer must be updatable
  7329. * @returns a new webGL buffer
  7330. */
  7331. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7332. /**
  7333. * Bind a webGL buffer to the webGL context
  7334. * @param buffer defines the buffer to bind
  7335. */
  7336. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7337. /**
  7338. * Bind an uniform buffer to the current webGL context
  7339. * @param buffer defines the buffer to bind
  7340. */
  7341. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7342. /**
  7343. * Bind a buffer to the current webGL context at a given location
  7344. * @param buffer defines the buffer to bind
  7345. * @param location defines the index where to bind the buffer
  7346. */
  7347. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7348. /**
  7349. * Bind a specific block at a given index in a specific shader program
  7350. * @param shaderProgram defines the shader program
  7351. * @param blockName defines the block name
  7352. * @param index defines the index where to bind the block
  7353. */
  7354. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7355. private bindIndexBuffer(buffer);
  7356. private bindBuffer(buffer, target);
  7357. /**
  7358. * update the bound buffer with the given data
  7359. * @param data defines the data to update
  7360. */
  7361. updateArrayBuffer(data: Float32Array): void;
  7362. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7363. private _bindIndexBufferWithCache(indexBuffer);
  7364. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7365. /**
  7366. * Records a vertex array object
  7367. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7368. * @param vertexBuffers defines the list of vertex buffers to store
  7369. * @param indexBuffer defines the index buffer to store
  7370. * @param effect defines the effect to store
  7371. * @returns the new vertex array object
  7372. */
  7373. recordVertexArrayObject(vertexBuffers: {
  7374. [key: string]: VertexBuffer;
  7375. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7376. /**
  7377. * Bind a specific vertex array object
  7378. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7379. * @param vertexArrayObject defines the vertex array object to bind
  7380. * @param indexBuffer defines the index buffer to bind
  7381. */
  7382. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7383. /**
  7384. * Bind webGl buffers directly to the webGL context
  7385. * @param vertexBuffer defines the vertex buffer to bind
  7386. * @param indexBuffer defines the index buffer to bind
  7387. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7388. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7389. * @param effect defines the effect associated with the vertex buffer
  7390. */
  7391. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7392. private _unbindVertexArrayObject();
  7393. /**
  7394. * Bind a list of vertex buffers to the webGL context
  7395. * @param vertexBuffers defines the list of vertex buffers to bind
  7396. * @param indexBuffer defines the index buffer to bind
  7397. * @param effect defines the effect associated with the vertex buffers
  7398. */
  7399. bindBuffers(vertexBuffers: {
  7400. [key: string]: Nullable<VertexBuffer>;
  7401. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7402. /**
  7403. * Unbind all instance attributes
  7404. */
  7405. unbindInstanceAttributes(): void;
  7406. /**
  7407. * Release and free the memory of a vertex array object
  7408. * @param vao defines the vertex array object to delete
  7409. */
  7410. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7411. /** @hidden */
  7412. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7413. /**
  7414. * Creates a webGL buffer to use with instanciation
  7415. * @param capacity defines the size of the buffer
  7416. * @returns the webGL buffer
  7417. */
  7418. createInstancesBuffer(capacity: number): WebGLBuffer;
  7419. /**
  7420. * Delete a webGL buffer used with instanciation
  7421. * @param buffer defines the webGL buffer to delete
  7422. */
  7423. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7424. /**
  7425. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7426. * @param instancesBuffer defines the webGL buffer to update and bind
  7427. * @param data defines the data to store in the buffer
  7428. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7429. */
  7430. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7431. /**
  7432. * Apply all cached states (depth, culling, stencil and alpha)
  7433. */
  7434. applyStates(): void;
  7435. /**
  7436. * Send a draw order
  7437. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7438. * @param indexStart defines the starting index
  7439. * @param indexCount defines the number of index to draw
  7440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7441. */
  7442. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7443. /**
  7444. * Draw a list of points
  7445. * @param verticesStart defines the index of first vertex to draw
  7446. * @param verticesCount defines the count of vertices to draw
  7447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7448. */
  7449. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7450. /**
  7451. * Draw a list of unindexed primitives
  7452. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7453. * @param verticesStart defines the index of first vertex to draw
  7454. * @param verticesCount defines the count of vertices to draw
  7455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7456. */
  7457. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7458. /**
  7459. * Draw a list of indexed primitives
  7460. * @param fillMode defines the primitive to use
  7461. * @param indexStart defines the starting index
  7462. * @param indexCount defines the number of index to draw
  7463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7464. */
  7465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7466. /**
  7467. * Draw a list of unindexed primitives
  7468. * @param fillMode defines the primitive to use
  7469. * @param verticesStart defines the index of first vertex to draw
  7470. * @param verticesCount defines the count of vertices to draw
  7471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7472. */
  7473. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7474. private _drawMode(fillMode);
  7475. /** @hidden */
  7476. _releaseEffect(effect: Effect): void;
  7477. /** @hidden */
  7478. _deleteProgram(program: WebGLProgram): void;
  7479. /**
  7480. * Create a new effect (used to store vertex/fragment shaders)
  7481. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7482. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7483. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7484. * @param samplers defines an array of string used to represent textures
  7485. * @param defines defines the string containing the defines to use to compile the shaders
  7486. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7487. * @param onCompiled defines a function to call when the effect creation is successful
  7488. * @param onError defines a function to call when the effect creation has failed
  7489. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7490. * @returns the new Effect
  7491. */
  7492. 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;
  7493. /**
  7494. * Create an effect to use with particle systems
  7495. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7496. * @param uniformsNames defines a list of attribute names
  7497. * @param samplers defines an array of string used to represent textures
  7498. * @param defines defines the string containing the defines to use to compile the shaders
  7499. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7500. * @param onCompiled defines a function to call when the effect creation is successful
  7501. * @param onError defines a function to call when the effect creation has failed
  7502. * @returns the new Effect
  7503. */
  7504. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7505. /**
  7506. * Directly creates a webGL program
  7507. * @param vertexCode defines the vertex shader code to use
  7508. * @param fragmentCode defines the fragment shader code to use
  7509. * @param context defines the webGL context to use (if not set, the current one will be used)
  7510. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7511. * @returns the new webGL program
  7512. */
  7513. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7514. /**
  7515. * Creates a webGL program
  7516. * @param vertexCode defines the vertex shader code to use
  7517. * @param fragmentCode defines the fragment shader code to use
  7518. * @param defines defines the string containing the defines to use to compile the shaders
  7519. * @param context defines the webGL context to use (if not set, the current one will be used)
  7520. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7521. * @returns the new webGL program
  7522. */
  7523. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7524. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7525. /**
  7526. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7527. * @param shaderProgram defines the webGL program to use
  7528. * @param uniformsNames defines the list of uniform names
  7529. * @returns an array of webGL uniform locations
  7530. */
  7531. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7532. /**
  7533. * Gets the lsit of active attributes for a given webGL program
  7534. * @param shaderProgram defines the webGL program to use
  7535. * @param attributesNames defines the list of attribute names to get
  7536. * @returns an array of indices indicating the offset of each attribute
  7537. */
  7538. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7539. /**
  7540. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7541. * @param effect defines the effect to activate
  7542. */
  7543. enableEffect(effect: Nullable<Effect>): void;
  7544. /**
  7545. * Set the value of an uniform to an array of int32
  7546. * @param uniform defines the webGL uniform location where to store the value
  7547. * @param array defines the array of int32 to store
  7548. */
  7549. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7550. /**
  7551. * Set the value of an uniform to an array of int32 (stored as vec2)
  7552. * @param uniform defines the webGL uniform location where to store the value
  7553. * @param array defines the array of int32 to store
  7554. */
  7555. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7556. /**
  7557. * Set the value of an uniform to an array of int32 (stored as vec3)
  7558. * @param uniform defines the webGL uniform location where to store the value
  7559. * @param array defines the array of int32 to store
  7560. */
  7561. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7562. /**
  7563. * Set the value of an uniform to an array of int32 (stored as vec4)
  7564. * @param uniform defines the webGL uniform location where to store the value
  7565. * @param array defines the array of int32 to store
  7566. */
  7567. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7568. /**
  7569. * Set the value of an uniform to an array of float32
  7570. * @param uniform defines the webGL uniform location where to store the value
  7571. * @param array defines the array of float32 to store
  7572. */
  7573. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7574. /**
  7575. * Set the value of an uniform to an array of float32 (stored as vec2)
  7576. * @param uniform defines the webGL uniform location where to store the value
  7577. * @param array defines the array of float32 to store
  7578. */
  7579. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7580. /**
  7581. * Set the value of an uniform to an array of float32 (stored as vec3)
  7582. * @param uniform defines the webGL uniform location where to store the value
  7583. * @param array defines the array of float32 to store
  7584. */
  7585. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7586. /**
  7587. * Set the value of an uniform to an array of float32 (stored as vec4)
  7588. * @param uniform defines the webGL uniform location where to store the value
  7589. * @param array defines the array of float32 to store
  7590. */
  7591. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7592. /**
  7593. * Set the value of an uniform to an array of number
  7594. * @param uniform defines the webGL uniform location where to store the value
  7595. * @param array defines the array of number to store
  7596. */
  7597. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7598. /**
  7599. * Set the value of an uniform to an array of number (stored as vec2)
  7600. * @param uniform defines the webGL uniform location where to store the value
  7601. * @param array defines the array of number to store
  7602. */
  7603. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7604. /**
  7605. * Set the value of an uniform to an array of number (stored as vec3)
  7606. * @param uniform defines the webGL uniform location where to store the value
  7607. * @param array defines the array of number to store
  7608. */
  7609. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7610. /**
  7611. * Set the value of an uniform to an array of number (stored as vec4)
  7612. * @param uniform defines the webGL uniform location where to store the value
  7613. * @param array defines the array of number to store
  7614. */
  7615. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7616. /**
  7617. * Set the value of an uniform to an array of float32 (stored as matrices)
  7618. * @param uniform defines the webGL uniform location where to store the value
  7619. * @param matrices defines the array of float32 to store
  7620. */
  7621. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7622. /**
  7623. * Set the value of an uniform to a matrix
  7624. * @param uniform defines the webGL uniform location where to store the value
  7625. * @param matrix defines the matrix to store
  7626. */
  7627. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7628. /**
  7629. * Set the value of an uniform to a matrix (3x3)
  7630. * @param uniform defines the webGL uniform location where to store the value
  7631. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7632. */
  7633. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7634. /**
  7635. * Set the value of an uniform to a matrix (2x2)
  7636. * @param uniform defines the webGL uniform location where to store the value
  7637. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7638. */
  7639. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7640. /**
  7641. * Set the value of an uniform to a number (int)
  7642. * @param uniform defines the webGL uniform location where to store the value
  7643. * @param value defines the int number to store
  7644. */
  7645. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7646. /**
  7647. * Set the value of an uniform to a number (float)
  7648. * @param uniform defines the webGL uniform location where to store the value
  7649. * @param value defines the float number to store
  7650. */
  7651. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7652. /**
  7653. * Set the value of an uniform to a vec2
  7654. * @param uniform defines the webGL uniform location where to store the value
  7655. * @param x defines the 1st component of the value
  7656. * @param y defines the 2nd component of the value
  7657. */
  7658. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7659. /**
  7660. * Set the value of an uniform to a vec3
  7661. * @param uniform defines the webGL uniform location where to store the value
  7662. * @param x defines the 1st component of the value
  7663. * @param y defines the 2nd component of the value
  7664. * @param z defines the 3rd component of the value
  7665. */
  7666. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7667. /**
  7668. * Set the value of an uniform to a boolean
  7669. * @param uniform defines the webGL uniform location where to store the value
  7670. * @param bool defines the boolean to store
  7671. */
  7672. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7673. /**
  7674. * Set the value of an uniform to a vec4
  7675. * @param uniform defines the webGL uniform location where to store the value
  7676. * @param x defines the 1st component of the value
  7677. * @param y defines the 2nd component of the value
  7678. * @param z defines the 3rd component of the value
  7679. * @param w defines the 4th component of the value
  7680. */
  7681. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7682. /**
  7683. * Set the value of an uniform to a Color3
  7684. * @param uniform defines the webGL uniform location where to store the value
  7685. * @param color3 defines the color to store
  7686. */
  7687. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7688. /**
  7689. * Set the value of an uniform to a Color3 and an alpha value
  7690. * @param uniform defines the webGL uniform location where to store the value
  7691. * @param color3 defines the color to store
  7692. * @param alpha defines the alpha component to store
  7693. */
  7694. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7695. /**
  7696. * Sets a Color4 on a uniform variable
  7697. * @param uniform defines the uniform location
  7698. * @param color4 defines the value to be set
  7699. */
  7700. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7701. /**
  7702. * Set various states to the webGL context
  7703. * @param culling defines backface culling state
  7704. * @param zOffset defines the value to apply to zOffset (0 by default)
  7705. * @param force defines if states must be applied even if cache is up to date
  7706. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7707. */
  7708. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7709. /**
  7710. * Set the z offset to apply to current rendering
  7711. * @param value defines the offset to apply
  7712. */
  7713. setZOffset(value: number): void;
  7714. /**
  7715. * Gets the current value of the zOffset
  7716. * @returns the current zOffset state
  7717. */
  7718. getZOffset(): number;
  7719. /**
  7720. * Enable or disable depth buffering
  7721. * @param enable defines the state to set
  7722. */
  7723. setDepthBuffer(enable: boolean): void;
  7724. /**
  7725. * Gets a boolean indicating if depth writing is enabled
  7726. * @returns the current depth writing state
  7727. */
  7728. getDepthWrite(): boolean;
  7729. /**
  7730. * Enable or disable depth writing
  7731. * @param enable defines the state to set
  7732. */
  7733. setDepthWrite(enable: boolean): void;
  7734. /**
  7735. * Enable or disable color writing
  7736. * @param enable defines the state to set
  7737. */
  7738. setColorWrite(enable: boolean): void;
  7739. /**
  7740. * Gets a boolean indicating if color writing is enabled
  7741. * @returns the current color writing state
  7742. */
  7743. getColorWrite(): boolean;
  7744. /**
  7745. * Sets alpha constants used by some alpha blending modes
  7746. * @param r defines the red component
  7747. * @param g defines the green component
  7748. * @param b defines the blue component
  7749. * @param a defines the alpha component
  7750. */
  7751. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7752. /**
  7753. * Sets the current alpha mode
  7754. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7755. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7756. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7757. */
  7758. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7759. /**
  7760. * Gets the current alpha mode
  7761. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7762. * @returns the current alpha mode
  7763. */
  7764. getAlphaMode(): number;
  7765. /**
  7766. * Force the entire cache to be cleared
  7767. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7768. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7769. */
  7770. wipeCaches(bruteForce?: boolean): void;
  7771. /**
  7772. * Set the compressed texture format to use, based on the formats you have, and the formats
  7773. * supported by the hardware / browser.
  7774. *
  7775. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7776. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7777. * to API arguments needed to compressed textures. This puts the burden on the container
  7778. * generator to house the arcane code for determining these for current & future formats.
  7779. *
  7780. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  7781. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  7782. *
  7783. * Note: The result of this call is not taken into account when a texture is base64.
  7784. *
  7785. * @param formatsAvailable defines the list of those format families you have created
  7786. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  7787. *
  7788. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  7789. * @returns The extension selected.
  7790. */
  7791. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  7792. /** @hidden */
  7793. _createTexture(): WebGLTexture;
  7794. /**
  7795. * Usually called from BABYLON.Texture.ts.
  7796. * Passed information to create a WebGLTexture
  7797. * @param urlArg defines a value which contains one of the following:
  7798. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  7799. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  7800. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  7801. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  7802. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  7803. * @param scene needed for loading to the correct scene
  7804. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  7805. * @param onLoad optional callback to be called upon successful completion
  7806. * @param onError optional callback to be called upon failure
  7807. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  7808. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  7809. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  7810. * @returns a InternalTexture for assignment back into BABYLON.Texture
  7811. */
  7812. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  7813. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  7814. /**
  7815. * Update a raw texture
  7816. * @param texture defines the texture to update
  7817. * @param data defines the data to store in the texture
  7818. * @param format defines the format of the data
  7819. * @param invertY defines if data must be stored with Y axis inverted
  7820. * @param compression defines the compression used (null by default)
  7821. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7822. */
  7823. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  7824. /**
  7825. * Creates a raw texture
  7826. * @param data defines the data to store in the texture
  7827. * @param width defines the width of the texture
  7828. * @param height defines the height of the texture
  7829. * @param format defines the format of the data
  7830. * @param generateMipMaps defines if the engine should generate the mip levels
  7831. * @param invertY defines if data must be stored with Y axis inverted
  7832. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7833. * @param compression defines the compression used (null by default)
  7834. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7835. * @returns the raw texture inside an InternalTexture
  7836. */
  7837. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  7838. /**
  7839. * Creates a dynamic texture
  7840. * @param width defines the width of the texture
  7841. * @param height defines the height of the texture
  7842. * @param generateMipMaps defines if the engine should generate the mip levels
  7843. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7844. * @returns the dynamic texture inside an InternalTexture
  7845. */
  7846. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  7847. /**
  7848. * Update the sampling mode of a given texture
  7849. * @param samplingMode defines the required sampling mode
  7850. * @param texture defines the texture to update
  7851. */
  7852. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7853. /**
  7854. * Update the content of a dynamic texture
  7855. * @param texture defines the texture to update
  7856. * @param canvas defines the canvas containing the source
  7857. * @param invertY defines if data must be stored with Y axis inverted
  7858. * @param premulAlpha defines if alpha is stored as premultiplied
  7859. * @param format defines the format of the data
  7860. */
  7861. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  7862. /**
  7863. * Update a video texture
  7864. * @param texture defines the texture to update
  7865. * @param video defines the video element to use
  7866. * @param invertY defines if data must be stored with Y axis inverted
  7867. */
  7868. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  7869. /**
  7870. * Updates a depth texture Comparison Mode and Function.
  7871. * If the comparison Function is equal to 0, the mode will be set to none.
  7872. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  7873. * @param texture The texture to set the comparison function for
  7874. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  7875. */
  7876. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  7877. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  7878. /**
  7879. * Creates a depth stencil texture.
  7880. * This is only available in WebGL 2 or with the depth texture extension available.
  7881. * @param size The size of face edge in the texture.
  7882. * @param options The options defining the texture.
  7883. * @returns The texture
  7884. */
  7885. createDepthStencilTexture(size: number | {
  7886. width: number;
  7887. height: number;
  7888. }, options: DepthTextureCreationOptions): InternalTexture;
  7889. /**
  7890. * Creates a depth stencil texture.
  7891. * This is only available in WebGL 2 or with the depth texture extension available.
  7892. * @param size The size of face edge in the texture.
  7893. * @param options The options defining the texture.
  7894. * @returns The texture
  7895. */
  7896. private _createDepthStencilTexture(size, options);
  7897. /**
  7898. * Creates a depth stencil cube texture.
  7899. * This is only available in WebGL 2.
  7900. * @param size The size of face edge in the cube texture.
  7901. * @param options The options defining the cube texture.
  7902. * @returns The cube texture
  7903. */
  7904. private _createDepthStencilCubeTexture(size, options);
  7905. /**
  7906. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  7907. * @param renderTarget The render target to set the frame buffer for
  7908. */
  7909. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  7910. /**
  7911. * Creates a new render target texture
  7912. * @param size defines the size of the texture
  7913. * @param options defines the options used to create the texture
  7914. * @returns a new render target texture stored in an InternalTexture
  7915. */
  7916. createRenderTargetTexture(size: number | {
  7917. width: number;
  7918. height: number;
  7919. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7920. /**
  7921. * Create a multi render target texture
  7922. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  7923. * @param size defines the size of the texture
  7924. * @param options defines the creation options
  7925. * @returns the cube texture as an InternalTexture
  7926. */
  7927. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  7928. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  7929. /**
  7930. * Updates the sample count of a render target texture
  7931. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7932. * @param texture defines the texture to update
  7933. * @param samples defines the sample count to set
  7934. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7935. */
  7936. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  7937. /**
  7938. * Update the sample count for a given multiple render target texture
  7939. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7940. * @param textures defines the textures to update
  7941. * @param samples defines the sample count to set
  7942. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7943. */
  7944. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  7945. /** @hidden */
  7946. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  7947. /** @hidden */
  7948. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  7949. /** @hidden */
  7950. _uploadImageToTexture(texture: InternalTexture, faceIndex: number, lod: number, image: HTMLImageElement): void;
  7951. /**
  7952. * Creates a new render target cube texture
  7953. * @param size defines the size of the texture
  7954. * @param options defines the options used to create the texture
  7955. * @returns a new render target cube texture stored in an InternalTexture
  7956. */
  7957. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  7958. /**
  7959. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  7960. * @param rootUrl defines the url where the file to load is located
  7961. * @param scene defines the current scene
  7962. * @param lodScale defines scale to apply to the mip map selection
  7963. * @param lodOffset defines offset to apply to the mip map selection
  7964. * @param onLoad defines an optional callback raised when the texture is loaded
  7965. * @param onError defines an optional callback raised if there is an issue to load the texture
  7966. * @param format defines the format of the data
  7967. * @param forcedExtension defines the extension to use to pick the right loader
  7968. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  7969. * @returns the cube texture as an InternalTexture
  7970. */
  7971. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  7972. /**
  7973. * Creates a cube texture
  7974. * @param rootUrl defines the url where the files to load is located
  7975. * @param scene defines the current scene
  7976. * @param files defines the list of files to load (1 per face)
  7977. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7978. * @param onLoad defines an optional callback raised when the texture is loaded
  7979. * @param onError defines an optional callback raised if there is an issue to load the texture
  7980. * @param format defines the format of the data
  7981. * @param forcedExtension defines the extension to use to pick the right loader
  7982. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7983. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7984. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7985. * @returns the cube texture as an InternalTexture
  7986. */
  7987. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number): InternalTexture;
  7988. private setCubeMapTextureParams(gl, loadMipmap);
  7989. /**
  7990. * Update a raw cube texture
  7991. * @param texture defines the texture to udpdate
  7992. * @param data defines the data to store
  7993. * @param format defines the data format
  7994. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7995. * @param invertY defines if data must be stored with Y axis inverted
  7996. * @param compression defines the compression used (null by default)
  7997. * @param level defines which level of the texture to update
  7998. */
  7999. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8000. /**
  8001. * Creates a new raw cube texture
  8002. * @param data defines the array of data to use to create each face
  8003. * @param size defines the size of the textures
  8004. * @param format defines the format of the data
  8005. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8006. * @param generateMipMaps defines if the engine should generate the mip levels
  8007. * @param invertY defines if data must be stored with Y axis inverted
  8008. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8009. * @param compression defines the compression used (null by default)
  8010. * @returns the cube texture as an InternalTexture
  8011. */
  8012. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8013. /**
  8014. * Creates a new raw cube texture from a specified url
  8015. * @param url defines the url where the data is located
  8016. * @param scene defines the current scene
  8017. * @param size defines the size of the textures
  8018. * @param format defines the format of the data
  8019. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8020. * @param noMipmap defines if the engine should avoid generating the mip levels
  8021. * @param callback defines a callback used to extract texture data from loaded data
  8022. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8023. * @param onLoad defines a callback called when texture is loaded
  8024. * @param onError defines a callback called if there is an error
  8025. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8026. * @param invertY defines if data must be stored with Y axis inverted
  8027. * @returns the cube texture as an InternalTexture
  8028. */
  8029. 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;
  8030. /**
  8031. * Update a raw 3D texture
  8032. * @param texture defines the texture to update
  8033. * @param data defines the data to store
  8034. * @param format defines the data format
  8035. * @param invertY defines if data must be stored with Y axis inverted
  8036. * @param compression defines the used compression (can be null)
  8037. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8038. */
  8039. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8040. /**
  8041. * Creates a new raw 3D texture
  8042. * @param data defines the data used to create the texture
  8043. * @param width defines the width of the texture
  8044. * @param height defines the height of the texture
  8045. * @param depth defines the depth of the texture
  8046. * @param format defines the format of the texture
  8047. * @param generateMipMaps defines if the engine must generate mip levels
  8048. * @param invertY defines if data must be stored with Y axis inverted
  8049. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8050. * @param compression defines the compressed used (can be null)
  8051. * @param textureType defines the compressed used (can be null)
  8052. * @returns a new raw 3D texture (stored in an InternalTexture)
  8053. */
  8054. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8055. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8056. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8057. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8058. /** @hidden */
  8059. _releaseFramebufferObjects(texture: InternalTexture): void;
  8060. /** @hidden */
  8061. _releaseTexture(texture: InternalTexture): void;
  8062. private setProgram(program);
  8063. private _boundUniforms;
  8064. /**
  8065. * Binds an effect to the webGL context
  8066. * @param effect defines the effect to bind
  8067. */
  8068. bindSamplers(effect: Effect): void;
  8069. private _moveBoundTextureOnTop(internalTexture);
  8070. private _getCorrectTextureChannel(channel, internalTexture);
  8071. private _linkTrackers(previous, next);
  8072. private _removeDesignatedSlot(internalTexture);
  8073. private _activateCurrentTexture();
  8074. /** @hidden */
  8075. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8076. /** @hidden */
  8077. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8078. /**
  8079. * Sets a texture to the webGL context from a postprocess
  8080. * @param channel defines the channel to use
  8081. * @param postProcess defines the source postprocess
  8082. */
  8083. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8084. /**
  8085. * Binds the output of the passed in post process to the texture channel specified
  8086. * @param channel The channel the texture should be bound to
  8087. * @param postProcess The post process which's output should be bound
  8088. */
  8089. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8090. /**
  8091. * Unbind all textures from the webGL context
  8092. */
  8093. unbindAllTextures(): void;
  8094. /**
  8095. * Sets a texture to the according uniform.
  8096. * @param channel The texture channel
  8097. * @param uniform The uniform to set
  8098. * @param texture The texture to apply
  8099. */
  8100. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8101. /**
  8102. * Sets a depth stencil texture from a render target to the according uniform.
  8103. * @param channel The texture channel
  8104. * @param uniform The uniform to set
  8105. * @param texture The render target texture containing the depth stencil texture to apply
  8106. */
  8107. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8108. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8109. private _getTextureWrapMode(mode);
  8110. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8111. /**
  8112. * Sets an array of texture to the webGL context
  8113. * @param channel defines the channel where the texture array must be set
  8114. * @param uniform defines the associated uniform location
  8115. * @param textures defines the array of textures to bind
  8116. */
  8117. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8118. /** @hidden */
  8119. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8120. private _setTextureParameterFloat(target, parameter, value, texture);
  8121. private _setTextureParameterInteger(target, parameter, value, texture?);
  8122. /**
  8123. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8124. * @param x defines the x coordinate of the rectangle where pixels must be read
  8125. * @param y defines the y coordinate of the rectangle where pixels must be read
  8126. * @param width defines the width of the rectangle where pixels must be read
  8127. * @param height defines the height of the rectangle where pixels must be read
  8128. * @returns a Uint8Array containing RGBA colors
  8129. */
  8130. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8131. /**
  8132. * Add an externaly attached data from its key.
  8133. * This method call will fail and return false, if such key already exists.
  8134. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8135. * @param key the unique key that identifies the data
  8136. * @param data the data object to associate to the key for this Engine instance
  8137. * @return true if no such key were already present and the data was added successfully, false otherwise
  8138. */
  8139. addExternalData<T>(key: string, data: T): boolean;
  8140. /**
  8141. * Get an externaly attached data from its key
  8142. * @param key the unique key that identifies the data
  8143. * @return the associated data, if present (can be null), or undefined if not present
  8144. */
  8145. getExternalData<T>(key: string): T;
  8146. /**
  8147. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8148. * @param key the unique key that identifies the data
  8149. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8150. * @return the associated data, can be null if the factory returned null.
  8151. */
  8152. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8153. /**
  8154. * Remove an externaly attached data from the Engine instance
  8155. * @param key the unique key that identifies the data
  8156. * @return true if the data was successfully removed, false if it doesn't exist
  8157. */
  8158. removeExternalData(key: string): boolean;
  8159. /**
  8160. * Unbind all vertex attributes from the webGL context
  8161. */
  8162. unbindAllAttributes(): void;
  8163. /**
  8164. * 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
  8165. */
  8166. releaseEffects(): void;
  8167. /**
  8168. * Dispose and release all associated resources
  8169. */
  8170. dispose(): void;
  8171. /**
  8172. * Display the loading screen
  8173. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8174. */
  8175. displayLoadingUI(): void;
  8176. /**
  8177. * Hide the loading screen
  8178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8179. */
  8180. hideLoadingUI(): void;
  8181. /**
  8182. * Gets the current loading screen object
  8183. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8184. */
  8185. /**
  8186. * Sets the current loading screen object
  8187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8188. */
  8189. loadingScreen: ILoadingScreen;
  8190. /**
  8191. * Sets the current loading screen text
  8192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8193. */
  8194. loadingUIText: string;
  8195. /**
  8196. * Sets the current loading screen background color
  8197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8198. */
  8199. loadingUIBackgroundColor: string;
  8200. /**
  8201. * Attach a new callback raised when context lost event is fired
  8202. * @param callback defines the callback to call
  8203. */
  8204. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8205. /**
  8206. * Attach a new callback raised when context restored event is fired
  8207. * @param callback defines the callback to call
  8208. */
  8209. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8210. /**
  8211. * Gets the source code of the vertex shader associated with a specific webGL program
  8212. * @param program defines the program to use
  8213. * @returns a string containing the source code of the vertex shader associated with the program
  8214. */
  8215. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8216. /**
  8217. * Gets the source code of the fragment shader associated with a specific webGL program
  8218. * @param program defines the program to use
  8219. * @returns a string containing the source code of the fragment shader associated with the program
  8220. */
  8221. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8222. /**
  8223. * Get the current error code of the webGL context
  8224. * @returns the error code
  8225. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8226. */
  8227. getError(): number;
  8228. /**
  8229. * Gets the current framerate
  8230. * @returns a number representing the framerate
  8231. */
  8232. getFps(): number;
  8233. /**
  8234. * Gets the time spent between current and previous frame
  8235. * @returns a number representing the delta time in ms
  8236. */
  8237. getDeltaTime(): number;
  8238. private _measureFps();
  8239. /** @hidden */
  8240. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  8241. private _canRenderToFloatFramebuffer();
  8242. private _canRenderToHalfFloatFramebuffer();
  8243. private _canRenderToFramebuffer(type);
  8244. /** @hidden */
  8245. _getWebGLTextureType(type: number): number;
  8246. private _getInternalFormat(format);
  8247. /** @hidden */
  8248. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8249. /** @hidden */
  8250. _getRGBAMultiSampleBufferFormat(type: number): number;
  8251. /**
  8252. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8253. * @return the new query
  8254. */
  8255. createQuery(): WebGLQuery;
  8256. /**
  8257. * Delete and release a webGL query
  8258. * @param query defines the query to delete
  8259. * @return the current engine
  8260. */
  8261. deleteQuery(query: WebGLQuery): Engine;
  8262. /**
  8263. * Check if a given query has resolved and got its value
  8264. * @param query defines the query to check
  8265. * @returns true if the query got its value
  8266. */
  8267. isQueryResultAvailable(query: WebGLQuery): boolean;
  8268. /**
  8269. * Gets the value of a given query
  8270. * @param query defines the query to check
  8271. * @returns the value of the query
  8272. */
  8273. getQueryResult(query: WebGLQuery): number;
  8274. /**
  8275. * Initiates an occlusion query
  8276. * @param algorithmType defines the algorithm to use
  8277. * @param query defines the query to use
  8278. * @returns the current engine
  8279. * @see http://doc.babylonjs.com/features/occlusionquery
  8280. */
  8281. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8282. /**
  8283. * Ends an occlusion query
  8284. * @see http://doc.babylonjs.com/features/occlusionquery
  8285. * @param algorithmType defines the algorithm to use
  8286. * @returns the current engine
  8287. */
  8288. endOcclusionQuery(algorithmType: number): Engine;
  8289. private _createTimeQuery();
  8290. private _deleteTimeQuery(query);
  8291. private _getTimeQueryResult(query);
  8292. private _getTimeQueryAvailability(query);
  8293. private _currentNonTimestampToken;
  8294. /**
  8295. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8296. * Please note that only one query can be issued at a time
  8297. * @returns a time token used to track the time span
  8298. */
  8299. startTimeQuery(): Nullable<_TimeToken>;
  8300. /**
  8301. * Ends a time query
  8302. * @param token defines the token used to measure the time span
  8303. * @returns the time spent (in ns)
  8304. */
  8305. endTimeQuery(token: _TimeToken): int;
  8306. private getGlAlgorithmType(algorithmType);
  8307. /**
  8308. * Creates a webGL transform feedback object
  8309. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8310. * @returns the webGL transform feedback object
  8311. */
  8312. createTransformFeedback(): WebGLTransformFeedback;
  8313. /**
  8314. * Delete a webGL transform feedback object
  8315. * @param value defines the webGL transform feedback object to delete
  8316. */
  8317. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8318. /**
  8319. * Bind a webGL transform feedback object to the webgl context
  8320. * @param value defines the webGL transform feedback object to bind
  8321. */
  8322. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8323. /**
  8324. * Begins a transform feedback operation
  8325. * @param usePoints defines if points or triangles must be used
  8326. */
  8327. beginTransformFeedback(usePoints?: boolean): void;
  8328. /**
  8329. * Ends a transform feedback operation
  8330. */
  8331. endTransformFeedback(): void;
  8332. /**
  8333. * Specify the varyings to use with transform feedback
  8334. * @param program defines the associated webGL program
  8335. * @param value defines the list of strings representing the varying names
  8336. */
  8337. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8338. /**
  8339. * Bind a webGL buffer for a transform feedback operation
  8340. * @param value defines the webGL buffer to bind
  8341. */
  8342. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8343. /** @hidden */
  8344. _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;
  8345. /** @hidden */
  8346. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8347. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8348. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8349. /**
  8350. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8351. * @returns true if the engine can be created
  8352. * @ignorenaming
  8353. */
  8354. static isSupported(): boolean;
  8355. }
  8356. }
  8357. declare module BABYLON {
  8358. class NullEngineOptions {
  8359. renderWidth: number;
  8360. renderHeight: number;
  8361. textureSize: number;
  8362. deterministicLockstep: boolean;
  8363. lockstepMaxSteps: number;
  8364. }
  8365. /**
  8366. * The null engine class provides support for headless version of babylon.js.
  8367. * This can be used in server side scenario or for testing purposes
  8368. */
  8369. class NullEngine extends Engine {
  8370. private _options;
  8371. isDeterministicLockStep(): boolean;
  8372. getLockstepMaxSteps(): number;
  8373. getHardwareScalingLevel(): number;
  8374. constructor(options?: NullEngineOptions);
  8375. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8376. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8377. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8378. getRenderWidth(useScreen?: boolean): number;
  8379. getRenderHeight(useScreen?: boolean): number;
  8380. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8381. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8382. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8383. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8384. bindSamplers(effect: Effect): void;
  8385. enableEffect(effect: Effect): void;
  8386. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8387. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8388. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8389. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8390. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8391. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8392. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8393. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8394. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8395. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8396. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8397. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8398. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8399. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8400. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8401. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8402. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8403. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8404. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8405. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8406. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8407. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8408. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8409. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8410. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8411. bindBuffers(vertexBuffers: {
  8412. [key: string]: VertexBuffer;
  8413. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8414. wipeCaches(bruteForce?: boolean): void;
  8415. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8416. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8417. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8418. _createTexture(): WebGLTexture;
  8419. _releaseTexture(texture: InternalTexture): void;
  8420. 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;
  8421. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8422. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8423. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8424. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8425. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8426. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8427. /**
  8428. * Updates a dynamic vertex buffer.
  8429. * @param vertexBuffer the vertex buffer to update
  8430. * @param data the data used to update the vertex buffer
  8431. * @param byteOffset the byte offset of the data (optional)
  8432. * @param byteLength the byte length of the data (optional)
  8433. */
  8434. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8435. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8436. _bindTexture(channel: number, texture: InternalTexture): void;
  8437. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8438. releaseEffects(): void;
  8439. }
  8440. }
  8441. interface WebGLRenderingContext {
  8442. readonly RASTERIZER_DISCARD: number;
  8443. readonly DEPTH_COMPONENT24: number;
  8444. readonly TEXTURE_3D: number;
  8445. readonly TEXTURE_2D_ARRAY: number;
  8446. readonly TEXTURE_COMPARE_FUNC: number;
  8447. readonly TEXTURE_COMPARE_MODE: number;
  8448. readonly COMPARE_REF_TO_TEXTURE: number;
  8449. readonly TEXTURE_WRAP_R: number;
  8450. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8451. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8452. 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;
  8453. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8454. readonly TRANSFORM_FEEDBACK: number;
  8455. readonly INTERLEAVED_ATTRIBS: number;
  8456. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8457. createTransformFeedback(): WebGLTransformFeedback;
  8458. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8459. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8460. beginTransformFeedback(primitiveMode: number): void;
  8461. endTransformFeedback(): void;
  8462. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8463. }
  8464. interface ImageBitmap {
  8465. readonly width: number;
  8466. readonly height: number;
  8467. close(): void;
  8468. }
  8469. interface WebGLQuery extends WebGLObject {
  8470. }
  8471. declare var WebGLQuery: {
  8472. prototype: WebGLQuery;
  8473. new (): WebGLQuery;
  8474. };
  8475. interface WebGLSampler extends WebGLObject {
  8476. }
  8477. declare var WebGLSampler: {
  8478. prototype: WebGLSampler;
  8479. new (): WebGLSampler;
  8480. };
  8481. interface WebGLSync extends WebGLObject {
  8482. }
  8483. declare var WebGLSync: {
  8484. prototype: WebGLSync;
  8485. new (): WebGLSync;
  8486. };
  8487. interface WebGLTransformFeedback extends WebGLObject {
  8488. }
  8489. declare var WebGLTransformFeedback: {
  8490. prototype: WebGLTransformFeedback;
  8491. new (): WebGLTransformFeedback;
  8492. };
  8493. interface WebGLVertexArrayObject extends WebGLObject {
  8494. }
  8495. declare var WebGLVertexArrayObject: {
  8496. prototype: WebGLVertexArrayObject;
  8497. new (): WebGLVertexArrayObject;
  8498. };
  8499. declare module BABYLON {
  8500. /**
  8501. * Class used to store bone information
  8502. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8503. */
  8504. class Bone extends Node {
  8505. /**
  8506. * defines the bone name
  8507. */
  8508. name: string;
  8509. private static _tmpVecs;
  8510. private static _tmpQuat;
  8511. private static _tmpMats;
  8512. /**
  8513. * Gets the list of child bones
  8514. */
  8515. children: Bone[];
  8516. /** Gets the animations associated with this bone */
  8517. animations: Animation[];
  8518. /**
  8519. * Gets or sets bone length
  8520. */
  8521. length: number;
  8522. /**
  8523. * @hidden Internal only
  8524. * Set this value to map this bone to a different index in the transform matrices
  8525. * Set this value to -1 to exclude the bone from the transform matrices
  8526. */
  8527. _index: Nullable<number>;
  8528. private _skeleton;
  8529. private _localMatrix;
  8530. private _restPose;
  8531. private _baseMatrix;
  8532. private _absoluteTransform;
  8533. private _invertedAbsoluteTransform;
  8534. private _parent;
  8535. private _scalingDeterminant;
  8536. private _worldTransform;
  8537. private _localScaling;
  8538. private _localRotation;
  8539. private _localPosition;
  8540. private _needToDecompose;
  8541. private _needToCompose;
  8542. /** @hidden */
  8543. /** @hidden */
  8544. _matrix: Matrix;
  8545. /**
  8546. * Create a new bone
  8547. * @param name defines the bone name
  8548. * @param skeleton defines the parent skeleton
  8549. * @param parentBone defines the parent (can be null if the bone is the root)
  8550. * @param localMatrix defines the local matrix
  8551. * @param restPose defines the rest pose matrix
  8552. * @param baseMatrix defines the base matrix
  8553. * @param index defines index of the bone in the hiearchy
  8554. */
  8555. constructor(
  8556. /**
  8557. * defines the bone name
  8558. */
  8559. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8560. /**
  8561. * Gets the parent skeleton
  8562. * @returns a skeleton
  8563. */
  8564. getSkeleton(): Skeleton;
  8565. /**
  8566. * Gets parent bone
  8567. * @returns a bone or null if the bone is the root of the bone hierarchy
  8568. */
  8569. getParent(): Nullable<Bone>;
  8570. /**
  8571. * Sets the parent bone
  8572. * @param parent defines the parent (can be null if the bone is the root)
  8573. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8574. */
  8575. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8576. /**
  8577. * Gets the local matrix
  8578. * @returns a matrix
  8579. */
  8580. getLocalMatrix(): Matrix;
  8581. /**
  8582. * Gets the base matrix (initial matrix which remains unchanged)
  8583. * @returns a matrix
  8584. */
  8585. getBaseMatrix(): Matrix;
  8586. /**
  8587. * Gets the rest pose matrix
  8588. * @returns a matrix
  8589. */
  8590. getRestPose(): Matrix;
  8591. /**
  8592. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8593. */
  8594. getWorldMatrix(): Matrix;
  8595. /**
  8596. * Sets the local matrix to rest pose matrix
  8597. */
  8598. returnToRest(): void;
  8599. /**
  8600. * Gets the inverse of the absolute transform matrix.
  8601. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8602. * @returns a matrix
  8603. */
  8604. getInvertedAbsoluteTransform(): Matrix;
  8605. /**
  8606. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8607. * @returns a matrix
  8608. */
  8609. getAbsoluteTransform(): Matrix;
  8610. /** Gets or sets current position (in local space) */
  8611. position: Vector3;
  8612. /** Gets or sets current rotation (in local space) */
  8613. rotation: Vector3;
  8614. /** Gets or sets current rotation quaternion (in local space) */
  8615. rotationQuaternion: Quaternion;
  8616. /** Gets or sets current scaling (in local space) */
  8617. scaling: Vector3;
  8618. /**
  8619. * Gets the animation properties override
  8620. */
  8621. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8622. private _decompose();
  8623. private _compose();
  8624. /**
  8625. * Update the base and local matrices
  8626. * @param matrix defines the new base or local matrix
  8627. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8628. * @param updateLocalMatrix defines if the local matrix should be updated
  8629. */
  8630. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8631. /** @hidden */
  8632. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8633. /**
  8634. * Flag the bone as dirty (Forcing it to update everything)
  8635. */
  8636. markAsDirty(): void;
  8637. private _markAsDirtyAndCompose();
  8638. private _markAsDirtyAndDecompose();
  8639. /**
  8640. * Copy an animation range from another bone
  8641. * @param source defines the source bone
  8642. * @param rangeName defines the range name to copy
  8643. * @param frameOffset defines the frame offset
  8644. * @param rescaleAsRequired defines if rescaling must be applied if required
  8645. * @param skelDimensionsRatio defines the scaling ratio
  8646. * @returns true if operation was successful
  8647. */
  8648. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  8649. /**
  8650. * Translate the bone in local or world space
  8651. * @param vec The amount to translate the bone
  8652. * @param space The space that the translation is in
  8653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8654. */
  8655. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8656. /**
  8657. * Set the postion of the bone in local or world space
  8658. * @param position The position to set the bone
  8659. * @param space The space that the position is in
  8660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8661. */
  8662. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8663. /**
  8664. * Set the absolute position of the bone (world space)
  8665. * @param position The position to set the bone
  8666. * @param mesh The mesh that this bone is attached to
  8667. */
  8668. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8669. /**
  8670. * Scale the bone on the x, y and z axes (in local space)
  8671. * @param x The amount to scale the bone on the x axis
  8672. * @param y The amount to scale the bone on the y axis
  8673. * @param z The amount to scale the bone on the z axis
  8674. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8675. */
  8676. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8677. /**
  8678. * Set the bone scaling in local space
  8679. * @param scale defines the scaling vector
  8680. */
  8681. setScale(scale: Vector3): void;
  8682. /**
  8683. * Gets the current scaling in local space
  8684. * @returns the current scaling vector
  8685. */
  8686. getScale(): Vector3;
  8687. /**
  8688. * Gets the current scaling in local space and stores it in a target vector
  8689. * @param result defines the target vector
  8690. */
  8691. getScaleToRef(result: Vector3): void;
  8692. /**
  8693. * Set the yaw, pitch, and roll of the bone in local or world space
  8694. * @param yaw The rotation of the bone on the y axis
  8695. * @param pitch The rotation of the bone on the x axis
  8696. * @param roll The rotation of the bone on the z axis
  8697. * @param space The space that the axes of rotation are in
  8698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8699. */
  8700. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8701. /**
  8702. * Add a rotation to the bone on an axis in local or world space
  8703. * @param axis The axis to rotate the bone on
  8704. * @param amount The amount to rotate the bone
  8705. * @param space The space that the axis is in
  8706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8707. */
  8708. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8709. /**
  8710. * Set the rotation of the bone to a particular axis angle in local or world space
  8711. * @param axis The axis to rotate the bone on
  8712. * @param angle The angle that the bone should be rotated to
  8713. * @param space The space that the axis is in
  8714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8715. */
  8716. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8717. /**
  8718. * Set the euler rotation of the bone in local of world space
  8719. * @param rotation The euler rotation that the bone should be set to
  8720. * @param space The space that the rotation is in
  8721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8722. */
  8723. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8724. /**
  8725. * Set the quaternion rotation of the bone in local of world space
  8726. * @param quat The quaternion rotation that the bone should be set to
  8727. * @param space The space that the rotation is in
  8728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8729. */
  8730. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8731. /**
  8732. * Set the rotation matrix of the bone in local of world space
  8733. * @param rotMat The rotation matrix that the bone should be set to
  8734. * @param space The space that the rotation is in
  8735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8736. */
  8737. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8738. private _rotateWithMatrix(rmat, space?, mesh?);
  8739. private _getNegativeRotationToRef(rotMatInv, mesh?);
  8740. /**
  8741. * Get the position of the bone in local or world space
  8742. * @param space The space that the returned position is in
  8743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8744. * @returns The position of the bone
  8745. */
  8746. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8747. /**
  8748. * Copy the position of the bone to a vector3 in local or world space
  8749. * @param space The space that the returned position is in
  8750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8751. * @param result The vector3 to copy the position to
  8752. */
  8753. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8754. /**
  8755. * Get the absolute position of the bone (world space)
  8756. * @param mesh The mesh that this bone is attached to
  8757. * @returns The absolute position of the bone
  8758. */
  8759. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8760. /**
  8761. * Copy the absolute position of the bone (world space) to the result param
  8762. * @param mesh The mesh that this bone is attached to
  8763. * @param result The vector3 to copy the absolute position to
  8764. */
  8765. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8766. /**
  8767. * Compute the absolute transforms of this bone and its children
  8768. */
  8769. computeAbsoluteTransforms(): void;
  8770. /**
  8771. * Get the world direction from an axis that is in the local space of the bone
  8772. * @param localAxis The local direction that is used to compute the world direction
  8773. * @param mesh The mesh that this bone is attached to
  8774. * @returns The world direction
  8775. */
  8776. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8777. /**
  8778. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8779. * @param localAxis The local direction that is used to compute the world direction
  8780. * @param mesh The mesh that this bone is attached to
  8781. * @param result The vector3 that the world direction will be copied to
  8782. */
  8783. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8784. /**
  8785. * Get the euler rotation of the bone in local or world space
  8786. * @param space The space that the rotation should be in
  8787. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8788. * @returns The euler rotation
  8789. */
  8790. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8791. /**
  8792. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8793. * @param space The space that the rotation should be in
  8794. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8795. * @param result The vector3 that the rotation should be copied to
  8796. */
  8797. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8798. /**
  8799. * Get the quaternion rotation of the bone in either local or world space
  8800. * @param space The space that the rotation should be in
  8801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8802. * @returns The quaternion rotation
  8803. */
  8804. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8805. /**
  8806. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8807. * @param space The space that the rotation should be in
  8808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8809. * @param result The quaternion that the rotation should be copied to
  8810. */
  8811. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8812. /**
  8813. * Get the rotation matrix of the bone in local or world space
  8814. * @param space The space that the rotation should be in
  8815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8816. * @returns The rotation matrix
  8817. */
  8818. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8819. /**
  8820. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8821. * @param space The space that the rotation should be in
  8822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8823. * @param result The quaternion that the rotation should be copied to
  8824. */
  8825. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8826. /**
  8827. * Get the world position of a point that is in the local space of the bone
  8828. * @param position The local position
  8829. * @param mesh The mesh that this bone is attached to
  8830. * @returns The world position
  8831. */
  8832. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8833. /**
  8834. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8835. * @param position The local position
  8836. * @param mesh The mesh that this bone is attached to
  8837. * @param result The vector3 that the world position should be copied to
  8838. */
  8839. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8840. /**
  8841. * Get the local position of a point that is in world space
  8842. * @param position The world position
  8843. * @param mesh The mesh that this bone is attached to
  8844. * @returns The local position
  8845. */
  8846. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8847. /**
  8848. * Get the local position of a point that is in world space and copy it to the result param
  8849. * @param position The world position
  8850. * @param mesh The mesh that this bone is attached to
  8851. * @param result The vector3 that the local position should be copied to
  8852. */
  8853. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8854. }
  8855. }
  8856. declare module BABYLON {
  8857. /**
  8858. * Class used to apply inverse kinematics to bones
  8859. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  8860. */
  8861. class BoneIKController {
  8862. private static _tmpVecs;
  8863. private static _tmpQuat;
  8864. private static _tmpMats;
  8865. /**
  8866. * Gets or sets the target mesh
  8867. */
  8868. targetMesh: AbstractMesh;
  8869. /** Gets or sets the mesh used as pole */
  8870. poleTargetMesh: AbstractMesh;
  8871. /**
  8872. * Gets or sets the bone used as pole
  8873. */
  8874. poleTargetBone: Nullable<Bone>;
  8875. /**
  8876. * Gets or sets the target position
  8877. */
  8878. targetPosition: Vector3;
  8879. /**
  8880. * Gets or sets the pole target position
  8881. */
  8882. poleTargetPosition: Vector3;
  8883. /**
  8884. * Gets or sets the pole target local offset
  8885. */
  8886. poleTargetLocalOffset: Vector3;
  8887. /**
  8888. * Gets or sets the pole angle
  8889. */
  8890. poleAngle: number;
  8891. /**
  8892. * Gets or sets the mesh associated with the controller
  8893. */
  8894. mesh: AbstractMesh;
  8895. /**
  8896. * 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)
  8897. */
  8898. slerpAmount: number;
  8899. private _bone1Quat;
  8900. private _bone1Mat;
  8901. private _bone2Ang;
  8902. private _bone1;
  8903. private _bone2;
  8904. private _bone1Length;
  8905. private _bone2Length;
  8906. private _maxAngle;
  8907. private _maxReach;
  8908. private _rightHandedSystem;
  8909. private _bendAxis;
  8910. private _slerping;
  8911. private _adjustRoll;
  8912. /**
  8913. * Gets or sets maximum allowed angle
  8914. */
  8915. maxAngle: number;
  8916. /**
  8917. * Creates a new BoneIKController
  8918. * @param mesh defines the mesh to control
  8919. * @param bone defines the bone to control
  8920. * @param options defines options to set up the controller
  8921. */
  8922. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  8923. targetMesh?: AbstractMesh;
  8924. poleTargetMesh?: AbstractMesh;
  8925. poleTargetBone?: Bone;
  8926. poleTargetLocalOffset?: Vector3;
  8927. poleAngle?: number;
  8928. bendAxis?: Vector3;
  8929. maxAngle?: number;
  8930. slerpAmount?: number;
  8931. });
  8932. private _setMaxAngle(ang);
  8933. /**
  8934. * Force the controller to update the bones
  8935. */
  8936. update(): void;
  8937. }
  8938. }
  8939. declare module BABYLON {
  8940. /**
  8941. * Class used to make a bone look toward a point in space
  8942. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  8943. */
  8944. class BoneLookController {
  8945. private static _tmpVecs;
  8946. private static _tmpQuat;
  8947. private static _tmpMats;
  8948. /**
  8949. * The target Vector3 that the bone will look at
  8950. */
  8951. target: Vector3;
  8952. /**
  8953. * The mesh that the bone is attached to
  8954. */
  8955. mesh: AbstractMesh;
  8956. /**
  8957. * The bone that will be looking to the target
  8958. */
  8959. bone: Bone;
  8960. /**
  8961. * The up axis of the coordinate system that is used when the bone is rotated
  8962. */
  8963. upAxis: Vector3;
  8964. /**
  8965. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  8966. */
  8967. upAxisSpace: Space;
  8968. /**
  8969. * Used to make an adjustment to the yaw of the bone
  8970. */
  8971. adjustYaw: number;
  8972. /**
  8973. * Used to make an adjustment to the pitch of the bone
  8974. */
  8975. adjustPitch: number;
  8976. /**
  8977. * Used to make an adjustment to the roll of the bone
  8978. */
  8979. adjustRoll: number;
  8980. /**
  8981. * 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)
  8982. */
  8983. slerpAmount: number;
  8984. private _minYaw;
  8985. private _maxYaw;
  8986. private _minPitch;
  8987. private _maxPitch;
  8988. private _minYawSin;
  8989. private _minYawCos;
  8990. private _maxYawSin;
  8991. private _maxYawCos;
  8992. private _midYawConstraint;
  8993. private _minPitchTan;
  8994. private _maxPitchTan;
  8995. private _boneQuat;
  8996. private _slerping;
  8997. private _transformYawPitch;
  8998. private _transformYawPitchInv;
  8999. private _firstFrameSkipped;
  9000. private _yawRange;
  9001. private _fowardAxis;
  9002. /**
  9003. * Gets or sets the minimum yaw angle that the bone can look to
  9004. */
  9005. minYaw: number;
  9006. /**
  9007. * Gets or sets the maximum yaw angle that the bone can look to
  9008. */
  9009. maxYaw: number;
  9010. /**
  9011. * Gets or sets the minimum pitch angle that the bone can look to
  9012. */
  9013. minPitch: number;
  9014. /**
  9015. * Gets or sets the maximum pitch angle that the bone can look to
  9016. */
  9017. maxPitch: number;
  9018. /**
  9019. * Create a BoneLookController
  9020. * @param mesh the mesh that the bone belongs to
  9021. * @param bone the bone that will be looking to the target
  9022. * @param target the target Vector3 to look at
  9023. * @param settings optional settings:
  9024. * * maxYaw: the maximum angle the bone will yaw to
  9025. * * minYaw: the minimum angle the bone will yaw to
  9026. * * maxPitch: the maximum angle the bone will pitch to
  9027. * * minPitch: the minimum angle the bone will yaw to
  9028. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  9029. * * upAxis: the up axis of the coordinate system
  9030. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  9031. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  9032. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  9033. * * adjustYaw: used to make an adjustment to the yaw of the bone
  9034. * * adjustPitch: used to make an adjustment to the pitch of the bone
  9035. * * adjustRoll: used to make an adjustment to the roll of the bone
  9036. **/
  9037. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  9038. maxYaw?: number;
  9039. minYaw?: number;
  9040. maxPitch?: number;
  9041. minPitch?: number;
  9042. slerpAmount?: number;
  9043. upAxis?: Vector3;
  9044. upAxisSpace?: Space;
  9045. yawAxis?: Vector3;
  9046. pitchAxis?: Vector3;
  9047. adjustYaw?: number;
  9048. adjustPitch?: number;
  9049. adjustRoll?: number;
  9050. });
  9051. /**
  9052. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  9053. */
  9054. update(): void;
  9055. private _getAngleDiff(ang1, ang2);
  9056. private _getAngleBetween(ang1, ang2);
  9057. private _isAngleBetween(ang, ang1, ang2);
  9058. }
  9059. }
  9060. declare module BABYLON {
  9061. /**
  9062. * Class used to handle skinning animations
  9063. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9064. */
  9065. class Skeleton implements IAnimatable {
  9066. /** defines the skeleton name */
  9067. name: string;
  9068. /** defines the skeleton Id */
  9069. id: string;
  9070. /**
  9071. * Gets the list of child bones
  9072. */
  9073. bones: Bone[];
  9074. /**
  9075. * Gets an estimate of the dimension of the skeleton at rest
  9076. */
  9077. dimensionsAtRest: Vector3;
  9078. /**
  9079. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9080. */
  9081. needInitialSkinMatrix: boolean;
  9082. /**
  9083. * Gets the list of animations attached to this skeleton
  9084. */
  9085. animations: Array<Animation>;
  9086. private _scene;
  9087. private _isDirty;
  9088. private _transformMatrices;
  9089. private _meshesWithPoseMatrix;
  9090. private _animatables;
  9091. private _identity;
  9092. private _synchronizedWithMesh;
  9093. private _ranges;
  9094. private _lastAbsoluteTransformsUpdateId;
  9095. /**
  9096. * Specifies if the skeleton should be serialized
  9097. */
  9098. doNotSerialize: boolean;
  9099. private _animationPropertiesOverride;
  9100. /**
  9101. * Gets or sets the animation properties override
  9102. */
  9103. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9104. /**
  9105. * An observable triggered before computing the skeleton's matrices
  9106. */
  9107. onBeforeComputeObservable: Observable<Skeleton>;
  9108. /**
  9109. * Creates a new skeleton
  9110. * @param name defines the skeleton name
  9111. * @param id defines the skeleton Id
  9112. * @param scene defines the hosting scene
  9113. */
  9114. constructor(
  9115. /** defines the skeleton name */
  9116. name: string,
  9117. /** defines the skeleton Id */
  9118. id: string, scene: Scene);
  9119. /**
  9120. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9121. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9122. * @returns a Float32Array containing matrices data
  9123. */
  9124. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9125. /**
  9126. * Gets the current hosting scene
  9127. * @returns a scene object
  9128. */
  9129. getScene(): Scene;
  9130. /**
  9131. * Gets a string representing the current skeleton data
  9132. * @param fullDetails defines a boolean indicating if we want a verbose version
  9133. * @returns a string representing the current skeleton data
  9134. */
  9135. toString(fullDetails?: boolean): string;
  9136. /**
  9137. * Get bone's index searching by name
  9138. * @param name defines bone's name to search for
  9139. * @return the indice of the bone. Returns -1 if not found
  9140. */
  9141. getBoneIndexByName(name: string): number;
  9142. /**
  9143. * Creater a new animation range
  9144. * @param name defines the name of the range
  9145. * @param from defines the start key
  9146. * @param to defines the end key
  9147. */
  9148. createAnimationRange(name: string, from: number, to: number): void;
  9149. /**
  9150. * Delete a specific animation range
  9151. * @param name defines the name of the range
  9152. * @param deleteFrames defines if frames must be removed as well
  9153. */
  9154. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9155. /**
  9156. * Gets a specific animation range
  9157. * @param name defines the name of the range to look for
  9158. * @returns the requested animation range or null if not found
  9159. */
  9160. getAnimationRange(name: string): Nullable<AnimationRange>;
  9161. /**
  9162. * Gets the list of all animation ranges defined on this skeleton
  9163. * @returns an array
  9164. */
  9165. getAnimationRanges(): Nullable<AnimationRange>[];
  9166. /**
  9167. * Copy animation range from a source skeleton.
  9168. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9169. * @param source defines the source skeleton
  9170. * @param name defines the name of the range to copy
  9171. * @param rescaleAsRequired defines if rescaling must be applied if required
  9172. * @returns true if operation was successful
  9173. */
  9174. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9175. /**
  9176. * Forces the skeleton to go to rest pose
  9177. */
  9178. returnToRest(): void;
  9179. private _getHighestAnimationFrame();
  9180. /**
  9181. * Begin a specific animation range
  9182. * @param name defines the name of the range to start
  9183. * @param loop defines if looping must be turned on (false by default)
  9184. * @param speedRatio defines the speed ratio to apply (1 by default)
  9185. * @param onAnimationEnd defines a callback which will be called when animation will end
  9186. * @returns a new animatable
  9187. */
  9188. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  9189. /** @hidden */
  9190. _markAsDirty(): void;
  9191. /** @hidden */
  9192. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9193. /** @hidden */
  9194. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9195. /** @hidden */
  9196. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  9197. /**
  9198. * Build all resources required to render a skeleton
  9199. */
  9200. prepare(): void;
  9201. /**
  9202. * Gets the list of animatables currently running for this skeleton
  9203. * @returns an array of animatables
  9204. */
  9205. getAnimatables(): IAnimatable[];
  9206. /**
  9207. * Clone the current skeleton
  9208. * @param name defines the name of the new skeleton
  9209. * @param id defines the id of the enw skeleton
  9210. * @returns the new skeleton
  9211. */
  9212. clone(name: string, id: string): Skeleton;
  9213. /**
  9214. * Enable animation blending for this skeleton
  9215. * @param blendingSpeed defines the blending speed to apply
  9216. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9217. */
  9218. enableBlending(blendingSpeed?: number): void;
  9219. /**
  9220. * Releases all resources associated with the current skeleton
  9221. */
  9222. dispose(): void;
  9223. /**
  9224. * Serialize the skeleton in a JSON object
  9225. * @returns a JSON object
  9226. */
  9227. serialize(): any;
  9228. /**
  9229. * Creates a new skeleton from serialized data
  9230. * @param parsedSkeleton defines the serialized data
  9231. * @param scene defines the hosting scene
  9232. * @returns a new skeleton
  9233. */
  9234. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  9235. /**
  9236. * Compute all node absolute transforms
  9237. * @param forceUpdate defines if computation must be done even if cache is up to date
  9238. */
  9239. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  9240. /**
  9241. * Gets the root pose matrix
  9242. * @returns a matrix
  9243. */
  9244. getPoseMatrix(): Nullable<Matrix>;
  9245. /**
  9246. * Sorts bones per internal index
  9247. */
  9248. sortBones(): void;
  9249. private _sortBones(index, bones, visited);
  9250. }
  9251. }
  9252. declare module BABYLON {
  9253. class StickValues {
  9254. x: number;
  9255. y: number;
  9256. constructor(x: number, y: number);
  9257. }
  9258. interface GamepadButtonChanges {
  9259. changed: boolean;
  9260. pressChanged: boolean;
  9261. touchChanged: boolean;
  9262. valueChanged: boolean;
  9263. }
  9264. class Gamepad {
  9265. id: string;
  9266. index: number;
  9267. browserGamepad: any;
  9268. type: number;
  9269. private _leftStick;
  9270. private _rightStick;
  9271. _isConnected: boolean;
  9272. private _leftStickAxisX;
  9273. private _leftStickAxisY;
  9274. private _rightStickAxisX;
  9275. private _rightStickAxisY;
  9276. private _onleftstickchanged;
  9277. private _onrightstickchanged;
  9278. static GAMEPAD: number;
  9279. static GENERIC: number;
  9280. static XBOX: number;
  9281. static POSE_ENABLED: number;
  9282. protected _invertLeftStickY: boolean;
  9283. readonly isConnected: boolean;
  9284. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9285. onleftstickchanged(callback: (values: StickValues) => void): void;
  9286. onrightstickchanged(callback: (values: StickValues) => void): void;
  9287. leftStick: StickValues;
  9288. rightStick: StickValues;
  9289. update(): void;
  9290. dispose(): void;
  9291. }
  9292. class GenericPad extends Gamepad {
  9293. private _buttons;
  9294. private _onbuttondown;
  9295. private _onbuttonup;
  9296. onButtonDownObservable: Observable<number>;
  9297. onButtonUpObservable: Observable<number>;
  9298. onbuttondown(callback: (buttonPressed: number) => void): void;
  9299. onbuttonup(callback: (buttonReleased: number) => void): void;
  9300. constructor(id: string, index: number, browserGamepad: any);
  9301. private _setButtonValue(newValue, currentValue, buttonIndex);
  9302. update(): void;
  9303. dispose(): void;
  9304. }
  9305. }
  9306. declare module BABYLON {
  9307. class GamepadManager {
  9308. private _scene;
  9309. private _babylonGamepads;
  9310. private _oneGamepadConnected;
  9311. _isMonitoring: boolean;
  9312. private _gamepadEventSupported;
  9313. private _gamepadSupport;
  9314. onGamepadConnectedObservable: Observable<Gamepad>;
  9315. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9316. private _onGamepadConnectedEvent;
  9317. private _onGamepadDisconnectedEvent;
  9318. constructor(_scene?: Scene | undefined);
  9319. readonly gamepads: Gamepad[];
  9320. getGamepadByType(type?: number): Nullable<Gamepad>;
  9321. dispose(): void;
  9322. private _addNewGamepad(gamepad);
  9323. private _startMonitoringGamepads();
  9324. private _stopMonitoringGamepads();
  9325. _checkGamepadsStatus(): void;
  9326. private _updateGamepadObjects();
  9327. }
  9328. }
  9329. declare module BABYLON {
  9330. /**
  9331. * Defines supported buttons for XBox360 compatible gamepads
  9332. */
  9333. enum Xbox360Button {
  9334. /** A */
  9335. A = 0,
  9336. /** B */
  9337. B = 1,
  9338. /** X */
  9339. X = 2,
  9340. /** Y */
  9341. Y = 3,
  9342. /** Start */
  9343. Start = 4,
  9344. /** Back */
  9345. Back = 5,
  9346. /** Left button */
  9347. LB = 6,
  9348. /** Right button */
  9349. RB = 7,
  9350. /** Left stick */
  9351. LeftStick = 8,
  9352. /** Right stick */
  9353. RightStick = 9,
  9354. }
  9355. /** Defines values for XBox360 DPad */
  9356. enum Xbox360Dpad {
  9357. /** Up */
  9358. Up = 0,
  9359. /** Down */
  9360. Down = 1,
  9361. /** Left */
  9362. Left = 2,
  9363. /** Right */
  9364. Right = 3,
  9365. }
  9366. /**
  9367. * Defines a XBox360 gamepad
  9368. */
  9369. class Xbox360Pad extends Gamepad {
  9370. private _leftTrigger;
  9371. private _rightTrigger;
  9372. private _onlefttriggerchanged;
  9373. private _onrighttriggerchanged;
  9374. private _onbuttondown;
  9375. private _onbuttonup;
  9376. private _ondpaddown;
  9377. private _ondpadup;
  9378. /** Observable raised when a button is pressed */
  9379. onButtonDownObservable: Observable<Xbox360Button>;
  9380. /** Observable raised when a button is released */
  9381. onButtonUpObservable: Observable<Xbox360Button>;
  9382. /** Observable raised when a pad is pressed */
  9383. onPadDownObservable: Observable<Xbox360Dpad>;
  9384. /** Observable raised when a pad is released */
  9385. onPadUpObservable: Observable<Xbox360Dpad>;
  9386. private _buttonA;
  9387. private _buttonB;
  9388. private _buttonX;
  9389. private _buttonY;
  9390. private _buttonBack;
  9391. private _buttonStart;
  9392. private _buttonLB;
  9393. private _buttonRB;
  9394. private _buttonLeftStick;
  9395. private _buttonRightStick;
  9396. private _dPadUp;
  9397. private _dPadDown;
  9398. private _dPadLeft;
  9399. private _dPadRight;
  9400. private _isXboxOnePad;
  9401. /**
  9402. * Creates a new XBox360 gamepad object
  9403. * @param id defines the id of this gamepad
  9404. * @param index defines its index
  9405. * @param gamepad defines the internal HTML gamepad object
  9406. * @param xboxOne defines if it is a XBox One gamepad
  9407. */
  9408. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9409. /**
  9410. * Defines the callback to call when left trigger is pressed
  9411. * @param callback defines the callback to use
  9412. */
  9413. onlefttriggerchanged(callback: (value: number) => void): void;
  9414. /**
  9415. * Defines the callback to call when right trigger is pressed
  9416. * @param callback defines the callback to use
  9417. */
  9418. onrighttriggerchanged(callback: (value: number) => void): void;
  9419. /**
  9420. * Gets or sets left trigger value
  9421. */
  9422. leftTrigger: number;
  9423. /**
  9424. * Gets or sets right trigger value
  9425. */
  9426. rightTrigger: number;
  9427. /**
  9428. * Defines the callback to call when a button is pressed
  9429. * @param callback defines the callback to use
  9430. */
  9431. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9432. /**
  9433. * Defines the callback to call when a button is released
  9434. * @param callback defines the callback to use
  9435. */
  9436. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9437. /**
  9438. * Defines the callback to call when a pad is pressed
  9439. * @param callback defines the callback to use
  9440. */
  9441. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9442. /**
  9443. * Defines the callback to call when a pad is released
  9444. * @param callback defines the callback to use
  9445. */
  9446. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9447. private _setButtonValue(newValue, currentValue, buttonType);
  9448. private _setDPadValue(newValue, currentValue, buttonType);
  9449. /** Gets or sets value of A button */
  9450. buttonA: number;
  9451. /** Gets or sets value of B button */
  9452. buttonB: number;
  9453. /** Gets or sets value of X button */
  9454. buttonX: number;
  9455. /** Gets or sets value of Y button */
  9456. buttonY: number;
  9457. /** Gets or sets value of Start button */
  9458. buttonStart: number;
  9459. /** Gets or sets value of Back button */
  9460. buttonBack: number;
  9461. /** Gets or sets value of Left button */
  9462. buttonLB: number;
  9463. /** Gets or sets value of Right button */
  9464. buttonRB: number;
  9465. /** Gets or sets value of left stick */
  9466. buttonLeftStick: number;
  9467. /** Gets or sets value of right stick */
  9468. buttonRightStick: number;
  9469. /** Gets or sets value of DPad up */
  9470. dPadUp: number;
  9471. /** Gets or sets value of DPad down */
  9472. dPadDown: number;
  9473. /** Gets or sets value of DPad left */
  9474. dPadLeft: number;
  9475. /** Gets or sets value of DPad right */
  9476. dPadRight: number;
  9477. /**
  9478. * Force the gamepad to synchronize with device values
  9479. */
  9480. update(): void;
  9481. dispose(): void;
  9482. }
  9483. }
  9484. declare module BABYLON {
  9485. /**
  9486. * Single axis drag gizmo
  9487. */
  9488. class AxisDragGizmo extends Gizmo {
  9489. private _dragBehavior;
  9490. /**
  9491. * Creates an AxisDragGizmo
  9492. * @param gizmoLayer The utility layer the gizmo will be added to
  9493. * @param dragAxis The axis which the gizmo will be able to drag on
  9494. * @param color The color of the gizmo
  9495. */
  9496. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9497. protected _onInteractionsEnabledChanged(value: boolean): void;
  9498. /**
  9499. * Disposes of the gizmo
  9500. */
  9501. dispose(): void;
  9502. }
  9503. }
  9504. declare module BABYLON {
  9505. /**
  9506. * Single axis scale gizmo
  9507. */
  9508. class AxisScaleGizmo extends Gizmo {
  9509. private _dragBehavior;
  9510. /**
  9511. * Creates an AxisScaleGizmo
  9512. * @param gizmoLayer The utility layer the gizmo will be added to
  9513. * @param dragAxis The axis which the gizmo will be able to scale on
  9514. * @param color The color of the gizmo
  9515. */
  9516. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9517. protected _onInteractionsEnabledChanged(value: boolean): void;
  9518. /**
  9519. * Disposes of the gizmo
  9520. */
  9521. dispose(): void;
  9522. }
  9523. }
  9524. declare module BABYLON {
  9525. /**
  9526. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9527. */
  9528. class Gizmo implements IDisposable {
  9529. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9530. /**
  9531. * The root mesh of the gizmo
  9532. */
  9533. protected _rootMesh: Mesh;
  9534. /**
  9535. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9536. */
  9537. attachedMesh: Nullable<AbstractMesh>;
  9538. protected _interactionsEnabled: boolean;
  9539. protected _onInteractionsEnabledChanged(value: boolean): void;
  9540. /**
  9541. * If interactions are enabled with this gizmo. (eg. dragging/rotation)
  9542. */
  9543. interactionsEnabled: boolean;
  9544. private _beforeRenderObserver;
  9545. /**
  9546. * Creates a gizmo
  9547. * @param gizmoLayer The utility layer the gizmo will be added to
  9548. */
  9549. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  9550. /**
  9551. * Disposes of the gizmo
  9552. */
  9553. dispose(): void;
  9554. }
  9555. }
  9556. declare module BABYLON {
  9557. /**
  9558. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9559. */
  9560. class GizmoManager implements IDisposable {
  9561. private scene;
  9562. private _gizmoLayer;
  9563. private _gizmoSet;
  9564. private _pointerObserver;
  9565. /**
  9566. * Instatiates a gizmo manager
  9567. * @param scene the scene to overlay the gizmos on top of
  9568. * @param options If only a single gizmo should exist at one time
  9569. */
  9570. constructor(scene: Scene, options?: {
  9571. singleGizmo?: boolean;
  9572. });
  9573. /**
  9574. * Disposes of the gizmo manager
  9575. */
  9576. dispose(): void;
  9577. private _clearGizmos();
  9578. }
  9579. }
  9580. declare module BABYLON {
  9581. /**
  9582. * Single plane rotation gizmo
  9583. */
  9584. class PlaneRotationGizmo extends Gizmo {
  9585. private _dragBehavior;
  9586. /**
  9587. * Creates a PlaneRotationGizmo
  9588. * @param gizmoLayer The utility layer the gizmo will be added to
  9589. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9590. * @param color The color of the gizmo
  9591. */
  9592. constructor(gizmoLayer: UtilityLayerRenderer, planeNormal: Vector3, color: Color3);
  9593. protected _onInteractionsEnabledChanged(value: boolean): void;
  9594. /**
  9595. * Disposes of the gizmo
  9596. */
  9597. dispose(): void;
  9598. }
  9599. }
  9600. declare module BABYLON {
  9601. /**
  9602. * Gizmo that enables dragging a mesh along 3 axis
  9603. */
  9604. class PositionGizmo extends Gizmo {
  9605. private _xDrag;
  9606. private _yDrag;
  9607. private _zDrag;
  9608. attachedMesh: Nullable<AbstractMesh>;
  9609. /**
  9610. * Creates a PositionGizmo
  9611. * @param gizmoLayer The utility layer the gizmo will be added to
  9612. */
  9613. constructor(gizmoLayer: UtilityLayerRenderer);
  9614. protected _onInteractionsEnabledChanged(value: boolean): void;
  9615. /**
  9616. * Disposes of the gizmo
  9617. */
  9618. dispose(): void;
  9619. }
  9620. }
  9621. declare module BABYLON {
  9622. /**
  9623. * Gizmo that enables rotating a mesh along 3 axis
  9624. */
  9625. class RotationGizmo extends Gizmo {
  9626. private _xDrag;
  9627. private _yDrag;
  9628. private _zDrag;
  9629. attachedMesh: Nullable<AbstractMesh>;
  9630. /**
  9631. * Creates a RotationGizmo
  9632. * @param gizmoLayer The utility layer the gizmo will be added to
  9633. */
  9634. constructor(gizmoLayer: UtilityLayerRenderer);
  9635. protected _onInteractionsEnabledChanged(value: boolean): void;
  9636. /**
  9637. * Disposes of the gizmo
  9638. */
  9639. dispose(): void;
  9640. }
  9641. }
  9642. declare module BABYLON {
  9643. /**
  9644. * Gizmo that enables scaling a mesh along 3 axis
  9645. */
  9646. class ScaleGizmo extends Gizmo {
  9647. private _xDrag;
  9648. private _yDrag;
  9649. private _zDrag;
  9650. attachedMesh: Nullable<AbstractMesh>;
  9651. /**
  9652. * Creates a ScaleGizmo
  9653. * @param gizmoLayer The utility layer the gizmo will be added to
  9654. */
  9655. constructor(gizmoLayer: UtilityLayerRenderer);
  9656. protected _onInteractionsEnabledChanged(value: boolean): void;
  9657. /**
  9658. * Disposes of the gizmo
  9659. */
  9660. dispose(): void;
  9661. }
  9662. }
  9663. declare module BABYLON {
  9664. class KeyboardEventTypes {
  9665. static _KEYDOWN: number;
  9666. static _KEYUP: number;
  9667. static readonly KEYDOWN: number;
  9668. static readonly KEYUP: number;
  9669. }
  9670. class KeyboardInfo {
  9671. type: number;
  9672. event: KeyboardEvent;
  9673. constructor(type: number, event: KeyboardEvent);
  9674. }
  9675. /**
  9676. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9677. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9678. */
  9679. class KeyboardInfoPre extends KeyboardInfo {
  9680. constructor(type: number, event: KeyboardEvent);
  9681. skipOnPointerObservable: boolean;
  9682. }
  9683. }
  9684. declare module BABYLON {
  9685. class PointerEventTypes {
  9686. static _POINTERDOWN: number;
  9687. static _POINTERUP: number;
  9688. static _POINTERMOVE: number;
  9689. static _POINTERWHEEL: number;
  9690. static _POINTERPICK: number;
  9691. static _POINTERTAP: number;
  9692. static _POINTERDOUBLETAP: number;
  9693. static readonly POINTERDOWN: number;
  9694. static readonly POINTERUP: number;
  9695. static readonly POINTERMOVE: number;
  9696. static readonly POINTERWHEEL: number;
  9697. static readonly POINTERPICK: number;
  9698. static readonly POINTERTAP: number;
  9699. static readonly POINTERDOUBLETAP: number;
  9700. }
  9701. class PointerInfoBase {
  9702. type: number;
  9703. event: PointerEvent | MouseWheelEvent;
  9704. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9705. }
  9706. /**
  9707. * This class is used to store pointer related info for the onPrePointerObservable event.
  9708. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9709. */
  9710. class PointerInfoPre extends PointerInfoBase {
  9711. /**
  9712. * Ray from a pointer if availible (eg. 6dof controller)
  9713. */
  9714. ray: Nullable<Ray>;
  9715. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9716. localPosition: Vector2;
  9717. skipOnPointerObservable: boolean;
  9718. }
  9719. /**
  9720. * This type contains all the data related to a pointer event in Babylon.js.
  9721. * 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.
  9722. */
  9723. class PointerInfo extends PointerInfoBase {
  9724. pickInfo: Nullable<PickingInfo>;
  9725. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9726. }
  9727. }
  9728. declare module BABYLON {
  9729. /**
  9730. * This class can be used to get instrumentation data from a Babylon engine
  9731. */
  9732. class EngineInstrumentation implements IDisposable {
  9733. engine: Engine;
  9734. private _captureGPUFrameTime;
  9735. private _gpuFrameTimeToken;
  9736. private _gpuFrameTime;
  9737. private _captureShaderCompilationTime;
  9738. private _shaderCompilationTime;
  9739. private _onBeginFrameObserver;
  9740. private _onEndFrameObserver;
  9741. private _onBeforeShaderCompilationObserver;
  9742. private _onAfterShaderCompilationObserver;
  9743. /**
  9744. * Gets the perf counter used for GPU frame time
  9745. */
  9746. readonly gpuFrameTimeCounter: PerfCounter;
  9747. /**
  9748. * Gets the GPU frame time capture status
  9749. */
  9750. /**
  9751. * Enable or disable the GPU frame time capture
  9752. */
  9753. captureGPUFrameTime: boolean;
  9754. /**
  9755. * Gets the perf counter used for shader compilation time
  9756. */
  9757. readonly shaderCompilationTimeCounter: PerfCounter;
  9758. /**
  9759. * Gets the shader compilation time capture status
  9760. */
  9761. /**
  9762. * Enable or disable the shader compilation time capture
  9763. */
  9764. captureShaderCompilationTime: boolean;
  9765. constructor(engine: Engine);
  9766. dispose(): void;
  9767. }
  9768. }
  9769. declare module BABYLON {
  9770. /**
  9771. * This class can be used to get instrumentation data from a Babylon engine
  9772. */
  9773. class SceneInstrumentation implements IDisposable {
  9774. scene: Scene;
  9775. private _captureActiveMeshesEvaluationTime;
  9776. private _activeMeshesEvaluationTime;
  9777. private _captureRenderTargetsRenderTime;
  9778. private _renderTargetsRenderTime;
  9779. private _captureFrameTime;
  9780. private _frameTime;
  9781. private _captureRenderTime;
  9782. private _renderTime;
  9783. private _captureInterFrameTime;
  9784. private _interFrameTime;
  9785. private _captureParticlesRenderTime;
  9786. private _particlesRenderTime;
  9787. private _captureSpritesRenderTime;
  9788. private _spritesRenderTime;
  9789. private _capturePhysicsTime;
  9790. private _physicsTime;
  9791. private _captureAnimationsTime;
  9792. private _animationsTime;
  9793. private _onBeforeActiveMeshesEvaluationObserver;
  9794. private _onAfterActiveMeshesEvaluationObserver;
  9795. private _onBeforeRenderTargetsRenderObserver;
  9796. private _onAfterRenderTargetsRenderObserver;
  9797. private _onAfterRenderObserver;
  9798. private _onBeforeDrawPhaseObserver;
  9799. private _onAfterDrawPhaseObserver;
  9800. private _onBeforeAnimationsObserver;
  9801. private _onBeforeParticlesRenderingObserver;
  9802. private _onAfterParticlesRenderingObserver;
  9803. private _onBeforeSpritesRenderingObserver;
  9804. private _onAfterSpritesRenderingObserver;
  9805. private _onBeforePhysicsObserver;
  9806. private _onAfterPhysicsObserver;
  9807. private _onAfterAnimationsObserver;
  9808. /**
  9809. * Gets the perf counter used for active meshes evaluation time
  9810. */
  9811. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9812. /**
  9813. * Gets the active meshes evaluation time capture status
  9814. */
  9815. /**
  9816. * Enable or disable the active meshes evaluation time capture
  9817. */
  9818. captureActiveMeshesEvaluationTime: boolean;
  9819. /**
  9820. * Gets the perf counter used for render targets render time
  9821. */
  9822. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9823. /**
  9824. * Gets the render targets render time capture status
  9825. */
  9826. /**
  9827. * Enable or disable the render targets render time capture
  9828. */
  9829. captureRenderTargetsRenderTime: boolean;
  9830. /**
  9831. * Gets the perf counter used for particles render time
  9832. */
  9833. readonly particlesRenderTimeCounter: PerfCounter;
  9834. /**
  9835. * Gets the particles render time capture status
  9836. */
  9837. /**
  9838. * Enable or disable the particles render time capture
  9839. */
  9840. captureParticlesRenderTime: boolean;
  9841. /**
  9842. * Gets the perf counter used for sprites render time
  9843. */
  9844. readonly spritesRenderTimeCounter: PerfCounter;
  9845. /**
  9846. * Gets the sprites render time capture status
  9847. */
  9848. /**
  9849. * Enable or disable the sprites render time capture
  9850. */
  9851. captureSpritesRenderTime: boolean;
  9852. /**
  9853. * Gets the perf counter used for physics time
  9854. */
  9855. readonly physicsTimeCounter: PerfCounter;
  9856. /**
  9857. * Gets the physics time capture status
  9858. */
  9859. /**
  9860. * Enable or disable the physics time capture
  9861. */
  9862. capturePhysicsTime: boolean;
  9863. /**
  9864. * Gets the perf counter used for animations time
  9865. */
  9866. readonly animationsTimeCounter: PerfCounter;
  9867. /**
  9868. * Gets the animations time capture status
  9869. */
  9870. /**
  9871. * Enable or disable the animations time capture
  9872. */
  9873. captureAnimationsTime: boolean;
  9874. /**
  9875. * Gets the perf counter used for frame time capture
  9876. */
  9877. readonly frameTimeCounter: PerfCounter;
  9878. /**
  9879. * Gets the frame time capture status
  9880. */
  9881. /**
  9882. * Enable or disable the frame time capture
  9883. */
  9884. captureFrameTime: boolean;
  9885. /**
  9886. * Gets the perf counter used for inter-frames time capture
  9887. */
  9888. readonly interFrameTimeCounter: PerfCounter;
  9889. /**
  9890. * Gets the inter-frames time capture status
  9891. */
  9892. /**
  9893. * Enable or disable the inter-frames time capture
  9894. */
  9895. captureInterFrameTime: boolean;
  9896. /**
  9897. * Gets the perf counter used for render time capture
  9898. */
  9899. readonly renderTimeCounter: PerfCounter;
  9900. /**
  9901. * Gets the render time capture status
  9902. */
  9903. /**
  9904. * Enable or disable the render time capture
  9905. */
  9906. captureRenderTime: boolean;
  9907. /**
  9908. * Gets the perf counter used for draw calls
  9909. */
  9910. readonly drawCallsCounter: PerfCounter;
  9911. /**
  9912. * Gets the perf counter used for texture collisions
  9913. */
  9914. readonly textureCollisionsCounter: PerfCounter;
  9915. constructor(scene: Scene);
  9916. dispose(): void;
  9917. }
  9918. }
  9919. declare module BABYLON {
  9920. /**
  9921. * @hidden
  9922. **/
  9923. class _TimeToken {
  9924. _startTimeQuery: Nullable<WebGLQuery>;
  9925. _endTimeQuery: Nullable<WebGLQuery>;
  9926. _timeElapsedQuery: Nullable<WebGLQuery>;
  9927. _timeElapsedQueryEnded: boolean;
  9928. }
  9929. }
  9930. declare module BABYLON {
  9931. /**
  9932. * Effect layer options. This helps customizing the behaviour
  9933. * of the effect layer.
  9934. */
  9935. interface IEffectLayerOptions {
  9936. /**
  9937. * Multiplication factor apply to the canvas size to compute the render target size
  9938. * used to generated the objects (the smaller the faster).
  9939. */
  9940. mainTextureRatio: number;
  9941. /**
  9942. * Enforces a fixed size texture to ensure effect stability across devices.
  9943. */
  9944. mainTextureFixedSize?: number;
  9945. /**
  9946. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  9947. */
  9948. alphaBlendingMode: number;
  9949. /**
  9950. * The camera attached to the layer.
  9951. */
  9952. camera: Nullable<Camera>;
  9953. }
  9954. /**
  9955. * The effect layer Helps adding post process effect blended with the main pass.
  9956. *
  9957. * This can be for instance use to generate glow or higlight effects on the scene.
  9958. *
  9959. * The effect layer class can not be used directly and is intented to inherited from to be
  9960. * customized per effects.
  9961. */
  9962. abstract class EffectLayer {
  9963. private _vertexBuffers;
  9964. private _indexBuffer;
  9965. private _cachedDefines;
  9966. private _effectLayerMapGenerationEffect;
  9967. private _effectLayerOptions;
  9968. private _mergeEffect;
  9969. protected _scene: Scene;
  9970. protected _engine: Engine;
  9971. protected _maxSize: number;
  9972. protected _mainTextureDesiredSize: ISize;
  9973. protected _mainTexture: RenderTargetTexture;
  9974. protected _shouldRender: boolean;
  9975. protected _postProcesses: PostProcess[];
  9976. protected _textures: BaseTexture[];
  9977. protected _emissiveTextureAndColor: {
  9978. texture: Nullable<BaseTexture>;
  9979. color: Color4;
  9980. };
  9981. /**
  9982. * The name of the layer
  9983. */
  9984. name: string;
  9985. /**
  9986. * The clear color of the texture used to generate the glow map.
  9987. */
  9988. neutralColor: Color4;
  9989. /**
  9990. * Specifies wether the highlight layer is enabled or not.
  9991. */
  9992. isEnabled: boolean;
  9993. /**
  9994. * Gets the camera attached to the layer.
  9995. */
  9996. readonly camera: Nullable<Camera>;
  9997. /**
  9998. * An event triggered when the effect layer has been disposed.
  9999. */
  10000. onDisposeObservable: Observable<EffectLayer>;
  10001. /**
  10002. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10003. */
  10004. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10005. /**
  10006. * An event triggered when the generated texture is being merged in the scene.
  10007. */
  10008. onBeforeComposeObservable: Observable<EffectLayer>;
  10009. /**
  10010. * An event triggered when the generated texture has been merged in the scene.
  10011. */
  10012. onAfterComposeObservable: Observable<EffectLayer>;
  10013. /**
  10014. * An event triggered when the efffect layer changes its size.
  10015. */
  10016. onSizeChangedObservable: Observable<EffectLayer>;
  10017. /**
  10018. * Instantiates a new effect Layer and references it in the scene.
  10019. * @param name The name of the layer
  10020. * @param scene The scene to use the layer in
  10021. */
  10022. constructor(
  10023. /** The Friendly of the effect in the scene */
  10024. name: string, scene: Scene);
  10025. /**
  10026. * Get the effect name of the layer.
  10027. * @return The effect name
  10028. */
  10029. abstract getEffectName(): string;
  10030. /**
  10031. * Checks for the readiness of the element composing the layer.
  10032. * @param subMesh the mesh to check for
  10033. * @param useInstances specify wether or not to use instances to render the mesh
  10034. * @return true if ready otherwise, false
  10035. */
  10036. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10037. /**
  10038. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10039. * @returns true if the effect requires stencil during the main canvas render pass.
  10040. */
  10041. abstract needStencil(): boolean;
  10042. /**
  10043. * Create the merge effect. This is the shader use to blit the information back
  10044. * to the main canvas at the end of the scene rendering.
  10045. * @returns The effect containing the shader used to merge the effect on the main canvas
  10046. */
  10047. protected abstract _createMergeEffect(): Effect;
  10048. /**
  10049. * Creates the render target textures and post processes used in the effect layer.
  10050. */
  10051. protected abstract _createTextureAndPostProcesses(): void;
  10052. /**
  10053. * Implementation specific of rendering the generating effect on the main canvas.
  10054. * @param effect The effect used to render through
  10055. */
  10056. protected abstract _internalRender(effect: Effect): void;
  10057. /**
  10058. * Sets the required values for both the emissive texture and and the main color.
  10059. */
  10060. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10061. /**
  10062. * Free any resources and references associated to a mesh.
  10063. * Internal use
  10064. * @param mesh The mesh to free.
  10065. */
  10066. abstract _disposeMesh(mesh: Mesh): void;
  10067. /**
  10068. * Serializes this layer (Glow or Highlight for example)
  10069. * @returns a serialized layer object
  10070. */
  10071. abstract serialize?(): any;
  10072. /**
  10073. * Initializes the effect layer with the required options.
  10074. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10075. */
  10076. protected _init(options: Partial<IEffectLayerOptions>): void;
  10077. /**
  10078. * Generates the index buffer of the full screen quad blending to the main canvas.
  10079. */
  10080. private _generateIndexBuffer();
  10081. /**
  10082. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10083. */
  10084. private _genrateVertexBuffer();
  10085. /**
  10086. * Sets the main texture desired size which is the closest power of two
  10087. * of the engine canvas size.
  10088. */
  10089. private _setMainTextureSize();
  10090. /**
  10091. * Creates the main texture for the effect layer.
  10092. */
  10093. protected _createMainTexture(): void;
  10094. /**
  10095. * Checks for the readiness of the element composing the layer.
  10096. * @param subMesh the mesh to check for
  10097. * @param useInstances specify wether or not to use instances to render the mesh
  10098. * @param emissiveTexture the associated emissive texture used to generate the glow
  10099. * @return true if ready otherwise, false
  10100. */
  10101. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10102. /**
  10103. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10104. */
  10105. render(): void;
  10106. /**
  10107. * Determine if a given mesh will be used in the current effect.
  10108. * @param mesh mesh to test
  10109. * @returns true if the mesh will be used
  10110. */
  10111. hasMesh(mesh: AbstractMesh): boolean;
  10112. /**
  10113. * Returns true if the layer contains information to display, otherwise false.
  10114. * @returns true if the glow layer should be rendered
  10115. */
  10116. shouldRender(): boolean;
  10117. /**
  10118. * Returns true if the mesh should render, otherwise false.
  10119. * @param mesh The mesh to render
  10120. * @returns true if it should render otherwise false
  10121. */
  10122. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10123. /**
  10124. * Returns true if the mesh should render, otherwise false.
  10125. * @param mesh The mesh to render
  10126. * @returns true if it should render otherwise false
  10127. */
  10128. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10129. /**
  10130. * Renders the submesh passed in parameter to the generation map.
  10131. */
  10132. protected _renderSubMesh(subMesh: SubMesh): void;
  10133. /**
  10134. * Rebuild the required buffers.
  10135. * @hidden Internal use only.
  10136. */
  10137. _rebuild(): void;
  10138. /**
  10139. * Dispose only the render target textures and post process.
  10140. */
  10141. private _disposeTextureAndPostProcesses();
  10142. /**
  10143. * Dispose the highlight layer and free resources.
  10144. */
  10145. dispose(): void;
  10146. /**
  10147. * Gets the class name of the effect layer
  10148. * @returns the string with the class name of the effect layer
  10149. */
  10150. getClassName(): string;
  10151. /**
  10152. * Creates an effect layer from parsed effect layer data
  10153. * @param parsedEffectLayer defines effect layer data
  10154. * @param scene defines the current scene
  10155. * @param rootUrl defines the root URL containing the effect layer information
  10156. * @returns a parsed effect Layer
  10157. */
  10158. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10159. }
  10160. }
  10161. declare module BABYLON {
  10162. /**
  10163. * Glow layer options. This helps customizing the behaviour
  10164. * of the glow layer.
  10165. */
  10166. interface IGlowLayerOptions {
  10167. /**
  10168. * Multiplication factor apply to the canvas size to compute the render target size
  10169. * used to generated the glowing objects (the smaller the faster).
  10170. */
  10171. mainTextureRatio: number;
  10172. /**
  10173. * Enforces a fixed size texture to ensure resize independant blur.
  10174. */
  10175. mainTextureFixedSize?: number;
  10176. /**
  10177. * How big is the kernel of the blur texture.
  10178. */
  10179. blurKernelSize: number;
  10180. /**
  10181. * The camera attached to the layer.
  10182. */
  10183. camera: Nullable<Camera>;
  10184. /**
  10185. * Enable MSAA by chosing the number of samples.
  10186. */
  10187. mainTextureSamples?: number;
  10188. }
  10189. /**
  10190. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10191. *
  10192. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10193. * glowy meshes to your scene.
  10194. *
  10195. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10196. */
  10197. class GlowLayer extends EffectLayer {
  10198. /**
  10199. * Effect Name of the layer.
  10200. */
  10201. static readonly EffectName: string;
  10202. /**
  10203. * The default blur kernel size used for the glow.
  10204. */
  10205. static DefaultBlurKernelSize: number;
  10206. /**
  10207. * The default texture size ratio used for the glow.
  10208. */
  10209. static DefaultTextureRatio: number;
  10210. /**
  10211. * Gets the kernel size of the blur.
  10212. */
  10213. /**
  10214. * Sets the kernel size of the blur.
  10215. */
  10216. blurKernelSize: number;
  10217. /**
  10218. * Gets the glow intensity.
  10219. */
  10220. /**
  10221. * Sets the glow intensity.
  10222. */
  10223. intensity: number;
  10224. private _options;
  10225. private _intensity;
  10226. private _horizontalBlurPostprocess1;
  10227. private _verticalBlurPostprocess1;
  10228. private _horizontalBlurPostprocess2;
  10229. private _verticalBlurPostprocess2;
  10230. private _blurTexture1;
  10231. private _blurTexture2;
  10232. private _postProcesses1;
  10233. private _postProcesses2;
  10234. private _includedOnlyMeshes;
  10235. private _excludedMeshes;
  10236. /**
  10237. * Callback used to let the user override the color selection on a per mesh basis
  10238. */
  10239. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10240. /**
  10241. * Callback used to let the user override the texture selection on a per mesh basis
  10242. */
  10243. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10244. /**
  10245. * Instantiates a new glow Layer and references it to the scene.
  10246. * @param name The name of the layer
  10247. * @param scene The scene to use the layer in
  10248. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10249. */
  10250. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10251. /**
  10252. * Get the effect name of the layer.
  10253. * @return The effect name
  10254. */
  10255. getEffectName(): string;
  10256. /**
  10257. * Create the merge effect. This is the shader use to blit the information back
  10258. * to the main canvas at the end of the scene rendering.
  10259. */
  10260. protected _createMergeEffect(): Effect;
  10261. /**
  10262. * Creates the render target textures and post processes used in the glow layer.
  10263. */
  10264. protected _createTextureAndPostProcesses(): void;
  10265. /**
  10266. * Checks for the readiness of the element composing the layer.
  10267. * @param subMesh the mesh to check for
  10268. * @param useInstances specify wether or not to use instances to render the mesh
  10269. * @param emissiveTexture the associated emissive texture used to generate the glow
  10270. * @return true if ready otherwise, false
  10271. */
  10272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10273. /**
  10274. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10275. */
  10276. needStencil(): boolean;
  10277. /**
  10278. * Implementation specific of rendering the generating effect on the main canvas.
  10279. * @param effect The effect used to render through
  10280. */
  10281. protected _internalRender(effect: Effect): void;
  10282. /**
  10283. * Sets the required values for both the emissive texture and and the main color.
  10284. */
  10285. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10286. /**
  10287. * Returns true if the mesh should render, otherwise false.
  10288. * @param mesh The mesh to render
  10289. * @returns true if it should render otherwise false
  10290. */
  10291. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10292. /**
  10293. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10294. * @param mesh The mesh to exclude from the glow layer
  10295. */
  10296. addExcludedMesh(mesh: Mesh): void;
  10297. /**
  10298. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10299. * @param mesh The mesh to remove
  10300. */
  10301. removeExcludedMesh(mesh: Mesh): void;
  10302. /**
  10303. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10304. * @param mesh The mesh to include in the glow layer
  10305. */
  10306. addIncludedOnlyMesh(mesh: Mesh): void;
  10307. /**
  10308. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10309. * @param mesh The mesh to remove
  10310. */
  10311. removeIncludedOnlyMesh(mesh: Mesh): void;
  10312. /**
  10313. * Determine if a given mesh will be used in the glow layer
  10314. * @param mesh The mesh to test
  10315. * @returns true if the mesh will be highlighted by the current glow layer
  10316. */
  10317. hasMesh(mesh: AbstractMesh): boolean;
  10318. /**
  10319. * Free any resources and references associated to a mesh.
  10320. * Internal use
  10321. * @param mesh The mesh to free.
  10322. */
  10323. _disposeMesh(mesh: Mesh): void;
  10324. /**
  10325. * Gets the class name of the effect layer
  10326. * @returns the string with the class name of the effect layer
  10327. */
  10328. getClassName(): string;
  10329. /**
  10330. * Serializes this glow layer
  10331. * @returns a serialized glow layer object
  10332. */
  10333. serialize(): any;
  10334. /**
  10335. * Creates a Glow Layer from parsed glow layer data
  10336. * @param parsedGlowLayer defines glow layer data
  10337. * @param scene defines the current scene
  10338. * @param rootUrl defines the root URL containing the glow layer information
  10339. * @returns a parsed Glow Layer
  10340. */
  10341. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10342. }
  10343. }
  10344. declare module BABYLON {
  10345. /**
  10346. * Highlight layer options. This helps customizing the behaviour
  10347. * of the highlight layer.
  10348. */
  10349. interface IHighlightLayerOptions {
  10350. /**
  10351. * Multiplication factor apply to the canvas size to compute the render target size
  10352. * used to generated the glowing objects (the smaller the faster).
  10353. */
  10354. mainTextureRatio: number;
  10355. /**
  10356. * Enforces a fixed size texture to ensure resize independant blur.
  10357. */
  10358. mainTextureFixedSize?: number;
  10359. /**
  10360. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10361. * of the picture to blur (the smaller the faster).
  10362. */
  10363. blurTextureSizeRatio: number;
  10364. /**
  10365. * How big in texel of the blur texture is the vertical blur.
  10366. */
  10367. blurVerticalSize: number;
  10368. /**
  10369. * How big in texel of the blur texture is the horizontal blur.
  10370. */
  10371. blurHorizontalSize: number;
  10372. /**
  10373. * Alpha blending mode used to apply the blur. Default is combine.
  10374. */
  10375. alphaBlendingMode: number;
  10376. /**
  10377. * The camera attached to the layer.
  10378. */
  10379. camera: Nullable<Camera>;
  10380. /**
  10381. * Should we display highlight as a solid stroke?
  10382. */
  10383. isStroke?: boolean;
  10384. }
  10385. /**
  10386. * The highlight layer Helps adding a glow effect around a mesh.
  10387. *
  10388. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10389. * glowy meshes to your scene.
  10390. *
  10391. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10392. */
  10393. class HighlightLayer extends EffectLayer {
  10394. name: string;
  10395. /**
  10396. * Effect Name of the highlight layer.
  10397. */
  10398. static readonly EffectName: string;
  10399. /**
  10400. * The neutral color used during the preparation of the glow effect.
  10401. * This is black by default as the blend operation is a blend operation.
  10402. */
  10403. static NeutralColor: Color4;
  10404. /**
  10405. * Stencil value used for glowing meshes.
  10406. */
  10407. static GlowingMeshStencilReference: number;
  10408. /**
  10409. * Stencil value used for the other meshes in the scene.
  10410. */
  10411. static NormalMeshStencilReference: number;
  10412. /**
  10413. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10414. */
  10415. innerGlow: boolean;
  10416. /**
  10417. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10418. */
  10419. outerGlow: boolean;
  10420. /**
  10421. * Gets the horizontal size of the blur.
  10422. */
  10423. /**
  10424. * Specifies the horizontal size of the blur.
  10425. */
  10426. blurHorizontalSize: number;
  10427. /**
  10428. * Gets the vertical size of the blur.
  10429. */
  10430. /**
  10431. * Specifies the vertical size of the blur.
  10432. */
  10433. blurVerticalSize: number;
  10434. /**
  10435. * An event triggered when the highlight layer is being blurred.
  10436. */
  10437. onBeforeBlurObservable: Observable<HighlightLayer>;
  10438. /**
  10439. * An event triggered when the highlight layer has been blurred.
  10440. */
  10441. onAfterBlurObservable: Observable<HighlightLayer>;
  10442. private _instanceGlowingMeshStencilReference;
  10443. private _options;
  10444. private _downSamplePostprocess;
  10445. private _horizontalBlurPostprocess;
  10446. private _verticalBlurPostprocess;
  10447. private _blurTexture;
  10448. private _meshes;
  10449. private _excludedMeshes;
  10450. /**
  10451. * Instantiates a new highlight Layer and references it to the scene..
  10452. * @param name The name of the layer
  10453. * @param scene The scene to use the layer in
  10454. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10455. */
  10456. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10457. /**
  10458. * Get the effect name of the layer.
  10459. * @return The effect name
  10460. */
  10461. getEffectName(): string;
  10462. /**
  10463. * Create the merge effect. This is the shader use to blit the information back
  10464. * to the main canvas at the end of the scene rendering.
  10465. */
  10466. protected _createMergeEffect(): Effect;
  10467. /**
  10468. * Creates the render target textures and post processes used in the highlight layer.
  10469. */
  10470. protected _createTextureAndPostProcesses(): void;
  10471. /**
  10472. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10473. */
  10474. needStencil(): boolean;
  10475. /**
  10476. * Checks for the readiness of the element composing the layer.
  10477. * @param subMesh the mesh to check for
  10478. * @param useInstances specify wether or not to use instances to render the mesh
  10479. * @param emissiveTexture the associated emissive texture used to generate the glow
  10480. * @return true if ready otherwise, false
  10481. */
  10482. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10483. /**
  10484. * Implementation specific of rendering the generating effect on the main canvas.
  10485. * @param effect The effect used to render through
  10486. */
  10487. protected _internalRender(effect: Effect): void;
  10488. /**
  10489. * Returns true if the layer contains information to display, otherwise false.
  10490. */
  10491. shouldRender(): boolean;
  10492. /**
  10493. * Returns true if the mesh should render, otherwise false.
  10494. * @param mesh The mesh to render
  10495. * @returns true if it should render otherwise false
  10496. */
  10497. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10498. /**
  10499. * Sets the required values for both the emissive texture and and the main color.
  10500. */
  10501. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10502. /**
  10503. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10504. * @param mesh The mesh to exclude from the highlight layer
  10505. */
  10506. addExcludedMesh(mesh: Mesh): void;
  10507. /**
  10508. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10509. * @param mesh The mesh to highlight
  10510. */
  10511. removeExcludedMesh(mesh: Mesh): void;
  10512. /**
  10513. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10514. * @param mesh mesh to test
  10515. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10516. */
  10517. hasMesh(mesh: AbstractMesh): boolean;
  10518. /**
  10519. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10520. * @param mesh The mesh to highlight
  10521. * @param color The color of the highlight
  10522. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10523. */
  10524. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10525. /**
  10526. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10527. * @param mesh The mesh to highlight
  10528. */
  10529. removeMesh(mesh: Mesh): void;
  10530. /**
  10531. * Force the stencil to the normal expected value for none glowing parts
  10532. */
  10533. private _defaultStencilReference(mesh);
  10534. /**
  10535. * Free any resources and references associated to a mesh.
  10536. * Internal use
  10537. * @param mesh The mesh to free.
  10538. */
  10539. _disposeMesh(mesh: Mesh): void;
  10540. /**
  10541. * Dispose the highlight layer and free resources.
  10542. */
  10543. dispose(): void;
  10544. /**
  10545. * Gets the class name of the effect layer
  10546. * @returns the string with the class name of the effect layer
  10547. */
  10548. getClassName(): string;
  10549. /**
  10550. * Serializes this Highlight layer
  10551. * @returns a serialized Highlight layer object
  10552. */
  10553. serialize(): any;
  10554. /**
  10555. * Creates a Highlight layer from parsed Highlight layer data
  10556. * @param parsedHightlightLayer defines the Highlight layer data
  10557. * @param scene defines the current scene
  10558. * @param rootUrl defines the root URL containing the Highlight layer information
  10559. * @returns a parsed Highlight layer
  10560. */
  10561. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10562. }
  10563. }
  10564. declare module BABYLON {
  10565. class Layer {
  10566. name: string;
  10567. texture: Nullable<Texture>;
  10568. isBackground: boolean;
  10569. color: Color4;
  10570. scale: Vector2;
  10571. offset: Vector2;
  10572. alphaBlendingMode: number;
  10573. alphaTest: boolean;
  10574. layerMask: number;
  10575. private _scene;
  10576. private _vertexBuffers;
  10577. private _indexBuffer;
  10578. private _effect;
  10579. private _alphaTestEffect;
  10580. /**
  10581. * An event triggered when the layer is disposed.
  10582. */
  10583. onDisposeObservable: Observable<Layer>;
  10584. private _onDisposeObserver;
  10585. onDispose: () => void;
  10586. /**
  10587. * An event triggered before rendering the scene
  10588. */
  10589. onBeforeRenderObservable: Observable<Layer>;
  10590. private _onBeforeRenderObserver;
  10591. onBeforeRender: () => void;
  10592. /**
  10593. * An event triggered after rendering the scene
  10594. */
  10595. onAfterRenderObservable: Observable<Layer>;
  10596. private _onAfterRenderObserver;
  10597. onAfterRender: () => void;
  10598. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10599. private _createIndexBuffer();
  10600. _rebuild(): void;
  10601. render(): void;
  10602. dispose(): void;
  10603. }
  10604. }
  10605. declare module BABYLON {
  10606. /**
  10607. * Represents the different options available during the creation of
  10608. * a Environment helper.
  10609. *
  10610. * This can control the default ground, skybox and image processing setup of your scene.
  10611. */
  10612. interface IEnvironmentHelperOptions {
  10613. /**
  10614. * Specifies wether or not to create a ground.
  10615. * True by default.
  10616. */
  10617. createGround: boolean;
  10618. /**
  10619. * Specifies the ground size.
  10620. * 15 by default.
  10621. */
  10622. groundSize: number;
  10623. /**
  10624. * The texture used on the ground for the main color.
  10625. * Comes from the BabylonJS CDN by default.
  10626. *
  10627. * Remarks: Can be either a texture or a url.
  10628. */
  10629. groundTexture: string | BaseTexture;
  10630. /**
  10631. * The color mixed in the ground texture by default.
  10632. * BabylonJS clearColor by default.
  10633. */
  10634. groundColor: Color3;
  10635. /**
  10636. * Specifies the ground opacity.
  10637. * 1 by default.
  10638. */
  10639. groundOpacity: number;
  10640. /**
  10641. * Enables the ground to receive shadows.
  10642. * True by default.
  10643. */
  10644. enableGroundShadow: boolean;
  10645. /**
  10646. * Helps preventing the shadow to be fully black on the ground.
  10647. * 0.5 by default.
  10648. */
  10649. groundShadowLevel: number;
  10650. /**
  10651. * Creates a mirror texture attach to the ground.
  10652. * false by default.
  10653. */
  10654. enableGroundMirror: boolean;
  10655. /**
  10656. * Specifies the ground mirror size ratio.
  10657. * 0.3 by default as the default kernel is 64.
  10658. */
  10659. groundMirrorSizeRatio: number;
  10660. /**
  10661. * Specifies the ground mirror blur kernel size.
  10662. * 64 by default.
  10663. */
  10664. groundMirrorBlurKernel: number;
  10665. /**
  10666. * Specifies the ground mirror visibility amount.
  10667. * 1 by default
  10668. */
  10669. groundMirrorAmount: number;
  10670. /**
  10671. * Specifies the ground mirror reflectance weight.
  10672. * This uses the standard weight of the background material to setup the fresnel effect
  10673. * of the mirror.
  10674. * 1 by default.
  10675. */
  10676. groundMirrorFresnelWeight: number;
  10677. /**
  10678. * Specifies the ground mirror Falloff distance.
  10679. * This can helps reducing the size of the reflection.
  10680. * 0 by Default.
  10681. */
  10682. groundMirrorFallOffDistance: number;
  10683. /**
  10684. * Specifies the ground mirror texture type.
  10685. * Unsigned Int by Default.
  10686. */
  10687. groundMirrorTextureType: number;
  10688. /**
  10689. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  10690. * the shown objects.
  10691. */
  10692. groundYBias: number;
  10693. /**
  10694. * Specifies wether or not to create a skybox.
  10695. * True by default.
  10696. */
  10697. createSkybox: boolean;
  10698. /**
  10699. * Specifies the skybox size.
  10700. * 20 by default.
  10701. */
  10702. skyboxSize: number;
  10703. /**
  10704. * The texture used on the skybox for the main color.
  10705. * Comes from the BabylonJS CDN by default.
  10706. *
  10707. * Remarks: Can be either a texture or a url.
  10708. */
  10709. skyboxTexture: string | BaseTexture;
  10710. /**
  10711. * The color mixed in the skybox texture by default.
  10712. * BabylonJS clearColor by default.
  10713. */
  10714. skyboxColor: Color3;
  10715. /**
  10716. * The background rotation around the Y axis of the scene.
  10717. * This helps aligning the key lights of your scene with the background.
  10718. * 0 by default.
  10719. */
  10720. backgroundYRotation: number;
  10721. /**
  10722. * Compute automatically the size of the elements to best fit with the scene.
  10723. */
  10724. sizeAuto: boolean;
  10725. /**
  10726. * Default position of the rootMesh if autoSize is not true.
  10727. */
  10728. rootPosition: Vector3;
  10729. /**
  10730. * Sets up the image processing in the scene.
  10731. * true by default.
  10732. */
  10733. setupImageProcessing: boolean;
  10734. /**
  10735. * The texture used as your environment texture in the scene.
  10736. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10737. *
  10738. * Remarks: Can be either a texture or a url.
  10739. */
  10740. environmentTexture: string | BaseTexture;
  10741. /**
  10742. * The value of the exposure to apply to the scene.
  10743. * 0.6 by default if setupImageProcessing is true.
  10744. */
  10745. cameraExposure: number;
  10746. /**
  10747. * The value of the contrast to apply to the scene.
  10748. * 1.6 by default if setupImageProcessing is true.
  10749. */
  10750. cameraContrast: number;
  10751. /**
  10752. * Specifies wether or not tonemapping should be enabled in the scene.
  10753. * true by default if setupImageProcessing is true.
  10754. */
  10755. toneMappingEnabled: boolean;
  10756. }
  10757. /**
  10758. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10759. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10760. * It also helps with the default setup of your imageProcessing configuration.
  10761. */
  10762. class EnvironmentHelper {
  10763. /**
  10764. * Default ground texture URL.
  10765. */
  10766. private static _groundTextureCDNUrl;
  10767. /**
  10768. * Default skybox texture URL.
  10769. */
  10770. private static _skyboxTextureCDNUrl;
  10771. /**
  10772. * Default environment texture URL.
  10773. */
  10774. private static _environmentTextureCDNUrl;
  10775. /**
  10776. * Creates the default options for the helper.
  10777. */
  10778. private static _getDefaultOptions();
  10779. private _rootMesh;
  10780. /**
  10781. * Gets the root mesh created by the helper.
  10782. */
  10783. readonly rootMesh: Mesh;
  10784. private _skybox;
  10785. /**
  10786. * Gets the skybox created by the helper.
  10787. */
  10788. readonly skybox: Nullable<Mesh>;
  10789. private _skyboxTexture;
  10790. /**
  10791. * Gets the skybox texture created by the helper.
  10792. */
  10793. readonly skyboxTexture: Nullable<BaseTexture>;
  10794. private _skyboxMaterial;
  10795. /**
  10796. * Gets the skybox material created by the helper.
  10797. */
  10798. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10799. private _ground;
  10800. /**
  10801. * Gets the ground mesh created by the helper.
  10802. */
  10803. readonly ground: Nullable<Mesh>;
  10804. private _groundTexture;
  10805. /**
  10806. * Gets the ground texture created by the helper.
  10807. */
  10808. readonly groundTexture: Nullable<BaseTexture>;
  10809. private _groundMirror;
  10810. /**
  10811. * Gets the ground mirror created by the helper.
  10812. */
  10813. readonly groundMirror: Nullable<MirrorTexture>;
  10814. /**
  10815. * Gets the ground mirror render list to helps pushing the meshes
  10816. * you wish in the ground reflection.
  10817. */
  10818. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10819. private _groundMaterial;
  10820. /**
  10821. * Gets the ground material created by the helper.
  10822. */
  10823. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10824. /**
  10825. * Stores the creation options.
  10826. */
  10827. private readonly _scene;
  10828. private _options;
  10829. /**
  10830. * This observable will be notified with any error during the creation of the environment,
  10831. * mainly texture creation errors.
  10832. */
  10833. onErrorObservable: Observable<{
  10834. message?: string;
  10835. exception?: any;
  10836. }>;
  10837. /**
  10838. * constructor
  10839. * @param options
  10840. * @param scene The scene to add the material to
  10841. */
  10842. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10843. /**
  10844. * Updates the background according to the new options
  10845. * @param options
  10846. */
  10847. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10848. /**
  10849. * Sets the primary color of all the available elements.
  10850. * @param color the main color to affect to the ground and the background
  10851. */
  10852. setMainColor(color: Color3): void;
  10853. /**
  10854. * Setup the image processing according to the specified options.
  10855. */
  10856. private _setupImageProcessing();
  10857. /**
  10858. * Setup the environment texture according to the specified options.
  10859. */
  10860. private _setupEnvironmentTexture();
  10861. /**
  10862. * Setup the background according to the specified options.
  10863. */
  10864. private _setupBackground();
  10865. /**
  10866. * Get the scene sizes according to the setup.
  10867. */
  10868. private _getSceneSize();
  10869. /**
  10870. * Setup the ground according to the specified options.
  10871. */
  10872. private _setupGround(sceneSize);
  10873. /**
  10874. * Setup the ground material according to the specified options.
  10875. */
  10876. private _setupGroundMaterial();
  10877. /**
  10878. * Setup the ground diffuse texture according to the specified options.
  10879. */
  10880. private _setupGroundDiffuseTexture();
  10881. /**
  10882. * Setup the ground mirror texture according to the specified options.
  10883. */
  10884. private _setupGroundMirrorTexture(sceneSize);
  10885. /**
  10886. * Setup the ground to receive the mirror texture.
  10887. */
  10888. private _setupMirrorInGroundMaterial();
  10889. /**
  10890. * Setup the skybox according to the specified options.
  10891. */
  10892. private _setupSkybox(sceneSize);
  10893. /**
  10894. * Setup the skybox material according to the specified options.
  10895. */
  10896. private _setupSkyboxMaterial();
  10897. /**
  10898. * Setup the skybox reflection texture according to the specified options.
  10899. */
  10900. private _setupSkyboxReflectionTexture();
  10901. private _errorHandler;
  10902. /**
  10903. * Dispose all the elements created by the Helper.
  10904. */
  10905. dispose(): void;
  10906. }
  10907. }
  10908. declare module BABYLON {
  10909. /**
  10910. * Represents all the data needed to create a ParticleSystem.
  10911. */
  10912. interface IParticleSystemData {
  10913. /**
  10914. * ParticleSystem type
  10915. */
  10916. type: string;
  10917. /**
  10918. * Shape of the emitter
  10919. */
  10920. emitterType: string;
  10921. /**
  10922. * Maximum number of particles in the system
  10923. */
  10924. capacity: number;
  10925. /**
  10926. * Link for the texture file
  10927. */
  10928. textureFile: string;
  10929. /**
  10930. * minEmitBox Vector3
  10931. */
  10932. minEmitBox?: {
  10933. x: number;
  10934. y: number;
  10935. z: number;
  10936. };
  10937. /**
  10938. * maxEmitBox Vector3
  10939. */
  10940. maxEmitBox?: {
  10941. x: number;
  10942. y: number;
  10943. z: number;
  10944. };
  10945. /**
  10946. * color1 Color4
  10947. */
  10948. color1: {
  10949. r: number;
  10950. g: number;
  10951. b: number;
  10952. a: number;
  10953. };
  10954. /**
  10955. * color2 Color4
  10956. */
  10957. color2: {
  10958. r: number;
  10959. g: number;
  10960. b: number;
  10961. a: number;
  10962. };
  10963. /**
  10964. * colorDead Color4
  10965. */
  10966. colorDead: {
  10967. r: number;
  10968. g: number;
  10969. b: number;
  10970. a: number;
  10971. };
  10972. /**
  10973. * Minimum size of each particle
  10974. */
  10975. minSize: number;
  10976. /**
  10977. * Maximum size of each particle
  10978. */
  10979. maxSize: number;
  10980. /**
  10981. * Minimum scale of each particle on X axis
  10982. */
  10983. minScaleX: number;
  10984. /**
  10985. * Maximum scale of each particle on X axis
  10986. */
  10987. maxScaleX: number;
  10988. /**
  10989. * Minimum scale of each particle on Y axis
  10990. */
  10991. minScaleY: number;
  10992. /**
  10993. * Maximum scale of each particle on Y axis
  10994. */
  10995. maxScaleY: number;
  10996. /**
  10997. * Minimum lifetime for each particle
  10998. */
  10999. minLifeTime: number;
  11000. /**
  11001. * Maximum lifetime for each particle
  11002. */
  11003. maxLifeTime: number;
  11004. /**
  11005. * Emit rate
  11006. */
  11007. emitRate: number;
  11008. /**
  11009. * Blend Mode
  11010. */
  11011. blendMode: number;
  11012. /**
  11013. * gravity Vector3
  11014. */
  11015. gravity: {
  11016. x: number;
  11017. y: number;
  11018. z: number;
  11019. };
  11020. /**
  11021. * direction1 Vector3
  11022. */
  11023. direction1?: {
  11024. x: number;
  11025. y: number;
  11026. z: number;
  11027. };
  11028. /**
  11029. * direction2 Vector3
  11030. */
  11031. direction2?: {
  11032. x: number;
  11033. y: number;
  11034. z: number;
  11035. };
  11036. /**
  11037. * Minimum Angular Speed
  11038. */
  11039. minAngularSpeed: number;
  11040. /**
  11041. * Maximum Angular Speed
  11042. */
  11043. maxAngularSpeed: number;
  11044. /**
  11045. * Minimum Emit Power
  11046. */
  11047. minEmitPower: number;
  11048. /**
  11049. * Maximum Emit Power
  11050. */
  11051. maxEmitPower: number;
  11052. /**
  11053. * Update Speed
  11054. */
  11055. updateSpeed: number;
  11056. /**
  11057. * Radius
  11058. */
  11059. radius?: number;
  11060. /**
  11061. * Angle
  11062. */
  11063. angle?: number;
  11064. }
  11065. /**
  11066. * This class is made for on one-liner static method to help creating particle systems.
  11067. */
  11068. class ParticleHelper {
  11069. /**
  11070. * Base Assets URL.
  11071. */
  11072. private static _baseAssetsUrl;
  11073. /**
  11074. * This is the main static method (one-liner) of this helper to create different particle systems.
  11075. * @param type This string represents the type to the particle system to create
  11076. * @param emitter The object where the particle system will start to emit from.
  11077. * @param scene The scene where the particle system should live.
  11078. * @param gpu If the system will use gpu.
  11079. * @returns the ParticleSystem created.
  11080. */
  11081. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  11082. /**
  11083. * Static function used to create a new particle system from a IParticleSystemData
  11084. * @param data defines the source data
  11085. * @param scene defines the hosting scene
  11086. * @param emitter defines the particle emitter
  11087. * @returns a new ParticleSystem based on referenced data
  11088. */
  11089. static CreateSystem(data: IParticleSystemData, scene: Scene, emitter: AbstractMesh): ParticleSystem;
  11090. /**
  11091. * Static function used to update a particle system from a IParticleSystemData
  11092. * @param system defines the particle system to update
  11093. * @param data defines the source data
  11094. * @param scene defines the hosting scene
  11095. */
  11096. static UpdateSystem(system: ParticleSystem, data: IParticleSystemData, scene: Scene): void;
  11097. /**
  11098. * Static function used to export a particle system to a IParticleSystemData variable.
  11099. * Please note that texture file name is not exported and must be added manually
  11100. * @param system defines the particle system to export
  11101. */
  11102. static ExportSystem(system: ParticleSystem): IParticleSystemData;
  11103. }
  11104. }
  11105. declare module BABYLON {
  11106. /**
  11107. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  11108. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  11109. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  11110. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  11111. */
  11112. class PhotoDome extends Node {
  11113. /**
  11114. * The texture being displayed on the sphere
  11115. */
  11116. protected _photoTexture: Texture;
  11117. /**
  11118. * Gets the texture being displayed on the sphere
  11119. */
  11120. readonly photoTexture: Texture;
  11121. /**
  11122. * The skybox material
  11123. */
  11124. protected _material: BackgroundMaterial;
  11125. /**
  11126. * The surface used for the skybox
  11127. */
  11128. protected _mesh: Mesh;
  11129. /**
  11130. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  11131. * Also see the options.resolution property.
  11132. */
  11133. fovMultiplier: number;
  11134. /**
  11135. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  11136. * @param name Element's name, child elements will append suffixes for their own names.
  11137. * @param urlsOfPhoto define the url of the photo to display
  11138. * @param options An object containing optional or exposed sub element properties
  11139. */
  11140. constructor(name: string, urlOfPhoto: string, options: {
  11141. resolution?: number;
  11142. size?: number;
  11143. }, scene: Scene);
  11144. /**
  11145. * Releases resources associated with this node.
  11146. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11147. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11148. */
  11149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11150. }
  11151. }
  11152. declare module BABYLON {
  11153. /**
  11154. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  11155. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  11156. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  11157. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  11158. */
  11159. class VideoDome extends Node {
  11160. /**
  11161. * The video texture being displayed on the sphere
  11162. */
  11163. protected _videoTexture: VideoTexture;
  11164. /**
  11165. * Gets the video texture being displayed on the sphere
  11166. */
  11167. readonly videoTexture: VideoTexture;
  11168. /**
  11169. * The skybox material
  11170. */
  11171. protected _material: BackgroundMaterial;
  11172. /**
  11173. * The surface used for the skybox
  11174. */
  11175. protected _mesh: Mesh;
  11176. /**
  11177. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  11178. * Also see the options.resolution property.
  11179. */
  11180. fovMultiplier: number;
  11181. /**
  11182. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  11183. * @param name Element's name, child elements will append suffixes for their own names.
  11184. * @param urlsOrVideo defines the url(s) or the video element to use
  11185. * @param options An object containing optional or exposed sub element properties
  11186. */
  11187. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  11188. resolution?: number;
  11189. clickToPlay?: boolean;
  11190. autoPlay?: boolean;
  11191. loop?: boolean;
  11192. size?: number;
  11193. }, scene: Scene);
  11194. /**
  11195. * Releases resources associated with this node.
  11196. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11197. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11198. */
  11199. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11200. }
  11201. }
  11202. declare module BABYLON {
  11203. interface ILoadingScreen {
  11204. displayLoadingUI: () => void;
  11205. hideLoadingUI: () => void;
  11206. loadingUIBackgroundColor: string;
  11207. loadingUIText: string;
  11208. }
  11209. class DefaultLoadingScreen implements ILoadingScreen {
  11210. private _renderingCanvas;
  11211. private _loadingText;
  11212. private _loadingDivBackgroundColor;
  11213. private _loadingDiv;
  11214. private _loadingTextDiv;
  11215. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11216. displayLoadingUI(): void;
  11217. hideLoadingUI(): void;
  11218. loadingUIText: string;
  11219. loadingUIBackgroundColor: string;
  11220. private _resizeLoadingUI;
  11221. }
  11222. }
  11223. declare module BABYLON {
  11224. class SceneLoaderProgressEvent {
  11225. readonly lengthComputable: boolean;
  11226. readonly loaded: number;
  11227. readonly total: number;
  11228. constructor(lengthComputable: boolean, loaded: number, total: number);
  11229. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11230. }
  11231. interface ISceneLoaderPluginExtensions {
  11232. [extension: string]: {
  11233. isBinary: boolean;
  11234. };
  11235. }
  11236. interface ISceneLoaderPluginFactory {
  11237. name: string;
  11238. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11239. canDirectLoad?: (data: string) => boolean;
  11240. }
  11241. interface ISceneLoaderPlugin {
  11242. /**
  11243. * The friendly name of this plugin.
  11244. */
  11245. name: string;
  11246. /**
  11247. * The file extensions supported by this plugin.
  11248. */
  11249. extensions: string | ISceneLoaderPluginExtensions;
  11250. /**
  11251. * Import meshes into a scene.
  11252. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11253. * @param scene The scene to import into
  11254. * @param data The data to import
  11255. * @param rootUrl The root url for scene and resources
  11256. * @param meshes The meshes array to import into
  11257. * @param particleSystems The particle systems array to import into
  11258. * @param skeletons The skeletons array to import into
  11259. * @param onError The callback when import fails
  11260. * @returns True if successful or false otherwise
  11261. */
  11262. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11263. /**
  11264. * Load into a scene.
  11265. * @param scene The scene to load into
  11266. * @param data The data to import
  11267. * @param rootUrl The root url for scene and resources
  11268. * @param onError The callback when import fails
  11269. * @returns true if successful or false otherwise
  11270. */
  11271. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11272. /**
  11273. * The callback that returns true if the data can be directly loaded.
  11274. */
  11275. canDirectLoad?: (data: string) => boolean;
  11276. /**
  11277. * The callback that allows custom handling of the root url based on the response url.
  11278. */
  11279. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11280. /**
  11281. * Load into an asset container.
  11282. * @param scene The scene to load into
  11283. * @param data The data to import
  11284. * @param rootUrl The root url for scene and resources
  11285. * @param onError The callback when import fails
  11286. * @returns The loaded asset container
  11287. */
  11288. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11289. }
  11290. interface ISceneLoaderPluginAsync {
  11291. /**
  11292. * The friendly name of this plugin.
  11293. */
  11294. name: string;
  11295. /**
  11296. * The file extensions supported by this plugin.
  11297. */
  11298. extensions: string | ISceneLoaderPluginExtensions;
  11299. /**
  11300. * Import meshes into a scene.
  11301. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11302. * @param scene The scene to import into
  11303. * @param data The data to import
  11304. * @param rootUrl The root url for scene and resources
  11305. * @param onProgress The callback when the load progresses
  11306. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11307. */
  11308. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11309. meshes: AbstractMesh[];
  11310. particleSystems: ParticleSystem[];
  11311. skeletons: Skeleton[];
  11312. animationGroups: AnimationGroup[];
  11313. }>;
  11314. /**
  11315. * Load into a scene.
  11316. * @param scene The scene to load into
  11317. * @param data The data to import
  11318. * @param rootUrl The root url for scene and resources
  11319. * @param onProgress The callback when the load progresses
  11320. * @returns Nothing
  11321. */
  11322. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11323. /**
  11324. * The callback that returns true if the data can be directly loaded.
  11325. */
  11326. canDirectLoad?: (data: string) => boolean;
  11327. /**
  11328. * The callback that allows custom handling of the root url based on the response url.
  11329. */
  11330. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11331. /**
  11332. * Load into an asset container.
  11333. * @param scene The scene to load into
  11334. * @param data The data to import
  11335. * @param rootUrl The root url for scene and resources
  11336. * @param onProgress The callback when the load progresses
  11337. * @returns The loaded asset container
  11338. */
  11339. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11340. }
  11341. class SceneLoader {
  11342. private static _ForceFullSceneLoadingForIncremental;
  11343. private static _ShowLoadingScreen;
  11344. private static _CleanBoneMatrixWeights;
  11345. static readonly NO_LOGGING: number;
  11346. static readonly MINIMAL_LOGGING: number;
  11347. static readonly SUMMARY_LOGGING: number;
  11348. static readonly DETAILED_LOGGING: number;
  11349. private static _loggingLevel;
  11350. static ForceFullSceneLoadingForIncremental: boolean;
  11351. static ShowLoadingScreen: boolean;
  11352. static loggingLevel: number;
  11353. static CleanBoneMatrixWeights: boolean;
  11354. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11355. private static _registeredPlugins;
  11356. private static _getDefaultPlugin();
  11357. private static _getPluginForExtension(extension);
  11358. private static _getPluginForDirectLoad(data);
  11359. private static _getPluginForFilename(sceneFilename);
  11360. private static _getDirectLoad(sceneFilename);
  11361. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  11362. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  11363. static IsPluginForExtensionAvailable(extension: string): boolean;
  11364. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  11365. /**
  11366. * Import meshes into a scene
  11367. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11368. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11369. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11370. * @param scene the instance of BABYLON.Scene to append to
  11371. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  11372. * @param onProgress a callback with a progress event for each file being loaded
  11373. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11374. * @param pluginExtension the extension used to determine the plugin
  11375. * @returns The loaded plugin
  11376. */
  11377. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11378. /**
  11379. * Import meshes into a scene
  11380. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11381. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11382. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11383. * @param scene the instance of BABYLON.Scene to append to
  11384. * @param onProgress a callback with a progress event for each file being loaded
  11385. * @param pluginExtension the extension used to determine the plugin
  11386. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  11387. */
  11388. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  11389. meshes: AbstractMesh[];
  11390. particleSystems: ParticleSystem[];
  11391. skeletons: Skeleton[];
  11392. animationGroups: AnimationGroup[];
  11393. }>;
  11394. /**
  11395. * Load a scene
  11396. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11397. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11398. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11399. * @param onSuccess a callback with the scene when import succeeds
  11400. * @param onProgress a callback with a progress event for each file being loaded
  11401. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11402. * @param pluginExtension the extension used to determine the plugin
  11403. * @returns The loaded plugin
  11404. */
  11405. 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>;
  11406. /**
  11407. * Load a scene
  11408. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11409. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11410. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11411. * @param onProgress a callback with a progress event for each file being loaded
  11412. * @param pluginExtension the extension used to determine the plugin
  11413. * @returns The loaded scene
  11414. */
  11415. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11416. /**
  11417. * Append a scene
  11418. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11419. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11420. * @param scene is the instance of BABYLON.Scene to append to
  11421. * @param onSuccess a callback with the scene when import succeeds
  11422. * @param onProgress a callback with a progress event for each file being loaded
  11423. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11424. * @param pluginExtension the extension used to determine the plugin
  11425. * @returns The loaded plugin
  11426. */
  11427. static Append(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11428. /**
  11429. * Append a scene
  11430. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11431. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11432. * @param scene is the instance of BABYLON.Scene to append to
  11433. * @param onProgress a callback with a progress event for each file being loaded
  11434. * @param pluginExtension the extension used to determine the plugin
  11435. * @returns The given scene
  11436. */
  11437. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11438. /**
  11439. * Load a scene into an asset container
  11440. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11441. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11442. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  11443. * @param onSuccess a callback with the scene when import succeeds
  11444. * @param onProgress a callback with a progress event for each file being loaded
  11445. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11446. * @param pluginExtension the extension used to determine the plugin
  11447. * @returns The loaded plugin
  11448. */
  11449. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11450. /**
  11451. * Load a scene into an asset container
  11452. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11453. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11454. * @param scene is the instance of BABYLON.Scene to append to
  11455. * @param onProgress a callback with a progress event for each file being loaded
  11456. * @param pluginExtension the extension used to determine the plugin
  11457. * @returns The loaded asset container
  11458. */
  11459. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11460. }
  11461. }
  11462. declare module BABYLON {
  11463. /**
  11464. * A directional light is defined by a direction (what a surprise!).
  11465. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11466. * 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.
  11467. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11468. */
  11469. class DirectionalLight extends ShadowLight {
  11470. private _shadowFrustumSize;
  11471. /**
  11472. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11473. */
  11474. /**
  11475. * Specifies a fix frustum size for the shadow generation.
  11476. */
  11477. shadowFrustumSize: number;
  11478. private _shadowOrthoScale;
  11479. /**
  11480. * Gets the shadow projection scale against the optimal computed one.
  11481. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11482. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11483. */
  11484. /**
  11485. * Sets the shadow projection scale against the optimal computed one.
  11486. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11487. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11488. */
  11489. shadowOrthoScale: number;
  11490. /**
  11491. * Automatically compute the projection matrix to best fit (including all the casters)
  11492. * on each frame.
  11493. */
  11494. autoUpdateExtends: boolean;
  11495. private _orthoLeft;
  11496. private _orthoRight;
  11497. private _orthoTop;
  11498. private _orthoBottom;
  11499. /**
  11500. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11501. * The directional light is emitted from everywhere in the given direction.
  11502. * It can cast shawdows.
  11503. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11504. * @param name The friendly name of the light
  11505. * @param direction The direction of the light
  11506. * @param scene The scene the light belongs to
  11507. */
  11508. constructor(name: string, direction: Vector3, scene: Scene);
  11509. /**
  11510. * Returns the string "DirectionalLight".
  11511. * @return The class name
  11512. */
  11513. getClassName(): string;
  11514. /**
  11515. * Returns the integer 1.
  11516. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11517. */
  11518. getTypeID(): number;
  11519. /**
  11520. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11521. * Returns the DirectionalLight Shadow projection matrix.
  11522. */
  11523. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11524. /**
  11525. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11526. * Returns the DirectionalLight Shadow projection matrix.
  11527. */
  11528. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11529. /**
  11530. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11531. * Returns the DirectionalLight Shadow projection matrix.
  11532. */
  11533. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11534. protected _buildUniformLayout(): void;
  11535. /**
  11536. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11537. * @param effect The effect to update
  11538. * @param lightIndex The index of the light in the effect to update
  11539. * @returns The directional light
  11540. */
  11541. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11542. /**
  11543. * Gets the minZ used for shadow according to both the scene and the light.
  11544. *
  11545. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11546. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11547. * @param activeCamera The camera we are returning the min for
  11548. * @returns the depth min z
  11549. */
  11550. getDepthMinZ(activeCamera: Camera): number;
  11551. /**
  11552. * Gets the maxZ used for shadow according to both the scene and the light.
  11553. *
  11554. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11555. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11556. * @param activeCamera The camera we are returning the max for
  11557. * @returns the depth max z
  11558. */
  11559. getDepthMaxZ(activeCamera: Camera): number;
  11560. }
  11561. }
  11562. declare module BABYLON {
  11563. /**
  11564. * The HemisphericLight simulates the ambient environment light,
  11565. * so the passed direction is the light reflection direction, not the incoming direction.
  11566. */
  11567. class HemisphericLight extends Light {
  11568. /**
  11569. * The groundColor is the light in the opposite direction to the one specified during creation.
  11570. * 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.
  11571. */
  11572. groundColor: Color3;
  11573. /**
  11574. * The light reflection direction, not the incoming direction.
  11575. */
  11576. direction: Vector3;
  11577. private _worldMatrix;
  11578. /**
  11579. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11580. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11581. * The HemisphericLight can't cast shadows.
  11582. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11583. * @param name The friendly name of the light
  11584. * @param direction The direction of the light reflection
  11585. * @param scene The scene the light belongs to
  11586. */
  11587. constructor(name: string, direction: Vector3, scene: Scene);
  11588. protected _buildUniformLayout(): void;
  11589. /**
  11590. * Returns the string "HemisphericLight".
  11591. * @return The class name
  11592. */
  11593. getClassName(): string;
  11594. /**
  11595. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11596. * Returns the updated direction.
  11597. * @param target The target the direction should point to
  11598. * @return The computed direction
  11599. */
  11600. setDirectionToTarget(target: Vector3): Vector3;
  11601. /**
  11602. * Returns the shadow generator associated to the light.
  11603. * @returns Always null for hemispheric lights because it does not support shadows.
  11604. */
  11605. getShadowGenerator(): Nullable<ShadowGenerator>;
  11606. /**
  11607. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11608. * @param effect The effect to update
  11609. * @param lightIndex The index of the light in the effect to update
  11610. * @returns The hemispheric light
  11611. */
  11612. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11613. /**
  11614. * @hidden internal use only.
  11615. */
  11616. _getWorldMatrix(): Matrix;
  11617. /**
  11618. * Returns the integer 3.
  11619. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11620. */
  11621. getTypeID(): number;
  11622. }
  11623. }
  11624. declare module BABYLON {
  11625. /**
  11626. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11627. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11628. * 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.
  11629. */
  11630. abstract class Light extends Node {
  11631. private static _LIGHTMAP_DEFAULT;
  11632. private static _LIGHTMAP_SPECULAR;
  11633. private static _LIGHTMAP_SHADOWSONLY;
  11634. /**
  11635. * If every light affecting the material is in this lightmapMode,
  11636. * material.lightmapTexture adds or multiplies
  11637. * (depends on material.useLightmapAsShadowmap)
  11638. * after every other light calculations.
  11639. */
  11640. static readonly LIGHTMAP_DEFAULT: number;
  11641. /**
  11642. * material.lightmapTexture as only diffuse lighting from this light
  11643. * adds only specular lighting from this light
  11644. * adds dynamic shadows
  11645. */
  11646. static readonly LIGHTMAP_SPECULAR: number;
  11647. /**
  11648. * material.lightmapTexture as only lighting
  11649. * no light calculation from this light
  11650. * only adds dynamic shadows from this light
  11651. */
  11652. static readonly LIGHTMAP_SHADOWSONLY: number;
  11653. private static _INTENSITYMODE_AUTOMATIC;
  11654. private static _INTENSITYMODE_LUMINOUSPOWER;
  11655. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11656. private static _INTENSITYMODE_ILLUMINANCE;
  11657. private static _INTENSITYMODE_LUMINANCE;
  11658. /**
  11659. * Each light type uses the default quantity according to its type:
  11660. * point/spot lights use luminous intensity
  11661. * directional lights use illuminance
  11662. */
  11663. static readonly INTENSITYMODE_AUTOMATIC: number;
  11664. /**
  11665. * lumen (lm)
  11666. */
  11667. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11668. /**
  11669. * candela (lm/sr)
  11670. */
  11671. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11672. /**
  11673. * lux (lm/m^2)
  11674. */
  11675. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11676. /**
  11677. * nit (cd/m^2)
  11678. */
  11679. static readonly INTENSITYMODE_LUMINANCE: number;
  11680. private static _LIGHTTYPEID_POINTLIGHT;
  11681. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11682. private static _LIGHTTYPEID_SPOTLIGHT;
  11683. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11684. /**
  11685. * Light type const id of the point light.
  11686. */
  11687. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11688. /**
  11689. * Light type const id of the directional light.
  11690. */
  11691. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11692. /**
  11693. * Light type const id of the spot light.
  11694. */
  11695. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11696. /**
  11697. * Light type const id of the hemispheric light.
  11698. */
  11699. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11700. /**
  11701. * Diffuse gives the basic color to an object.
  11702. */
  11703. diffuse: Color3;
  11704. /**
  11705. * Specular produces a highlight color on an object.
  11706. * Note: This is note affecting PBR materials.
  11707. */
  11708. specular: Color3;
  11709. /**
  11710. * Strength of the light.
  11711. * Note: By default it is define in the framework own unit.
  11712. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11713. */
  11714. intensity: number;
  11715. /**
  11716. * Defines how far from the source the light is impacting in scene units.
  11717. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11718. */
  11719. range: number;
  11720. /**
  11721. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11722. * of light.
  11723. */
  11724. private _photometricScale;
  11725. private _intensityMode;
  11726. /**
  11727. * Gets the photometric scale used to interpret the intensity.
  11728. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11729. */
  11730. /**
  11731. * Sets the photometric scale used to interpret the intensity.
  11732. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11733. */
  11734. intensityMode: number;
  11735. private _radius;
  11736. /**
  11737. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11738. */
  11739. /**
  11740. * sets the light radius used by PBR Materials to simulate soft area lights.
  11741. */
  11742. radius: number;
  11743. private _renderPriority;
  11744. /**
  11745. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11746. * exceeding the number allowed of the materials.
  11747. */
  11748. renderPriority: number;
  11749. private _shadowEnabled;
  11750. /**
  11751. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11752. * the current shadow generator.
  11753. */
  11754. /**
  11755. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11756. * the current shadow generator.
  11757. */
  11758. shadowEnabled: boolean;
  11759. private _includedOnlyMeshes;
  11760. /**
  11761. * Gets the only meshes impacted by this light.
  11762. */
  11763. /**
  11764. * Sets the only meshes impacted by this light.
  11765. */
  11766. includedOnlyMeshes: AbstractMesh[];
  11767. private _excludedMeshes;
  11768. /**
  11769. * Gets the meshes not impacted by this light.
  11770. */
  11771. /**
  11772. * Sets the meshes not impacted by this light.
  11773. */
  11774. excludedMeshes: AbstractMesh[];
  11775. private _excludeWithLayerMask;
  11776. /**
  11777. * Gets the layer id use to find what meshes are not impacted by the light.
  11778. * Inactive if 0
  11779. */
  11780. /**
  11781. * Sets the layer id use to find what meshes are not impacted by the light.
  11782. * Inactive if 0
  11783. */
  11784. excludeWithLayerMask: number;
  11785. private _includeOnlyWithLayerMask;
  11786. /**
  11787. * Gets the layer id use to find what meshes are impacted by the light.
  11788. * Inactive if 0
  11789. */
  11790. /**
  11791. * Sets the layer id use to find what meshes are impacted by the light.
  11792. * Inactive if 0
  11793. */
  11794. includeOnlyWithLayerMask: number;
  11795. private _lightmapMode;
  11796. /**
  11797. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11798. */
  11799. /**
  11800. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11801. */
  11802. lightmapMode: number;
  11803. private _parentedWorldMatrix;
  11804. /**
  11805. * Shadow generator associted to the light.
  11806. * Internal use only.
  11807. */
  11808. _shadowGenerator: Nullable<IShadowGenerator>;
  11809. /**
  11810. * @hidden Internal use only.
  11811. */
  11812. _excludedMeshesIds: string[];
  11813. /**
  11814. * @hidden Internal use only.
  11815. */
  11816. _includedOnlyMeshesIds: string[];
  11817. /**
  11818. * The current light unifom buffer.
  11819. * @hidden Internal use only.
  11820. */
  11821. _uniformBuffer: UniformBuffer;
  11822. /**
  11823. * Creates a Light object in the scene.
  11824. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11825. * @param name The firendly name of the light
  11826. * @param scene The scene the light belongs too
  11827. */
  11828. constructor(name: string, scene: Scene);
  11829. protected abstract _buildUniformLayout(): void;
  11830. /**
  11831. * Sets the passed Effect "effect" with the Light information.
  11832. * @param effect The effect to update
  11833. * @param lightIndex The index of the light in the effect to update
  11834. * @returns The light
  11835. */
  11836. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11837. /**
  11838. * @hidden internal use only.
  11839. */
  11840. abstract _getWorldMatrix(): Matrix;
  11841. /**
  11842. * Returns the string "Light".
  11843. * @returns the class name
  11844. */
  11845. getClassName(): string;
  11846. /**
  11847. * Converts the light information to a readable string for debug purpose.
  11848. * @param fullDetails Supports for multiple levels of logging within scene loading
  11849. * @returns the human readable light info
  11850. */
  11851. toString(fullDetails?: boolean): string;
  11852. /**
  11853. * Set the enabled state of this node.
  11854. * @param value - the new enabled state
  11855. */
  11856. setEnabled(value: boolean): void;
  11857. /**
  11858. * Returns the Light associated shadow generator if any.
  11859. * @return the associated shadow generator.
  11860. */
  11861. getShadowGenerator(): Nullable<IShadowGenerator>;
  11862. /**
  11863. * Returns a Vector3, the absolute light position in the World.
  11864. * @returns the world space position of the light
  11865. */
  11866. getAbsolutePosition(): Vector3;
  11867. /**
  11868. * Specifies if the light will affect the passed mesh.
  11869. * @param mesh The mesh to test against the light
  11870. * @return true the mesh is affected otherwise, false.
  11871. */
  11872. canAffectMesh(mesh: AbstractMesh): boolean;
  11873. /**
  11874. * Computes and Returns the light World matrix.
  11875. * @returns the world matrix
  11876. */
  11877. getWorldMatrix(): Matrix;
  11878. /**
  11879. * Sort function to order lights for rendering.
  11880. * @param a First Light object to compare to second.
  11881. * @param b Second Light object to compare first.
  11882. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11883. */
  11884. static CompareLightsPriority(a: Light, b: Light): number;
  11885. /**
  11886. * Releases resources associated with this node.
  11887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11889. */
  11890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11891. /**
  11892. * Returns the light type ID (integer).
  11893. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11894. */
  11895. getTypeID(): number;
  11896. /**
  11897. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11898. * @returns the scaled intensity in intensity mode unit
  11899. */
  11900. getScaledIntensity(): number;
  11901. /**
  11902. * Returns a new Light object, named "name", from the current one.
  11903. * @param name The name of the cloned light
  11904. * @returns the new created light
  11905. */
  11906. clone(name: string): Nullable<Light>;
  11907. /**
  11908. * Serializes the current light into a Serialization object.
  11909. * @returns the serialized object.
  11910. */
  11911. serialize(): any;
  11912. /**
  11913. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11914. * This new light is named "name" and added to the passed scene.
  11915. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11916. * @param name The friendly name of the light
  11917. * @param scene The scene the new light will belong to
  11918. * @returns the constructor function
  11919. */
  11920. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11921. /**
  11922. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11923. * @param parsedLight The JSON representation of the light
  11924. * @param scene The scene to create the parsed light in
  11925. * @returns the created light after parsing
  11926. */
  11927. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11928. private _hookArrayForExcluded(array);
  11929. private _hookArrayForIncludedOnly(array);
  11930. private _resyncMeshes();
  11931. /**
  11932. * Forces the meshes to update their light related information in their rendering used effects
  11933. * @hidden Internal Use Only
  11934. */
  11935. _markMeshesAsLightDirty(): void;
  11936. /**
  11937. * Recomputes the cached photometric scale if needed.
  11938. */
  11939. private _computePhotometricScale();
  11940. /**
  11941. * Returns the Photometric Scale according to the light type and intensity mode.
  11942. */
  11943. private _getPhotometricScale();
  11944. /**
  11945. * Reorder the light in the scene according to their defined priority.
  11946. * @hidden Internal Use Only
  11947. */
  11948. _reorderLightsInScene(): void;
  11949. }
  11950. }
  11951. declare module BABYLON {
  11952. /**
  11953. * A point light is a light defined by an unique point in world space.
  11954. * The light is emitted in every direction from this point.
  11955. * A good example of a point light is a standard light bulb.
  11956. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11957. */
  11958. class PointLight extends ShadowLight {
  11959. private _shadowAngle;
  11960. /**
  11961. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11962. * This specifies what angle the shadow will use to be created.
  11963. *
  11964. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11965. */
  11966. /**
  11967. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11968. * This specifies what angle the shadow will use to be created.
  11969. *
  11970. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11971. */
  11972. shadowAngle: number;
  11973. /**
  11974. * Gets the direction if it has been set.
  11975. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11976. */
  11977. /**
  11978. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11979. */
  11980. direction: Vector3;
  11981. /**
  11982. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11983. * A PointLight emits the light in every direction.
  11984. * It can cast shadows.
  11985. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11986. * ```javascript
  11987. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11988. * ```
  11989. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11990. * @param name The light friendly name
  11991. * @param position The position of the point light in the scene
  11992. * @param scene The scene the lights belongs to
  11993. */
  11994. constructor(name: string, position: Vector3, scene: Scene);
  11995. /**
  11996. * Returns the string "PointLight"
  11997. * @returns the class name
  11998. */
  11999. getClassName(): string;
  12000. /**
  12001. * Returns the integer 0.
  12002. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12003. */
  12004. getTypeID(): number;
  12005. /**
  12006. * Specifies wether or not the shadowmap should be a cube texture.
  12007. * @returns true if the shadowmap needs to be a cube texture.
  12008. */
  12009. needCube(): boolean;
  12010. /**
  12011. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12012. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12013. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12014. */
  12015. getShadowDirection(faceIndex?: number): Vector3;
  12016. /**
  12017. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12018. * - fov = PI / 2
  12019. * - aspect ratio : 1.0
  12020. * - z-near and far equal to the active camera minZ and maxZ.
  12021. * Returns the PointLight.
  12022. */
  12023. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12024. protected _buildUniformLayout(): void;
  12025. /**
  12026. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12027. * @param effect The effect to update
  12028. * @param lightIndex The index of the light in the effect to update
  12029. * @returns The point light
  12030. */
  12031. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12032. }
  12033. }
  12034. declare module BABYLON {
  12035. /**
  12036. * Interface describing all the common properties and methods a shadow light needs to implement.
  12037. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12038. * as well as binding the different shadow properties to the effects.
  12039. */
  12040. interface IShadowLight extends Light {
  12041. /**
  12042. * The light id in the scene (used in scene.findLighById for instance)
  12043. */
  12044. id: string;
  12045. /**
  12046. * The position the shdow will be casted from.
  12047. */
  12048. position: Vector3;
  12049. /**
  12050. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12051. */
  12052. direction: Vector3;
  12053. /**
  12054. * The transformed position. Position of the light in world space taking parenting in account.
  12055. */
  12056. transformedPosition: Vector3;
  12057. /**
  12058. * The transformed direction. Direction of the light in world space taking parenting in account.
  12059. */
  12060. transformedDirection: Vector3;
  12061. /**
  12062. * The friendly name of the light in the scene.
  12063. */
  12064. name: string;
  12065. /**
  12066. * Defines the shadow projection clipping minimum z value.
  12067. */
  12068. shadowMinZ: number;
  12069. /**
  12070. * Defines the shadow projection clipping maximum z value.
  12071. */
  12072. shadowMaxZ: number;
  12073. /**
  12074. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12075. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12076. */
  12077. computeTransformedInformation(): boolean;
  12078. /**
  12079. * Gets the scene the light belongs to.
  12080. * @returns The scene
  12081. */
  12082. getScene(): Scene;
  12083. /**
  12084. * Callback defining a custom Projection Matrix Builder.
  12085. * This can be used to override the default projection matrix computation.
  12086. */
  12087. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12088. /**
  12089. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12090. * @param matrix The materix to updated with the projection information
  12091. * @param viewMatrix The transform matrix of the light
  12092. * @param renderList The list of mesh to render in the map
  12093. * @returns The current light
  12094. */
  12095. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12096. /**
  12097. * Gets the current depth scale used in ESM.
  12098. * @returns The scale
  12099. */
  12100. getDepthScale(): number;
  12101. /**
  12102. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12103. * @returns true if a cube texture needs to be use
  12104. */
  12105. needCube(): boolean;
  12106. /**
  12107. * Detects if the projection matrix requires to be recomputed this frame.
  12108. * @returns true if it requires to be recomputed otherwise, false.
  12109. */
  12110. needProjectionMatrixCompute(): boolean;
  12111. /**
  12112. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12113. */
  12114. forceProjectionMatrixCompute(): void;
  12115. /**
  12116. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12117. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12118. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12119. */
  12120. getShadowDirection(faceIndex?: number): Vector3;
  12121. /**
  12122. * Gets the minZ used for shadow according to both the scene and the light.
  12123. * @param activeCamera The camera we are returning the min for
  12124. * @returns the depth min z
  12125. */
  12126. getDepthMinZ(activeCamera: Camera): number;
  12127. /**
  12128. * Gets the maxZ used for shadow according to both the scene and the light.
  12129. * @param activeCamera The camera we are returning the max for
  12130. * @returns the depth max z
  12131. */
  12132. getDepthMaxZ(activeCamera: Camera): number;
  12133. }
  12134. /**
  12135. * Base implementation IShadowLight
  12136. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12137. */
  12138. abstract class ShadowLight extends Light implements IShadowLight {
  12139. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12140. protected _position: Vector3;
  12141. protected _setPosition(value: Vector3): void;
  12142. /**
  12143. * Sets the position the shadow will be casted from. Also use as the light position for both
  12144. * point and spot lights.
  12145. */
  12146. /**
  12147. * Sets the position the shadow will be casted from. Also use as the light position for both
  12148. * point and spot lights.
  12149. */
  12150. position: Vector3;
  12151. protected _direction: Vector3;
  12152. protected _setDirection(value: Vector3): void;
  12153. /**
  12154. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12155. * Also use as the light direction on spot and directional lights.
  12156. */
  12157. /**
  12158. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12159. * Also use as the light direction on spot and directional lights.
  12160. */
  12161. direction: Vector3;
  12162. private _shadowMinZ;
  12163. /**
  12164. * Gets the shadow projection clipping minimum z value.
  12165. */
  12166. /**
  12167. * Sets the shadow projection clipping minimum z value.
  12168. */
  12169. shadowMinZ: number;
  12170. private _shadowMaxZ;
  12171. /**
  12172. * Sets the shadow projection clipping maximum z value.
  12173. */
  12174. /**
  12175. * Gets the shadow projection clipping maximum z value.
  12176. */
  12177. shadowMaxZ: number;
  12178. /**
  12179. * Callback defining a custom Projection Matrix Builder.
  12180. * This can be used to override the default projection matrix computation.
  12181. */
  12182. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12183. /**
  12184. * The transformed position. Position of the light in world space taking parenting in account.
  12185. */
  12186. transformedPosition: Vector3;
  12187. /**
  12188. * The transformed direction. Direction of the light in world space taking parenting in account.
  12189. */
  12190. transformedDirection: Vector3;
  12191. private _worldMatrix;
  12192. private _needProjectionMatrixCompute;
  12193. /**
  12194. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12195. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12196. */
  12197. computeTransformedInformation(): boolean;
  12198. /**
  12199. * Return the depth scale used for the shadow map.
  12200. * @returns the depth scale.
  12201. */
  12202. getDepthScale(): number;
  12203. /**
  12204. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12205. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12206. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12207. */
  12208. getShadowDirection(faceIndex?: number): Vector3;
  12209. /**
  12210. * Returns the ShadowLight absolute position in the World.
  12211. * @returns the position vector in world space
  12212. */
  12213. getAbsolutePosition(): Vector3;
  12214. /**
  12215. * Sets the ShadowLight direction toward the passed target.
  12216. * @param target The point tot target in local space
  12217. * @returns the updated ShadowLight direction
  12218. */
  12219. setDirectionToTarget(target: Vector3): Vector3;
  12220. /**
  12221. * Returns the light rotation in euler definition.
  12222. * @returns the x y z rotation in local space.
  12223. */
  12224. getRotation(): Vector3;
  12225. /**
  12226. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12227. * @returns true if a cube texture needs to be use
  12228. */
  12229. needCube(): boolean;
  12230. /**
  12231. * Detects if the projection matrix requires to be recomputed this frame.
  12232. * @returns true if it requires to be recomputed otherwise, false.
  12233. */
  12234. needProjectionMatrixCompute(): boolean;
  12235. /**
  12236. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12237. */
  12238. forceProjectionMatrixCompute(): void;
  12239. /**
  12240. * Get the world matrix of the sahdow lights.
  12241. * @hidden Internal Use Only
  12242. */
  12243. _getWorldMatrix(): Matrix;
  12244. /**
  12245. * Gets the minZ used for shadow according to both the scene and the light.
  12246. * @param activeCamera The camera we are returning the min for
  12247. * @returns the depth min z
  12248. */
  12249. getDepthMinZ(activeCamera: Camera): number;
  12250. /**
  12251. * Gets the maxZ used for shadow according to both the scene and the light.
  12252. * @param activeCamera The camera we are returning the max for
  12253. * @returns the depth max z
  12254. */
  12255. getDepthMaxZ(activeCamera: Camera): number;
  12256. /**
  12257. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12258. * @param matrix The materix to updated with the projection information
  12259. * @param viewMatrix The transform matrix of the light
  12260. * @param renderList The list of mesh to render in the map
  12261. * @returns The current light
  12262. */
  12263. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12264. }
  12265. }
  12266. declare module BABYLON {
  12267. /**
  12268. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12269. * These values define a cone of light starting from the position, emitting toward the direction.
  12270. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12271. * and the exponent defines the speed of the decay of the light with distance (reach).
  12272. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12273. */
  12274. class SpotLight extends ShadowLight {
  12275. private _angle;
  12276. /**
  12277. * Gets the cone angle of the spot light in Radians.
  12278. */
  12279. /**
  12280. * Sets the cone angle of the spot light in Radians.
  12281. */
  12282. angle: number;
  12283. private _shadowAngleScale;
  12284. /**
  12285. * Allows scaling the angle of the light for shadow generation only.
  12286. */
  12287. /**
  12288. * Allows scaling the angle of the light for shadow generation only.
  12289. */
  12290. shadowAngleScale: number;
  12291. /**
  12292. * The light decay speed with the distance from the emission spot.
  12293. */
  12294. exponent: number;
  12295. private _projectionTextureMatrix;
  12296. /**
  12297. * Allows reading the projecton texture
  12298. */
  12299. readonly projectionTextureMatrix: Matrix;
  12300. protected _projectionTextureLightNear: number;
  12301. /**
  12302. * Gets the near clip of the Spotlight for texture projection.
  12303. */
  12304. /**
  12305. * Sets the near clip of the Spotlight for texture projection.
  12306. */
  12307. projectionTextureLightNear: number;
  12308. protected _projectionTextureLightFar: number;
  12309. /**
  12310. * Gets the far clip of the Spotlight for texture projection.
  12311. */
  12312. /**
  12313. * Sets the far clip of the Spotlight for texture projection.
  12314. */
  12315. projectionTextureLightFar: number;
  12316. protected _projectionTextureUpDirection: Vector3;
  12317. /**
  12318. * Gets the Up vector of the Spotlight for texture projection.
  12319. */
  12320. /**
  12321. * Sets the Up vector of the Spotlight for texture projection.
  12322. */
  12323. projectionTextureUpDirection: Vector3;
  12324. private _projectionTexture;
  12325. /**
  12326. * Gets the projection texture of the light.
  12327. */
  12328. /**
  12329. * Sets the projection texture of the light.
  12330. */
  12331. projectionTexture: Nullable<BaseTexture>;
  12332. private _projectionTextureViewLightDirty;
  12333. private _projectionTextureProjectionLightDirty;
  12334. private _projectionTextureDirty;
  12335. private _projectionTextureViewTargetVector;
  12336. private _projectionTextureViewLightMatrix;
  12337. private _projectionTextureProjectionLightMatrix;
  12338. private _projectionTextureScalingMatrix;
  12339. /**
  12340. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12341. * It can cast shadows.
  12342. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12343. * @param name The light friendly name
  12344. * @param position The position of the spot light in the scene
  12345. * @param direction The direction of the light in the scene
  12346. * @param angle The cone angle of the light in Radians
  12347. * @param exponent The light decay speed with the distance from the emission spot
  12348. * @param scene The scene the lights belongs to
  12349. */
  12350. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12351. /**
  12352. * Returns the string "SpotLight".
  12353. * @returns the class name
  12354. */
  12355. getClassName(): string;
  12356. /**
  12357. * Returns the integer 2.
  12358. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12359. */
  12360. getTypeID(): number;
  12361. /**
  12362. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12363. */
  12364. protected _setDirection(value: Vector3): void;
  12365. /**
  12366. * Overrides the position setter to recompute the projection texture view light Matrix.
  12367. */
  12368. protected _setPosition(value: Vector3): void;
  12369. /**
  12370. * 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.
  12371. * Returns the SpotLight.
  12372. */
  12373. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12374. protected _computeProjectionTextureViewLightMatrix(): void;
  12375. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12376. /**
  12377. * Main function for light texture projection matrix computing.
  12378. */
  12379. protected _computeProjectionTextureMatrix(): void;
  12380. protected _buildUniformLayout(): void;
  12381. /**
  12382. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12383. * @param effect The effect to update
  12384. * @param lightIndex The index of the light in the effect to update
  12385. * @returns The spot light
  12386. */
  12387. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12388. /**
  12389. * Disposes the light and the associated resources.
  12390. */
  12391. dispose(): void;
  12392. }
  12393. }
  12394. declare module BABYLON {
  12395. class Scalar {
  12396. /**
  12397. * Two pi constants convenient for computation.
  12398. */
  12399. static TwoPi: number;
  12400. /**
  12401. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  12402. */
  12403. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  12404. /**
  12405. * Returns a string : the upper case translation of the number i to hexadecimal.
  12406. */
  12407. static ToHex(i: number): string;
  12408. /**
  12409. * Returns -1 if value is negative and +1 is value is positive.
  12410. * Returns the value itself if it's equal to zero.
  12411. */
  12412. static Sign(value: number): number;
  12413. /**
  12414. * Returns the value itself if it's between min and max.
  12415. * Returns min if the value is lower than min.
  12416. * Returns max if the value is greater than max.
  12417. */
  12418. static Clamp(value: number, min?: number, max?: number): number;
  12419. /**
  12420. * Returns the log2 of value.
  12421. */
  12422. static Log2(value: number): number;
  12423. /**
  12424. * Loops the value, so that it is never larger than length and never smaller than 0.
  12425. *
  12426. * This is similar to the modulo operator but it works with floating point numbers.
  12427. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  12428. * With t = 5 and length = 2.5, the result would be 0.0.
  12429. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  12430. */
  12431. static Repeat(value: number, length: number): number;
  12432. /**
  12433. * Normalize the value between 0.0 and 1.0 using min and max values
  12434. */
  12435. static Normalize(value: number, min: number, max: number): number;
  12436. /**
  12437. * Denormalize the value from 0.0 and 1.0 using min and max values
  12438. */
  12439. static Denormalize(normalized: number, min: number, max: number): number;
  12440. /**
  12441. * Calculates the shortest difference between two given angles given in degrees.
  12442. */
  12443. static DeltaAngle(current: number, target: number): number;
  12444. /**
  12445. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  12446. *
  12447. * The returned value will move back and forth between 0 and length
  12448. */
  12449. static PingPong(tx: number, length: number): number;
  12450. /**
  12451. * Interpolates between min and max with smoothing at the limits.
  12452. *
  12453. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  12454. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  12455. */
  12456. static SmoothStep(from: number, to: number, tx: number): number;
  12457. /**
  12458. * Moves a value current towards target.
  12459. *
  12460. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  12461. * Negative values of maxDelta pushes the value away from target.
  12462. */
  12463. static MoveTowards(current: number, target: number, maxDelta: number): number;
  12464. /**
  12465. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12466. *
  12467. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  12468. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  12469. */
  12470. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  12471. /**
  12472. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  12473. */
  12474. static Lerp(start: number, end: number, amount: number): number;
  12475. /**
  12476. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12477. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  12478. */
  12479. static LerpAngle(start: number, end: number, amount: number): number;
  12480. /**
  12481. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  12482. */
  12483. static InverseLerp(a: number, b: number, value: number): number;
  12484. /**
  12485. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  12486. */
  12487. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  12488. /**
  12489. * Returns a random float number between and min and max values
  12490. */
  12491. static RandomRange(min: number, max: number): number;
  12492. /**
  12493. * This function returns percentage of a number in a given range.
  12494. *
  12495. * RangeToPercent(40,20,60) will return 0.5 (50%)
  12496. * RangeToPercent(34,0,100) will return 0.34 (34%)
  12497. */
  12498. static RangeToPercent(number: number, min: number, max: number): number;
  12499. /**
  12500. * This function returns number that corresponds to the percentage in a given range.
  12501. *
  12502. * PercentToRange(0.34,0,100) will return 34.
  12503. */
  12504. static PercentToRange(percent: number, min: number, max: number): number;
  12505. /**
  12506. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  12507. * @param angle The angle to normalize in radian.
  12508. * @return The converted angle.
  12509. */
  12510. static NormalizeRadians(angle: number): number;
  12511. }
  12512. }
  12513. declare module BABYLON {
  12514. const ToGammaSpace: number;
  12515. const ToLinearSpace = 2.2;
  12516. const Epsilon = 0.001;
  12517. /**
  12518. * Class used to hold a RBG color
  12519. */
  12520. class Color3 {
  12521. /**
  12522. * Defines the red component (between 0 and 1, default is 0)
  12523. */
  12524. r: number;
  12525. /**
  12526. * Defines the green component (between 0 and 1, default is 0)
  12527. */
  12528. g: number;
  12529. /**
  12530. * Defines the blue component (between 0 and 1, default is 0)
  12531. */
  12532. b: number;
  12533. /**
  12534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  12535. * @param r defines the red component (between 0 and 1, default is 0)
  12536. * @param g defines the green component (between 0 and 1, default is 0)
  12537. * @param b defines the blue component (between 0 and 1, default is 0)
  12538. */
  12539. constructor(
  12540. /**
  12541. * Defines the red component (between 0 and 1, default is 0)
  12542. */
  12543. r?: number,
  12544. /**
  12545. * Defines the green component (between 0 and 1, default is 0)
  12546. */
  12547. g?: number,
  12548. /**
  12549. * Defines the blue component (between 0 and 1, default is 0)
  12550. */
  12551. b?: number);
  12552. /**
  12553. * Creates a string with the Color3 current values
  12554. * @returns the string representation of the Color3 object
  12555. */
  12556. toString(): string;
  12557. /**
  12558. * Returns the string "Color3"
  12559. * @returns "Color3"
  12560. */
  12561. getClassName(): string;
  12562. /**
  12563. * Compute the Color3 hash code
  12564. * @returns an unique number that can be used to hash Color3 objects
  12565. */
  12566. getHashCode(): number;
  12567. /**
  12568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  12569. * @param array defines the array where to store the r,g,b components
  12570. * @param index defines an optional index in the target array to define where to start storing values
  12571. * @returns the current Color3 object
  12572. */
  12573. toArray(array: FloatArray, index?: number): Color3;
  12574. /**
  12575. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  12576. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  12577. * @returns a new {BABYLON.Color4} object
  12578. */
  12579. toColor4(alpha?: number): Color4;
  12580. /**
  12581. * Returns a new array populated with 3 numeric elements : red, green and blue values
  12582. * @returns the new array
  12583. */
  12584. asArray(): number[];
  12585. /**
  12586. * Returns the luminance value
  12587. * @returns a float value
  12588. */
  12589. toLuminance(): number;
  12590. /**
  12591. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  12592. * @param otherColor defines the second operand
  12593. * @returns the new Color3 object
  12594. */
  12595. multiply(otherColor: Color3): Color3;
  12596. /**
  12597. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  12598. * @param otherColor defines the second operand
  12599. * @param result defines the Color3 object where to store the result
  12600. * @returns the current Color3
  12601. */
  12602. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  12603. /**
  12604. * Determines equality between Color3 objects
  12605. * @param otherColor defines the second operand
  12606. * @returns true if the rgb values are equal to the given ones
  12607. */
  12608. equals(otherColor: Color3): boolean;
  12609. /**
  12610. * Determines equality between the current Color3 object and a set of r,b,g values
  12611. * @param r defines the red component to check
  12612. * @param g defines the green component to check
  12613. * @param b defines the blue component to check
  12614. * @returns true if the rgb values are equal to the given ones
  12615. */
  12616. equalsFloats(r: number, g: number, b: number): boolean;
  12617. /**
  12618. * Multiplies in place each rgb value by scale
  12619. * @param scale defines the scaling factor
  12620. * @returns the updated Color3
  12621. */
  12622. scale(scale: number): Color3;
  12623. /**
  12624. * Multiplies the rgb values by scale and stores the result into "result"
  12625. * @param scale defines the scaling factor
  12626. * @param result defines the Color3 object where to store the result
  12627. * @returns the unmodified current Color3
  12628. */
  12629. scaleToRef(scale: number, result: Color3): Color3;
  12630. /**
  12631. * Scale the current Color3 values by a factor and add the result to a given Color3
  12632. * @param scale defines the scale factor
  12633. * @param result defines color to store the result into
  12634. * @returns the unmodified current Color3
  12635. */
  12636. scaleAndAddToRef(scale: number, result: Color3): Color3;
  12637. /**
  12638. * Clamps the rgb values by the min and max values and stores the result into "result"
  12639. * @param min defines minimum clamping value (default is 0)
  12640. * @param max defines maximum clamping value (default is 1)
  12641. * @param result defines color to store the result into
  12642. * @returns the original Color3
  12643. */
  12644. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  12645. /**
  12646. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  12647. * @param otherColor defines the second operand
  12648. * @returns the new Color3
  12649. */
  12650. add(otherColor: Color3): Color3;
  12651. /**
  12652. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  12653. * @param otherColor defines the second operand
  12654. * @param result defines Color3 object to store the result into
  12655. * @returns the unmodified current Color3
  12656. */
  12657. addToRef(otherColor: Color3, result: Color3): Color3;
  12658. /**
  12659. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  12660. * @param otherColor defines the second operand
  12661. * @returns the new Color3
  12662. */
  12663. subtract(otherColor: Color3): Color3;
  12664. /**
  12665. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  12666. * @param otherColor defines the second operand
  12667. * @param result defines Color3 object to store the result into
  12668. * @returns the unmodified current Color3
  12669. */
  12670. subtractToRef(otherColor: Color3, result: Color3): Color3;
  12671. /**
  12672. * Copy the current object
  12673. * @returns a new Color3 copied the current one
  12674. */
  12675. clone(): Color3;
  12676. /**
  12677. * Copies the rgb values from the source in the current Color3
  12678. * @param source defines the source Color3 object
  12679. * @returns the updated Color3 object
  12680. */
  12681. copyFrom(source: Color3): Color3;
  12682. /**
  12683. * Updates the Color3 rgb values from the given floats
  12684. * @param r defines the red component to read from
  12685. * @param g defines the green component to read from
  12686. * @param b defines the blue component to read from
  12687. * @returns the current Color3 object
  12688. */
  12689. copyFromFloats(r: number, g: number, b: number): Color3;
  12690. /**
  12691. * Updates the Color3 rgb values from the given floats
  12692. * @param r defines the red component to read from
  12693. * @param g defines the green component to read from
  12694. * @param b defines the blue component to read from
  12695. * @returns the current Color3 object
  12696. */
  12697. set(r: number, g: number, b: number): Color3;
  12698. /**
  12699. * Compute the Color3 hexadecimal code as a string
  12700. * @returns a string containing the hexadecimal representation of the Color3 object
  12701. */
  12702. toHexString(): string;
  12703. /**
  12704. * Computes a new Color3 converted from the current one to linear space
  12705. * @returns a new Color3 object
  12706. */
  12707. toLinearSpace(): Color3;
  12708. /**
  12709. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  12710. * @param convertedColor defines the Color3 object where to store the linear space version
  12711. * @returns the unmodified Color3
  12712. */
  12713. toLinearSpaceToRef(convertedColor: Color3): Color3;
  12714. /**
  12715. * Computes a new Color3 converted from the current one to gamma space
  12716. * @returns a new Color3 object
  12717. */
  12718. toGammaSpace(): Color3;
  12719. /**
  12720. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  12721. * @param convertedColor defines the Color3 object where to store the gamma space version
  12722. * @returns the unmodified Color3
  12723. */
  12724. toGammaSpaceToRef(convertedColor: Color3): Color3;
  12725. /**
  12726. * Creates a new Color3 from the string containing valid hexadecimal values
  12727. * @param hex defines a string containing valid hexadecimal values
  12728. * @returns a new Color3 object
  12729. */
  12730. static FromHexString(hex: string): Color3;
  12731. /**
  12732. * Creates a new Vector3 from the starting index of the given array
  12733. * @param array defines the source array
  12734. * @param offset defines an offset in the source array
  12735. * @returns a new Color3 object
  12736. */
  12737. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  12738. /**
  12739. * Creates a new Color3 from integer values (< 256)
  12740. * @param r defines the red component to read from (value between 0 and 255)
  12741. * @param g defines the green component to read from (value between 0 and 255)
  12742. * @param b defines the blue component to read from (value between 0 and 255)
  12743. * @returns a new Color3 object
  12744. */
  12745. static FromInts(r: number, g: number, b: number): Color3;
  12746. /**
  12747. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  12748. * @param start defines the start Color3 value
  12749. * @param end defines the end Color3 value
  12750. * @param amount defines the gradient value between start and end
  12751. * @returns a new Color3 object
  12752. */
  12753. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  12754. /**
  12755. * Returns a Color3 value containing a red color
  12756. * @returns a new Color3 object
  12757. */
  12758. static Red(): Color3;
  12759. /**
  12760. * Returns a Color3 value containing a green color
  12761. * @returns a new Color3 object
  12762. */
  12763. static Green(): Color3;
  12764. /**
  12765. * Returns a Color3 value containing a blue color
  12766. * @returns a new Color3 object
  12767. */
  12768. static Blue(): Color3;
  12769. /**
  12770. * Returns a Color3 value containing a black color
  12771. * @returns a new Color3 object
  12772. */
  12773. static Black(): Color3;
  12774. /**
  12775. * Returns a Color3 value containing a white color
  12776. * @returns a new Color3 object
  12777. */
  12778. static White(): Color3;
  12779. /**
  12780. * Returns a Color3 value containing a purple color
  12781. * @returns a new Color3 object
  12782. */
  12783. static Purple(): Color3;
  12784. /**
  12785. * Returns a Color3 value containing a magenta color
  12786. * @returns a new Color3 object
  12787. */
  12788. static Magenta(): Color3;
  12789. /**
  12790. * Returns a Color3 value containing a yellow color
  12791. * @returns a new Color3 object
  12792. */
  12793. static Yellow(): Color3;
  12794. /**
  12795. * Returns a Color3 value containing a gray color
  12796. * @returns a new Color3 object
  12797. */
  12798. static Gray(): Color3;
  12799. /**
  12800. * Returns a Color3 value containing a teal color
  12801. * @returns a new Color3 object
  12802. */
  12803. static Teal(): Color3;
  12804. /**
  12805. * Returns a Color3 value containing a random color
  12806. * @returns a new Color3 object
  12807. */
  12808. static Random(): Color3;
  12809. }
  12810. /**
  12811. * Class used to hold a RBGA color
  12812. */
  12813. class Color4 {
  12814. /**
  12815. * Defines the red component (between 0 and 1, default is 0)
  12816. */
  12817. r: number;
  12818. /**
  12819. * Defines the green component (between 0 and 1, default is 0)
  12820. */
  12821. g: number;
  12822. /**
  12823. * Defines the blue component (between 0 and 1, default is 0)
  12824. */
  12825. b: number;
  12826. /**
  12827. * Defines the alpha component (between 0 and 1, default is 1)
  12828. */
  12829. a: number;
  12830. /**
  12831. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  12832. * @param r defines the red component (between 0 and 1, default is 0)
  12833. * @param g defines the green component (between 0 and 1, default is 0)
  12834. * @param b defines the blue component (between 0 and 1, default is 0)
  12835. * @param a defines the alpha component (between 0 and 1, default is 1)
  12836. */
  12837. constructor(
  12838. /**
  12839. * Defines the red component (between 0 and 1, default is 0)
  12840. */
  12841. r?: number,
  12842. /**
  12843. * Defines the green component (between 0 and 1, default is 0)
  12844. */
  12845. g?: number,
  12846. /**
  12847. * Defines the blue component (between 0 and 1, default is 0)
  12848. */
  12849. b?: number,
  12850. /**
  12851. * Defines the alpha component (between 0 and 1, default is 1)
  12852. */
  12853. a?: number);
  12854. /**
  12855. * Adds in place the given Color4 values to the current Color4 object
  12856. * @param right defines the second operand
  12857. * @returns the current updated Color4 object
  12858. */
  12859. addInPlace(right: Color4): Color4;
  12860. /**
  12861. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  12862. * @returns the new array
  12863. */
  12864. asArray(): number[];
  12865. /**
  12866. * Stores from the starting index in the given array the Color4 successive values
  12867. * @param array defines the array where to store the r,g,b components
  12868. * @param index defines an optional index in the target array to define where to start storing values
  12869. * @returns the current Color4 object
  12870. */
  12871. toArray(array: number[], index?: number): Color4;
  12872. /**
  12873. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  12874. * @param right defines the second operand
  12875. * @returns a new Color4 object
  12876. */
  12877. add(right: Color4): Color4;
  12878. /**
  12879. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  12880. * @param right defines the second operand
  12881. * @returns a new Color4 object
  12882. */
  12883. subtract(right: Color4): Color4;
  12884. /**
  12885. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  12886. * @param right defines the second operand
  12887. * @param result defines the Color4 object where to store the result
  12888. * @returns the current Color4 object
  12889. */
  12890. subtractToRef(right: Color4, result: Color4): Color4;
  12891. /**
  12892. * Creates a new Color4 with the current Color4 values multiplied by scale
  12893. * @param scale defines the scaling factor to apply
  12894. * @returns a new Color4 object
  12895. */
  12896. scale(scale: number): Color4;
  12897. /**
  12898. * Multiplies the current Color4 values by scale and stores the result in "result"
  12899. * @param scale defines the scaling factor to apply
  12900. * @param result defines the Color4 object where to store the result
  12901. * @returns the current unmodified Color4
  12902. */
  12903. scaleToRef(scale: number, result: Color4): Color4;
  12904. /**
  12905. * Scale the current Color4 values by a factor and add the result to a given Color4
  12906. * @param scale defines the scale factor
  12907. * @param result defines the Color4 object where to store the result
  12908. * @returns the unmodified current Color4
  12909. */
  12910. scaleAndAddToRef(scale: number, result: Color4): Color4;
  12911. /**
  12912. * Clamps the rgb values by the min and max values and stores the result into "result"
  12913. * @param min defines minimum clamping value (default is 0)
  12914. * @param max defines maximum clamping value (default is 1)
  12915. * @param result defines color to store the result into.
  12916. * @returns the cuurent Color4
  12917. */
  12918. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  12919. /**
  12920. * Multipy an Color4 value by another and return a new Color4 object
  12921. * @param color defines the Color4 value to multiply by
  12922. * @returns a new Color4 object
  12923. */
  12924. multiply(color: Color4): Color4;
  12925. /**
  12926. * Multipy a Color4 value by another and push the result in a reference value
  12927. * @param color defines the Color4 value to multiply by
  12928. * @param result defines the Color4 to fill the result in
  12929. * @returns the result Color4
  12930. */
  12931. multiplyToRef(color: Color4, result: Color4): Color4;
  12932. /**
  12933. * Creates a string with the Color4 current values
  12934. * @returns the string representation of the Color4 object
  12935. */
  12936. toString(): string;
  12937. /**
  12938. * Returns the string "Color4"
  12939. * @returns "Color4"
  12940. */
  12941. getClassName(): string;
  12942. /**
  12943. * Compute the Color4 hash code
  12944. * @returns an unique number that can be used to hash Color4 objects
  12945. */
  12946. getHashCode(): number;
  12947. /**
  12948. * Creates a new Color4 copied from the current one
  12949. * @returns a new Color4 object
  12950. */
  12951. clone(): Color4;
  12952. /**
  12953. * Copies the given Color4 values into the current one
  12954. * @param source defines the source Color4 object
  12955. * @returns the current updated Color4 object
  12956. */
  12957. copyFrom(source: Color4): Color4;
  12958. /**
  12959. * Copies the given float values into the current one
  12960. * @param r defines the red component to read from
  12961. * @param g defines the green component to read from
  12962. * @param b defines the blue component to read from
  12963. * @param a defines the alpha component to read from
  12964. * @returns the current updated Color4 object
  12965. */
  12966. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  12967. /**
  12968. * Copies the given float values into the current one
  12969. * @param r defines the red component to read from
  12970. * @param g defines the green component to read from
  12971. * @param b defines the blue component to read from
  12972. * @param a defines the alpha component to read from
  12973. * @returns the current updated Color4 object
  12974. */
  12975. set(r: number, g: number, b: number, a: number): Color4;
  12976. /**
  12977. * Compute the Color4 hexadecimal code as a string
  12978. * @returns a string containing the hexadecimal representation of the Color4 object
  12979. */
  12980. toHexString(): string;
  12981. /**
  12982. * Computes a new Color4 converted from the current one to linear space
  12983. * @returns a new Color4 object
  12984. */
  12985. toLinearSpace(): Color4;
  12986. /**
  12987. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  12988. * @param convertedColor defines the Color4 object where to store the linear space version
  12989. * @returns the unmodified Color4
  12990. */
  12991. toLinearSpaceToRef(convertedColor: Color4): Color4;
  12992. /**
  12993. * Computes a new Color4 converted from the current one to gamma space
  12994. * @returns a new Color4 object
  12995. */
  12996. toGammaSpace(): Color4;
  12997. /**
  12998. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  12999. * @param convertedColor defines the Color4 object where to store the gamma space version
  13000. * @returns the unmodified Color4
  13001. */
  13002. toGammaSpaceToRef(convertedColor: Color4): Color4;
  13003. /**
  13004. * Creates a new Color4 from the string containing valid hexadecimal values
  13005. * @param hex defines a string containing valid hexadecimal values
  13006. * @returns a new Color4 object
  13007. */
  13008. static FromHexString(hex: string): Color4;
  13009. /**
  13010. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13011. * @param left defines the start value
  13012. * @param right defines the end value
  13013. * @param amount defines the gradient factor
  13014. * @returns a new Color4 object
  13015. */
  13016. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  13017. /**
  13018. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13019. * @param left defines the start value
  13020. * @param right defines the end value
  13021. * @param amount defines the gradient factor
  13022. * @param result defines the Color4 object where to store data
  13023. */
  13024. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  13025. /**
  13026. * Creates a new Color4 from the starting index element of the given array
  13027. * @param array defines the source array to read from
  13028. * @param offset defines the offset in the source array
  13029. * @returns a new Color4 object
  13030. */
  13031. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  13032. /**
  13033. * Creates a new Color3 from integer values (< 256)
  13034. * @param r defines the red component to read from (value between 0 and 255)
  13035. * @param g defines the green component to read from (value between 0 and 255)
  13036. * @param b defines the blue component to read from (value between 0 and 255)
  13037. * @param a defines the alpha component to read from (value between 0 and 255)
  13038. * @returns a new Color3 object
  13039. */
  13040. static FromInts(r: number, g: number, b: number, a: number): Color4;
  13041. /**
  13042. * Check the content of a given array and convert it to an array containing RGBA data
  13043. * If the original array was already containing count * 4 values then it is returned directly
  13044. * @param colors defines the array to check
  13045. * @param count defines the number of RGBA data to expect
  13046. * @returns an array containing count * 4 values (RGBA)
  13047. */
  13048. static CheckColors4(colors: number[], count: number): number[];
  13049. }
  13050. /**
  13051. * Class representing a vector containing 2 coordinates
  13052. */
  13053. class Vector2 {
  13054. /** defines the first coordinate */
  13055. x: number;
  13056. /** defines the second coordinate */
  13057. y: number;
  13058. /**
  13059. * Creates a new Vector2 from the given x and y coordinates
  13060. * @param x defines the first coordinate
  13061. * @param y defines the second coordinate
  13062. */
  13063. constructor(
  13064. /** defines the first coordinate */
  13065. x: number,
  13066. /** defines the second coordinate */
  13067. y: number);
  13068. /**
  13069. * Gets a string with the Vector2 coordinates
  13070. * @returns a string with the Vector2 coordinates
  13071. */
  13072. toString(): string;
  13073. /**
  13074. * Gets class name
  13075. * @returns the string "Vector2"
  13076. */
  13077. getClassName(): string;
  13078. /**
  13079. * Gets current vector hash code
  13080. * @returns the Vector2 hash code as a number
  13081. */
  13082. getHashCode(): number;
  13083. /**
  13084. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  13085. * @param array defines the source array
  13086. * @param index defines the offset in source array
  13087. * @returns the current Vector2
  13088. */
  13089. toArray(array: FloatArray, index?: number): Vector2;
  13090. /**
  13091. * Copy the current vector to an array
  13092. * @returns a new array with 2 elements: the Vector2 coordinates.
  13093. */
  13094. asArray(): number[];
  13095. /**
  13096. * Sets the Vector2 coordinates with the given Vector2 coordinates
  13097. * @param source defines the source Vector2
  13098. * @returns the current updated Vector2
  13099. */
  13100. copyFrom(source: Vector2): Vector2;
  13101. /**
  13102. * Sets the Vector2 coordinates with the given floats
  13103. * @param x defines the first coordinate
  13104. * @param y defines the second coordinate
  13105. * @returns the current updated Vector2
  13106. */
  13107. copyFromFloats(x: number, y: number): Vector2;
  13108. /**
  13109. * Sets the Vector2 coordinates with the given floats
  13110. * @param x defines the first coordinate
  13111. * @param y defines the second coordinate
  13112. * @returns the current updated Vector2
  13113. */
  13114. set(x: number, y: number): Vector2;
  13115. /**
  13116. * Add another vector with the current one
  13117. * @param otherVector defines the other vector
  13118. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  13119. */
  13120. add(otherVector: Vector2): Vector2;
  13121. /**
  13122. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  13123. * @param otherVector defines the other vector
  13124. * @param result defines the target vector
  13125. * @returns the unmodified current Vector2
  13126. */
  13127. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  13128. /**
  13129. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  13130. * @param otherVector defines the other vector
  13131. * @returns the current updated Vector2
  13132. */
  13133. addInPlace(otherVector: Vector2): Vector2;
  13134. /**
  13135. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  13136. * @param otherVector defines the other vector
  13137. * @returns a new Vector2
  13138. */
  13139. addVector3(otherVector: Vector3): Vector2;
  13140. /**
  13141. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  13142. * @param otherVector defines the other vector
  13143. * @returns a new Vector2
  13144. */
  13145. subtract(otherVector: Vector2): Vector2;
  13146. /**
  13147. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  13148. * @param otherVector defines the other vector
  13149. * @param result defines the target vector
  13150. * @returns the unmodified current Vector2
  13151. */
  13152. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  13153. /**
  13154. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  13155. * @param otherVector defines the other vector
  13156. * @returns the current updated Vector2
  13157. */
  13158. subtractInPlace(otherVector: Vector2): Vector2;
  13159. /**
  13160. * Multiplies in place the current Vector2 coordinates by the given ones
  13161. * @param otherVector defines the other vector
  13162. * @returns the current updated Vector2
  13163. */
  13164. multiplyInPlace(otherVector: Vector2): Vector2;
  13165. /**
  13166. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  13167. * @param otherVector defines the other vector
  13168. * @returns a new Vector2
  13169. */
  13170. multiply(otherVector: Vector2): Vector2;
  13171. /**
  13172. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  13173. * @param otherVector defines the other vector
  13174. * @param result defines the target vector
  13175. * @returns the unmodified current Vector2
  13176. */
  13177. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  13178. /**
  13179. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  13180. * @param x defines the first coordinate
  13181. * @param y defines the second coordinate
  13182. * @returns a new Vector2
  13183. */
  13184. multiplyByFloats(x: number, y: number): Vector2;
  13185. /**
  13186. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  13187. * @param otherVector defines the other vector
  13188. * @returns a new Vector2
  13189. */
  13190. divide(otherVector: Vector2): Vector2;
  13191. /**
  13192. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  13193. * @param otherVector defines the other vector
  13194. * @param result defines the target vector
  13195. * @returns the unmodified current Vector2
  13196. */
  13197. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  13198. /**
  13199. * Divides the current Vector3 coordinates by the given ones
  13200. * @param otherVector defines the other vector
  13201. * @returns the current updated Vector2
  13202. */
  13203. divideInPlace(otherVector: Vector2): Vector2;
  13204. /**
  13205. * Gets a new Vector2 with current Vector2 negated coordinates
  13206. * @returns a new Vector2
  13207. */
  13208. negate(): Vector2;
  13209. /**
  13210. * Multiply the Vector2 coordinates by scale
  13211. * @param scale defines the scaling factor
  13212. * @returns the current updated Vector2
  13213. */
  13214. scaleInPlace(scale: number): Vector2;
  13215. /**
  13216. * Returns a new Vector2 scaled by "scale" from the current Vector2
  13217. * @param scale defines the scaling factor
  13218. * @returns a new Vector2
  13219. */
  13220. scale(scale: number): Vector2;
  13221. /**
  13222. * Scale the current Vector2 values by a factor to a given Vector2
  13223. * @param scale defines the scale factor
  13224. * @param result defines the Vector2 object where to store the result
  13225. * @returns the unmodified current Vector2
  13226. */
  13227. scaleToRef(scale: number, result: Vector2): Vector2;
  13228. /**
  13229. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  13230. * @param scale defines the scale factor
  13231. * @param result defines the Vector2 object where to store the result
  13232. * @returns the unmodified current Vector2
  13233. */
  13234. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  13235. /**
  13236. * Gets a boolean if two vectors are equals
  13237. * @param otherVector defines the other vector
  13238. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  13239. */
  13240. equals(otherVector: Vector2): boolean;
  13241. /**
  13242. * Gets a boolean if two vectors are equals (using an epsilon value)
  13243. * @param otherVector defines the other vector
  13244. * @param epsilon defines the minimal distance to consider equality
  13245. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  13246. */
  13247. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  13248. /**
  13249. * Gets the length of the vector
  13250. * @returns the vector length (float)
  13251. */
  13252. length(): number;
  13253. /**
  13254. * Gets the vector squared length
  13255. * @returns the vector squared length (float)
  13256. */
  13257. lengthSquared(): number;
  13258. /**
  13259. * Normalize the vector
  13260. * @returns the current updated Vector2
  13261. */
  13262. normalize(): Vector2;
  13263. /**
  13264. * Gets a new Vector2 copied from the Vector2
  13265. * @returns a new Vector2
  13266. */
  13267. clone(): Vector2;
  13268. /**
  13269. * Gets a new Vector2(0, 0)
  13270. * @returns a new Vector2
  13271. */
  13272. static Zero(): Vector2;
  13273. /**
  13274. * Gets a new Vector2(1, 1)
  13275. * @returns a new Vector2
  13276. */
  13277. static One(): Vector2;
  13278. /**
  13279. * Gets a new Vector2 set from the given index element of the given array
  13280. * @param array defines the data source
  13281. * @param offset defines the offset in the data source
  13282. * @returns a new Vector2
  13283. */
  13284. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  13285. /**
  13286. * Sets "result" from the given index element of the given array
  13287. * @param array defines the data source
  13288. * @param offset defines the offset in the data source
  13289. * @param result defines the target vector
  13290. */
  13291. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  13292. /**
  13293. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  13294. * @param value1 defines 1st point of control
  13295. * @param value2 defines 2nd point of control
  13296. * @param value3 defines 3rd point of control
  13297. * @param value4 defines 4th point of control
  13298. * @param amount defines the interpolation factor
  13299. * @returns a new Vector2
  13300. */
  13301. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  13302. /**
  13303. * 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".
  13304. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  13305. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  13306. * @param value defines the value to clamp
  13307. * @param min defines the lower limit
  13308. * @param max defines the upper limit
  13309. * @returns a new Vector2
  13310. */
  13311. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  13312. /**
  13313. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  13314. * @param value1 defines the 1st control point
  13315. * @param tangent1 defines the outgoing tangent
  13316. * @param value2 defines the 2nd control point
  13317. * @param tangent2 defines the incoming tangent
  13318. * @param amount defines the interpolation factor
  13319. * @returns a new Vector2
  13320. */
  13321. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  13322. /**
  13323. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  13324. * @param start defines the start vector
  13325. * @param end defines the end vector
  13326. * @param amount defines the interpolation factor
  13327. * @returns a new Vector2
  13328. */
  13329. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  13330. /**
  13331. * Gets the dot product of the vector "left" and the vector "right"
  13332. * @param left defines first vector
  13333. * @param right defines second vector
  13334. * @returns the dot product (float)
  13335. */
  13336. static Dot(left: Vector2, right: Vector2): number;
  13337. /**
  13338. * Returns a new Vector2 equal to the normalized given vector
  13339. * @param vector defines the vector to normalize
  13340. * @returns a new Vector2
  13341. */
  13342. static Normalize(vector: Vector2): Vector2;
  13343. /**
  13344. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  13345. * @param left defines 1st vector
  13346. * @param right defines 2nd vector
  13347. * @returns a new Vector2
  13348. */
  13349. static Minimize(left: Vector2, right: Vector2): Vector2;
  13350. /**
  13351. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  13352. * @param left defines 1st vector
  13353. * @param right defines 2nd vector
  13354. * @returns a new Vector2
  13355. */
  13356. static Maximize(left: Vector2, right: Vector2): Vector2;
  13357. /**
  13358. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  13359. * @param vector defines the vector to transform
  13360. * @param transformation defines the matrix to apply
  13361. * @returns a new Vector2
  13362. */
  13363. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  13364. /**
  13365. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  13366. * @param vector defines the vector to transform
  13367. * @param transformation defines the matrix to apply
  13368. * @param result defines the target vector
  13369. */
  13370. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  13371. /**
  13372. * Determines if a given vector is included in a triangle
  13373. * @param p defines the vector to test
  13374. * @param p0 defines 1st triangle point
  13375. * @param p1 defines 2nd triangle point
  13376. * @param p2 defines 3rd triangle point
  13377. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  13378. */
  13379. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  13380. /**
  13381. * Gets the distance between the vectors "value1" and "value2"
  13382. * @param value1 defines first vector
  13383. * @param value2 defines second vector
  13384. * @returns the distance between vectors
  13385. */
  13386. static Distance(value1: Vector2, value2: Vector2): number;
  13387. /**
  13388. * Returns the squared distance between the vectors "value1" and "value2"
  13389. * @param value1 defines first vector
  13390. * @param value2 defines second vector
  13391. * @returns the squared distance between vectors
  13392. */
  13393. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  13394. /**
  13395. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  13396. * @param value1 defines first vector
  13397. * @param value2 defines second vector
  13398. * @returns a new Vector2
  13399. */
  13400. static Center(value1: Vector2, value2: Vector2): Vector2;
  13401. /**
  13402. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  13403. * @param p defines the middle point
  13404. * @param segA defines one point of the segment
  13405. * @param segB defines the other point of the segment
  13406. * @returns the shortest distance
  13407. */
  13408. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  13409. }
  13410. /**
  13411. * Classed used to store (x,y,z) vector representation
  13412. * A Vector3 is the main object used in 3D geometry
  13413. * It can represent etiher the coordinates of a point the space, either a direction
  13414. * Reminder: Babylon.js uses a left handed forward facing system
  13415. */
  13416. class Vector3 {
  13417. /**
  13418. * Defines the first coordinates (on X axis)
  13419. */
  13420. x: number;
  13421. /**
  13422. * Defines the second coordinates (on Y axis)
  13423. */
  13424. y: number;
  13425. /**
  13426. * Defines the third coordinates (on Z axis)
  13427. */
  13428. z: number;
  13429. /**
  13430. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  13431. * @param x defines the first coordinates (on X axis)
  13432. * @param y defines the second coordinates (on Y axis)
  13433. * @param z defines the third coordinates (on Z axis)
  13434. */
  13435. constructor(
  13436. /**
  13437. * Defines the first coordinates (on X axis)
  13438. */
  13439. x: number,
  13440. /**
  13441. * Defines the second coordinates (on Y axis)
  13442. */
  13443. y: number,
  13444. /**
  13445. * Defines the third coordinates (on Z axis)
  13446. */
  13447. z: number);
  13448. /**
  13449. * Creates a string representation of the Vector3
  13450. * @returns a string with the Vector3 coordinates.
  13451. */
  13452. toString(): string;
  13453. /**
  13454. * Gets the class name
  13455. * @returns the string "Vector3"
  13456. */
  13457. getClassName(): string;
  13458. /**
  13459. * Creates the Vector3 hash code
  13460. * @returns a number which tends to be unique between Vector3 instances
  13461. */
  13462. getHashCode(): number;
  13463. /**
  13464. * Creates an array containing three elements : the coordinates of the Vector3
  13465. * @returns a new array of numbers
  13466. */
  13467. asArray(): number[];
  13468. /**
  13469. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  13470. * @param array defines the destination array
  13471. * @param index defines the offset in the destination array
  13472. * @returns the current Vector3
  13473. */
  13474. toArray(array: FloatArray, index?: number): Vector3;
  13475. /**
  13476. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  13477. * @returns a new Quaternion object, computed from the Vector3 coordinates
  13478. */
  13479. toQuaternion(): Quaternion;
  13480. /**
  13481. * Adds the given vector to the current Vector3
  13482. * @param otherVector defines the second operand
  13483. * @returns the current updated Vector3
  13484. */
  13485. addInPlace(otherVector: Vector3): Vector3;
  13486. /**
  13487. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  13488. * @param otherVector defines the second operand
  13489. * @returns the resulting Vector3
  13490. */
  13491. add(otherVector: Vector3): Vector3;
  13492. /**
  13493. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  13494. * @param otherVector defines the second operand
  13495. * @param result defines the Vector3 object where to store the result
  13496. * @returns the current Vector3
  13497. */
  13498. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  13499. /**
  13500. * Subtract the given vector from the current Vector3
  13501. * @param otherVector defines the second operand
  13502. * @returns the current updated Vector3
  13503. */
  13504. subtractInPlace(otherVector: Vector3): Vector3;
  13505. /**
  13506. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  13507. * @param otherVector defines the second operand
  13508. * @returns the resulting Vector3
  13509. */
  13510. subtract(otherVector: Vector3): Vector3;
  13511. /**
  13512. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  13513. * @param otherVector defines the second operand
  13514. * @param result defines the Vector3 object where to store the result
  13515. * @returns the current Vector3
  13516. */
  13517. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  13518. /**
  13519. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  13520. * @param x defines the x coordinate of the operand
  13521. * @param y defines the y coordinate of the operand
  13522. * @param z defines the z coordinate of the operand
  13523. * @returns the resulting Vector3
  13524. */
  13525. subtractFromFloats(x: number, y: number, z: number): Vector3;
  13526. /**
  13527. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  13528. * @param x defines the x coordinate of the operand
  13529. * @param y defines the y coordinate of the operand
  13530. * @param z defines the z coordinate of the operand
  13531. * @param result defines the Vector3 object where to store the result
  13532. * @returns the current Vector3
  13533. */
  13534. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  13535. /**
  13536. * Gets a new Vector3 set with the current Vector3 negated coordinates
  13537. * @returns a new Vector3
  13538. */
  13539. negate(): Vector3;
  13540. /**
  13541. * Multiplies the Vector3 coordinates by the float "scale"
  13542. * @param scale defines the multiplier factor
  13543. * @returns the current updated Vector3
  13544. */
  13545. scaleInPlace(scale: number): Vector3;
  13546. /**
  13547. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  13548. * @param scale defines the multiplier factor
  13549. * @returns a new Vector3
  13550. */
  13551. scale(scale: number): Vector3;
  13552. /**
  13553. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  13554. * @param scale defines the multiplier factor
  13555. * @param result defines the Vector3 object where to store the result
  13556. * @returns the current Vector3
  13557. */
  13558. scaleToRef(scale: number, result: Vector3): Vector3;
  13559. /**
  13560. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  13561. * @param scale defines the scale factor
  13562. * @param result defines the Vector3 object where to store the result
  13563. * @returns the unmodified current Vector3
  13564. */
  13565. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  13566. /**
  13567. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  13568. * @param otherVector defines the second operand
  13569. * @returns true if both vectors are equals
  13570. */
  13571. equals(otherVector: Vector3): boolean;
  13572. /**
  13573. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  13574. * @param otherVector defines the second operand
  13575. * @param epsilon defines the minimal distance to define values as equals
  13576. * @returns true if both vectors are distant less than epsilon
  13577. */
  13578. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  13579. /**
  13580. * Returns true if the current Vector3 coordinates equals the given floats
  13581. * @param x defines the x coordinate of the operand
  13582. * @param y defines the y coordinate of the operand
  13583. * @param z defines the z coordinate of the operand
  13584. * @returns true if both vectors are equals
  13585. */
  13586. equalsToFloats(x: number, y: number, z: number): boolean;
  13587. /**
  13588. * Multiplies the current Vector3 coordinates by the given ones
  13589. * @param otherVector defines the second operand
  13590. * @returns the current updated Vector3
  13591. */
  13592. multiplyInPlace(otherVector: Vector3): Vector3;
  13593. /**
  13594. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  13595. * @param otherVector defines the second operand
  13596. * @returns the new Vector3
  13597. */
  13598. multiply(otherVector: Vector3): Vector3;
  13599. /**
  13600. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  13601. * @param otherVector defines the second operand
  13602. * @param result defines the Vector3 object where to store the result
  13603. * @returns the current Vector3
  13604. */
  13605. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  13606. /**
  13607. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  13608. * @param x defines the x coordinate of the operand
  13609. * @param y defines the y coordinate of the operand
  13610. * @param z defines the z coordinate of the operand
  13611. * @returns the new Vector3
  13612. */
  13613. multiplyByFloats(x: number, y: number, z: number): Vector3;
  13614. /**
  13615. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  13616. * @param otherVector defines the second operand
  13617. * @returns the new Vector3
  13618. */
  13619. divide(otherVector: Vector3): Vector3;
  13620. /**
  13621. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  13622. * @param otherVector defines the second operand
  13623. * @param result defines the Vector3 object where to store the result
  13624. * @returns the current Vector3
  13625. */
  13626. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  13627. /**
  13628. * Divides the current Vector3 coordinates by the given ones.
  13629. * @param otherVector defines the second operand
  13630. * @returns the current updated Vector3
  13631. */
  13632. divideInPlace(otherVector: Vector3): Vector3;
  13633. /**
  13634. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  13635. * @param other defines the second operand
  13636. * @returns the current updated Vector3
  13637. */
  13638. minimizeInPlace(other: Vector3): Vector3;
  13639. /**
  13640. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  13641. * @param other defines the second operand
  13642. * @returns the current updated Vector3
  13643. */
  13644. maximizeInPlace(other: Vector3): Vector3;
  13645. /**
  13646. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  13647. */
  13648. readonly isNonUniform: boolean;
  13649. /**
  13650. * Gets the length of the Vector3
  13651. * @returns the length of the Vecto3
  13652. */
  13653. length(): number;
  13654. /**
  13655. * Gets the squared length of the Vector3
  13656. * @returns squared length of the Vector3
  13657. */
  13658. lengthSquared(): number;
  13659. /**
  13660. * Normalize the current Vector3.
  13661. * Please note that this is an in place operation.
  13662. * @returns the current updated Vector3
  13663. */
  13664. normalize(): Vector3;
  13665. /**
  13666. * Normalize the current Vector3 to a new vector
  13667. * @returns the new Vector3
  13668. */
  13669. normalizeToNew(): Vector3;
  13670. /**
  13671. * Normalize the current Vector3 to the reference
  13672. * @param reference define the Vector3 to update
  13673. * @returns the updated Vector3
  13674. */
  13675. normalizeToRef(reference: Vector3): Vector3;
  13676. /**
  13677. * Creates a new Vector3 copied from the current Vector3
  13678. * @returns the new Vector3
  13679. */
  13680. clone(): Vector3;
  13681. /**
  13682. * Copies the given vector coordinates to the current Vector3 ones
  13683. * @param source defines the source Vector3
  13684. * @returns the current updated Vector3
  13685. */
  13686. copyFrom(source: Vector3): Vector3;
  13687. /**
  13688. * Copies the given floats to the current Vector3 coordinates
  13689. * @param x defines the x coordinate of the operand
  13690. * @param y defines the y coordinate of the operand
  13691. * @param z defines the z coordinate of the operand
  13692. * @returns the current updated Vector3
  13693. */
  13694. copyFromFloats(x: number, y: number, z: number): Vector3;
  13695. /**
  13696. * Copies the given floats to the current Vector3 coordinates
  13697. * @param x defines the x coordinate of the operand
  13698. * @param y defines the y coordinate of the operand
  13699. * @param z defines the z coordinate of the operand
  13700. * @returns the current updated Vector3
  13701. */
  13702. set(x: number, y: number, z: number): Vector3;
  13703. /**
  13704. * Get the clip factor between two vectors
  13705. * @param vector0 defines the first operand
  13706. * @param vector1 defines the second operand
  13707. * @param axis defines the axis to use
  13708. * @param size defines the size along the axis
  13709. * @returns the clip factor
  13710. */
  13711. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  13712. /**
  13713. * Get angle between two vectors
  13714. * @param vector0 angle between vector0 and vector1
  13715. * @param vector1 angle between vector0 and vector1
  13716. * @param normal direction of the normal
  13717. * @return the angle between vector0 and vector1
  13718. */
  13719. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  13720. /**
  13721. * Returns a new Vector3 set from the index "offset" of the given array
  13722. * @param array defines the source array
  13723. * @param offset defines the offset in the source array
  13724. * @returns the new Vector3
  13725. */
  13726. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  13727. /**
  13728. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  13729. * This function is deprecated. Use FromArray instead
  13730. * @param array defines the source array
  13731. * @param offset defines the offset in the source array
  13732. * @returns the new Vector3
  13733. */
  13734. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  13735. /**
  13736. * Sets the given vector "result" with the element values from the index "offset" of the given array
  13737. * @param array defines the source array
  13738. * @param offset defines the offset in the source array
  13739. * @param result defines the Vector3 where to store the result
  13740. */
  13741. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  13742. /**
  13743. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  13744. * This function is deprecated. Use FromArrayToRef instead.
  13745. * @param array defines the source array
  13746. * @param offset defines the offset in the source array
  13747. * @param result defines the Vector3 where to store the result
  13748. */
  13749. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  13750. /**
  13751. * Sets the given vector "result" with the given floats.
  13752. * @param x defines the x coordinate of the source
  13753. * @param y defines the y coordinate of the source
  13754. * @param z defines the z coordinate of the source
  13755. * @param result defines the Vector3 where to store the result
  13756. */
  13757. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  13758. /**
  13759. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  13760. * @returns a new empty Vector3
  13761. */
  13762. static Zero(): Vector3;
  13763. /**
  13764. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  13765. * @returns a new unit Vector3
  13766. */
  13767. static One(): Vector3;
  13768. /**
  13769. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  13770. * @returns a new up Vector3
  13771. */
  13772. static Up(): Vector3;
  13773. /**
  13774. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  13775. * @returns a new forward Vector3
  13776. */
  13777. static Forward(): Vector3;
  13778. /**
  13779. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  13780. * @returns a new right Vector3
  13781. */
  13782. static Right(): Vector3;
  13783. /**
  13784. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  13785. * @returns a new left Vector3
  13786. */
  13787. static Left(): Vector3;
  13788. /**
  13789. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  13790. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13791. * @param vector defines the Vector3 to transform
  13792. * @param transformation defines the transformation matrix
  13793. * @returns the transformed Vector3
  13794. */
  13795. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  13796. /**
  13797. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  13798. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13799. * @param vector defines the Vector3 to transform
  13800. * @param transformation defines the transformation matrix
  13801. * @param result defines the Vector3 where to store the result
  13802. */
  13803. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13804. /**
  13805. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  13806. * This method computes tranformed coordinates only, not transformed direction vectors
  13807. * @param x define the x coordinate of the source vector
  13808. * @param y define the y coordinate of the source vector
  13809. * @param z define the z coordinate of the source vector
  13810. * @param transformation defines the transformation matrix
  13811. * @param result defines the Vector3 where to store the result
  13812. */
  13813. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13814. /**
  13815. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  13816. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13817. * @param vector defines the Vector3 to transform
  13818. * @param transformation defines the transformation matrix
  13819. * @returns the new Vector3
  13820. */
  13821. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  13822. /**
  13823. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  13824. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13825. * @param vector defines the Vector3 to transform
  13826. * @param transformation defines the transformation matrix
  13827. * @param result defines the Vector3 where to store the result
  13828. */
  13829. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13830. /**
  13831. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  13832. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13833. * @param x define the x coordinate of the source vector
  13834. * @param y define the y coordinate of the source vector
  13835. * @param z define the z coordinate of the source vector
  13836. * @param transformation defines the transformation matrix
  13837. * @param result defines the Vector3 where to store the result
  13838. */
  13839. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13840. /**
  13841. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  13842. * @param value1 defines the first control point
  13843. * @param value2 defines the second control point
  13844. * @param value3 defines the third control point
  13845. * @param value4 defines the fourth control point
  13846. * @param amount defines the amount on the spline to use
  13847. * @returns the new Vector3
  13848. */
  13849. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13850. /**
  13851. * 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"
  13852. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  13853. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  13854. * @param value defines the current value
  13855. * @param min defines the lower range value
  13856. * @param max defines the upper range value
  13857. * @returns the new Vector3
  13858. */
  13859. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13860. /**
  13861. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  13862. * @param value1 defines the first control point
  13863. * @param tangent1 defines the first tangent vector
  13864. * @param value2 defines the second control point
  13865. * @param tangent2 defines the second tangent vector
  13866. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  13867. * @returns the new Vector3
  13868. */
  13869. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13870. /**
  13871. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  13872. * @param start defines the start value
  13873. * @param end defines the end value
  13874. * @param amount max defines amount between both (between 0 and 1)
  13875. * @returns the new Vector3
  13876. */
  13877. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13878. /**
  13879. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  13880. * @param start defines the start value
  13881. * @param end defines the end value
  13882. * @param amount max defines amount between both (between 0 and 1)
  13883. * @param result defines the Vector3 where to store the result
  13884. */
  13885. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13886. /**
  13887. * Returns the dot product (float) between the vectors "left" and "right"
  13888. * @param left defines the left operand
  13889. * @param right defines the right operand
  13890. * @returns the dot product
  13891. */
  13892. static Dot(left: Vector3, right: Vector3): number;
  13893. /**
  13894. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  13895. * The cross product is then orthogonal to both "left" and "right"
  13896. * @param left defines the left operand
  13897. * @param right defines the right operand
  13898. * @returns the cross product
  13899. */
  13900. static Cross(left: Vector3, right: Vector3): Vector3;
  13901. /**
  13902. * Sets the given vector "result" with the cross product of "left" and "right"
  13903. * The cross product is then orthogonal to both "left" and "right"
  13904. * @param left defines the left operand
  13905. * @param right defines the right operand
  13906. * @param result defines the Vector3 where to store the result
  13907. */
  13908. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  13909. /**
  13910. * Returns a new Vector3 as the normalization of the given vector
  13911. * @param vector defines the Vector3 to normalize
  13912. * @returns the new Vector3
  13913. */
  13914. static Normalize(vector: Vector3): Vector3;
  13915. /**
  13916. * Sets the given vector "result" with the normalization of the given first vector
  13917. * @param vector defines the Vector3 to normalize
  13918. * @param result defines the Vector3 where to store the result
  13919. */
  13920. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  13921. private static _viewportMatrixCache;
  13922. /**
  13923. * Project a Vector3 onto screen space
  13924. * @param vector defines the Vector3 to project
  13925. * @param world defines the world matrix to use
  13926. * @param transform defines the transform (view x projection) matrix to use
  13927. * @param viewport defines the screen viewport to use
  13928. * @returns the new Vector3
  13929. */
  13930. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  13931. /**
  13932. * Unproject from screen space to object space
  13933. * @param source defines the screen space Vector3 to use
  13934. * @param viewportWidth defines the current width of the viewport
  13935. * @param viewportHeight defines the current height of the viewport
  13936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13937. * @param transform defines the transform (view x projection) matrix to use
  13938. * @returns the new Vector3
  13939. */
  13940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  13941. /**
  13942. * Unproject from screen space to object space
  13943. * @param source defines the screen space Vector3 to use
  13944. * @param viewportWidth defines the current width of the viewport
  13945. * @param viewportHeight defines the current height of the viewport
  13946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13947. * @param view defines the view matrix to use
  13948. * @param projection defines the projection matrix to use
  13949. * @returns the new Vector3
  13950. */
  13951. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  13952. /**
  13953. * Unproject from screen space to object space
  13954. * @param source defines the screen space Vector3 to use
  13955. * @param viewportWidth defines the current width of the viewport
  13956. * @param viewportHeight defines the current height of the viewport
  13957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13958. * @param view defines the view matrix to use
  13959. * @param projection defines the projection matrix to use
  13960. * @param result defines the Vector3 where to store the result
  13961. */
  13962. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13963. /**
  13964. * Unproject from screen space to object space
  13965. * @param sourceX defines the screen space x coordinate to use
  13966. * @param sourceY defines the screen space y coordinate to use
  13967. * @param sourceZ defines the screen space z coordinate to use
  13968. * @param viewportWidth defines the current width of the viewport
  13969. * @param viewportHeight defines the current height of the viewport
  13970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13971. * @param view defines the view matrix to use
  13972. * @param projection defines the projection matrix to use
  13973. * @param result defines the Vector3 where to store the result
  13974. */
  13975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13976. /**
  13977. * Gets the minimal coordinate values between two Vector3
  13978. * @param left defines the first operand
  13979. * @param right defines the second operand
  13980. * @returns the new Vector3
  13981. */
  13982. static Minimize(left: Vector3, right: Vector3): Vector3;
  13983. /**
  13984. * Gets the maximal coordinate values between two Vector3
  13985. * @param left defines the first operand
  13986. * @param right defines the second operand
  13987. * @returns the new Vector3
  13988. */
  13989. static Maximize(left: Vector3, right: Vector3): Vector3;
  13990. /**
  13991. * Returns the distance between the vectors "value1" and "value2"
  13992. * @param value1 defines the first operand
  13993. * @param value2 defines the second operand
  13994. * @returns the distance
  13995. */
  13996. static Distance(value1: Vector3, value2: Vector3): number;
  13997. /**
  13998. * Returns the squared distance between the vectors "value1" and "value2"
  13999. * @param value1 defines the first operand
  14000. * @param value2 defines the second operand
  14001. * @returns the squared distance
  14002. */
  14003. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  14004. /**
  14005. * Returns a new Vector3 located at the center between "value1" and "value2"
  14006. * @param value1 defines the first operand
  14007. * @param value2 defines the second operand
  14008. * @returns the new Vector3
  14009. */
  14010. static Center(value1: Vector3, value2: Vector3): Vector3;
  14011. /**
  14012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  14013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  14014. * to something in order to rotate it from its local system to the given target system
  14015. * Note: axis1, axis2 and axis3 are normalized during this operation
  14016. * @param axis1 defines the first axis
  14017. * @param axis2 defines the second axis
  14018. * @param axis3 defines the third axis
  14019. * @returns a new Vector3
  14020. */
  14021. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  14022. /**
  14023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  14024. * @param axis1 defines the first axis
  14025. * @param axis2 defines the second axis
  14026. * @param axis3 defines the third axis
  14027. * @param ref defines the Vector3 where to store the result
  14028. */
  14029. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  14030. }
  14031. class Vector4 {
  14032. x: number;
  14033. y: number;
  14034. z: number;
  14035. w: number;
  14036. /**
  14037. * Creates a Vector4 object from the given floats.
  14038. */
  14039. constructor(x: number, y: number, z: number, w: number);
  14040. /**
  14041. * Returns the string with the Vector4 coordinates.
  14042. */
  14043. toString(): string;
  14044. /**
  14045. * Returns the string "Vector4".
  14046. */
  14047. getClassName(): string;
  14048. /**
  14049. * Returns the Vector4 hash code.
  14050. */
  14051. getHashCode(): number;
  14052. /**
  14053. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  14054. */
  14055. asArray(): number[];
  14056. /**
  14057. * Populates the given array from the given index with the Vector4 coordinates.
  14058. * Returns the Vector4.
  14059. */
  14060. toArray(array: FloatArray, index?: number): Vector4;
  14061. /**
  14062. * Adds the given vector to the current Vector4.
  14063. * Returns the updated Vector4.
  14064. */
  14065. addInPlace(otherVector: Vector4): Vector4;
  14066. /**
  14067. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  14068. */
  14069. add(otherVector: Vector4): Vector4;
  14070. /**
  14071. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  14072. * Returns the current Vector4.
  14073. */
  14074. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  14075. /**
  14076. * Subtract in place the given vector from the current Vector4.
  14077. * Returns the updated Vector4.
  14078. */
  14079. subtractInPlace(otherVector: Vector4): Vector4;
  14080. /**
  14081. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  14082. */
  14083. subtract(otherVector: Vector4): Vector4;
  14084. /**
  14085. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  14086. * Returns the current Vector4.
  14087. */
  14088. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  14089. /**
  14090. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14091. */
  14092. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14093. /**
  14094. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14095. * Returns the current Vector4.
  14096. */
  14097. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  14098. /**
  14099. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  14100. */
  14101. negate(): Vector4;
  14102. /**
  14103. * Multiplies the current Vector4 coordinates by scale (float).
  14104. * Returns the updated Vector4.
  14105. */
  14106. scaleInPlace(scale: number): Vector4;
  14107. /**
  14108. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  14109. */
  14110. scale(scale: number): Vector4;
  14111. /**
  14112. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  14113. * Returns the current Vector4.
  14114. */
  14115. scaleToRef(scale: number, result: Vector4): Vector4;
  14116. /**
  14117. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  14118. * @param scale defines the scale factor
  14119. * @param result defines the Vector4 object where to store the result
  14120. * @returns the unmodified current Vector4
  14121. */
  14122. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  14123. /**
  14124. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  14125. */
  14126. equals(otherVector: Vector4): boolean;
  14127. /**
  14128. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  14129. */
  14130. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  14131. /**
  14132. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  14133. */
  14134. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  14135. /**
  14136. * Multiplies in place the current Vector4 by the given one.
  14137. * Returns the updated Vector4.
  14138. */
  14139. multiplyInPlace(otherVector: Vector4): Vector4;
  14140. /**
  14141. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  14142. */
  14143. multiply(otherVector: Vector4): Vector4;
  14144. /**
  14145. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  14146. * Returns the current Vector4.
  14147. */
  14148. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  14149. /**
  14150. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  14151. */
  14152. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  14153. /**
  14154. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  14155. */
  14156. divide(otherVector: Vector4): Vector4;
  14157. /**
  14158. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  14159. * Returns the current Vector4.
  14160. */
  14161. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  14162. /**
  14163. * Divides the current Vector3 coordinates by the given ones.
  14164. * @returns the updated Vector3.
  14165. */
  14166. divideInPlace(otherVector: Vector4): Vector4;
  14167. /**
  14168. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  14169. * @param other defines the second operand
  14170. * @returns the current updated Vector4
  14171. */
  14172. minimizeInPlace(other: Vector4): Vector4;
  14173. /**
  14174. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  14175. * @param other defines the second operand
  14176. * @returns the current updated Vector4
  14177. */
  14178. maximizeInPlace(other: Vector4): Vector4;
  14179. /**
  14180. * Returns the Vector4 length (float).
  14181. */
  14182. length(): number;
  14183. /**
  14184. * Returns the Vector4 squared length (float).
  14185. */
  14186. lengthSquared(): number;
  14187. /**
  14188. * Normalizes in place the Vector4.
  14189. * Returns the updated Vector4.
  14190. */
  14191. normalize(): Vector4;
  14192. /**
  14193. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  14194. */
  14195. toVector3(): Vector3;
  14196. /**
  14197. * Returns a new Vector4 copied from the current one.
  14198. */
  14199. clone(): Vector4;
  14200. /**
  14201. * Updates the current Vector4 with the given one coordinates.
  14202. * Returns the updated Vector4.
  14203. */
  14204. copyFrom(source: Vector4): Vector4;
  14205. /**
  14206. * Updates the current Vector4 coordinates with the given floats.
  14207. * Returns the updated Vector4.
  14208. */
  14209. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14210. /**
  14211. * Updates the current Vector4 coordinates with the given floats.
  14212. * Returns the updated Vector4.
  14213. */
  14214. set(x: number, y: number, z: number, w: number): Vector4;
  14215. /**
  14216. * Returns a new Vector4 set from the starting index of the given array.
  14217. */
  14218. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  14219. /**
  14220. * Updates the given vector "result" from the starting index of the given array.
  14221. */
  14222. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  14223. /**
  14224. * Updates the given vector "result" from the starting index of the given Float32Array.
  14225. */
  14226. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  14227. /**
  14228. * Updates the given vector "result" coordinates from the given floats.
  14229. */
  14230. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  14231. /**
  14232. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  14233. */
  14234. static Zero(): Vector4;
  14235. /**
  14236. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  14237. */
  14238. static One(): Vector4;
  14239. /**
  14240. * Returns a new normalized Vector4 from the given one.
  14241. */
  14242. static Normalize(vector: Vector4): Vector4;
  14243. /**
  14244. * Updates the given vector "result" from the normalization of the given one.
  14245. */
  14246. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  14247. static Minimize(left: Vector4, right: Vector4): Vector4;
  14248. static Maximize(left: Vector4, right: Vector4): Vector4;
  14249. /**
  14250. * Returns the distance (float) between the vectors "value1" and "value2".
  14251. */
  14252. static Distance(value1: Vector4, value2: Vector4): number;
  14253. /**
  14254. * Returns the squared distance (float) between the vectors "value1" and "value2".
  14255. */
  14256. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  14257. /**
  14258. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  14259. */
  14260. static Center(value1: Vector4, value2: Vector4): Vector4;
  14261. /**
  14262. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  14263. * This methods computes transformed normalized direction vectors only.
  14264. */
  14265. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  14266. /**
  14267. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  14268. * This methods computes transformed normalized direction vectors only.
  14269. */
  14270. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  14271. /**
  14272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  14273. * This methods computes transformed normalized direction vectors only.
  14274. */
  14275. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  14276. }
  14277. interface ISize {
  14278. width: number;
  14279. height: number;
  14280. }
  14281. class Size implements ISize {
  14282. width: number;
  14283. height: number;
  14284. /**
  14285. * Creates a Size object from the given width and height (floats).
  14286. */
  14287. constructor(width: number, height: number);
  14288. toString(): string;
  14289. /**
  14290. * Returns the string "Size"
  14291. */
  14292. getClassName(): string;
  14293. /**
  14294. * Returns the Size hash code.
  14295. */
  14296. getHashCode(): number;
  14297. /**
  14298. * Updates the current size from the given one.
  14299. * Returns the updated Size.
  14300. */
  14301. copyFrom(src: Size): void;
  14302. /**
  14303. * Updates in place the current Size from the given floats.
  14304. * Returns the updated Size.
  14305. */
  14306. copyFromFloats(width: number, height: number): Size;
  14307. /**
  14308. * Updates in place the current Size from the given floats.
  14309. * Returns the updated Size.
  14310. */
  14311. set(width: number, height: number): Size;
  14312. /**
  14313. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  14314. */
  14315. multiplyByFloats(w: number, h: number): Size;
  14316. /**
  14317. * Returns a new Size copied from the given one.
  14318. */
  14319. clone(): Size;
  14320. /**
  14321. * Boolean : True if the current Size and the given one width and height are strictly equal.
  14322. */
  14323. equals(other: Size): boolean;
  14324. /**
  14325. * Returns the surface of the Size : width * height (float).
  14326. */
  14327. readonly surface: number;
  14328. /**
  14329. * Returns a new Size set to (0.0, 0.0)
  14330. */
  14331. static Zero(): Size;
  14332. /**
  14333. * Returns a new Size set as the addition result of the current Size and the given one.
  14334. */
  14335. add(otherSize: Size): Size;
  14336. /**
  14337. * Returns a new Size set as the subtraction result of the given one from the current Size.
  14338. */
  14339. subtract(otherSize: Size): Size;
  14340. /**
  14341. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  14342. */
  14343. static Lerp(start: Size, end: Size, amount: number): Size;
  14344. }
  14345. /**
  14346. * Class used to store quaternion data
  14347. * @see https://en.wikipedia.org/wiki/Quaternion
  14348. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  14349. */
  14350. class Quaternion {
  14351. /** defines the first component (0 by default) */
  14352. x: number;
  14353. /** defines the second component (0 by default) */
  14354. y: number;
  14355. /** defines the third component (0 by default) */
  14356. z: number;
  14357. /** defines the fourth component (1.0 by default) */
  14358. w: number;
  14359. /**
  14360. * Creates a new Quaternion from the given floats
  14361. * @param x defines the first component (0 by default)
  14362. * @param y defines the second component (0 by default)
  14363. * @param z defines the third component (0 by default)
  14364. * @param w defines the fourth component (1.0 by default)
  14365. */
  14366. constructor(
  14367. /** defines the first component (0 by default) */
  14368. x?: number,
  14369. /** defines the second component (0 by default) */
  14370. y?: number,
  14371. /** defines the third component (0 by default) */
  14372. z?: number,
  14373. /** defines the fourth component (1.0 by default) */
  14374. w?: number);
  14375. /**
  14376. * Gets a string representation for the current quaternion
  14377. * @returns a string with the Quaternion coordinates
  14378. */
  14379. toString(): string;
  14380. /**
  14381. * Gets the class name of the quaternion
  14382. * @returns the string "Quaternion"
  14383. */
  14384. getClassName(): string;
  14385. /**
  14386. * Gets a hash code for this quaternion
  14387. * @returns the quaternion hash code
  14388. */
  14389. getHashCode(): number;
  14390. /**
  14391. * Copy the quaternion to an array
  14392. * @returns a new array populated with 4 elements from the quaternion coordinates
  14393. */
  14394. asArray(): number[];
  14395. /**
  14396. * Check if two quaternions are equals
  14397. * @param otherQuaternion defines the second operand
  14398. * @return true if the current quaternion and the given one coordinates are strictly equals
  14399. */
  14400. equals(otherQuaternion: Quaternion): boolean;
  14401. /**
  14402. * Clone the current quaternion
  14403. * @returns a new quaternion copied from the current one
  14404. */
  14405. clone(): Quaternion;
  14406. /**
  14407. * Copy a quaternion to the current one
  14408. * @param other defines the other quaternion
  14409. * @returns the updated current quaternion
  14410. */
  14411. copyFrom(other: Quaternion): Quaternion;
  14412. /**
  14413. * Updates the current quaternion with the given float coordinates
  14414. * @param x defines the x coordinate
  14415. * @param y defines the y coordinate
  14416. * @param z defines the z coordinate
  14417. * @param w defines the w coordinate
  14418. * @returns the updated current quaternion
  14419. */
  14420. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  14421. /**
  14422. * Updates the current quaternion from the given float coordinates
  14423. * @param x defines the x coordinate
  14424. * @param y defines the y coordinate
  14425. * @param z defines the z coordinate
  14426. * @param w defines the w coordinate
  14427. * @returns the updated current quaternion
  14428. */
  14429. set(x: number, y: number, z: number, w: number): Quaternion;
  14430. /**
  14431. * Adds two quaternions
  14432. * @param other defines the second operand
  14433. * @returns a new quaternion as the addition result of the given one and the current quaternion
  14434. */
  14435. add(other: Quaternion): Quaternion;
  14436. /**
  14437. * Add a quaternion to the current one
  14438. * @param other defines the quaternion to add
  14439. * @returns the current quaternion
  14440. */
  14441. addInPlace(other: Quaternion): Quaternion;
  14442. /**
  14443. * Subtract two quaternions
  14444. * @param other defines the second operand
  14445. * @returns a new quaternion as the subtraction result of the given one from the current one
  14446. */
  14447. subtract(other: Quaternion): Quaternion;
  14448. /**
  14449. * Multiplies the current quaternion by a scale factor
  14450. * @param value defines the scale factor
  14451. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  14452. */
  14453. scale(value: number): Quaternion;
  14454. /**
  14455. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  14456. * @param scale defines the scale factor
  14457. * @param result defines the Quaternion object where to store the result
  14458. * @returns the unmodified current quaternion
  14459. */
  14460. scaleToRef(scale: number, result: Quaternion): Quaternion;
  14461. /**
  14462. * Multiplies in place the current quaternion by a scale factor
  14463. * @param value defines the scale factor
  14464. * @returns the current modified quaternion
  14465. */
  14466. scaleInPlace(value: number): Quaternion;
  14467. /**
  14468. * Scale the current quaternion values by a factor and add the result to a given quaternion
  14469. * @param scale defines the scale factor
  14470. * @param result defines the Quaternion object where to store the result
  14471. * @returns the unmodified current quaternion
  14472. */
  14473. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  14474. /**
  14475. * Multiplies two quaternions
  14476. * @param q1 defines the second operand
  14477. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  14478. */
  14479. multiply(q1: Quaternion): Quaternion;
  14480. /**
  14481. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  14482. * @param q1 defines the second operand
  14483. * @param result defines the target quaternion
  14484. * @returns the current quaternion
  14485. */
  14486. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  14487. /**
  14488. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  14489. * @param q1 defines the second operand
  14490. * @returns the currentupdated quaternion
  14491. */
  14492. multiplyInPlace(q1: Quaternion): Quaternion;
  14493. /**
  14494. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  14495. * @param ref defines the target quaternion
  14496. * @returns the current quaternion
  14497. */
  14498. conjugateToRef(ref: Quaternion): Quaternion;
  14499. /**
  14500. * Conjugates in place (1-q) the current quaternion
  14501. * @returns the current updated quaternion
  14502. */
  14503. conjugateInPlace(): Quaternion;
  14504. /**
  14505. * Conjugates in place (1-q) the current quaternion
  14506. * @returns a new quaternion
  14507. */
  14508. conjugate(): Quaternion;
  14509. /**
  14510. * Gets length of current quaternion
  14511. * @returns the quaternion length (float)
  14512. */
  14513. length(): number;
  14514. /**
  14515. * Normalize in place the current quaternion
  14516. * @returns the current updated quaternion
  14517. */
  14518. normalize(): Quaternion;
  14519. /**
  14520. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  14521. * @param order is a reserved parameter and is ignore for now
  14522. * @returns a new Vector3 containing the Euler angles
  14523. */
  14524. toEulerAngles(order?: string): Vector3;
  14525. /**
  14526. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  14527. * @param result defines the vector which will be filled with the Euler angles
  14528. * @param order is a reserved parameter and is ignore for now
  14529. * @returns the current unchanged quaternion
  14530. */
  14531. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  14532. /**
  14533. * Updates the given rotation matrix with the current quaternion values
  14534. * @param result defines the target matrix
  14535. * @returns the current unchanged quaternion
  14536. */
  14537. toRotationMatrix(result: Matrix): Quaternion;
  14538. /**
  14539. * Updates the current quaternion from the given rotation matrix values
  14540. * @param matrix defines the source matrix
  14541. * @returns the current updated quaternion
  14542. */
  14543. fromRotationMatrix(matrix: Matrix): Quaternion;
  14544. /**
  14545. * Creates a new quaternion from a rotation matrix
  14546. * @param matrix defines the source matrix
  14547. * @returns a new quaternion created from the given rotation matrix values
  14548. */
  14549. static FromRotationMatrix(matrix: Matrix): Quaternion;
  14550. /**
  14551. * Updates the given quaternion with the given rotation matrix values
  14552. * @param matrix defines the source matrix
  14553. * @param result defines the target quaternion
  14554. */
  14555. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  14556. /**
  14557. * Returns the dot product (float) between the quaternions "left" and "right"
  14558. * @param left defines the left operand
  14559. * @param right defines the right operand
  14560. * @returns the dot product
  14561. */
  14562. static Dot(left: Quaternion, right: Quaternion): number;
  14563. /**
  14564. * Checks if the two quaternions are close to each other
  14565. * @param quat0 defines the first quaternion to check
  14566. * @param quat1 defines the second quaternion to check
  14567. * @returns true if the two quaternions are close to each other
  14568. */
  14569. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  14570. /**
  14571. * Creates an empty quaternion
  14572. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  14573. */
  14574. static Zero(): Quaternion;
  14575. /**
  14576. * Inverse a given quaternion
  14577. * @param q defines the source quaternion
  14578. * @returns a new quaternion as the inverted current quaternion
  14579. */
  14580. static Inverse(q: Quaternion): Quaternion;
  14581. /**
  14582. * Creates an identity quaternion
  14583. * @returns the identity quaternion
  14584. */
  14585. static Identity(): Quaternion;
  14586. /**
  14587. * Gets a boolean indicating if the given quaternion is identity
  14588. * @param quaternion defines the quaternion to check
  14589. * @returns true if the quaternion is identity
  14590. */
  14591. static IsIdentity(quaternion: Quaternion): boolean;
  14592. /**
  14593. * Creates a quaternion from a rotation around an axis
  14594. * @param axis defines the axis to use
  14595. * @param angle defines the angle to use
  14596. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  14597. */
  14598. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  14599. /**
  14600. * Creates a rotation around an axis and stores it into the given quaternion
  14601. * @param axis defines the axis to use
  14602. * @param angle defines the angle to use
  14603. * @param result defines the target quaternion
  14604. * @returns the target quaternion
  14605. */
  14606. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  14607. /**
  14608. * Creates a new quaternion from data stored into an array
  14609. * @param array defines the data source
  14610. * @param offset defines the offset in the source array where the data starts
  14611. * @returns a new quaternion
  14612. */
  14613. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  14614. /**
  14615. * Creates a new quaternion from the given Euler float angles (y, x, z)
  14616. * @param yaw defines the rotation around Y axis
  14617. * @param pitch defines the rotation around X axis
  14618. * @param roll defines the rotation around Z axis
  14619. * @returns the new quaternion
  14620. */
  14621. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  14622. /**
  14623. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  14624. * @param yaw defines the rotation around Y axis
  14625. * @param pitch defines the rotation around X axis
  14626. * @param roll defines the rotation around Z axis
  14627. * @param result defines the target quaternion
  14628. */
  14629. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  14630. /**
  14631. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  14632. * @param alpha defines the rotation around first axis
  14633. * @param beta defines the rotation around second axis
  14634. * @param gamma defines the rotation around third axis
  14635. * @returns the new quaternion
  14636. */
  14637. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  14638. /**
  14639. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  14640. * @param alpha defines the rotation around first axis
  14641. * @param beta defines the rotation around second axis
  14642. * @param gamma defines the rotation around third axis
  14643. * @param result defines the target quaternion
  14644. */
  14645. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  14646. /**
  14647. * 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)
  14648. * @param axis1 defines the first axis
  14649. * @param axis2 defines the second axis
  14650. * @param axis3 defines the third axis
  14651. * @returns the new quaternion
  14652. */
  14653. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  14654. /**
  14655. * 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
  14656. * @param axis1 defines the first axis
  14657. * @param axis2 defines the second axis
  14658. * @param axis3 defines the third axis
  14659. * @param ref defines the target quaternion
  14660. */
  14661. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  14662. /**
  14663. * Interpolates between two quaternions
  14664. * @param left defines first quaternion
  14665. * @param right defines second quaternion
  14666. * @param amount defines the gradient to use
  14667. * @returns the new interpolated quaternion
  14668. */
  14669. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  14670. /**
  14671. * Interpolates between two quaternions and stores it into a target quaternion
  14672. * @param left defines first quaternion
  14673. * @param right defines second quaternion
  14674. * @param amount defines the gradient to use
  14675. * @param result defines the target quaternion
  14676. */
  14677. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  14678. /**
  14679. * Interpolate between two quaternions using Hermite interpolation
  14680. * @param value1 defines first quaternion
  14681. * @param tangent1 defines the incoming tangent
  14682. * @param value2 defines second quaternion
  14683. * @param tangent2 defines the outgoing tangent
  14684. * @param amount defines the target quaternion
  14685. * @returns the new interpolated quaternion
  14686. */
  14687. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  14688. }
  14689. /**
  14690. * Class used to store matrix data (4x4)
  14691. */
  14692. class Matrix {
  14693. private static _tempQuaternion;
  14694. private static _xAxis;
  14695. private static _yAxis;
  14696. private static _zAxis;
  14697. private static _updateFlagSeed;
  14698. private static _identityReadOnly;
  14699. private _isIdentity;
  14700. private _isIdentityDirty;
  14701. /**
  14702. * Gets the update flag of the matrix which is an unique number for the matrix.
  14703. * It will be incremented every time the matrix data change.
  14704. * You can use it to speed the comparison between two versions of the same matrix.
  14705. */
  14706. updateFlag: number;
  14707. /**
  14708. * Gets or sets the internal data of the matrix
  14709. */
  14710. m: Float32Array;
  14711. /** @hidden */
  14712. _markAsUpdated(): void;
  14713. /**
  14714. * Creates an empty matrix (filled with zeros)
  14715. */
  14716. constructor();
  14717. /**
  14718. * Check if the current matrix is indentity
  14719. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  14720. * @returns true is the matrix is the identity matrix
  14721. */
  14722. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  14723. /**
  14724. * Gets the determinant of the matrix
  14725. * @returns the matrix determinant
  14726. */
  14727. determinant(): number;
  14728. /**
  14729. * Returns the matrix as a Float32Array
  14730. * @returns the matrix underlying array
  14731. */
  14732. toArray(): Float32Array;
  14733. /**
  14734. * Returns the matrix as a Float32Array
  14735. * @returns the matrix underlying array.
  14736. */
  14737. asArray(): Float32Array;
  14738. /**
  14739. * Inverts the current matrix in place
  14740. * @returns the current inverted matrix
  14741. */
  14742. invert(): Matrix;
  14743. /**
  14744. * Sets all the matrix elements to zero
  14745. * @returns the current matrix
  14746. */
  14747. reset(): Matrix;
  14748. /**
  14749. * Adds the current matrix with a second one
  14750. * @param other defines the matrix to add
  14751. * @returns a new matrix as the addition of the current matrix and the given one
  14752. */
  14753. add(other: Matrix): Matrix;
  14754. /**
  14755. * Sets the given matrix "result" to the addition of the current matrix and the given one
  14756. * @param other defines the matrix to add
  14757. * @param result defines the target matrix
  14758. * @returns the current matrix
  14759. */
  14760. addToRef(other: Matrix, result: Matrix): Matrix;
  14761. /**
  14762. * Adds in place the given matrix to the current matrix
  14763. * @param other defines the second operand
  14764. * @returns the current updated matrix
  14765. */
  14766. addToSelf(other: Matrix): Matrix;
  14767. /**
  14768. * Sets the given matrix to the current inverted Matrix
  14769. * @param other defines the target matrix
  14770. * @returns the unmodified current matrix
  14771. */
  14772. invertToRef(other: Matrix): Matrix;
  14773. /**
  14774. * Inserts the translation vector (using 3 floats) in the current matrix
  14775. * @param x defines the 1st component of the translation
  14776. * @param y defines the 2nd component of the translation
  14777. * @param z defines the 3rd component of the translation
  14778. * @returns the current updated matrix
  14779. */
  14780. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  14781. /**
  14782. * Inserts the translation vector in the current matrix
  14783. * @param vector3 defines the translation to insert
  14784. * @returns the current updated matrix
  14785. */
  14786. setTranslation(vector3: Vector3): Matrix;
  14787. /**
  14788. * Gets the translation value of the current matrix
  14789. * @returns a new Vector3 as the extracted translation from the matrix
  14790. */
  14791. getTranslation(): Vector3;
  14792. /**
  14793. * Fill a Vector3 with the extracted translation from the matrix
  14794. * @param result defines the Vector3 where to store the translation
  14795. * @returns the current matrix
  14796. */
  14797. getTranslationToRef(result: Vector3): Matrix;
  14798. /**
  14799. * Remove rotation and scaling part from the matrix
  14800. * @returns the updated matrix
  14801. */
  14802. removeRotationAndScaling(): Matrix;
  14803. /**
  14804. * Multiply two matrices
  14805. * @param other defines the second operand
  14806. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  14807. */
  14808. multiply(other: Matrix): Matrix;
  14809. /**
  14810. * Copy the current matrix from the given one
  14811. * @param other defines the source matrix
  14812. * @returns the current updated matrix
  14813. */
  14814. copyFrom(other: Matrix): Matrix;
  14815. /**
  14816. * Populates the given array from the starting index with the current matrix values
  14817. * @param array defines the target array
  14818. * @param offset defines the offset in the target array where to start storing values
  14819. * @returns the current matrix
  14820. */
  14821. copyToArray(array: Float32Array, offset?: number): Matrix;
  14822. /**
  14823. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  14824. * @param other defines the second operand
  14825. * @param result defines the matrix where to store the multiplication
  14826. * @returns the current matrix
  14827. */
  14828. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  14829. /**
  14830. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  14831. * @param other defines the second operand
  14832. * @param result defines the array where to store the multiplication
  14833. * @param offset defines the offset in the target array where to start storing values
  14834. * @returns the current matrix
  14835. */
  14836. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  14837. /**
  14838. * Check equality between this matrix and a second one
  14839. * @param value defines the second matrix to compare
  14840. * @returns true is the current matrix and the given one values are strictly equal
  14841. */
  14842. equals(value: Matrix): boolean;
  14843. /**
  14844. * Clone the current matrix
  14845. * @returns a new matrix from the current matrix
  14846. */
  14847. clone(): Matrix;
  14848. /**
  14849. * Returns the name of the current matrix class
  14850. * @returns the string "Matrix"
  14851. */
  14852. getClassName(): string;
  14853. /**
  14854. * Gets the hash code of the current matrix
  14855. * @returns the hash code
  14856. */
  14857. getHashCode(): number;
  14858. /**
  14859. * Decomposes the current Matrix into a translation, rotation and scaling components
  14860. * @param scale defines the scale vector3 given as a reference to update
  14861. * @param rotation defines the rotation quaternion given as a reference to update
  14862. * @param translation defines the translation vector3 given as a reference to update
  14863. * @returns true if operation was successful
  14864. */
  14865. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  14866. /**
  14867. * Gets specific row of the matrix
  14868. * @param index defines the number of the row to get
  14869. * @returns the index-th row of the current matrix as a new Vector4
  14870. */
  14871. getRow(index: number): Nullable<Vector4>;
  14872. /**
  14873. * Sets the index-th row of the current matrix to the vector4 values
  14874. * @param index defines the number of the row to set
  14875. * @param row defines the target vector4
  14876. * @returns the updated current matrix
  14877. */
  14878. setRow(index: number, row: Vector4): Matrix;
  14879. /**
  14880. * Compute the transpose of the matrix
  14881. * @returns the new transposed matrix
  14882. */
  14883. transpose(): Matrix;
  14884. /**
  14885. * Compute the transpose of the matrix and store it in a given matrix
  14886. * @param result defines the target matrix
  14887. * @returns the current matrix
  14888. */
  14889. transposeToRef(result: Matrix): Matrix;
  14890. /**
  14891. * Sets the index-th row of the current matrix with the given 4 x float values
  14892. * @param index defines the row index
  14893. * @param x defines the x component to set
  14894. * @param y defines the y component to set
  14895. * @param z defines the z component to set
  14896. * @param w defines the w component to set
  14897. * @returns the updated current matrix
  14898. */
  14899. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  14900. /**
  14901. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  14902. * @param scale defines the scale factor
  14903. * @returns a new matrix
  14904. */
  14905. scale(scale: number): Matrix;
  14906. /**
  14907. * Scale the current matrix values by a factor to a given result matrix
  14908. * @param scale defines the scale factor
  14909. * @param result defines the matrix to store the result
  14910. * @returns the current matrix
  14911. */
  14912. scaleToRef(scale: number, result: Matrix): Matrix;
  14913. /**
  14914. * Scale the current matrix values by a factor and add the result to a given matrix
  14915. * @param scale defines the scale factor
  14916. * @param result defines the Matrix to store the result
  14917. * @returns the current matrix
  14918. */
  14919. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  14920. /**
  14921. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  14922. * @param ref matrix to store the result
  14923. */
  14924. toNormalMatrix(ref: Matrix): void;
  14925. /**
  14926. * Gets only rotation part of the current matrix
  14927. * @returns a new matrix sets to the extracted rotation matrix from the current one
  14928. */
  14929. getRotationMatrix(): Matrix;
  14930. /**
  14931. * Extracts the rotation matrix from the current one and sets it as the given "result"
  14932. * @param result defines the target matrix to store data to
  14933. * @returns the current matrix
  14934. */
  14935. getRotationMatrixToRef(result: Matrix): Matrix;
  14936. /**
  14937. * Creates a matrix from an array
  14938. * @param array defines the source array
  14939. * @param offset defines an offset in the source array
  14940. * @returns a new Matrix set from the starting index of the given array
  14941. */
  14942. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  14943. /**
  14944. * Copy the content of an array into a given matrix
  14945. * @param array defines the source array
  14946. * @param offset defines an offset in the source array
  14947. * @param result defines the target matrix
  14948. */
  14949. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  14950. /**
  14951. * Stores an array into a matrix after having multiplied each component by a given factor
  14952. * @param array defines the source array
  14953. * @param offset defines the offset in the source array
  14954. * @param scale defines the scaling factor
  14955. * @param result defines the target matrix
  14956. */
  14957. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  14958. /**
  14959. * Stores a list of values (16) inside a given matrix
  14960. * @param initialM11 defines 1st value of 1st row
  14961. * @param initialM12 defines 2nd value of 1st row
  14962. * @param initialM13 defines 3rd value of 1st row
  14963. * @param initialM14 defines 4th value of 1st row
  14964. * @param initialM21 defines 1st value of 2nd row
  14965. * @param initialM22 defines 2nd value of 2nd row
  14966. * @param initialM23 defines 3rd value of 2nd row
  14967. * @param initialM24 defines 4th value of 2nd row
  14968. * @param initialM31 defines 1st value of 3rd row
  14969. * @param initialM32 defines 2nd value of 3rd row
  14970. * @param initialM33 defines 3rd value of 3rd row
  14971. * @param initialM34 defines 4th value of 3rd row
  14972. * @param initialM41 defines 1st value of 4th row
  14973. * @param initialM42 defines 2nd value of 4th row
  14974. * @param initialM43 defines 3rd value of 4th row
  14975. * @param initialM44 defines 4th value of 4th row
  14976. * @param result defines the target matrix
  14977. */
  14978. 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;
  14979. /**
  14980. * Gets an identity matrix that must not be updated
  14981. */
  14982. static readonly IdentityReadOnly: Matrix;
  14983. /**
  14984. * Creates new matrix from a list of values (16)
  14985. * @param initialM11 defines 1st value of 1st row
  14986. * @param initialM12 defines 2nd value of 1st row
  14987. * @param initialM13 defines 3rd value of 1st row
  14988. * @param initialM14 defines 4th value of 1st row
  14989. * @param initialM21 defines 1st value of 2nd row
  14990. * @param initialM22 defines 2nd value of 2nd row
  14991. * @param initialM23 defines 3rd value of 2nd row
  14992. * @param initialM24 defines 4th value of 2nd row
  14993. * @param initialM31 defines 1st value of 3rd row
  14994. * @param initialM32 defines 2nd value of 3rd row
  14995. * @param initialM33 defines 3rd value of 3rd row
  14996. * @param initialM34 defines 4th value of 3rd row
  14997. * @param initialM41 defines 1st value of 4th row
  14998. * @param initialM42 defines 2nd value of 4th row
  14999. * @param initialM43 defines 3rd value of 4th row
  15000. * @param initialM44 defines 4th value of 4th row
  15001. * @returns the new matrix
  15002. */
  15003. 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;
  15004. /**
  15005. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15006. * @param scale defines the scale vector3
  15007. * @param rotation defines the rotation quaternion
  15008. * @param translation defines the translation vector3
  15009. * @returns a new matrix
  15010. */
  15011. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  15012. /**
  15013. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15014. * @param scale defines the scale vector3
  15015. * @param rotation defines the rotation quaternion
  15016. * @param translation defines the translation vector3
  15017. * @param result defines the target matrix
  15018. */
  15019. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  15020. /**
  15021. * Creates a new identity matrix
  15022. * @returns a new identity matrix
  15023. */
  15024. static Identity(): Matrix;
  15025. /**
  15026. * Creates a new identity matrix and stores the result in a given matrix
  15027. * @param result defines the target matrix
  15028. */
  15029. static IdentityToRef(result: Matrix): void;
  15030. /**
  15031. * Creates a new zero matrix
  15032. * @returns a new zero matrix
  15033. */
  15034. static Zero(): Matrix;
  15035. /**
  15036. * Creates a new rotation matrix for "angle" radians around the X axis
  15037. * @param angle defines the angle (in radians) to use
  15038. * @return the new matrix
  15039. */
  15040. static RotationX(angle: number): Matrix;
  15041. /**
  15042. * Creates a new matrix as the invert of a given matrix
  15043. * @param source defines the source matrix
  15044. * @returns the new matrix
  15045. */
  15046. static Invert(source: Matrix): Matrix;
  15047. /**
  15048. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  15049. * @param angle defines the angle (in radians) to use
  15050. * @param result defines the target matrix
  15051. */
  15052. static RotationXToRef(angle: number, result: Matrix): void;
  15053. /**
  15054. * Creates a new rotation matrix for "angle" radians around the Y axis
  15055. * @param angle defines the angle (in radians) to use
  15056. * @return the new matrix
  15057. */
  15058. static RotationY(angle: number): Matrix;
  15059. /**
  15060. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  15061. * @param angle defines the angle (in radians) to use
  15062. * @param result defines the target matrix
  15063. */
  15064. static RotationYToRef(angle: number, result: Matrix): void;
  15065. /**
  15066. * Creates a new rotation matrix for "angle" radians around the Z axis
  15067. * @param angle defines the angle (in radians) to use
  15068. * @return the new matrix
  15069. */
  15070. static RotationZ(angle: number): Matrix;
  15071. /**
  15072. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  15073. * @param angle defines the angle (in radians) to use
  15074. * @param result defines the target matrix
  15075. */
  15076. static RotationZToRef(angle: number, result: Matrix): void;
  15077. /**
  15078. * Creates a new rotation matrix for "angle" radians around the given axis
  15079. * @param axis defines the axis to use
  15080. * @param angle defines the angle (in radians) to use
  15081. * @return the new matrix
  15082. */
  15083. static RotationAxis(axis: Vector3, angle: number): Matrix;
  15084. /**
  15085. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  15086. * @param axis defines the axis to use
  15087. * @param angle defines the angle (in radians) to use
  15088. * @param result defines the target matrix
  15089. */
  15090. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  15091. /**
  15092. * Creates a rotation matrix
  15093. * @param yaw defines the yaw angle in radians (Y axis)
  15094. * @param pitch defines the pitch angle in radians (X axis)
  15095. * @param roll defines the roll angle in radians (X axis)
  15096. * @returns the new rotation matrix
  15097. */
  15098. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  15099. /**
  15100. * Creates a rotation matrix and stores it in a given matrix
  15101. * @param yaw defines the yaw angle in radians (Y axis)
  15102. * @param pitch defines the pitch angle in radians (X axis)
  15103. * @param roll defines the roll angle in radians (X axis)
  15104. * @param result defines the target matrix
  15105. */
  15106. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  15107. /**
  15108. * Creates a scaling matrix
  15109. * @param x defines the scale factor on X axis
  15110. * @param y defines the scale factor on Y axis
  15111. * @param z defines the scale factor on Z axis
  15112. * @returns the new matrix
  15113. */
  15114. static Scaling(x: number, y: number, z: number): Matrix;
  15115. /**
  15116. * Creates a scaling matrix and stores it in a given matrix
  15117. * @param x defines the scale factor on X axis
  15118. * @param y defines the scale factor on Y axis
  15119. * @param z defines the scale factor on Z axis
  15120. * @param result defines the target matrix
  15121. */
  15122. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  15123. /**
  15124. * Creates a translation matrix
  15125. * @param x defines the translation on X axis
  15126. * @param y defines the translation on Y axis
  15127. * @param z defines the translationon Z axis
  15128. * @returns the new matrix
  15129. */
  15130. static Translation(x: number, y: number, z: number): Matrix;
  15131. /**
  15132. * Creates a translation matrix and stores it in a given matrix
  15133. * @param x defines the translation on X axis
  15134. * @param y defines the translation on Y axis
  15135. * @param z defines the translationon Z axis
  15136. * @param result defines the target matrix
  15137. */
  15138. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  15139. /**
  15140. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15141. * @param startValue defines the start value
  15142. * @param endValue defines the end value
  15143. * @param gradient defines the gradient factor
  15144. * @returns the new matrix
  15145. */
  15146. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15147. /**
  15148. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15149. * @param startValue defines the start value
  15150. * @param endValue defines the end value
  15151. * @param gradient defines the gradient factor
  15152. * @param result defines the Matrix object where to store data
  15153. */
  15154. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  15155. /**
  15156. * Builds a new matrix whose values are computed by:
  15157. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  15158. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  15159. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  15160. * @param startValue defines the first matrix
  15161. * @param endValue defines the second matrix
  15162. * @param gradient defines the gradient between the two matrices
  15163. * @returns the new matrix
  15164. */
  15165. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15166. /**
  15167. * Update a matrix to values which are computed by:
  15168. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  15169. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  15170. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  15171. * @param startValue defines the first matrix
  15172. * @param endValue defines the second matrix
  15173. * @param gradient defines the gradient between the two matrices
  15174. * @param result defines the target matrix
  15175. */
  15176. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  15177. /**
  15178. * 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"
  15179. * This function works in left handed mode
  15180. * @param eye defines the final position of the entity
  15181. * @param target defines where the entity should look at
  15182. * @param up defines the up vector for the entity
  15183. * @returns the new matrix
  15184. */
  15185. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  15186. /**
  15187. * 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".
  15188. * This function works in left handed mode
  15189. * @param eye defines the final position of the entity
  15190. * @param target defines where the entity should look at
  15191. * @param up defines the up vector for the entity
  15192. * @param result defines the target matrix
  15193. */
  15194. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  15195. /**
  15196. * 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"
  15197. * This function works in right handed mode
  15198. * @param eye defines the final position of the entity
  15199. * @param target defines where the entity should look at
  15200. * @param up defines the up vector for the entity
  15201. * @returns the new matrix
  15202. */
  15203. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  15204. /**
  15205. * 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".
  15206. * This function works in right handed mode
  15207. * @param eye defines the final position of the entity
  15208. * @param target defines where the entity should look at
  15209. * @param up defines the up vector for the entity
  15210. * @param result defines the target matrix
  15211. */
  15212. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  15213. /**
  15214. * Create a left-handed orthographic projection matrix
  15215. * @param width defines the viewport width
  15216. * @param height defines the viewport height
  15217. * @param znear defines the near clip plane
  15218. * @param zfar defines the far clip plane
  15219. * @returns a new matrix as a left-handed orthographic projection matrix
  15220. */
  15221. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  15222. /**
  15223. * Store a left-handed orthographic projection to a given matrix
  15224. * @param width defines the viewport width
  15225. * @param height defines the viewport height
  15226. * @param znear defines the near clip plane
  15227. * @param zfar defines the far clip plane
  15228. * @param result defines the target matrix
  15229. */
  15230. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  15231. /**
  15232. * Create a left-handed orthographic projection matrix
  15233. * @param left defines the viewport left coordinate
  15234. * @param right defines the viewport right coordinate
  15235. * @param bottom defines the viewport bottom coordinate
  15236. * @param top defines the viewport top coordinate
  15237. * @param znear defines the near clip plane
  15238. * @param zfar defines the far clip plane
  15239. * @returns a new matrix as a left-handed orthographic projection matrix
  15240. */
  15241. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  15242. /**
  15243. * Stores a left-handed orthographic projection into a given matrix
  15244. * @param left defines the viewport left coordinate
  15245. * @param right defines the viewport right coordinate
  15246. * @param bottom defines the viewport bottom coordinate
  15247. * @param top defines the viewport top coordinate
  15248. * @param znear defines the near clip plane
  15249. * @param zfar defines the far clip plane
  15250. * @param result defines the target matrix
  15251. */
  15252. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  15253. /**
  15254. * Creates a right-handed orthographic projection matrix
  15255. * @param left defines the viewport left coordinate
  15256. * @param right defines the viewport right coordinate
  15257. * @param bottom defines the viewport bottom coordinate
  15258. * @param top defines the viewport top coordinate
  15259. * @param znear defines the near clip plane
  15260. * @param zfar defines the far clip plane
  15261. * @returns a new matrix as a right-handed orthographic projection matrix
  15262. */
  15263. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  15264. /**
  15265. * Stores a right-handed orthographic projection into a given matrix
  15266. * @param left defines the viewport left coordinate
  15267. * @param right defines the viewport right coordinate
  15268. * @param bottom defines the viewport bottom coordinate
  15269. * @param top defines the viewport top coordinate
  15270. * @param znear defines the near clip plane
  15271. * @param zfar defines the far clip plane
  15272. * @param result defines the target matrix
  15273. */
  15274. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  15275. /**
  15276. * Creates a left-handed perspective projection matrix
  15277. * @param width defines the viewport width
  15278. * @param height defines the viewport height
  15279. * @param znear defines the near clip plane
  15280. * @param zfar defines the far clip plane
  15281. * @returns a new matrix as a left-handed perspective projection matrix
  15282. */
  15283. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  15284. /**
  15285. * Creates a left-handed perspective projection matrix
  15286. * @param fov defines the horizontal field of view
  15287. * @param aspect defines the aspect ratio
  15288. * @param znear defines the near clip plane
  15289. * @param zfar defines the far clip plane
  15290. * @returns a new matrix as a left-handed perspective projection matrix
  15291. */
  15292. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15293. /**
  15294. * Stores a left-handed perspective projection into a given matrix
  15295. * @param fov defines the horizontal field of view
  15296. * @param aspect defines the aspect ratio
  15297. * @param znear defines the near clip plane
  15298. * @param zfar defines the far clip plane
  15299. * @param result defines the target matrix
  15300. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  15301. */
  15302. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15303. /**
  15304. * Creates a right-handed perspective projection matrix
  15305. * @param fov defines the horizontal field of view
  15306. * @param aspect defines the aspect ratio
  15307. * @param znear defines the near clip plane
  15308. * @param zfar defines the far clip plane
  15309. * @returns a new matrix as a right-handed perspective projection matrix
  15310. */
  15311. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15312. /**
  15313. * Stores a right-handed perspective projection into a given matrix
  15314. * @param fov defines the horizontal field of view
  15315. * @param aspect defines the aspect ratio
  15316. * @param znear defines the near clip plane
  15317. * @param zfar defines the far clip plane
  15318. * @param result defines the target matrix
  15319. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  15320. */
  15321. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15322. /**
  15323. * Stores a perspective projection for WebVR info a given matrix
  15324. * @param fov defines the field of view
  15325. * @param znear defines the near clip plane
  15326. * @param zfar defines the far clip plane
  15327. * @param result defines the target matrix
  15328. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  15329. */
  15330. static PerspectiveFovWebVRToRef(fov: {
  15331. upDegrees: number;
  15332. downDegrees: number;
  15333. leftDegrees: number;
  15334. rightDegrees: number;
  15335. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  15336. /**
  15337. * Computes a complete transformation matrix
  15338. * @param viewport defines the viewport to use
  15339. * @param world defines the world matrix
  15340. * @param view defines the view matrix
  15341. * @param projection defines the projection matrix
  15342. * @param zmin defines the near clip plane
  15343. * @param zmax defines the far clip plane
  15344. * @returns the transformation matrix
  15345. */
  15346. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  15347. /**
  15348. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  15349. * @param matrix defines the matrix to use
  15350. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  15351. */
  15352. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  15353. /**
  15354. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  15355. * @param matrix defines the matrix to use
  15356. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  15357. */
  15358. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  15359. /**
  15360. * Compute the transpose of a given matrix
  15361. * @param matrix defines the matrix to transpose
  15362. * @returns the new matrix
  15363. */
  15364. static Transpose(matrix: Matrix): Matrix;
  15365. /**
  15366. * Compute the transpose of a matrix and store it in a target matrix
  15367. * @param matrix defines the matrix to transpose
  15368. * @param result defines the target matrix
  15369. */
  15370. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  15371. /**
  15372. * Computes a reflection matrix from a plane
  15373. * @param plane defines the reflection plane
  15374. * @returns a new matrix
  15375. */
  15376. static Reflection(plane: Plane): Matrix;
  15377. /**
  15378. * Computes a reflection matrix from a plane
  15379. * @param plane defines the reflection plane
  15380. * @param result defines the target matrix
  15381. */
  15382. static ReflectionToRef(plane: Plane, result: Matrix): void;
  15383. /**
  15384. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  15385. * @param xaxis defines the value of the 1st axis
  15386. * @param yaxis defines the value of the 2nd axis
  15387. * @param zaxis defines the value of the 3rd axis
  15388. * @param result defines the target matrix
  15389. */
  15390. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  15391. /**
  15392. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  15393. * @param quat defines the quaternion to use
  15394. * @param result defines the target matrix
  15395. */
  15396. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  15397. }
  15398. class Plane {
  15399. normal: Vector3;
  15400. d: number;
  15401. /**
  15402. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  15403. */
  15404. constructor(a: number, b: number, c: number, d: number);
  15405. /**
  15406. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  15407. */
  15408. asArray(): number[];
  15409. /**
  15410. * Returns a new plane copied from the current Plane.
  15411. */
  15412. clone(): Plane;
  15413. /**
  15414. * Returns the string "Plane".
  15415. */
  15416. getClassName(): string;
  15417. /**
  15418. * Returns the Plane hash code.
  15419. */
  15420. getHashCode(): number;
  15421. /**
  15422. * Normalize the current Plane in place.
  15423. * Returns the updated Plane.
  15424. */
  15425. normalize(): Plane;
  15426. /**
  15427. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  15428. */
  15429. transform(transformation: Matrix): Plane;
  15430. /**
  15431. * Returns the dot product (float) of the point coordinates and the plane normal.
  15432. */
  15433. dotCoordinate(point: Vector3): number;
  15434. /**
  15435. * Updates the current Plane from the plane defined by the three given points.
  15436. * Returns the updated Plane.
  15437. */
  15438. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15439. /**
  15440. * Boolean : True is the vector "direction" is the same side than the plane normal.
  15441. */
  15442. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  15443. /**
  15444. * Returns the signed distance (float) from the given point to the Plane.
  15445. */
  15446. signedDistanceTo(point: Vector3): number;
  15447. /**
  15448. * Returns a new Plane from the given array.
  15449. */
  15450. static FromArray(array: ArrayLike<number>): Plane;
  15451. /**
  15452. * Returns a new Plane defined by the three given points.
  15453. */
  15454. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15455. /**
  15456. * Returns a new Plane the normal vector to this plane at the given origin point.
  15457. * Note : the vector "normal" is updated because normalized.
  15458. */
  15459. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  15460. /**
  15461. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  15462. */
  15463. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  15464. }
  15465. class Viewport {
  15466. x: number;
  15467. y: number;
  15468. width: number;
  15469. height: number;
  15470. /**
  15471. * Creates a Viewport object located at (x, y) and sized (width, height).
  15472. */
  15473. constructor(x: number, y: number, width: number, height: number);
  15474. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  15475. /**
  15476. * Returns a new Viewport copied from the current one.
  15477. */
  15478. clone(): Viewport;
  15479. }
  15480. class Frustum {
  15481. /**
  15482. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15483. */
  15484. static GetPlanes(transform: Matrix): Plane[];
  15485. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15486. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15487. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15488. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15489. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15490. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15491. /**
  15492. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15493. */
  15494. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  15495. }
  15496. /** Defines supported spaces */
  15497. enum Space {
  15498. /** Local (object) space */
  15499. LOCAL = 0,
  15500. /** World space */
  15501. WORLD = 1,
  15502. /** Bone space */
  15503. BONE = 2,
  15504. }
  15505. /** Defines the 3 main axes */
  15506. class Axis {
  15507. /** X axis */
  15508. static X: Vector3;
  15509. /** Y axis */
  15510. static Y: Vector3;
  15511. /** Z axis */
  15512. static Z: Vector3;
  15513. }
  15514. class BezierCurve {
  15515. /**
  15516. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  15517. */
  15518. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  15519. }
  15520. /**
  15521. * Defines potential orientation for back face culling
  15522. */
  15523. enum Orientation {
  15524. /**
  15525. * Clockwise
  15526. */
  15527. CW = 0,
  15528. /** Counter clockwise */
  15529. CCW = 1,
  15530. }
  15531. /**
  15532. * Defines angle representation
  15533. */
  15534. class Angle {
  15535. private _radians;
  15536. /**
  15537. * Creates an Angle object of "radians" radians (float).
  15538. */
  15539. constructor(radians: number);
  15540. /**
  15541. * Get value in degrees
  15542. * @returns the Angle value in degrees (float)
  15543. */
  15544. degrees(): number;
  15545. /**
  15546. * Get value in radians
  15547. * @returns the Angle value in radians (float)
  15548. */
  15549. radians(): number;
  15550. /**
  15551. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  15552. * @param a defines first vector
  15553. * @param b defines second vector
  15554. * @returns a new Angle
  15555. */
  15556. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  15557. /**
  15558. * Gets a new Angle object from the given float in radians
  15559. * @param radians defines the angle value in radians
  15560. * @returns a new Angle
  15561. */
  15562. static FromRadians(radians: number): Angle;
  15563. /**
  15564. * Gets a new Angle object from the given float in degrees
  15565. * @param degrees defines the angle value in degrees
  15566. * @returns a new Angle
  15567. */
  15568. static FromDegrees(degrees: number): Angle;
  15569. }
  15570. class Arc2 {
  15571. startPoint: Vector2;
  15572. midPoint: Vector2;
  15573. endPoint: Vector2;
  15574. centerPoint: Vector2;
  15575. radius: number;
  15576. angle: Angle;
  15577. startAngle: Angle;
  15578. orientation: Orientation;
  15579. /**
  15580. * Creates an Arc object from the three given points : start, middle and end.
  15581. */
  15582. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  15583. }
  15584. class Path2 {
  15585. private _points;
  15586. private _length;
  15587. closed: boolean;
  15588. /**
  15589. * Creates a Path2 object from the starting 2D coordinates x and y.
  15590. */
  15591. constructor(x: number, y: number);
  15592. /**
  15593. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  15594. * Returns the updated Path2.
  15595. */
  15596. addLineTo(x: number, y: number): Path2;
  15597. /**
  15598. * 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.
  15599. * Returns the updated Path2.
  15600. */
  15601. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  15602. /**
  15603. * Closes the Path2.
  15604. * Returns the Path2.
  15605. */
  15606. close(): Path2;
  15607. /**
  15608. * Returns the Path2 total length (float).
  15609. */
  15610. length(): number;
  15611. /**
  15612. * Returns the Path2 internal array of points.
  15613. */
  15614. getPoints(): Vector2[];
  15615. /**
  15616. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  15617. */
  15618. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  15619. /**
  15620. * Returns a new Path2 starting at the coordinates (x, y).
  15621. */
  15622. static StartingAt(x: number, y: number): Path2;
  15623. }
  15624. class Path3D {
  15625. path: Vector3[];
  15626. private _curve;
  15627. private _distances;
  15628. private _tangents;
  15629. private _normals;
  15630. private _binormals;
  15631. private _raw;
  15632. /**
  15633. * new Path3D(path, normal, raw)
  15634. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  15635. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  15636. * path : an array of Vector3, the curve axis of the Path3D
  15637. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  15638. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  15639. */
  15640. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  15641. /**
  15642. * Returns the Path3D array of successive Vector3 designing its curve.
  15643. */
  15644. getCurve(): Vector3[];
  15645. /**
  15646. * Returns an array populated with tangent vectors on each Path3D curve point.
  15647. */
  15648. getTangents(): Vector3[];
  15649. /**
  15650. * Returns an array populated with normal vectors on each Path3D curve point.
  15651. */
  15652. getNormals(): Vector3[];
  15653. /**
  15654. * Returns an array populated with binormal vectors on each Path3D curve point.
  15655. */
  15656. getBinormals(): Vector3[];
  15657. /**
  15658. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  15659. */
  15660. getDistances(): number[];
  15661. /**
  15662. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  15663. * Returns the same object updated.
  15664. */
  15665. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  15666. private _compute(firstNormal);
  15667. private _getFirstNonNullVector(index);
  15668. private _getLastNonNullVector(index);
  15669. private _normalVector(v0, vt, va);
  15670. }
  15671. class Curve3 {
  15672. private _points;
  15673. private _length;
  15674. /**
  15675. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  15676. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  15677. * @param v1 (Vector3) the control point
  15678. * @param v2 (Vector3) the end point of the Quadratic Bezier
  15679. * @param nbPoints (integer) the wanted number of points in the curve
  15680. */
  15681. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  15682. /**
  15683. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  15684. * @param v0 (Vector3) the origin point of the Cubic Bezier
  15685. * @param v1 (Vector3) the first control point
  15686. * @param v2 (Vector3) the second control point
  15687. * @param v3 (Vector3) the end point of the Cubic Bezier
  15688. * @param nbPoints (integer) the wanted number of points in the curve
  15689. */
  15690. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  15691. /**
  15692. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  15693. * @param p1 (Vector3) the origin point of the Hermite Spline
  15694. * @param t1 (Vector3) the tangent vector at the origin point
  15695. * @param p2 (Vector3) the end point of the Hermite Spline
  15696. * @param t2 (Vector3) the tangent vector at the end point
  15697. * @param nbPoints (integer) the wanted number of points in the curve
  15698. */
  15699. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  15700. /**
  15701. * Returns a Curve3 object along a CatmullRom Spline curve :
  15702. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  15703. * @param nbPoints (integer) the wanted number of points between each curve control points
  15704. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  15705. */
  15706. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  15707. /**
  15708. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  15709. * A Curve3 is designed from a series of successive Vector3.
  15710. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  15711. */
  15712. constructor(points: Vector3[]);
  15713. /**
  15714. * Returns the Curve3 stored array of successive Vector3
  15715. */
  15716. getPoints(): Vector3[];
  15717. /**
  15718. * Returns the computed length (float) of the curve.
  15719. */
  15720. length(): number;
  15721. /**
  15722. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  15723. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  15724. * curveA and curveB keep unchanged.
  15725. */
  15726. continue(curve: Curve3): Curve3;
  15727. private _computeLength(path);
  15728. }
  15729. class PositionNormalVertex {
  15730. position: Vector3;
  15731. normal: Vector3;
  15732. constructor(position?: Vector3, normal?: Vector3);
  15733. clone(): PositionNormalVertex;
  15734. }
  15735. class PositionNormalTextureVertex {
  15736. position: Vector3;
  15737. normal: Vector3;
  15738. uv: Vector2;
  15739. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  15740. clone(): PositionNormalTextureVertex;
  15741. }
  15742. class Tmp {
  15743. static Color3: Color3[];
  15744. static Vector2: Vector2[];
  15745. static Vector3: Vector3[];
  15746. static Vector4: Vector4[];
  15747. static Quaternion: Quaternion[];
  15748. static Matrix: Matrix[];
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. class SphericalPolynomial {
  15753. x: Vector3;
  15754. y: Vector3;
  15755. z: Vector3;
  15756. xx: Vector3;
  15757. yy: Vector3;
  15758. zz: Vector3;
  15759. xy: Vector3;
  15760. yz: Vector3;
  15761. zx: Vector3;
  15762. addAmbient(color: Color3): void;
  15763. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  15764. scale(scale: number): void;
  15765. }
  15766. class SphericalHarmonics {
  15767. L00: Vector3;
  15768. L1_1: Vector3;
  15769. L10: Vector3;
  15770. L11: Vector3;
  15771. L2_2: Vector3;
  15772. L2_1: Vector3;
  15773. L20: Vector3;
  15774. L21: Vector3;
  15775. L22: Vector3;
  15776. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  15777. scale(scale: number): void;
  15778. convertIncidentRadianceToIrradiance(): void;
  15779. convertIrradianceToLambertianRadiance(): void;
  15780. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  15781. }
  15782. }
  15783. declare module BABYLON {
  15784. class LensFlare {
  15785. size: number;
  15786. position: number;
  15787. color: Color3;
  15788. texture: Nullable<Texture>;
  15789. alphaMode: number;
  15790. private _system;
  15791. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15792. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15793. dispose(): void;
  15794. }
  15795. }
  15796. declare module BABYLON {
  15797. class LensFlareSystem {
  15798. name: string;
  15799. lensFlares: LensFlare[];
  15800. borderLimit: number;
  15801. viewportBorder: number;
  15802. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15803. layerMask: number;
  15804. id: string;
  15805. private _scene;
  15806. private _emitter;
  15807. private _vertexBuffers;
  15808. private _indexBuffer;
  15809. private _effect;
  15810. private _positionX;
  15811. private _positionY;
  15812. private _isEnabled;
  15813. constructor(name: string, emitter: any, scene: Scene);
  15814. isEnabled: boolean;
  15815. getScene(): Scene;
  15816. getEmitter(): any;
  15817. setEmitter(newEmitter: any): void;
  15818. getEmitterPosition(): Vector3;
  15819. computeEffectivePosition(globalViewport: Viewport): boolean;
  15820. _isVisible(): boolean;
  15821. render(): boolean;
  15822. dispose(): void;
  15823. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15824. serialize(): any;
  15825. }
  15826. }
  15827. declare module BABYLON {
  15828. /**
  15829. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15830. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15831. * 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;
  15832. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15833. */
  15834. class ColorCurves {
  15835. private _dirty;
  15836. private _tempColor;
  15837. private _globalCurve;
  15838. private _highlightsCurve;
  15839. private _midtonesCurve;
  15840. private _shadowsCurve;
  15841. private _positiveCurve;
  15842. private _negativeCurve;
  15843. private _globalHue;
  15844. private _globalDensity;
  15845. private _globalSaturation;
  15846. private _globalExposure;
  15847. /**
  15848. * Gets the global Hue value.
  15849. * 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).
  15850. */
  15851. /**
  15852. * Sets the global Hue value.
  15853. * 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).
  15854. */
  15855. globalHue: number;
  15856. /**
  15857. * Gets the global Density value.
  15858. * 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.
  15859. * Values less than zero provide a filter of opposite hue.
  15860. */
  15861. /**
  15862. * Sets the global Density value.
  15863. * 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.
  15864. * Values less than zero provide a filter of opposite hue.
  15865. */
  15866. globalDensity: number;
  15867. /**
  15868. * Gets the global Saturation value.
  15869. * 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.
  15870. */
  15871. /**
  15872. * Sets the global Saturation value.
  15873. * 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.
  15874. */
  15875. globalSaturation: number;
  15876. /**
  15877. * Gets the global Exposure value.
  15878. * 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.
  15879. */
  15880. /**
  15881. * Sets the global Exposure value.
  15882. * 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.
  15883. */
  15884. globalExposure: number;
  15885. private _highlightsHue;
  15886. private _highlightsDensity;
  15887. private _highlightsSaturation;
  15888. private _highlightsExposure;
  15889. /**
  15890. * Gets the highlights Hue value.
  15891. * 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).
  15892. */
  15893. /**
  15894. * Sets the highlights Hue value.
  15895. * 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).
  15896. */
  15897. highlightsHue: number;
  15898. /**
  15899. * Gets the highlights Density value.
  15900. * 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.
  15901. * Values less than zero provide a filter of opposite hue.
  15902. */
  15903. /**
  15904. * Sets the highlights Density value.
  15905. * 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.
  15906. * Values less than zero provide a filter of opposite hue.
  15907. */
  15908. highlightsDensity: number;
  15909. /**
  15910. * Gets the highlights Saturation value.
  15911. * 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.
  15912. */
  15913. /**
  15914. * Sets the highlights Saturation value.
  15915. * 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.
  15916. */
  15917. highlightsSaturation: number;
  15918. /**
  15919. * Gets the highlights Exposure value.
  15920. * 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.
  15921. */
  15922. /**
  15923. * Sets the highlights Exposure value.
  15924. * 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.
  15925. */
  15926. highlightsExposure: number;
  15927. private _midtonesHue;
  15928. private _midtonesDensity;
  15929. private _midtonesSaturation;
  15930. private _midtonesExposure;
  15931. /**
  15932. * Gets the midtones Hue value.
  15933. * 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).
  15934. */
  15935. /**
  15936. * Sets the midtones Hue value.
  15937. * 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).
  15938. */
  15939. midtonesHue: number;
  15940. /**
  15941. * Gets the midtones Density value.
  15942. * 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.
  15943. * Values less than zero provide a filter of opposite hue.
  15944. */
  15945. /**
  15946. * Sets the midtones Density value.
  15947. * 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.
  15948. * Values less than zero provide a filter of opposite hue.
  15949. */
  15950. midtonesDensity: number;
  15951. /**
  15952. * Gets the midtones Saturation value.
  15953. * 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.
  15954. */
  15955. /**
  15956. * Sets the midtones Saturation value.
  15957. * 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.
  15958. */
  15959. midtonesSaturation: number;
  15960. /**
  15961. * Gets the midtones Exposure value.
  15962. * 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.
  15963. */
  15964. /**
  15965. * Sets the midtones Exposure value.
  15966. * 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.
  15967. */
  15968. midtonesExposure: number;
  15969. private _shadowsHue;
  15970. private _shadowsDensity;
  15971. private _shadowsSaturation;
  15972. private _shadowsExposure;
  15973. /**
  15974. * Gets the shadows Hue value.
  15975. * 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).
  15976. */
  15977. /**
  15978. * Sets the shadows Hue value.
  15979. * 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).
  15980. */
  15981. shadowsHue: number;
  15982. /**
  15983. * Gets the shadows Density value.
  15984. * 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.
  15985. * Values less than zero provide a filter of opposite hue.
  15986. */
  15987. /**
  15988. * Sets the shadows Density value.
  15989. * 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.
  15990. * Values less than zero provide a filter of opposite hue.
  15991. */
  15992. shadowsDensity: number;
  15993. /**
  15994. * Gets the shadows Saturation value.
  15995. * 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.
  15996. */
  15997. /**
  15998. * Sets the shadows Saturation value.
  15999. * 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.
  16000. */
  16001. shadowsSaturation: number;
  16002. /**
  16003. * Gets the shadows Exposure value.
  16004. * 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.
  16005. */
  16006. /**
  16007. * Sets the shadows Exposure value.
  16008. * 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.
  16009. */
  16010. shadowsExposure: number;
  16011. getClassName(): string;
  16012. /**
  16013. * Binds the color curves to the shader.
  16014. * @param colorCurves The color curve to bind
  16015. * @param effect The effect to bind to
  16016. */
  16017. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16018. /**
  16019. * Prepare the list of uniforms associated with the ColorCurves effects.
  16020. * @param uniformsList The list of uniforms used in the effect
  16021. */
  16022. static PrepareUniforms(uniformsList: string[]): void;
  16023. /**
  16024. * Returns color grading data based on a hue, density, saturation and exposure value.
  16025. * @param filterHue The hue of the color filter.
  16026. * @param filterDensity The density of the color filter.
  16027. * @param saturation The saturation.
  16028. * @param exposure The exposure.
  16029. * @param result The result data container.
  16030. */
  16031. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  16032. /**
  16033. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16034. * @param value The input slider value in range [-100,100].
  16035. * @returns Adjusted value.
  16036. */
  16037. private static applyColorGradingSliderNonlinear(value);
  16038. /**
  16039. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16040. * @param hue The hue (H) input.
  16041. * @param saturation The saturation (S) input.
  16042. * @param brightness The brightness (B) input.
  16043. * @result An RGBA color represented as Vector4.
  16044. */
  16045. private static fromHSBToRef(hue, saturation, brightness, result);
  16046. /**
  16047. * Returns a value clamped between min and max
  16048. * @param value The value to clamp
  16049. * @param min The minimum of value
  16050. * @param max The maximum of value
  16051. * @returns The clamped value.
  16052. */
  16053. private static clamp(value, min, max);
  16054. /**
  16055. * Clones the current color curve instance.
  16056. * @return The cloned curves
  16057. */
  16058. clone(): ColorCurves;
  16059. /**
  16060. * Serializes the current color curve instance to a json representation.
  16061. * @return a JSON representation
  16062. */
  16063. serialize(): any;
  16064. /**
  16065. * Parses the color curve from a json representation.
  16066. * @param source the JSON source to parse
  16067. * @return The parsed curves
  16068. */
  16069. static Parse(source: any): ColorCurves;
  16070. }
  16071. }
  16072. declare module BABYLON {
  16073. /**
  16074. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16075. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16076. */
  16077. class EffectFallbacks {
  16078. private _defines;
  16079. private _currentRank;
  16080. private _maxRank;
  16081. private _mesh;
  16082. /**
  16083. * Removes the fallback from the bound mesh.
  16084. */
  16085. unBindMesh(): void;
  16086. /**
  16087. * Adds a fallback on the specified property.
  16088. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16089. * @param define The name of the define in the shader
  16090. */
  16091. addFallback(rank: number, define: string): void;
  16092. /**
  16093. * Sets the mesh to use CPU skinning when needing to fallback.
  16094. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16095. * @param mesh The mesh to use the fallbacks.
  16096. */
  16097. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16098. /**
  16099. * Checks to see if more fallbacks are still availible.
  16100. */
  16101. readonly isMoreFallbacks: boolean;
  16102. /**
  16103. * Removes the defines that shoould be removed when falling back.
  16104. * @param currentDefines defines the current define statements for the shader.
  16105. * @param effect defines the current effect we try to compile
  16106. * @returns The resulting defines with defines of the current rank removed.
  16107. */
  16108. reduce(currentDefines: string, effect: Effect): string;
  16109. }
  16110. /**
  16111. * Options to be used when creating an effect.
  16112. */
  16113. class EffectCreationOptions {
  16114. /**
  16115. * Atrributes that will be used in the shader.
  16116. */
  16117. attributes: string[];
  16118. /**
  16119. * Uniform varible names that will be set in the shader.
  16120. */
  16121. uniformsNames: string[];
  16122. /**
  16123. * Uniform buffer varible names that will be set in the shader.
  16124. */
  16125. uniformBuffersNames: string[];
  16126. /**
  16127. * Sampler texture variable names that will be set in the shader.
  16128. */
  16129. samplers: string[];
  16130. /**
  16131. * Define statements that will be set in the shader.
  16132. */
  16133. defines: any;
  16134. /**
  16135. * Possible fallbacks for this effect to improve performance when needed.
  16136. */
  16137. fallbacks: Nullable<EffectFallbacks>;
  16138. /**
  16139. * Callback that will be called when the shader is compiled.
  16140. */
  16141. onCompiled: Nullable<(effect: Effect) => void>;
  16142. /**
  16143. * Callback that will be called if an error occurs during shader compilation.
  16144. */
  16145. onError: Nullable<(effect: Effect, errors: string) => void>;
  16146. /**
  16147. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16148. */
  16149. indexParameters: any;
  16150. /**
  16151. * Max number of lights that can be used in the shader.
  16152. */
  16153. maxSimultaneousLights: number;
  16154. /**
  16155. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16156. */
  16157. transformFeedbackVaryings: Nullable<string[]>;
  16158. }
  16159. /**
  16160. * Effect containing vertex and fragment shader that can be executed on an object.
  16161. */
  16162. class Effect {
  16163. /**
  16164. * Name of the effect.
  16165. */
  16166. name: any;
  16167. /**
  16168. * String container all the define statements that should be set on the shader.
  16169. */
  16170. defines: string;
  16171. /**
  16172. * Callback that will be called when the shader is compiled.
  16173. */
  16174. onCompiled: Nullable<(effect: Effect) => void>;
  16175. /**
  16176. * Callback that will be called if an error occurs during shader compilation.
  16177. */
  16178. onError: Nullable<(effect: Effect, errors: string) => void>;
  16179. /**
  16180. * Callback that will be called when effect is bound.
  16181. */
  16182. onBind: Nullable<(effect: Effect) => void>;
  16183. /**
  16184. * Unique ID of the effect.
  16185. */
  16186. uniqueId: number;
  16187. /**
  16188. * Observable that will be called when the shader is compiled.
  16189. */
  16190. onCompileObservable: Observable<Effect>;
  16191. /**
  16192. * Observable that will be called if an error occurs during shader compilation.
  16193. */
  16194. onErrorObservable: Observable<Effect>;
  16195. /**
  16196. * Observable that will be called when effect is bound.
  16197. */
  16198. onBindObservable: Observable<Effect>;
  16199. /** @hidden */
  16200. _bonesComputationForcedToCPU: boolean;
  16201. private static _uniqueIdSeed;
  16202. private _engine;
  16203. private _uniformBuffersNames;
  16204. private _uniformsNames;
  16205. private _samplers;
  16206. private _isReady;
  16207. private _compilationError;
  16208. private _attributesNames;
  16209. private _attributes;
  16210. private _uniforms;
  16211. /**
  16212. * Key for the effect.
  16213. */
  16214. _key: string;
  16215. private _indexParameters;
  16216. private _fallbacks;
  16217. private _vertexSourceCode;
  16218. private _fragmentSourceCode;
  16219. private _vertexSourceCodeOverride;
  16220. private _fragmentSourceCodeOverride;
  16221. private _transformFeedbackVaryings;
  16222. /**
  16223. * Compiled shader to webGL program.
  16224. */
  16225. _program: WebGLProgram;
  16226. private _valueCache;
  16227. private static _baseCache;
  16228. /**
  16229. * Instantiates an effect.
  16230. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16231. * @param baseName Name of the effect.
  16232. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16233. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16234. * @param samplers List of sampler variables that will be passed to the shader.
  16235. * @param engine Engine to be used to render the effect
  16236. * @param defines Define statements to be added to the shader.
  16237. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16238. * @param onCompiled Callback that will be called when the shader is compiled.
  16239. * @param onError Callback that will be called if an error occurs during shader compilation.
  16240. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16241. */
  16242. 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);
  16243. /**
  16244. * Unique key for this effect
  16245. */
  16246. readonly key: string;
  16247. /**
  16248. * If the effect has been compiled and prepared.
  16249. * @returns if the effect is compiled and prepared.
  16250. */
  16251. isReady(): boolean;
  16252. /**
  16253. * The engine the effect was initialized with.
  16254. * @returns the engine.
  16255. */
  16256. getEngine(): Engine;
  16257. /**
  16258. * The compiled webGL program for the effect
  16259. * @returns the webGL program.
  16260. */
  16261. getProgram(): WebGLProgram;
  16262. /**
  16263. * The set of names of attribute variables for the shader.
  16264. * @returns An array of attribute names.
  16265. */
  16266. getAttributesNames(): string[];
  16267. /**
  16268. * Returns the attribute at the given index.
  16269. * @param index The index of the attribute.
  16270. * @returns The location of the attribute.
  16271. */
  16272. getAttributeLocation(index: number): number;
  16273. /**
  16274. * Returns the attribute based on the name of the variable.
  16275. * @param name of the attribute to look up.
  16276. * @returns the attribute location.
  16277. */
  16278. getAttributeLocationByName(name: string): number;
  16279. /**
  16280. * The number of attributes.
  16281. * @returns the numnber of attributes.
  16282. */
  16283. getAttributesCount(): number;
  16284. /**
  16285. * Gets the index of a uniform variable.
  16286. * @param uniformName of the uniform to look up.
  16287. * @returns the index.
  16288. */
  16289. getUniformIndex(uniformName: string): number;
  16290. /**
  16291. * Returns the attribute based on the name of the variable.
  16292. * @param uniformName of the uniform to look up.
  16293. * @returns the location of the uniform.
  16294. */
  16295. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16296. /**
  16297. * Returns an array of sampler variable names
  16298. * @returns The array of sampler variable neames.
  16299. */
  16300. getSamplers(): string[];
  16301. /**
  16302. * The error from the last compilation.
  16303. * @returns the error string.
  16304. */
  16305. getCompilationError(): string;
  16306. /**
  16307. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16308. * @param func The callback to be used.
  16309. */
  16310. executeWhenCompiled(func: (effect: Effect) => void): void;
  16311. /** @hidden */
  16312. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  16313. /** @hidden */
  16314. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  16315. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  16316. private _processShaderConversion(sourceCode, isFragment, callback);
  16317. private _processIncludes(sourceCode, callback);
  16318. private _processPrecision(source);
  16319. /**
  16320. * Recompiles the webGL program
  16321. * @param vertexSourceCode The source code for the vertex shader.
  16322. * @param fragmentSourceCode The source code for the fragment shader.
  16323. * @param onCompiled Callback called when completed.
  16324. * @param onError Callback called on error.
  16325. */
  16326. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  16327. /**
  16328. * Gets the uniform locations of the the specified variable names
  16329. * @param names THe names of the variables to lookup.
  16330. * @returns Array of locations in the same order as variable names.
  16331. */
  16332. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16333. /**
  16334. * Prepares the effect
  16335. */
  16336. _prepareEffect(): void;
  16337. /**
  16338. * Checks if the effect is supported. (Must be called after compilation)
  16339. */
  16340. readonly isSupported: boolean;
  16341. /**
  16342. * Binds a texture to the engine to be used as output of the shader.
  16343. * @param channel Name of the output variable.
  16344. * @param texture Texture to bind.
  16345. */
  16346. _bindTexture(channel: string, texture: InternalTexture): void;
  16347. /**
  16348. * Sets a texture on the engine to be used in the shader.
  16349. * @param channel Name of the sampler variable.
  16350. * @param texture Texture to set.
  16351. */
  16352. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16353. /**
  16354. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16355. * @param channel Name of the sampler variable.
  16356. * @param texture Texture to set.
  16357. */
  16358. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16359. /**
  16360. * Sets an array of textures on the engine to be used in the shader.
  16361. * @param channel Name of the variable.
  16362. * @param textures Textures to set.
  16363. */
  16364. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16365. /**
  16366. * 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)
  16367. * @param channel Name of the sampler variable.
  16368. * @param postProcess Post process to get the input texture from.
  16369. */
  16370. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16371. /**
  16372. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16373. * 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)
  16374. * @param channel Name of the sampler variable.
  16375. * @param postProcess Post process to get the output texture from.
  16376. */
  16377. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16378. /** @hidden */
  16379. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  16380. /** @hidden */
  16381. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  16382. /** @hidden */
  16383. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  16384. /** @hidden */
  16385. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  16386. /**
  16387. * Binds a buffer to a uniform.
  16388. * @param buffer Buffer to bind.
  16389. * @param name Name of the uniform variable to bind to.
  16390. */
  16391. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16392. /**
  16393. * Binds block to a uniform.
  16394. * @param blockName Name of the block to bind.
  16395. * @param index Index to bind.
  16396. */
  16397. bindUniformBlock(blockName: string, index: number): void;
  16398. /**
  16399. * Sets an interger value on a uniform variable.
  16400. * @param uniformName Name of the variable.
  16401. * @param value Value to be set.
  16402. * @returns this effect.
  16403. */
  16404. setInt(uniformName: string, value: number): Effect;
  16405. /**
  16406. * Sets an int array on a uniform variable.
  16407. * @param uniformName Name of the variable.
  16408. * @param array array to be set.
  16409. * @returns this effect.
  16410. */
  16411. setIntArray(uniformName: string, array: Int32Array): Effect;
  16412. /**
  16413. * 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)
  16414. * @param uniformName Name of the variable.
  16415. * @param array array to be set.
  16416. * @returns this effect.
  16417. */
  16418. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16419. /**
  16420. * 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)
  16421. * @param uniformName Name of the variable.
  16422. * @param array array to be set.
  16423. * @returns this effect.
  16424. */
  16425. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16426. /**
  16427. * 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)
  16428. * @param uniformName Name of the variable.
  16429. * @param array array to be set.
  16430. * @returns this effect.
  16431. */
  16432. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16433. /**
  16434. * Sets an float array on a uniform variable.
  16435. * @param uniformName Name of the variable.
  16436. * @param array array to be set.
  16437. * @returns this effect.
  16438. */
  16439. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16440. /**
  16441. * 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)
  16442. * @param uniformName Name of the variable.
  16443. * @param array array to be set.
  16444. * @returns this effect.
  16445. */
  16446. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16447. /**
  16448. * 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)
  16449. * @param uniformName Name of the variable.
  16450. * @param array array to be set.
  16451. * @returns this effect.
  16452. */
  16453. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16454. /**
  16455. * 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)
  16456. * @param uniformName Name of the variable.
  16457. * @param array array to be set.
  16458. * @returns this effect.
  16459. */
  16460. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16461. /**
  16462. * Sets an array on a uniform variable.
  16463. * @param uniformName Name of the variable.
  16464. * @param array array to be set.
  16465. * @returns this effect.
  16466. */
  16467. setArray(uniformName: string, array: number[]): Effect;
  16468. /**
  16469. * 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)
  16470. * @param uniformName Name of the variable.
  16471. * @param array array to be set.
  16472. * @returns this effect.
  16473. */
  16474. setArray2(uniformName: string, array: number[]): Effect;
  16475. /**
  16476. * 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)
  16477. * @param uniformName Name of the variable.
  16478. * @param array array to be set.
  16479. * @returns this effect.
  16480. */
  16481. setArray3(uniformName: string, array: number[]): Effect;
  16482. /**
  16483. * 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)
  16484. * @param uniformName Name of the variable.
  16485. * @param array array to be set.
  16486. * @returns this effect.
  16487. */
  16488. setArray4(uniformName: string, array: number[]): Effect;
  16489. /**
  16490. * Sets matrices on a uniform variable.
  16491. * @param uniformName Name of the variable.
  16492. * @param matrices matrices to be set.
  16493. * @returns this effect.
  16494. */
  16495. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16496. /**
  16497. * Sets matrix on a uniform variable.
  16498. * @param uniformName Name of the variable.
  16499. * @param matrix matrix to be set.
  16500. * @returns this effect.
  16501. */
  16502. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16503. /**
  16504. * 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)
  16505. * @param uniformName Name of the variable.
  16506. * @param matrix matrix to be set.
  16507. * @returns this effect.
  16508. */
  16509. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16510. /**
  16511. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16512. * @param uniformName Name of the variable.
  16513. * @param matrix matrix to be set.
  16514. * @returns this effect.
  16515. */
  16516. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16517. /**
  16518. * Sets a float on a uniform variable.
  16519. * @param uniformName Name of the variable.
  16520. * @param value value to be set.
  16521. * @returns this effect.
  16522. */
  16523. setFloat(uniformName: string, value: number): Effect;
  16524. /**
  16525. * Sets a boolean on a uniform variable.
  16526. * @param uniformName Name of the variable.
  16527. * @param bool value to be set.
  16528. * @returns this effect.
  16529. */
  16530. setBool(uniformName: string, bool: boolean): Effect;
  16531. /**
  16532. * Sets a Vector2 on a uniform variable.
  16533. * @param uniformName Name of the variable.
  16534. * @param vector2 vector2 to be set.
  16535. * @returns this effect.
  16536. */
  16537. setVector2(uniformName: string, vector2: Vector2): Effect;
  16538. /**
  16539. * Sets a float2 on a uniform variable.
  16540. * @param uniformName Name of the variable.
  16541. * @param x First float in float2.
  16542. * @param y Second float in float2.
  16543. * @returns this effect.
  16544. */
  16545. setFloat2(uniformName: string, x: number, y: number): Effect;
  16546. /**
  16547. * Sets a Vector3 on a uniform variable.
  16548. * @param uniformName Name of the variable.
  16549. * @param vector3 Value to be set.
  16550. * @returns this effect.
  16551. */
  16552. setVector3(uniformName: string, vector3: Vector3): Effect;
  16553. /**
  16554. * Sets a float3 on a uniform variable.
  16555. * @param uniformName Name of the variable.
  16556. * @param x First float in float3.
  16557. * @param y Second float in float3.
  16558. * @param z Third float in float3.
  16559. * @returns this effect.
  16560. */
  16561. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16562. /**
  16563. * Sets a Vector4 on a uniform variable.
  16564. * @param uniformName Name of the variable.
  16565. * @param vector4 Value to be set.
  16566. * @returns this effect.
  16567. */
  16568. setVector4(uniformName: string, vector4: Vector4): Effect;
  16569. /**
  16570. * Sets a float4 on a uniform variable.
  16571. * @param uniformName Name of the variable.
  16572. * @param x First float in float4.
  16573. * @param y Second float in float4.
  16574. * @param z Third float in float4.
  16575. * @param w Fourth float in float4.
  16576. * @returns this effect.
  16577. */
  16578. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16579. /**
  16580. * Sets a Color3 on a uniform variable.
  16581. * @param uniformName Name of the variable.
  16582. * @param color3 Value to be set.
  16583. * @returns this effect.
  16584. */
  16585. setColor3(uniformName: string, color3: Color3): Effect;
  16586. /**
  16587. * Sets a Color4 on a uniform variable.
  16588. * @param uniformName Name of the variable.
  16589. * @param color3 Value to be set.
  16590. * @param alpha Alpha value to be set.
  16591. * @returns this effect.
  16592. */
  16593. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16594. /**
  16595. * Sets a Color4 on a uniform variable
  16596. * @param uniformName defines the name of the variable
  16597. * @param color4 defines the value to be set
  16598. * @returns this effect.
  16599. */
  16600. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16601. /**
  16602. * Store of each shader (The can be looked up using effect.key)
  16603. */
  16604. static ShadersStore: {
  16605. [key: string]: string;
  16606. };
  16607. /**
  16608. * Store of each included file for a shader (The can be looked up using effect.key)
  16609. */
  16610. static IncludesShadersStore: {
  16611. [key: string]: string;
  16612. };
  16613. /**
  16614. * Resets the cache of effects.
  16615. */
  16616. static ResetCache(): void;
  16617. }
  16618. }
  16619. declare module BABYLON {
  16620. class FresnelParameters {
  16621. private _isEnabled;
  16622. isEnabled: boolean;
  16623. leftColor: Color3;
  16624. rightColor: Color3;
  16625. bias: number;
  16626. power: number;
  16627. clone(): FresnelParameters;
  16628. serialize(): any;
  16629. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16630. }
  16631. }
  16632. declare module BABYLON {
  16633. /**
  16634. * Interface to follow in your material defines to integrate easily the
  16635. * Image proccessing functions.
  16636. * @hidden
  16637. */
  16638. interface IImageProcessingConfigurationDefines {
  16639. IMAGEPROCESSING: boolean;
  16640. VIGNETTE: boolean;
  16641. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16642. VIGNETTEBLENDMODEOPAQUE: boolean;
  16643. TONEMAPPING: boolean;
  16644. CONTRAST: boolean;
  16645. EXPOSURE: boolean;
  16646. COLORCURVES: boolean;
  16647. COLORGRADING: boolean;
  16648. COLORGRADING3D: boolean;
  16649. SAMPLER3DGREENDEPTH: boolean;
  16650. SAMPLER3DBGRMAP: boolean;
  16651. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16652. }
  16653. /**
  16654. * This groups together the common properties used for image processing either in direct forward pass
  16655. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16656. * or not.
  16657. */
  16658. class ImageProcessingConfiguration {
  16659. /**
  16660. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16661. */
  16662. colorCurves: Nullable<ColorCurves>;
  16663. private _colorCurvesEnabled;
  16664. /**
  16665. * Gets wether the color curves effect is enabled.
  16666. */
  16667. /**
  16668. * Sets wether the color curves effect is enabled.
  16669. */
  16670. colorCurvesEnabled: boolean;
  16671. /**
  16672. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16673. */
  16674. colorGradingTexture: Nullable<BaseTexture>;
  16675. private _colorGradingEnabled;
  16676. /**
  16677. * Gets wether the color grading effect is enabled.
  16678. */
  16679. /**
  16680. * Sets wether the color grading effect is enabled.
  16681. */
  16682. colorGradingEnabled: boolean;
  16683. private _colorGradingWithGreenDepth;
  16684. /**
  16685. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16686. */
  16687. /**
  16688. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16689. */
  16690. colorGradingWithGreenDepth: boolean;
  16691. private _colorGradingBGR;
  16692. /**
  16693. * Gets wether the color grading texture contains BGR values.
  16694. */
  16695. /**
  16696. * Sets wether the color grading texture contains BGR values.
  16697. */
  16698. colorGradingBGR: boolean;
  16699. _exposure: number;
  16700. /**
  16701. * Gets the Exposure used in the effect.
  16702. */
  16703. /**
  16704. * Sets the Exposure used in the effect.
  16705. */
  16706. exposure: number;
  16707. private _toneMappingEnabled;
  16708. /**
  16709. * Gets wether the tone mapping effect is enabled.
  16710. */
  16711. /**
  16712. * Sets wether the tone mapping effect is enabled.
  16713. */
  16714. toneMappingEnabled: boolean;
  16715. protected _contrast: number;
  16716. /**
  16717. * Gets the contrast used in the effect.
  16718. */
  16719. /**
  16720. * Sets the contrast used in the effect.
  16721. */
  16722. contrast: number;
  16723. /**
  16724. * Vignette stretch size.
  16725. */
  16726. vignetteStretch: number;
  16727. /**
  16728. * Vignette centre X Offset.
  16729. */
  16730. vignetteCentreX: number;
  16731. /**
  16732. * Vignette centre Y Offset.
  16733. */
  16734. vignetteCentreY: number;
  16735. /**
  16736. * Vignette weight or intensity of the vignette effect.
  16737. */
  16738. vignetteWeight: number;
  16739. /**
  16740. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16741. * if vignetteEnabled is set to true.
  16742. */
  16743. vignetteColor: Color4;
  16744. /**
  16745. * Camera field of view used by the Vignette effect.
  16746. */
  16747. vignetteCameraFov: number;
  16748. private _vignetteBlendMode;
  16749. /**
  16750. * Gets the vignette blend mode allowing different kind of effect.
  16751. */
  16752. /**
  16753. * Sets the vignette blend mode allowing different kind of effect.
  16754. */
  16755. vignetteBlendMode: number;
  16756. private _vignetteEnabled;
  16757. /**
  16758. * Gets wether the vignette effect is enabled.
  16759. */
  16760. /**
  16761. * Sets wether the vignette effect is enabled.
  16762. */
  16763. vignetteEnabled: boolean;
  16764. private _applyByPostProcess;
  16765. /**
  16766. * Gets wether the image processing is applied through a post process or not.
  16767. */
  16768. /**
  16769. * Sets wether the image processing is applied through a post process or not.
  16770. */
  16771. applyByPostProcess: boolean;
  16772. private _isEnabled;
  16773. /**
  16774. * Gets wether the image processing is enabled or not.
  16775. */
  16776. /**
  16777. * Sets wether the image processing is enabled or not.
  16778. */
  16779. isEnabled: boolean;
  16780. /**
  16781. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16782. */
  16783. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16784. /**
  16785. * Method called each time the image processing information changes requires to recompile the effect.
  16786. */
  16787. protected _updateParameters(): void;
  16788. getClassName(): string;
  16789. /**
  16790. * Prepare the list of uniforms associated with the Image Processing effects.
  16791. * @param uniformsList The list of uniforms used in the effect
  16792. * @param defines the list of defines currently in use
  16793. */
  16794. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16795. /**
  16796. * Prepare the list of samplers associated with the Image Processing effects.
  16797. * @param uniformsList The list of uniforms used in the effect
  16798. * @param defines the list of defines currently in use
  16799. */
  16800. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16801. /**
  16802. * Prepare the list of defines associated to the shader.
  16803. * @param defines the list of defines to complete
  16804. */
  16805. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16806. /**
  16807. * Returns true if all the image processing information are ready.
  16808. */
  16809. isReady(): boolean;
  16810. /**
  16811. * Binds the image processing to the shader.
  16812. * @param effect The effect to bind to
  16813. */
  16814. bind(effect: Effect, aspectRatio?: number): void;
  16815. /**
  16816. * Clones the current image processing instance.
  16817. * @return The cloned image processing
  16818. */
  16819. clone(): ImageProcessingConfiguration;
  16820. /**
  16821. * Serializes the current image processing instance to a json representation.
  16822. * @return a JSON representation
  16823. */
  16824. serialize(): any;
  16825. /**
  16826. * Parses the image processing from a json representation.
  16827. * @param source the JSON source to parse
  16828. * @return The parsed image processing
  16829. */
  16830. static Parse(source: any): ImageProcessingConfiguration;
  16831. private static _VIGNETTEMODE_MULTIPLY;
  16832. private static _VIGNETTEMODE_OPAQUE;
  16833. /**
  16834. * Used to apply the vignette as a mix with the pixel color.
  16835. */
  16836. static readonly VIGNETTEMODE_MULTIPLY: number;
  16837. /**
  16838. * Used to apply the vignette as a replacement of the pixel color.
  16839. */
  16840. static readonly VIGNETTEMODE_OPAQUE: number;
  16841. }
  16842. }
  16843. declare module BABYLON {
  16844. /**
  16845. * Manages the defines for the Material
  16846. */
  16847. class MaterialDefines {
  16848. private _keys;
  16849. private _isDirty;
  16850. /** @hidden */
  16851. _renderId: number;
  16852. /** @hidden */
  16853. _areLightsDirty: boolean;
  16854. /** @hidden */
  16855. _areAttributesDirty: boolean;
  16856. /** @hidden */
  16857. _areTexturesDirty: boolean;
  16858. /** @hidden */
  16859. _areFresnelDirty: boolean;
  16860. /** @hidden */
  16861. _areMiscDirty: boolean;
  16862. /** @hidden */
  16863. _areImageProcessingDirty: boolean;
  16864. /** @hidden */
  16865. _normals: boolean;
  16866. /** @hidden */
  16867. _uvs: boolean;
  16868. /** @hidden */
  16869. _needNormals: boolean;
  16870. /** @hidden */
  16871. _needUVs: boolean;
  16872. /**
  16873. * Specifies if the material needs to be re-calculated
  16874. */
  16875. readonly isDirty: boolean;
  16876. /**
  16877. * Marks the material to indicate that it has been re-calculated
  16878. */
  16879. markAsProcessed(): void;
  16880. /**
  16881. * Marks the material to indicate that it needs to be re-calculated
  16882. */
  16883. markAsUnprocessed(): void;
  16884. /**
  16885. * Marks the material to indicate all of its defines need to be re-calculated
  16886. */
  16887. markAllAsDirty(): void;
  16888. /**
  16889. * Marks the material to indicate that image processing needs to be re-calculated
  16890. */
  16891. markAsImageProcessingDirty(): void;
  16892. /**
  16893. * Marks the material to indicate the lights need to be re-calculated
  16894. */
  16895. markAsLightDirty(): void;
  16896. /**
  16897. * Marks the attribute state as changed
  16898. */
  16899. markAsAttributesDirty(): void;
  16900. /**
  16901. * Marks the texture state as changed
  16902. */
  16903. markAsTexturesDirty(): void;
  16904. /**
  16905. * Marks the fresnel state as changed
  16906. */
  16907. markAsFresnelDirty(): void;
  16908. /**
  16909. * Marks the misc state as changed
  16910. */
  16911. markAsMiscDirty(): void;
  16912. /**
  16913. * Rebuilds the material defines
  16914. */
  16915. rebuild(): void;
  16916. /**
  16917. * Specifies if two material defines are equal
  16918. * @param other - A material define instance to compare to
  16919. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  16920. */
  16921. isEqual(other: MaterialDefines): boolean;
  16922. /**
  16923. * Clones this instance's defines to another instance
  16924. * @param other - material defines to clone values to
  16925. */
  16926. cloneTo(other: MaterialDefines): void;
  16927. /**
  16928. * Resets the material define values
  16929. */
  16930. reset(): void;
  16931. /**
  16932. * Converts the material define values to a string
  16933. * @returns - String of material define information
  16934. */
  16935. toString(): string;
  16936. }
  16937. /**
  16938. * Base class for the main features of a material in Babylon.js
  16939. */
  16940. class Material implements IAnimatable {
  16941. private static _TriangleFillMode;
  16942. private static _WireFrameFillMode;
  16943. private static _PointFillMode;
  16944. private static _PointListDrawMode;
  16945. private static _LineListDrawMode;
  16946. private static _LineLoopDrawMode;
  16947. private static _LineStripDrawMode;
  16948. private static _TriangleStripDrawMode;
  16949. private static _TriangleFanDrawMode;
  16950. /**
  16951. * Returns the triangle fill mode
  16952. */
  16953. static readonly TriangleFillMode: number;
  16954. /**
  16955. * Returns the wireframe mode
  16956. */
  16957. static readonly WireFrameFillMode: number;
  16958. /**
  16959. * Returns the point fill mode
  16960. */
  16961. static readonly PointFillMode: number;
  16962. /**
  16963. * Returns the point list draw mode
  16964. */
  16965. static readonly PointListDrawMode: number;
  16966. /**
  16967. * Returns the line list draw mode
  16968. */
  16969. static readonly LineListDrawMode: number;
  16970. /**
  16971. * Returns the line loop draw mode
  16972. */
  16973. static readonly LineLoopDrawMode: number;
  16974. /**
  16975. * Returns the line strip draw mode
  16976. */
  16977. static readonly LineStripDrawMode: number;
  16978. /**
  16979. * Returns the triangle strip draw mode
  16980. */
  16981. static readonly TriangleStripDrawMode: number;
  16982. /**
  16983. * Returns the triangle fan draw mode
  16984. */
  16985. static readonly TriangleFanDrawMode: number;
  16986. /**
  16987. * Stores the clock-wise side orientation
  16988. */
  16989. private static _ClockWiseSideOrientation;
  16990. /**
  16991. * Stores the counter clock-wise side orientation
  16992. */
  16993. private static _CounterClockWiseSideOrientation;
  16994. /**
  16995. * Returns the clock-wise side orientation
  16996. */
  16997. static readonly ClockWiseSideOrientation: number;
  16998. /**
  16999. * Returns the counter clock-wise side orientation
  17000. */
  17001. static readonly CounterClockWiseSideOrientation: number;
  17002. /**
  17003. * The dirty texture flag value
  17004. */
  17005. private static _TextureDirtyFlag;
  17006. /**
  17007. * The dirty light flag value
  17008. */
  17009. private static _LightDirtyFlag;
  17010. /**
  17011. * The dirty fresnel flag value
  17012. */
  17013. private static _FresnelDirtyFlag;
  17014. /**
  17015. * The dirty attribute flag value
  17016. */
  17017. private static _AttributesDirtyFlag;
  17018. /**
  17019. * The dirty misc flag value
  17020. */
  17021. private static _MiscDirtyFlag;
  17022. /**
  17023. * Returns the dirty texture flag value
  17024. */
  17025. static readonly TextureDirtyFlag: number;
  17026. /**
  17027. * Returns the dirty light flag value
  17028. */
  17029. static readonly LightDirtyFlag: number;
  17030. /**
  17031. * Returns the dirty fresnel flag value
  17032. */
  17033. static readonly FresnelDirtyFlag: number;
  17034. /**
  17035. * Returns the dirty attributes flag value
  17036. */
  17037. static readonly AttributesDirtyFlag: number;
  17038. /**
  17039. * Returns the dirty misc flag value
  17040. */
  17041. static readonly MiscDirtyFlag: number;
  17042. /**
  17043. * The ID of the material
  17044. */
  17045. id: string;
  17046. /**
  17047. * Gets or sets the unique id of the material
  17048. */
  17049. uniqueId: number;
  17050. /**
  17051. * The name of the material
  17052. */
  17053. name: string;
  17054. /**
  17055. * Specifies if the ready state should be checked on each call
  17056. */
  17057. checkReadyOnEveryCall: boolean;
  17058. /**
  17059. * Specifies if the ready state should be checked once
  17060. */
  17061. checkReadyOnlyOnce: boolean;
  17062. /**
  17063. * The state of the material
  17064. */
  17065. state: string;
  17066. /**
  17067. * The alpha value of the material
  17068. */
  17069. protected _alpha: number;
  17070. /**
  17071. * Gets the alpha value of the material
  17072. */
  17073. /**
  17074. * Sets the alpha value of the material
  17075. */
  17076. alpha: number;
  17077. /**
  17078. * Specifies if back face culling is enabled
  17079. */
  17080. protected _backFaceCulling: boolean;
  17081. /**
  17082. * Gets the back-face culling state
  17083. */
  17084. /**
  17085. * Sets the back-face culling state
  17086. */
  17087. backFaceCulling: boolean;
  17088. /**
  17089. * Stores the value for side orientation
  17090. */
  17091. sideOrientation: number;
  17092. /**
  17093. * Callback triggered when the material is compiled
  17094. */
  17095. onCompiled: (effect: Effect) => void;
  17096. /**
  17097. * Callback triggered when an error occurs
  17098. */
  17099. onError: (effect: Effect, errors: string) => void;
  17100. /**
  17101. * Callback triggered to get the render target textures
  17102. */
  17103. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17104. /**
  17105. * Specifies if the material should be serialized
  17106. */
  17107. doNotSerialize: boolean;
  17108. /**
  17109. * Specifies if the effect should be stored on sub meshes
  17110. */
  17111. storeEffectOnSubMeshes: boolean;
  17112. /**
  17113. * Stores the animations for the material
  17114. */
  17115. animations: Array<Animation>;
  17116. /**
  17117. * An event triggered when the material is disposed
  17118. */
  17119. onDisposeObservable: Observable<Material>;
  17120. /**
  17121. * An observer which watches for dispose events
  17122. */
  17123. private _onDisposeObserver;
  17124. /**
  17125. * Called during a dispose event
  17126. */
  17127. onDispose: () => void;
  17128. /**
  17129. * An event triggered when the material is bound
  17130. */
  17131. onBindObservable: Observable<AbstractMesh>;
  17132. /**
  17133. * An observer which watches for bind events
  17134. */
  17135. private _onBindObserver;
  17136. /**
  17137. * Called during a bind event
  17138. */
  17139. onBind: (Mesh: AbstractMesh) => void;
  17140. /**
  17141. * An event triggered when the material is unbound
  17142. */
  17143. onUnBindObservable: Observable<Material>;
  17144. /**
  17145. * Stores the value of the alpha mode
  17146. */
  17147. private _alphaMode;
  17148. /**
  17149. * Gets the value of the alpha mode
  17150. */
  17151. /**
  17152. * Sets the value of the alpha mode.
  17153. *
  17154. * | Value | Type | Description |
  17155. * | --- | --- | --- |
  17156. * | 0 | ALPHA_DISABLE | |
  17157. * | 1 | ALPHA_ADD | |
  17158. * | 2 | ALPHA_COMBINE | |
  17159. * | 3 | ALPHA_SUBTRACT | |
  17160. * | 4 | ALPHA_MULTIPLY | |
  17161. * | 5 | ALPHA_MAXIMIZED | |
  17162. * | 6 | ALPHA_ONEONE | |
  17163. * | 7 | ALPHA_PREMULTIPLIED | |
  17164. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17165. * | 9 | ALPHA_INTERPOLATE | |
  17166. * | 10 | ALPHA_SCREENMODE | |
  17167. *
  17168. */
  17169. alphaMode: number;
  17170. /**
  17171. * Stores the state of the need depth pre-pass value
  17172. */
  17173. private _needDepthPrePass;
  17174. /**
  17175. * Gets the depth pre-pass value
  17176. */
  17177. /**
  17178. * Sets the need depth pre-pass value
  17179. */
  17180. needDepthPrePass: boolean;
  17181. /**
  17182. * Specifies if depth writing should be disabled
  17183. */
  17184. disableDepthWrite: boolean;
  17185. /**
  17186. * Specifies if depth writing should be forced
  17187. */
  17188. forceDepthWrite: boolean;
  17189. /**
  17190. * Specifies if there should be a separate pass for culling
  17191. */
  17192. separateCullingPass: boolean;
  17193. /**
  17194. * Stores the state specifing if fog should be enabled
  17195. */
  17196. private _fogEnabled;
  17197. /**
  17198. * Gets the value of the fog enabled state
  17199. */
  17200. /**
  17201. * Sets the state for enabling fog
  17202. */
  17203. fogEnabled: boolean;
  17204. /**
  17205. * Stores the size of points
  17206. */
  17207. pointSize: number;
  17208. /**
  17209. * Stores the z offset value
  17210. */
  17211. zOffset: number;
  17212. /**
  17213. * Gets a value specifying if wireframe mode is enabled
  17214. */
  17215. /**
  17216. * Sets the state of wireframe mode
  17217. */
  17218. wireframe: boolean;
  17219. /**
  17220. * Gets the value specifying if point clouds are enabled
  17221. */
  17222. /**
  17223. * Sets the state of point cloud mode
  17224. */
  17225. pointsCloud: boolean;
  17226. /**
  17227. * Gets the material fill mode
  17228. */
  17229. /**
  17230. * Sets the material fill mode
  17231. */
  17232. fillMode: number;
  17233. /**
  17234. * Stores the effects for the material
  17235. */
  17236. _effect: Nullable<Effect>;
  17237. /**
  17238. * Specifies if the material was previously ready
  17239. */
  17240. _wasPreviouslyReady: boolean;
  17241. /**
  17242. * Specifies if uniform buffers should be used
  17243. */
  17244. private _useUBO;
  17245. /**
  17246. * Stores a reference to the scene
  17247. */
  17248. private _scene;
  17249. /**
  17250. * Stores the fill mode state
  17251. */
  17252. private _fillMode;
  17253. /**
  17254. * Specifies if the depth write state should be cached
  17255. */
  17256. private _cachedDepthWriteState;
  17257. /**
  17258. * Stores the uniform buffer
  17259. */
  17260. protected _uniformBuffer: UniformBuffer;
  17261. /**
  17262. * Creates a material instance
  17263. * @param name defines the name of the material
  17264. * @param scene defines the scene to reference
  17265. * @param doNotAdd specifies if the material should be added to the scene
  17266. */
  17267. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17268. /**
  17269. * Returns a string representation of the current material
  17270. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17271. * @returns a string with material information
  17272. */
  17273. toString(fullDetails?: boolean): string;
  17274. /**
  17275. * Gets the class name of the material
  17276. * @returns a string with the class name of the material
  17277. */
  17278. getClassName(): string;
  17279. /**
  17280. * Specifies if updates for the material been locked
  17281. */
  17282. readonly isFrozen: boolean;
  17283. /**
  17284. * Locks updates for the material
  17285. */
  17286. freeze(): void;
  17287. /**
  17288. * Unlocks updates for the material
  17289. */
  17290. unfreeze(): void;
  17291. /**
  17292. * Specifies if the material is ready to be used
  17293. * @param mesh defines the mesh to check
  17294. * @param useInstances specifies if instances should be used
  17295. * @returns a boolean indicating if the material is ready to be used
  17296. */
  17297. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17298. /**
  17299. * Specifies that the submesh is ready to be used
  17300. * @param mesh defines the mesh to check
  17301. * @param subMesh defines which submesh to check
  17302. * @param useInstances specifies that instances should be used
  17303. * @returns a boolean indicating that the submesh is ready or not
  17304. */
  17305. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17306. /**
  17307. * Returns the material effect
  17308. * @returns the effect associated with the material
  17309. */
  17310. getEffect(): Nullable<Effect>;
  17311. /**
  17312. * Returns the current scene
  17313. * @returns a Scene
  17314. */
  17315. getScene(): Scene;
  17316. /**
  17317. * Specifies if the material will require alpha blending
  17318. * @returns a boolean specifying if alpha blending is needed
  17319. */
  17320. needAlphaBlending(): boolean;
  17321. /**
  17322. * Specifies if the mesh will require alpha blending
  17323. * @param mesh defines the mesh to check
  17324. * @returns a boolean specifying if alpha blending is needed for the mesh
  17325. */
  17326. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17327. /**
  17328. * Specifies if this material should be rendered in alpha test mode
  17329. * @returns a boolean specifying if an alpha test is needed.
  17330. */
  17331. needAlphaTesting(): boolean;
  17332. /**
  17333. * Gets the texture used for the alpha test
  17334. * @returns the texture to use for alpha testing
  17335. */
  17336. getAlphaTestTexture(): Nullable<BaseTexture>;
  17337. /**
  17338. * Marks the material to indicate that it needs to be re-calculated
  17339. */
  17340. markDirty(): void;
  17341. /** @hidden */
  17342. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17343. /**
  17344. * Binds the material to the mesh
  17345. * @param world defines the world transformation matrix
  17346. * @param mesh defines the mesh to bind the material to
  17347. */
  17348. bind(world: Matrix, mesh?: Mesh): void;
  17349. /**
  17350. * Binds the submesh to the material
  17351. * @param world defines the world transformation matrix
  17352. * @param mesh defines the mesh containing the submesh
  17353. * @param subMesh defines the submesh to bind the material to
  17354. */
  17355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17356. /**
  17357. * Binds the world matrix to the material
  17358. * @param world defines the world transformation matrix
  17359. */
  17360. bindOnlyWorldMatrix(world: Matrix): void;
  17361. /**
  17362. * Binds the scene's uniform buffer to the effect.
  17363. * @param effect defines the effect to bind to the scene uniform buffer
  17364. * @param sceneUbo defines the uniform buffer storing scene data
  17365. */
  17366. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17367. /**
  17368. * Binds the view matrix to the effect
  17369. * @param effect defines the effect to bind the view matrix to
  17370. */
  17371. bindView(effect: Effect): void;
  17372. /**
  17373. * Binds the view projection matrix to the effect
  17374. * @param effect defines the effect to bind the view projection matrix to
  17375. */
  17376. bindViewProjection(effect: Effect): void;
  17377. /**
  17378. * Specifies if material alpha testing should be turned on for the mesh
  17379. * @param mesh defines the mesh to check
  17380. */
  17381. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17382. /**
  17383. * Processes to execute after binding the material to a mesh
  17384. * @param mesh defines the rendered mesh
  17385. */
  17386. protected _afterBind(mesh?: Mesh): void;
  17387. /**
  17388. * Unbinds the material from the mesh
  17389. */
  17390. unbind(): void;
  17391. /**
  17392. * Gets the active textures from the material
  17393. * @returns an array of textures
  17394. */
  17395. getActiveTextures(): BaseTexture[];
  17396. /**
  17397. * Specifies if the material uses a texture
  17398. * @param texture defines the texture to check against the material
  17399. * @returns a boolean specifying if the material uses the texture
  17400. */
  17401. hasTexture(texture: BaseTexture): boolean;
  17402. /**
  17403. * Makes a duplicate of the material, and gives it a new name
  17404. * @param name defines the new name for the duplicated material
  17405. * @returns the cloned material
  17406. */
  17407. clone(name: string): Nullable<Material>;
  17408. /**
  17409. * Gets the meshes bound to the material
  17410. * @returns an array of meshes bound to the material
  17411. */
  17412. getBindedMeshes(): AbstractMesh[];
  17413. /**
  17414. * Force shader compilation
  17415. * @param mesh defines the mesh associated with this material
  17416. * @param onCompiled defines a function to execute once the material is compiled
  17417. * @param options defines the options to configure the compilation
  17418. */
  17419. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17420. clipPlane: boolean;
  17421. }>): void;
  17422. /**
  17423. * Force shader compilation
  17424. * @param mesh defines the mesh that will use this material
  17425. * @param options defines additional options for compiling the shaders
  17426. * @returns a promise that resolves when the compilation completes
  17427. */
  17428. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17429. clipPlane: boolean;
  17430. }>): Promise<void>;
  17431. /**
  17432. * Marks a define in the material to indicate that it needs to be re-computed
  17433. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17434. */
  17435. markAsDirty(flag: number): void;
  17436. /**
  17437. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17438. * @param func defines a function which checks material defines against the submeshes
  17439. */
  17440. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17441. /**
  17442. * Indicates that image processing needs to be re-calculated for all submeshes
  17443. */
  17444. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17445. /**
  17446. * Indicates that textures need to be re-calculated for all submeshes
  17447. */
  17448. protected _markAllSubMeshesAsTexturesDirty(): void;
  17449. /**
  17450. * Indicates that fresnel needs to be re-calculated for all submeshes
  17451. */
  17452. protected _markAllSubMeshesAsFresnelDirty(): void;
  17453. /**
  17454. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17455. */
  17456. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17457. /**
  17458. * Indicates that lights need to be re-calculated for all submeshes
  17459. */
  17460. protected _markAllSubMeshesAsLightsDirty(): void;
  17461. /**
  17462. * Indicates that attributes need to be re-calculated for all submeshes
  17463. */
  17464. protected _markAllSubMeshesAsAttributesDirty(): void;
  17465. /**
  17466. * Indicates that misc needs to be re-calculated for all submeshes
  17467. */
  17468. protected _markAllSubMeshesAsMiscDirty(): void;
  17469. /**
  17470. * Indicates that textures and misc need to be re-calculated for all submeshes
  17471. */
  17472. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17473. /**
  17474. * Disposes the material
  17475. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17476. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17477. */
  17478. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17479. /**
  17480. * Serializes this material
  17481. * @returns the serialized material object
  17482. */
  17483. serialize(): any;
  17484. /**
  17485. * Creates a MultiMaterial from parsed MultiMaterial data.
  17486. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  17487. * @param scene defines the hosting scene
  17488. * @returns a new MultiMaterial
  17489. */
  17490. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  17491. /**
  17492. * Creates a material from parsed material data
  17493. * @param parsedMaterial defines parsed material data
  17494. * @param scene defines the hosting scene
  17495. * @param rootUrl defines the root URL to use to load textures
  17496. * @returns a new material
  17497. */
  17498. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17499. }
  17500. }
  17501. declare module BABYLON {
  17502. /**
  17503. * "Static Class" containing the most commonly used helper while dealing with material for
  17504. * rendering purpose.
  17505. *
  17506. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  17507. *
  17508. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  17509. */
  17510. class MaterialHelper {
  17511. /**
  17512. * Bind the current view position to an effect.
  17513. * @param effect The effect to be bound
  17514. * @param scene The scene the eyes position is used from
  17515. */
  17516. static BindEyePosition(effect: Effect, scene: Scene): void;
  17517. /**
  17518. * Helps preparing the defines values about the UVs in used in the effect.
  17519. * UVs are shared as much as we can accross chanels in the shaders.
  17520. * @param texture The texture we are preparing the UVs for
  17521. * @param defines The defines to update
  17522. * @param key The chanel key "diffuse", "specular"... used in the shader
  17523. */
  17524. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17525. /**
  17526. * Binds a texture matrix value to its corrsponding uniform
  17527. * @param texture The texture to bind the matrix for
  17528. * @param uniformBuffer The uniform buffer receivin the data
  17529. * @param key The chanel key "diffuse", "specular"... used in the shader
  17530. */
  17531. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17532. /**
  17533. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17534. * @param mesh defines the current mesh
  17535. * @param scene defines the current scene
  17536. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17537. * @param pointsCloud defines if point cloud rendering has to be turned on
  17538. * @param fogEnabled defines if fog has to be turned on
  17539. * @param alphaTest defines if alpha testing has to be turned on
  17540. * @param defines defines the current list of defines
  17541. */
  17542. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17543. /**
  17544. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17545. * @param scene defines the current scene
  17546. * @param engine defines the current engine
  17547. * @param defines specifies the list of active defines
  17548. * @param useInstances defines if instances have to be turned on
  17549. * @param useClipPlane defines if clip plane have to be turned on
  17550. */
  17551. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17552. /**
  17553. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17554. * @param mesh The mesh containing the geometry data we will draw
  17555. * @param defines The defines to update
  17556. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17557. * @param useBones Precise whether bones should be used or not (override mesh info)
  17558. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17559. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17560. * @returns false if defines are considered not dirty and have not been checked
  17561. */
  17562. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17563. /**
  17564. * Prepares the defines related to the light information passed in parameter
  17565. * @param scene The scene we are intending to draw
  17566. * @param mesh The mesh the effect is compiling for
  17567. * @param defines The defines to update
  17568. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17569. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17570. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17571. * @returns true if normals will be required for the rest of the effect
  17572. */
  17573. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17574. /**
  17575. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17576. * that won t be acctive due to defines being turned off.
  17577. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17578. * @param samplersList The samplers list
  17579. * @param defines The defines helping in the list generation
  17580. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17581. */
  17582. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17583. /**
  17584. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17585. * @param defines The defines to update while falling back
  17586. * @param fallbacks The authorized effect fallbacks
  17587. * @param maxSimultaneousLights The maximum number of lights allowed
  17588. * @param rank the current rank of the Effect
  17589. * @returns The newly affected rank
  17590. */
  17591. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17592. /**
  17593. * Prepares the list of attributes required for morph targets according to the effect defines.
  17594. * @param attribs The current list of supported attribs
  17595. * @param mesh The mesh to prepare the morph targets attributes for
  17596. * @param defines The current Defines of the effect
  17597. */
  17598. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17599. /**
  17600. * Prepares the list of attributes required for bones according to the effect defines.
  17601. * @param attribs The current list of supported attribs
  17602. * @param mesh The mesh to prepare the bones attributes for
  17603. * @param defines The current Defines of the effect
  17604. * @param fallbacks The current efffect fallback strategy
  17605. */
  17606. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17607. /**
  17608. * Prepares the list of attributes required for instances according to the effect defines.
  17609. * @param attribs The current list of supported attribs
  17610. * @param defines The current Defines of the effect
  17611. */
  17612. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17613. /**
  17614. * Binds the light shadow information to the effect for the given mesh.
  17615. * @param light The light containing the generator
  17616. * @param scene The scene the lights belongs to
  17617. * @param mesh The mesh we are binding the information to render
  17618. * @param lightIndex The light index in the effect used to render the mesh
  17619. * @param effect The effect we are binding the data to
  17620. */
  17621. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17622. /**
  17623. * Binds the light information to the effect.
  17624. * @param light The light containing the generator
  17625. * @param effect The effect we are binding the data to
  17626. * @param lightIndex The light index in the effect used to render
  17627. */
  17628. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17629. /**
  17630. * Binds the lights information from the scene to the effect for the given mesh.
  17631. * @param scene The scene the lights belongs to
  17632. * @param mesh The mesh we are binding the information to render
  17633. * @param effect The effect we are binding the data to
  17634. * @param defines The generated defines for the effect
  17635. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17636. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17637. */
  17638. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17639. /**
  17640. * Binds the fog information from the scene to the effect for the given mesh.
  17641. * @param scene The scene the lights belongs to
  17642. * @param mesh The mesh we are binding the information to render
  17643. * @param effect The effect we are binding the data to
  17644. */
  17645. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  17646. /**
  17647. * Binds the bones information from the mesh to the effect.
  17648. * @param mesh The mesh we are binding the information to render
  17649. * @param effect The effect we are binding the data to
  17650. */
  17651. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17652. /**
  17653. * Binds the morph targets information from the mesh to the effect.
  17654. * @param abstractMesh The mesh we are binding the information to render
  17655. * @param effect The effect we are binding the data to
  17656. */
  17657. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17658. /**
  17659. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17660. * @param defines The generated defines used in the effect
  17661. * @param effect The effect we are binding the data to
  17662. * @param scene The scene we are willing to render with logarithmic scale for
  17663. */
  17664. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17665. /**
  17666. * Binds the clip plane information from the scene to the effect.
  17667. * @param scene The scene the clip plane information are extracted from
  17668. * @param effect The effect we are binding the data to
  17669. */
  17670. static BindClipPlane(effect: Effect, scene: Scene): void;
  17671. }
  17672. }
  17673. declare module BABYLON {
  17674. class MultiMaterial extends Material {
  17675. private _subMaterials;
  17676. subMaterials: Nullable<Material>[];
  17677. constructor(name: string, scene: Scene);
  17678. private _hookArray(array);
  17679. getSubMaterial(index: number): Nullable<Material>;
  17680. getActiveTextures(): BaseTexture[];
  17681. getClassName(): string;
  17682. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17683. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  17684. serialize(): any;
  17685. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17686. }
  17687. }
  17688. declare module BABYLON {
  17689. class PushMaterial extends Material {
  17690. protected _activeEffect: Effect;
  17691. protected _normalMatrix: Matrix;
  17692. constructor(name: string, scene: Scene);
  17693. getEffect(): Effect;
  17694. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17695. /**
  17696. * Binds the given world matrix to the active effect
  17697. *
  17698. * @param world the matrix to bind
  17699. */
  17700. bindOnlyWorldMatrix(world: Matrix): void;
  17701. /**
  17702. * Binds the given normal matrix to the active effect
  17703. *
  17704. * @param normalMatrix the matrix to bind
  17705. */
  17706. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17707. bind(world: Matrix, mesh?: Mesh): void;
  17708. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17709. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17710. }
  17711. }
  17712. declare module BABYLON {
  17713. class ShaderMaterial extends Material {
  17714. private _shaderPath;
  17715. private _options;
  17716. private _textures;
  17717. private _textureArrays;
  17718. private _floats;
  17719. private _ints;
  17720. private _floatsArrays;
  17721. private _colors3;
  17722. private _colors3Arrays;
  17723. private _colors4;
  17724. private _vectors2;
  17725. private _vectors3;
  17726. private _vectors4;
  17727. private _matrices;
  17728. private _matrices3x3;
  17729. private _matrices2x2;
  17730. private _vectors2Arrays;
  17731. private _vectors3Arrays;
  17732. private _cachedWorldViewMatrix;
  17733. private _renderId;
  17734. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  17735. getClassName(): string;
  17736. needAlphaBlending(): boolean;
  17737. needAlphaTesting(): boolean;
  17738. private _checkUniform(uniformName);
  17739. setTexture(name: string, texture: Texture): ShaderMaterial;
  17740. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17741. setFloat(name: string, value: number): ShaderMaterial;
  17742. setInt(name: string, value: number): ShaderMaterial;
  17743. setFloats(name: string, value: number[]): ShaderMaterial;
  17744. setColor3(name: string, value: Color3): ShaderMaterial;
  17745. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17746. setColor4(name: string, value: Color4): ShaderMaterial;
  17747. setVector2(name: string, value: Vector2): ShaderMaterial;
  17748. setVector3(name: string, value: Vector3): ShaderMaterial;
  17749. setVector4(name: string, value: Vector4): ShaderMaterial;
  17750. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17751. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17752. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17753. setArray2(name: string, value: number[]): ShaderMaterial;
  17754. setArray3(name: string, value: number[]): ShaderMaterial;
  17755. private _checkCache(scene, mesh?, useInstances?);
  17756. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17757. bindOnlyWorldMatrix(world: Matrix): void;
  17758. bind(world: Matrix, mesh?: Mesh): void;
  17759. getActiveTextures(): BaseTexture[];
  17760. hasTexture(texture: BaseTexture): boolean;
  17761. clone(name: string): ShaderMaterial;
  17762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17763. serialize(): any;
  17764. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17765. }
  17766. }
  17767. declare module BABYLON {
  17768. /** @hidden */
  17769. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17770. MAINUV1: boolean;
  17771. MAINUV2: boolean;
  17772. DIFFUSE: boolean;
  17773. DIFFUSEDIRECTUV: number;
  17774. AMBIENT: boolean;
  17775. AMBIENTDIRECTUV: number;
  17776. OPACITY: boolean;
  17777. OPACITYDIRECTUV: number;
  17778. OPACITYRGB: boolean;
  17779. REFLECTION: boolean;
  17780. EMISSIVE: boolean;
  17781. EMISSIVEDIRECTUV: number;
  17782. SPECULAR: boolean;
  17783. SPECULARDIRECTUV: number;
  17784. BUMP: boolean;
  17785. BUMPDIRECTUV: number;
  17786. PARALLAX: boolean;
  17787. PARALLAXOCCLUSION: boolean;
  17788. SPECULAROVERALPHA: boolean;
  17789. CLIPPLANE: boolean;
  17790. ALPHATEST: boolean;
  17791. DEPTHPREPASS: boolean;
  17792. ALPHAFROMDIFFUSE: boolean;
  17793. POINTSIZE: boolean;
  17794. FOG: boolean;
  17795. SPECULARTERM: boolean;
  17796. DIFFUSEFRESNEL: boolean;
  17797. OPACITYFRESNEL: boolean;
  17798. REFLECTIONFRESNEL: boolean;
  17799. REFRACTIONFRESNEL: boolean;
  17800. EMISSIVEFRESNEL: boolean;
  17801. FRESNEL: boolean;
  17802. NORMAL: boolean;
  17803. UV1: boolean;
  17804. UV2: boolean;
  17805. VERTEXCOLOR: boolean;
  17806. VERTEXALPHA: boolean;
  17807. NUM_BONE_INFLUENCERS: number;
  17808. BonesPerMesh: number;
  17809. INSTANCES: boolean;
  17810. GLOSSINESS: boolean;
  17811. ROUGHNESS: boolean;
  17812. EMISSIVEASILLUMINATION: boolean;
  17813. LINKEMISSIVEWITHDIFFUSE: boolean;
  17814. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17815. LIGHTMAP: boolean;
  17816. LIGHTMAPDIRECTUV: number;
  17817. OBJECTSPACE_NORMALMAP: boolean;
  17818. USELIGHTMAPASSHADOWMAP: boolean;
  17819. REFLECTIONMAP_3D: boolean;
  17820. REFLECTIONMAP_SPHERICAL: boolean;
  17821. REFLECTIONMAP_PLANAR: boolean;
  17822. REFLECTIONMAP_CUBIC: boolean;
  17823. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17824. REFLECTIONMAP_PROJECTION: boolean;
  17825. REFLECTIONMAP_SKYBOX: boolean;
  17826. REFLECTIONMAP_EXPLICIT: boolean;
  17827. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17828. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17829. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17830. INVERTCUBICMAP: boolean;
  17831. LOGARITHMICDEPTH: boolean;
  17832. REFRACTION: boolean;
  17833. REFRACTIONMAP_3D: boolean;
  17834. REFLECTIONOVERALPHA: boolean;
  17835. TWOSIDEDLIGHTING: boolean;
  17836. SHADOWFLOAT: boolean;
  17837. MORPHTARGETS: boolean;
  17838. MORPHTARGETS_NORMAL: boolean;
  17839. MORPHTARGETS_TANGENT: boolean;
  17840. NUM_MORPH_INFLUENCERS: number;
  17841. NONUNIFORMSCALING: boolean;
  17842. PREMULTIPLYALPHA: boolean;
  17843. IMAGEPROCESSING: boolean;
  17844. VIGNETTE: boolean;
  17845. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17846. VIGNETTEBLENDMODEOPAQUE: boolean;
  17847. TONEMAPPING: boolean;
  17848. CONTRAST: boolean;
  17849. COLORCURVES: boolean;
  17850. COLORGRADING: boolean;
  17851. COLORGRADING3D: boolean;
  17852. SAMPLER3DGREENDEPTH: boolean;
  17853. SAMPLER3DBGRMAP: boolean;
  17854. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17855. /**
  17856. * If the reflection texture on this material is in linear color space
  17857. * @hidden
  17858. */
  17859. IS_REFLECTION_LINEAR: boolean;
  17860. /**
  17861. * If the refraction texture on this material is in linear color space
  17862. * @hidden
  17863. */
  17864. IS_REFRACTION_LINEAR: boolean;
  17865. EXPOSURE: boolean;
  17866. constructor();
  17867. setReflectionMode(modeToEnable: string): void;
  17868. }
  17869. class StandardMaterial extends PushMaterial {
  17870. private _diffuseTexture;
  17871. diffuseTexture: Nullable<BaseTexture>;
  17872. private _ambientTexture;
  17873. ambientTexture: Nullable<BaseTexture>;
  17874. private _opacityTexture;
  17875. opacityTexture: Nullable<BaseTexture>;
  17876. private _reflectionTexture;
  17877. reflectionTexture: Nullable<BaseTexture>;
  17878. private _emissiveTexture;
  17879. emissiveTexture: Nullable<BaseTexture>;
  17880. private _specularTexture;
  17881. specularTexture: Nullable<BaseTexture>;
  17882. private _bumpTexture;
  17883. bumpTexture: Nullable<BaseTexture>;
  17884. private _lightmapTexture;
  17885. lightmapTexture: Nullable<BaseTexture>;
  17886. private _refractionTexture;
  17887. refractionTexture: Nullable<BaseTexture>;
  17888. ambientColor: Color3;
  17889. diffuseColor: Color3;
  17890. specularColor: Color3;
  17891. emissiveColor: Color3;
  17892. specularPower: number;
  17893. private _useAlphaFromDiffuseTexture;
  17894. useAlphaFromDiffuseTexture: boolean;
  17895. private _useEmissiveAsIllumination;
  17896. useEmissiveAsIllumination: boolean;
  17897. private _linkEmissiveWithDiffuse;
  17898. linkEmissiveWithDiffuse: boolean;
  17899. private _useSpecularOverAlpha;
  17900. useSpecularOverAlpha: boolean;
  17901. private _useReflectionOverAlpha;
  17902. useReflectionOverAlpha: boolean;
  17903. private _disableLighting;
  17904. disableLighting: boolean;
  17905. private _useObjectSpaceNormalMap;
  17906. /**
  17907. * Allows using an object space normal map (instead of tangent space).
  17908. */
  17909. useObjectSpaceNormalMap: boolean;
  17910. private _useParallax;
  17911. useParallax: boolean;
  17912. private _useParallaxOcclusion;
  17913. useParallaxOcclusion: boolean;
  17914. parallaxScaleBias: number;
  17915. private _roughness;
  17916. roughness: number;
  17917. indexOfRefraction: number;
  17918. invertRefractionY: boolean;
  17919. /**
  17920. * Defines the alpha limits in alpha test mode
  17921. */
  17922. alphaCutOff: number;
  17923. private _useLightmapAsShadowmap;
  17924. useLightmapAsShadowmap: boolean;
  17925. private _diffuseFresnelParameters;
  17926. diffuseFresnelParameters: FresnelParameters;
  17927. private _opacityFresnelParameters;
  17928. opacityFresnelParameters: FresnelParameters;
  17929. private _reflectionFresnelParameters;
  17930. reflectionFresnelParameters: FresnelParameters;
  17931. private _refractionFresnelParameters;
  17932. refractionFresnelParameters: FresnelParameters;
  17933. private _emissiveFresnelParameters;
  17934. emissiveFresnelParameters: FresnelParameters;
  17935. private _useReflectionFresnelFromSpecular;
  17936. useReflectionFresnelFromSpecular: boolean;
  17937. private _useGlossinessFromSpecularMapAlpha;
  17938. useGlossinessFromSpecularMapAlpha: boolean;
  17939. private _maxSimultaneousLights;
  17940. maxSimultaneousLights: number;
  17941. /**
  17942. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  17943. */
  17944. private _invertNormalMapX;
  17945. invertNormalMapX: boolean;
  17946. /**
  17947. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  17948. */
  17949. private _invertNormalMapY;
  17950. invertNormalMapY: boolean;
  17951. /**
  17952. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  17953. */
  17954. private _twoSidedLighting;
  17955. twoSidedLighting: boolean;
  17956. /**
  17957. * Default configuration related to image processing available in the standard Material.
  17958. */
  17959. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17960. /**
  17961. * Gets the image processing configuration used either in this material.
  17962. */
  17963. /**
  17964. * Sets the Default image processing configuration used either in the this material.
  17965. *
  17966. * If sets to null, the scene one is in use.
  17967. */
  17968. imageProcessingConfiguration: ImageProcessingConfiguration;
  17969. /**
  17970. * Keep track of the image processing observer to allow dispose and replace.
  17971. */
  17972. private _imageProcessingObserver;
  17973. /**
  17974. * Attaches a new image processing configuration to the Standard Material.
  17975. * @param configuration
  17976. */
  17977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17978. /**
  17979. * Gets wether the color curves effect is enabled.
  17980. */
  17981. /**
  17982. * Sets wether the color curves effect is enabled.
  17983. */
  17984. cameraColorCurvesEnabled: boolean;
  17985. /**
  17986. * Gets wether the color grading effect is enabled.
  17987. */
  17988. /**
  17989. * Gets wether the color grading effect is enabled.
  17990. */
  17991. cameraColorGradingEnabled: boolean;
  17992. /**
  17993. * Gets wether tonemapping is enabled or not.
  17994. */
  17995. /**
  17996. * Sets wether tonemapping is enabled or not
  17997. */
  17998. cameraToneMappingEnabled: boolean;
  17999. /**
  18000. * The camera exposure used on this material.
  18001. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18002. * This corresponds to a photographic exposure.
  18003. */
  18004. /**
  18005. * The camera exposure used on this material.
  18006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18007. * This corresponds to a photographic exposure.
  18008. */
  18009. cameraExposure: number;
  18010. /**
  18011. * Gets The camera contrast used on this material.
  18012. */
  18013. /**
  18014. * Sets The camera contrast used on this material.
  18015. */
  18016. cameraContrast: number;
  18017. /**
  18018. * Gets the Color Grading 2D Lookup Texture.
  18019. */
  18020. /**
  18021. * Sets the Color Grading 2D Lookup Texture.
  18022. */
  18023. cameraColorGradingTexture: Nullable<BaseTexture>;
  18024. /**
  18025. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18026. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18027. * 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;
  18028. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18029. */
  18030. /**
  18031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18033. * 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;
  18034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18035. */
  18036. cameraColorCurves: Nullable<ColorCurves>;
  18037. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  18038. protected _renderTargets: SmartArray<RenderTargetTexture>;
  18039. protected _worldViewProjectionMatrix: Matrix;
  18040. protected _globalAmbientColor: Color3;
  18041. protected _useLogarithmicDepth: boolean;
  18042. constructor(name: string, scene: Scene);
  18043. getClassName(): string;
  18044. useLogarithmicDepth: boolean;
  18045. needAlphaBlending(): boolean;
  18046. needAlphaTesting(): boolean;
  18047. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  18048. getAlphaTestTexture(): Nullable<BaseTexture>;
  18049. /**
  18050. * Child classes can use it to update shaders
  18051. */
  18052. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18053. buildUniformLayout(): void;
  18054. unbind(): void;
  18055. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18056. getAnimatables(): IAnimatable[];
  18057. getActiveTextures(): BaseTexture[];
  18058. hasTexture(texture: BaseTexture): boolean;
  18059. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18060. clone(name: string): StandardMaterial;
  18061. serialize(): any;
  18062. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  18063. static _DiffuseTextureEnabled: boolean;
  18064. static DiffuseTextureEnabled: boolean;
  18065. static _AmbientTextureEnabled: boolean;
  18066. static AmbientTextureEnabled: boolean;
  18067. static _OpacityTextureEnabled: boolean;
  18068. static OpacityTextureEnabled: boolean;
  18069. static _ReflectionTextureEnabled: boolean;
  18070. static ReflectionTextureEnabled: boolean;
  18071. static _EmissiveTextureEnabled: boolean;
  18072. static EmissiveTextureEnabled: boolean;
  18073. static _SpecularTextureEnabled: boolean;
  18074. static SpecularTextureEnabled: boolean;
  18075. static _BumpTextureEnabled: boolean;
  18076. static BumpTextureEnabled: boolean;
  18077. static _LightmapTextureEnabled: boolean;
  18078. static LightmapTextureEnabled: boolean;
  18079. static _RefractionTextureEnabled: boolean;
  18080. static RefractionTextureEnabled: boolean;
  18081. static _ColorGradingTextureEnabled: boolean;
  18082. static ColorGradingTextureEnabled: boolean;
  18083. static _FresnelEnabled: boolean;
  18084. static FresnelEnabled: boolean;
  18085. }
  18086. }
  18087. declare module BABYLON {
  18088. class UniformBuffer {
  18089. private _engine;
  18090. private _buffer;
  18091. private _data;
  18092. private _bufferData;
  18093. private _dynamic?;
  18094. private _uniformLocations;
  18095. private _uniformSizes;
  18096. private _uniformLocationPointer;
  18097. private _needSync;
  18098. private _noUBO;
  18099. private _currentEffect;
  18100. private static _MAX_UNIFORM_SIZE;
  18101. private static _tempBuffer;
  18102. /**
  18103. * Wrapper for updateUniform.
  18104. * @method updateMatrix3x3
  18105. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18106. * @param {Float32Array} matrix
  18107. */
  18108. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  18109. /**
  18110. * Wrapper for updateUniform.
  18111. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18112. * @param {Float32Array} matrix
  18113. */
  18114. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  18115. /**
  18116. * Wrapper for updateUniform.
  18117. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18118. * @param {number} x
  18119. */
  18120. updateFloat: (name: string, x: number) => void;
  18121. /**
  18122. * Wrapper for updateUniform.
  18123. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18124. * @param {number} x
  18125. * @param {number} y
  18126. * @param {string} [suffix] Suffix to add to the uniform name.
  18127. */
  18128. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  18129. /**
  18130. * Wrapper for updateUniform.
  18131. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18132. * @param {number} x
  18133. * @param {number} y
  18134. * @param {number} z
  18135. * @param {string} [suffix] Suffix to add to the uniform name.
  18136. */
  18137. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  18138. /**
  18139. * Wrapper for updateUniform.
  18140. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18141. * @param {number} x
  18142. * @param {number} y
  18143. * @param {number} z
  18144. * @param {number} w
  18145. * @param {string} [suffix] Suffix to add to the uniform name.
  18146. */
  18147. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  18148. /**
  18149. * Wrapper for updateUniform.
  18150. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18151. * @param {Matrix} A 4x4 matrix.
  18152. */
  18153. updateMatrix: (name: string, mat: Matrix) => void;
  18154. /**
  18155. * Wrapper for updateUniform.
  18156. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18157. * @param {Vector3} vector
  18158. */
  18159. updateVector3: (name: string, vector: Vector3) => void;
  18160. /**
  18161. * Wrapper for updateUniform.
  18162. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18163. * @param {Vector4} vector
  18164. */
  18165. updateVector4: (name: string, vector: Vector4) => void;
  18166. /**
  18167. * Wrapper for updateUniform.
  18168. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18169. * @param {Color3} color
  18170. * @param {string} [suffix] Suffix to add to the uniform name.
  18171. */
  18172. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  18173. /**
  18174. * Wrapper for updateUniform.
  18175. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18176. * @param {Color3} color
  18177. * @param {number} alpha
  18178. * @param {string} [suffix] Suffix to add to the uniform name.
  18179. */
  18180. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  18181. /**
  18182. * Uniform buffer objects.
  18183. *
  18184. * Handles blocks of uniform on the GPU.
  18185. *
  18186. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18187. *
  18188. * For more information, please refer to :
  18189. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18190. */
  18191. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  18192. /**
  18193. * Indicates if the buffer is using the WebGL2 UBO implementation,
  18194. * or just falling back on setUniformXXX calls.
  18195. */
  18196. readonly useUbo: boolean;
  18197. /**
  18198. * Indicates if the WebGL underlying uniform buffer is in sync
  18199. * with the javascript cache data.
  18200. */
  18201. readonly isSync: boolean;
  18202. /**
  18203. * Indicates if the WebGL underlying uniform buffer is dynamic.
  18204. * Also, a dynamic UniformBuffer will disable cache verification and always
  18205. * update the underlying WebGL uniform buffer to the GPU.
  18206. */
  18207. isDynamic(): boolean;
  18208. /**
  18209. * The data cache on JS side.
  18210. */
  18211. getData(): Float32Array;
  18212. /**
  18213. * The underlying WebGL Uniform buffer.
  18214. */
  18215. getBuffer(): Nullable<WebGLBuffer>;
  18216. /**
  18217. * std140 layout specifies how to align data within an UBO structure.
  18218. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  18219. * for specs.
  18220. */
  18221. private _fillAlignment(size);
  18222. /**
  18223. * Adds an uniform in the buffer.
  18224. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  18225. * for the layout to be correct !
  18226. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18227. * @param {number|number[]} size Data size, or data directly.
  18228. */
  18229. addUniform(name: string, size: number | number[]): void;
  18230. /**
  18231. * Wrapper for addUniform.
  18232. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18233. * @param {Matrix} mat A 4x4 matrix.
  18234. */
  18235. addMatrix(name: string, mat: Matrix): void;
  18236. /**
  18237. * Wrapper for addUniform.
  18238. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18239. * @param {number} x
  18240. * @param {number} y
  18241. */
  18242. addFloat2(name: string, x: number, y: number): void;
  18243. /**
  18244. * Wrapper for addUniform.
  18245. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18246. * @param {number} x
  18247. * @param {number} y
  18248. * @param {number} z
  18249. */
  18250. addFloat3(name: string, x: number, y: number, z: number): void;
  18251. /**
  18252. * Wrapper for addUniform.
  18253. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18254. * @param {Color3} color
  18255. */
  18256. addColor3(name: string, color: Color3): void;
  18257. /**
  18258. * Wrapper for addUniform.
  18259. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18260. * @param {Color3} color
  18261. * @param {number} alpha
  18262. */
  18263. addColor4(name: string, color: Color3, alpha: number): void;
  18264. /**
  18265. * Wrapper for addUniform.
  18266. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18267. * @param {Vector3} vector
  18268. */
  18269. addVector3(name: string, vector: Vector3): void;
  18270. /**
  18271. * Wrapper for addUniform.
  18272. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18273. */
  18274. addMatrix3x3(name: string): void;
  18275. /**
  18276. * Wrapper for addUniform.
  18277. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18278. */
  18279. addMatrix2x2(name: string): void;
  18280. /**
  18281. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  18282. */
  18283. create(): void;
  18284. _rebuild(): void;
  18285. /**
  18286. * Updates the WebGL Uniform Buffer on the GPU.
  18287. * If the `dynamic` flag is set to true, no cache comparison is done.
  18288. * Otherwise, the buffer will be updated only if the cache differs.
  18289. */
  18290. update(): void;
  18291. /**
  18292. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  18293. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18294. * @param {number[]|Float32Array} data Flattened data
  18295. * @param {number} size Size of the data.
  18296. */
  18297. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  18298. private _updateMatrix3x3ForUniform(name, matrix);
  18299. private _updateMatrix3x3ForEffect(name, matrix);
  18300. private _updateMatrix2x2ForEffect(name, matrix);
  18301. private _updateMatrix2x2ForUniform(name, matrix);
  18302. private _updateFloatForEffect(name, x);
  18303. private _updateFloatForUniform(name, x);
  18304. private _updateFloat2ForEffect(name, x, y, suffix?);
  18305. private _updateFloat2ForUniform(name, x, y, suffix?);
  18306. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  18307. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  18308. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  18309. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  18310. private _updateMatrixForEffect(name, mat);
  18311. private _updateMatrixForUniform(name, mat);
  18312. private _updateVector3ForEffect(name, vector);
  18313. private _updateVector3ForUniform(name, vector);
  18314. private _updateVector4ForEffect(name, vector);
  18315. private _updateVector4ForUniform(name, vector);
  18316. private _updateColor3ForEffect(name, color, suffix?);
  18317. private _updateColor3ForUniform(name, color, suffix?);
  18318. private _updateColor4ForEffect(name, color, alpha, suffix?);
  18319. private _updateColor4ForUniform(name, color, alpha, suffix?);
  18320. /**
  18321. * Sets a sampler uniform on the effect.
  18322. * @param {string} name Name of the sampler.
  18323. * @param {Texture} texture
  18324. */
  18325. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  18326. /**
  18327. * Directly updates the value of the uniform in the cache AND on the GPU.
  18328. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18329. * @param {number[]|Float32Array} data Flattened data
  18330. */
  18331. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  18332. /**
  18333. * Binds this uniform buffer to an effect.
  18334. * @param {Effect} effect
  18335. * @param {string} name Name of the uniform block in the shader.
  18336. */
  18337. bindToEffect(effect: Effect, name: string): void;
  18338. /**
  18339. * Disposes the uniform buffer.
  18340. */
  18341. dispose(): void;
  18342. }
  18343. }
  18344. declare module BABYLON {
  18345. /**
  18346. * This represents a GPU particle system in Babylon
  18347. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  18348. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  18349. */
  18350. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  18351. /**
  18352. * The id of the Particle system.
  18353. */
  18354. id: string;
  18355. /**
  18356. * The friendly name of the Particle system.
  18357. */
  18358. name: string;
  18359. /**
  18360. * The emitter represents the Mesh or position we are attaching the particle system to.
  18361. */
  18362. emitter: Nullable<AbstractMesh | Vector3>;
  18363. /**
  18364. * The rendering group used by the Particle system to chose when to render.
  18365. */
  18366. renderingGroupId: number;
  18367. /**
  18368. * The layer mask we are rendering the particles through.
  18369. */
  18370. layerMask: number;
  18371. private _capacity;
  18372. private _activeCount;
  18373. private _currentActiveCount;
  18374. private _renderEffect;
  18375. private _updateEffect;
  18376. private _buffer0;
  18377. private _buffer1;
  18378. private _spriteBuffer;
  18379. private _updateVAO;
  18380. private _renderVAO;
  18381. private _targetIndex;
  18382. private _sourceBuffer;
  18383. private _targetBuffer;
  18384. private _scene;
  18385. private _engine;
  18386. private _currentRenderId;
  18387. private _started;
  18388. private _stopped;
  18389. private _timeDelta;
  18390. private _randomTexture;
  18391. private readonly _attributesStrideSize;
  18392. private _updateEffectOptions;
  18393. private _randomTextureSize;
  18394. private _actualFrame;
  18395. /**
  18396. * List of animations used by the particle system.
  18397. */
  18398. animations: Animation[];
  18399. /**
  18400. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  18401. */
  18402. static readonly IsSupported: boolean;
  18403. /**
  18404. * An event triggered when the system is disposed.
  18405. */
  18406. onDisposeObservable: Observable<GPUParticleSystem>;
  18407. /**
  18408. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18409. */
  18410. updateSpeed: number;
  18411. /**
  18412. * The amount of time the particle system is running (depends of the overall update speed).
  18413. */
  18414. targetStopDuration: number;
  18415. /**
  18416. * The texture used to render each particle. (this can be a spritesheet)
  18417. */
  18418. particleTexture: Nullable<Texture>;
  18419. /**
  18420. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18421. */
  18422. blendMode: number;
  18423. /**
  18424. * Minimum life time of emitting particles.
  18425. */
  18426. minLifeTime: number;
  18427. /**
  18428. * Maximum life time of emitting particles.
  18429. */
  18430. maxLifeTime: number;
  18431. /**
  18432. * Minimum Size of emitting particles.
  18433. */
  18434. minSize: number;
  18435. /**
  18436. * Maximum Size of emitting particles.
  18437. */
  18438. maxSize: number;
  18439. /**
  18440. * Minimum scale of emitting particles on X axis.
  18441. */
  18442. minScaleX: number;
  18443. /**
  18444. * Maximum scale of emitting particles on X axis.
  18445. */
  18446. maxScaleX: number;
  18447. /**
  18448. * Minimum scale of emitting particles on Y axis.
  18449. */
  18450. minScaleY: number;
  18451. /**
  18452. * Maximum scale of emitting particles on Y axis.
  18453. */
  18454. maxScaleY: number;
  18455. /**
  18456. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18457. */
  18458. color1: Color4;
  18459. /**
  18460. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18461. */
  18462. color2: Color4;
  18463. /**
  18464. * Color the particle will have at the end of its lifetime.
  18465. */
  18466. colorDead: Color4;
  18467. /**
  18468. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18469. */
  18470. emitRate: number;
  18471. /**
  18472. * You can use gravity if you want to give an orientation to your particles.
  18473. */
  18474. gravity: Vector3;
  18475. /**
  18476. * Minimum power of emitting particles.
  18477. */
  18478. minEmitPower: number;
  18479. /**
  18480. * Maximum power of emitting particles.
  18481. */
  18482. maxEmitPower: number;
  18483. /**
  18484. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18485. */
  18486. minAngularSpeed: number;
  18487. /**
  18488. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18489. */
  18490. maxAngularSpeed: number;
  18491. /**
  18492. * The particle emitter type defines the emitter used by the particle system.
  18493. * It can be for example box, sphere, or cone...
  18494. */
  18495. particleEmitterType: Nullable<IParticleEmitterType>;
  18496. /**
  18497. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18498. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18499. */
  18500. direction1: Vector3;
  18501. /**
  18502. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18504. */
  18505. direction2: Vector3;
  18506. /**
  18507. * 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.
  18508. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18509. */
  18510. minEmitBox: Vector3;
  18511. /**
  18512. * 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.
  18513. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18514. */
  18515. maxEmitBox: Vector3;
  18516. /**
  18517. * Gets the maximum number of particles active at the same time.
  18518. * @returns The max number of active particles.
  18519. */
  18520. getCapacity(): number;
  18521. /**
  18522. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18523. * to override the particles.
  18524. */
  18525. forceDepthWrite: boolean;
  18526. /**
  18527. * Gets or set the number of active particles
  18528. */
  18529. activeParticleCount: number;
  18530. /**
  18531. * Is this system ready to be used/rendered
  18532. * @return true if the system is ready
  18533. */
  18534. isReady(): boolean;
  18535. /**
  18536. * Gets Wether the system has been started.
  18537. * @returns True if it has been started, otherwise false.
  18538. */
  18539. isStarted(): boolean;
  18540. /**
  18541. * Starts the particle system and begins to emit.
  18542. */
  18543. start(): void;
  18544. /**
  18545. * Stops the particle system.
  18546. */
  18547. stop(): void;
  18548. /**
  18549. * Remove all active particles
  18550. */
  18551. reset(): void;
  18552. /**
  18553. * Returns the string "GPUParticleSystem"
  18554. * @returns a string containing the class name
  18555. */
  18556. getClassName(): string;
  18557. /**
  18558. * Instantiates a GPU particle system.
  18559. * 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.
  18560. * @param name The name of the particle system
  18561. * @param capacity The max number of particles alive at the same time
  18562. * @param scene The scene the particle system belongs to
  18563. */
  18564. constructor(name: string, options: Partial<{
  18565. capacity: number;
  18566. randomTextureSize: number;
  18567. }>, scene: Scene);
  18568. private _createUpdateVAO(source);
  18569. private _createRenderVAO(source, spriteSource);
  18570. private _initialize(force?);
  18571. /** @hidden */
  18572. _recreateUpdateEffect(): void;
  18573. /** @hidden */
  18574. _recreateRenderEffect(): void;
  18575. /**
  18576. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18577. */
  18578. animate(): void;
  18579. /**
  18580. * Renders the particle system in its current state.
  18581. * @returns the current number of particles
  18582. */
  18583. render(): number;
  18584. /**
  18585. * Rebuilds the particle system
  18586. */
  18587. rebuild(): void;
  18588. private _releaseBuffers();
  18589. private _releaseVAOs();
  18590. /**
  18591. * Disposes the particle system and free the associated resources
  18592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18593. */
  18594. dispose(disposeTexture?: boolean): void;
  18595. /**
  18596. * Clones the particle system.
  18597. * @param name The name of the cloned object
  18598. * @param newEmitter The new emitter to use
  18599. * @returns the cloned particle system
  18600. */
  18601. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  18602. /**
  18603. * Serializes the particle system to a JSON object.
  18604. * @returns the JSON object
  18605. */
  18606. serialize(): any;
  18607. /**
  18608. * Parses a JSON object to create a GPU particle system.
  18609. * @param parsedParticleSystem The JSON object to parse
  18610. * @param scene The scene to create the particle system in
  18611. * @param rootUrl The root url to use to load external dependencies like texture
  18612. * @returns the parsed GPU particle system
  18613. */
  18614. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  18615. }
  18616. }
  18617. declare module BABYLON {
  18618. /**
  18619. * Interface representing a particle system in Babylon.
  18620. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18621. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18622. */
  18623. interface IParticleSystem {
  18624. /**
  18625. * The id of the Particle system.
  18626. */
  18627. id: string;
  18628. /**
  18629. * The name of the Particle system.
  18630. */
  18631. name: string;
  18632. /**
  18633. * The emitter represents the Mesh or position we are attaching the particle system to.
  18634. */
  18635. emitter: Nullable<AbstractMesh | Vector3>;
  18636. /**
  18637. * The rendering group used by the Particle system to chose when to render.
  18638. */
  18639. renderingGroupId: number;
  18640. /**
  18641. * The layer mask we are rendering the particles through.
  18642. */
  18643. layerMask: number;
  18644. /**
  18645. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18646. */
  18647. updateSpeed: number;
  18648. /**
  18649. * The amount of time the particle system is running (depends of the overall update speed).
  18650. */
  18651. targetStopDuration: number;
  18652. /**
  18653. * The texture used to render each particle. (this can be a spritesheet)
  18654. */
  18655. particleTexture: Nullable<Texture>;
  18656. /**
  18657. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18658. */
  18659. blendMode: number;
  18660. /**
  18661. * Minimum life time of emitting particles.
  18662. */
  18663. minLifeTime: number;
  18664. /**
  18665. * Maximum life time of emitting particles.
  18666. */
  18667. maxLifeTime: number;
  18668. /**
  18669. * Minimum Size of emitting particles.
  18670. */
  18671. minSize: number;
  18672. /**
  18673. * Maximum Size of emitting particles.
  18674. */
  18675. maxSize: number;
  18676. /**
  18677. * Minimum scale of emitting particles on X axis.
  18678. */
  18679. minScaleX: number;
  18680. /**
  18681. * Maximum scale of emitting particles on X axis.
  18682. */
  18683. maxScaleX: number;
  18684. /**
  18685. * Minimum scale of emitting particles on Y axis.
  18686. */
  18687. minScaleY: number;
  18688. /**
  18689. * Maximum scale of emitting particles on Y axis.
  18690. */
  18691. maxScaleY: number;
  18692. /**
  18693. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18694. */
  18695. color1: Color4;
  18696. /**
  18697. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18698. */
  18699. color2: Color4;
  18700. /**
  18701. * Color the particle will have at the end of its lifetime.
  18702. */
  18703. colorDead: Color4;
  18704. /**
  18705. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18706. */
  18707. emitRate: number;
  18708. /**
  18709. * You can use gravity if you want to give an orientation to your particles.
  18710. */
  18711. gravity: Vector3;
  18712. /**
  18713. * Minimum power of emitting particles.
  18714. */
  18715. minEmitPower: number;
  18716. /**
  18717. * Maximum power of emitting particles.
  18718. */
  18719. maxEmitPower: number;
  18720. /**
  18721. * The particle emitter type defines the emitter used by the particle system.
  18722. * It can be for example box, sphere, or cone...
  18723. */
  18724. particleEmitterType: Nullable<IParticleEmitterType>;
  18725. /**
  18726. * Gets the maximum number of particles active at the same time.
  18727. * @returns The max number of active particles.
  18728. */
  18729. getCapacity(): number;
  18730. /**
  18731. * Gets Wether the system has been started.
  18732. * @returns True if it has been started, otherwise false.
  18733. */
  18734. isStarted(): boolean;
  18735. /**
  18736. * Gets if the particle system has been started.
  18737. * @return true if the system has been started, otherwise false.
  18738. */
  18739. isStarted(): boolean;
  18740. /**
  18741. * Animates the particle system for this frame.
  18742. */
  18743. animate(): void;
  18744. /**
  18745. * Renders the particle system in its current state.
  18746. * @returns the current number of particles
  18747. */
  18748. render(): number;
  18749. /**
  18750. * Dispose the particle system and frees its associated resources.
  18751. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18752. */
  18753. dispose(disposeTexture?: boolean): void;
  18754. /**
  18755. * Clones the particle system.
  18756. * @param name The name of the cloned object
  18757. * @param newEmitter The new emitter to use
  18758. * @returns the cloned particle system
  18759. */
  18760. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18761. /**
  18762. * Serializes the particle system to a JSON object.
  18763. * @returns the JSON object
  18764. */
  18765. serialize(): any;
  18766. /**
  18767. * Rebuild the particle system
  18768. */
  18769. rebuild(): void;
  18770. /**
  18771. * Starts the particle system and begins to emit.
  18772. */
  18773. start(): void;
  18774. /**
  18775. * Stops the particle system.
  18776. */
  18777. stop(): void;
  18778. /**
  18779. * Remove all active particles
  18780. */
  18781. reset(): void;
  18782. /**
  18783. * Is this system ready to be used/rendered
  18784. * @return true if the system is ready
  18785. */
  18786. isReady(): boolean;
  18787. }
  18788. }
  18789. declare module BABYLON {
  18790. /**
  18791. * A particle represents one of the element emitted by a particle system.
  18792. * This is mainly define by its coordinates, direction, velocity and age.
  18793. */
  18794. class Particle {
  18795. /**
  18796. * particleSystem the particle system the particle belongs to.
  18797. */
  18798. particleSystem: ParticleSystem;
  18799. /**
  18800. * The world position of the particle in the scene.
  18801. */
  18802. position: Vector3;
  18803. /**
  18804. * The world direction of the particle in the scene.
  18805. */
  18806. direction: Vector3;
  18807. /**
  18808. * The color of the particle.
  18809. */
  18810. color: Color4;
  18811. /**
  18812. * The color change of the particle per step.
  18813. */
  18814. colorStep: Color4;
  18815. /**
  18816. * Defines how long will the life of the particle be.
  18817. */
  18818. lifeTime: number;
  18819. /**
  18820. * The current age of the particle.
  18821. */
  18822. age: number;
  18823. /**
  18824. * The current size of the particle.
  18825. */
  18826. size: number;
  18827. /**
  18828. * The current scale of the particle.
  18829. */
  18830. scale: Vector2;
  18831. /**
  18832. * The current angle of the particle.
  18833. */
  18834. angle: number;
  18835. /**
  18836. * Defines how fast is the angle changing.
  18837. */
  18838. angularSpeed: number;
  18839. /**
  18840. * Defines the cell index used by the particle to be rendered from a sprite.
  18841. */
  18842. cellIndex: number;
  18843. private _currentFrameCounter;
  18844. /**
  18845. * Creates a new instance Particle
  18846. * @param particleSystem the particle system the particle belongs to
  18847. */
  18848. constructor(
  18849. /**
  18850. * particleSystem the particle system the particle belongs to.
  18851. */
  18852. particleSystem: ParticleSystem);
  18853. private updateCellInfoFromSystem();
  18854. /**
  18855. * Defines how the sprite cell index is updated for the particle. This is
  18856. * defined as a callback.
  18857. */
  18858. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18859. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18860. private _updateCellIndexWithCustomSpeed();
  18861. /**
  18862. * Copy the properties of particle to another one.
  18863. * @param other the particle to copy the information to.
  18864. */
  18865. copyTo(other: Particle): void;
  18866. }
  18867. }
  18868. declare module BABYLON {
  18869. /**
  18870. * This represents a particle system in Babylon.
  18871. * 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.
  18872. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18873. * @example https://doc.babylonjs.com/babylon101/particles
  18874. */
  18875. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18876. /**
  18877. * Source color is added to the destination color without alpha affecting the result.
  18878. */
  18879. static BLENDMODE_ONEONE: number;
  18880. /**
  18881. * Blend current color and particle color using particle’s alpha.
  18882. */
  18883. static BLENDMODE_STANDARD: number;
  18884. /**
  18885. * List of animations used by the particle system.
  18886. */
  18887. animations: Animation[];
  18888. /**
  18889. * The id of the Particle system.
  18890. */
  18891. id: string;
  18892. /**
  18893. * The friendly name of the Particle system.
  18894. */
  18895. name: string;
  18896. /**
  18897. * The rendering group used by the Particle system to chose when to render.
  18898. */
  18899. renderingGroupId: number;
  18900. /**
  18901. * The emitter represents the Mesh or position we are attaching the particle system to.
  18902. */
  18903. emitter: Nullable<AbstractMesh | Vector3>;
  18904. /**
  18905. * The maximum number of particles to emit per frame
  18906. */
  18907. emitRate: number;
  18908. /**
  18909. * If you want to launch only a few particles at once, that can be done, as well.
  18910. */
  18911. manualEmitCount: number;
  18912. /**
  18913. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18914. */
  18915. updateSpeed: number;
  18916. /**
  18917. * The amount of time the particle system is running (depends of the overall update speed).
  18918. */
  18919. targetStopDuration: number;
  18920. /**
  18921. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18922. */
  18923. disposeOnStop: boolean;
  18924. /**
  18925. * Minimum power of emitting particles.
  18926. */
  18927. minEmitPower: number;
  18928. /**
  18929. * Maximum power of emitting particles.
  18930. */
  18931. maxEmitPower: number;
  18932. /**
  18933. * Minimum life time of emitting particles.
  18934. */
  18935. minLifeTime: number;
  18936. /**
  18937. * Maximum life time of emitting particles.
  18938. */
  18939. maxLifeTime: number;
  18940. /**
  18941. * Minimum Size of emitting particles.
  18942. */
  18943. minSize: number;
  18944. /**
  18945. * Maximum Size of emitting particles.
  18946. */
  18947. maxSize: number;
  18948. /**
  18949. * Minimum scale of emitting particles on X axis.
  18950. */
  18951. minScaleX: number;
  18952. /**
  18953. * Maximum scale of emitting particles on X axis.
  18954. */
  18955. maxScaleX: number;
  18956. /**
  18957. * Minimum scale of emitting particles on Y axis.
  18958. */
  18959. minScaleY: number;
  18960. /**
  18961. * Maximum scale of emitting particles on Y axis.
  18962. */
  18963. maxScaleY: number;
  18964. /**
  18965. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18966. */
  18967. minAngularSpeed: number;
  18968. /**
  18969. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18970. */
  18971. maxAngularSpeed: number;
  18972. /**
  18973. * The texture used to render each particle. (this can be a spritesheet)
  18974. */
  18975. particleTexture: Nullable<Texture>;
  18976. /**
  18977. * The layer mask we are rendering the particles through.
  18978. */
  18979. layerMask: number;
  18980. /**
  18981. * This can help using your own shader to render the particle system.
  18982. * The according effect will be created
  18983. */
  18984. customShader: any;
  18985. /**
  18986. * By default particle system starts as soon as they are created. This prevents the
  18987. * automatic start to happen and let you decide when to start emitting particles.
  18988. */
  18989. preventAutoStart: boolean;
  18990. /**
  18991. * This function can be defined to provide custom update for active particles.
  18992. * This function will be called instead of regular update (age, position, color, etc.).
  18993. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18994. */
  18995. updateFunction: (particles: Particle[]) => void;
  18996. /**
  18997. * Callback triggered when the particle animation is ending.
  18998. */
  18999. onAnimationEnd: Nullable<() => void>;
  19000. /**
  19001. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19002. */
  19003. blendMode: number;
  19004. /**
  19005. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19006. * to override the particles.
  19007. */
  19008. forceDepthWrite: boolean;
  19009. /**
  19010. * You can use gravity if you want to give an orientation to your particles.
  19011. */
  19012. gravity: Vector3;
  19013. /**
  19014. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19015. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19016. */
  19017. direction1: Vector3;
  19018. /**
  19019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19020. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19021. */
  19022. direction2: Vector3;
  19023. /**
  19024. * 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.
  19025. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19026. */
  19027. minEmitBox: Vector3;
  19028. /**
  19029. * 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.
  19030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19031. */
  19032. maxEmitBox: Vector3;
  19033. /**
  19034. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19035. */
  19036. color1: Color4;
  19037. /**
  19038. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19039. */
  19040. color2: Color4;
  19041. /**
  19042. * Color the particle will have at the end of its lifetime.
  19043. */
  19044. colorDead: Color4;
  19045. /**
  19046. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  19047. */
  19048. textureMask: Color4;
  19049. /**
  19050. * The particle emitter type defines the emitter used by the particle system.
  19051. * It can be for example box, sphere, or cone...
  19052. */
  19053. particleEmitterType: IParticleEmitterType;
  19054. /**
  19055. * This function can be defined to specify initial direction for every new particle.
  19056. * It by default use the emitterType defined function.
  19057. */
  19058. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19059. /**
  19060. * This function can be defined to specify initial position for every new particle.
  19061. * It by default use the emitterType defined function.
  19062. */
  19063. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19064. /**
  19065. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  19066. */
  19067. spriteCellLoop: boolean;
  19068. /**
  19069. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  19070. */
  19071. spriteCellChangeSpeed: number;
  19072. /**
  19073. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  19074. */
  19075. startSpriteCellID: number;
  19076. /**
  19077. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  19078. */
  19079. endSpriteCellID: number;
  19080. /**
  19081. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  19082. */
  19083. spriteCellWidth: number;
  19084. /**
  19085. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  19086. */
  19087. spriteCellHeight: number;
  19088. /**
  19089. * An event triggered when the system is disposed.
  19090. */
  19091. onDisposeObservable: Observable<ParticleSystem>;
  19092. private _onDisposeObserver;
  19093. /**
  19094. * Sets a callback that will be triggered when the system is disposed.
  19095. */
  19096. onDispose: () => void;
  19097. /**
  19098. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  19099. */
  19100. readonly isAnimationSheetEnabled: Boolean;
  19101. private _particles;
  19102. private _epsilon;
  19103. private _capacity;
  19104. private _scene;
  19105. private _stockParticles;
  19106. private _newPartsExcess;
  19107. private _vertexData;
  19108. private _vertexBuffer;
  19109. private _vertexBuffers;
  19110. private _indexBuffer;
  19111. private _effect;
  19112. private _customEffect;
  19113. private _cachedDefines;
  19114. private _scaledColorStep;
  19115. private _colorDiff;
  19116. private _scaledDirection;
  19117. private _scaledGravity;
  19118. private _currentRenderId;
  19119. private _alive;
  19120. private _started;
  19121. private _stopped;
  19122. private _actualFrame;
  19123. private _scaledUpdateSpeed;
  19124. private _vertexBufferSize;
  19125. private _isAnimationSheetEnabled;
  19126. /**
  19127. * 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.
  19128. */
  19129. subEmitters: ParticleSystem[];
  19130. /**
  19131. * The current active Sub-systems, this property is used by the root particle system only.
  19132. */
  19133. activeSubSystems: Array<ParticleSystem>;
  19134. private _rootParticleSystem;
  19135. /**
  19136. * Gets the current list of active particles
  19137. */
  19138. readonly particles: Particle[];
  19139. /**
  19140. * Returns the string "ParticleSystem"
  19141. * @returns a string containing the class name
  19142. */
  19143. getClassName(): string;
  19144. /**
  19145. * Instantiates a particle system.
  19146. * 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.
  19147. * @param name The name of the particle system
  19148. * @param capacity The max number of particles alive at the same time
  19149. * @param scene The scene the particle system belongs to
  19150. * @param customEffect a custom effect used to change the way particles are rendered by default
  19151. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19152. * @param epsilon Offset used to render the particles
  19153. */
  19154. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19155. private _createIndexBuffer();
  19156. /**
  19157. * Gets the maximum number of particles active at the same time.
  19158. * @returns The max number of active particles.
  19159. */
  19160. getCapacity(): number;
  19161. /**
  19162. * Gets Wether there are still active particles in the system.
  19163. * @returns True if it is alive, otherwise false.
  19164. */
  19165. isAlive(): boolean;
  19166. /**
  19167. * Gets Wether the system has been started.
  19168. * @returns True if it has been started, otherwise false.
  19169. */
  19170. isStarted(): boolean;
  19171. /**
  19172. * Starts the particle system and begins to emit.
  19173. */
  19174. start(): void;
  19175. /**
  19176. * Stops the particle system.
  19177. * @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.
  19178. */
  19179. stop(stopSubEmitters?: boolean): void;
  19180. /**
  19181. * Remove all active particles
  19182. */
  19183. reset(): void;
  19184. /**
  19185. * @hidden (for internal use only)
  19186. */
  19187. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19188. /**
  19189. * @hidden (for internal use only)
  19190. */
  19191. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19192. /**
  19193. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19194. * Its lifetime will start back at 0.
  19195. */
  19196. recycleParticle: (particle: Particle) => void;
  19197. private _stopSubEmitters();
  19198. private _createParticle;
  19199. private _removeFromRoot();
  19200. private _emitFromParticle;
  19201. private _update(newParticles);
  19202. private _getEffect();
  19203. /**
  19204. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19205. */
  19206. animate(): void;
  19207. private _appendParticleVertexes;
  19208. private _appenedParticleVertexesWithSheet(offset, particle);
  19209. private _appenedParticleVertexesNoSheet(offset, particle);
  19210. /**
  19211. * Rebuilds the particle system.
  19212. */
  19213. rebuild(): void;
  19214. /**
  19215. * Is this system ready to be used/rendered
  19216. * @return true if the system is ready
  19217. */
  19218. isReady(): boolean;
  19219. /**
  19220. * Renders the particle system in its current state.
  19221. * @returns the current number of particles
  19222. */
  19223. render(): number;
  19224. /**
  19225. * Disposes the particle system and free the associated resources
  19226. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19227. */
  19228. dispose(disposeTexture?: boolean): void;
  19229. /**
  19230. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  19231. * @param radius The radius of the sphere to emit from
  19232. * @returns the emitter
  19233. */
  19234. createSphereEmitter(radius?: number): SphereParticleEmitter;
  19235. /**
  19236. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  19237. * @param radius The radius of the sphere to emit from
  19238. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19239. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19240. * @returns the emitter
  19241. */
  19242. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19243. /**
  19244. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  19245. * @param radius The radius of the cone to emit from
  19246. * @param angle The base angle of the cone
  19247. * @returns the emitter
  19248. */
  19249. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19250. /**
  19251. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19252. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19253. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19254. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19255. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19256. * @returns the emitter
  19257. */
  19258. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19259. /**
  19260. * Clones the particle system.
  19261. * @param name The name of the cloned object
  19262. * @param newEmitter The new emitter to use
  19263. * @returns the cloned particle system
  19264. */
  19265. clone(name: string, newEmitter: any): ParticleSystem;
  19266. /**
  19267. * Serializes the particle system to a JSON object.
  19268. * @returns the JSON object
  19269. */
  19270. serialize(): any;
  19271. /**
  19272. * Parses a JSON object to create a particle system.
  19273. * @param parsedParticleSystem The JSON object to parse
  19274. * @param scene The scene to create the particle system in
  19275. * @param rootUrl The root url to use to load external dependencies like texture
  19276. * @returns the Parsed particle system
  19277. */
  19278. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  19279. }
  19280. }
  19281. declare module BABYLON {
  19282. /**
  19283. * Represents one particle of a solid particle system.
  19284. */
  19285. class SolidParticle {
  19286. /**
  19287. * particle global index
  19288. */
  19289. idx: number;
  19290. /**
  19291. * The color of the particle
  19292. */
  19293. color: Nullable<Color4>;
  19294. /**
  19295. * The world space position of the particle.
  19296. */
  19297. position: Vector3;
  19298. /**
  19299. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  19300. */
  19301. rotation: Vector3;
  19302. /**
  19303. * The world space rotation quaternion of the particle.
  19304. */
  19305. rotationQuaternion: Nullable<Quaternion>;
  19306. /**
  19307. * The scaling of the particle.
  19308. */
  19309. scaling: Vector3;
  19310. /**
  19311. * The uvs of the particle.
  19312. */
  19313. uvs: Vector4;
  19314. /**
  19315. * The current speed of the particle.
  19316. */
  19317. velocity: Vector3;
  19318. /**
  19319. * The pivot point in the particle local space.
  19320. */
  19321. pivot: Vector3;
  19322. /**
  19323. * Must the particle be translated from its pivot point in its local space ?
  19324. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  19325. * Default : false
  19326. */
  19327. translateFromPivot: boolean;
  19328. /**
  19329. * Is the particle active or not ?
  19330. */
  19331. alive: boolean;
  19332. /**
  19333. * Is the particle visible or not ?
  19334. */
  19335. isVisible: boolean;
  19336. /**
  19337. * Index of this particle in the global "positions" array (Internal use)
  19338. */
  19339. _pos: number;
  19340. /**
  19341. * Index of this particle in the global "indices" array (Internal use)
  19342. */
  19343. _ind: number;
  19344. /**
  19345. * ModelShape of this particle (Internal use)
  19346. */
  19347. _model: ModelShape;
  19348. /**
  19349. * ModelShape id of this particle
  19350. */
  19351. shapeId: number;
  19352. /**
  19353. * Index of the particle in its shape id (Internal use)
  19354. */
  19355. idxInShape: number;
  19356. /**
  19357. * Reference to the shape model BoundingInfo object (Internal use)
  19358. */
  19359. _modelBoundingInfo: BoundingInfo;
  19360. /**
  19361. * Particle BoundingInfo object (Internal use)
  19362. */
  19363. _boundingInfo: BoundingInfo;
  19364. /**
  19365. * Reference to the SPS what the particle belongs to (Internal use)
  19366. */
  19367. _sps: SolidParticleSystem;
  19368. /**
  19369. * Still set as invisible in order to skip useless computations (Internal use)
  19370. */
  19371. _stillInvisible: boolean;
  19372. /**
  19373. * Last computed particle rotation matrix
  19374. */
  19375. _rotationMatrix: number[];
  19376. /**
  19377. * Parent particle Id, if any.
  19378. * Default null.
  19379. */
  19380. parentId: Nullable<number>;
  19381. /**
  19382. * Internal global position in the SPS.
  19383. */
  19384. _globalPosition: Vector3;
  19385. /**
  19386. * Creates a Solid Particle object.
  19387. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  19388. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  19389. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  19390. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  19391. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  19392. * @param shapeId (integer) is the model shape identifier in the SPS.
  19393. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  19394. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  19395. */
  19396. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  19397. /**
  19398. * Legacy support, changed scale to scaling
  19399. */
  19400. /**
  19401. * Legacy support, changed scale to scaling
  19402. */
  19403. scale: Vector3;
  19404. /**
  19405. * Legacy support, changed quaternion to rotationQuaternion
  19406. */
  19407. /**
  19408. * Legacy support, changed quaternion to rotationQuaternion
  19409. */
  19410. quaternion: Nullable<Quaternion>;
  19411. /**
  19412. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  19413. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  19414. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  19415. * @returns true if it intersects
  19416. */
  19417. intersectsMesh(target: Mesh | SolidParticle): boolean;
  19418. }
  19419. /**
  19420. * Represents the shape of the model used by one particle of a solid particle system.
  19421. * SPS internal tool, don't use it manually.
  19422. */
  19423. class ModelShape {
  19424. /**
  19425. * The shape id.
  19426. */
  19427. shapeID: number;
  19428. /**
  19429. * flat array of model positions (internal use)
  19430. */
  19431. _shape: Vector3[];
  19432. /**
  19433. * flat array of model UVs (internal use)
  19434. */
  19435. _shapeUV: number[];
  19436. /**
  19437. * length of the shape in the model indices array (internal use)
  19438. */
  19439. _indicesLength: number;
  19440. /**
  19441. * Custom position function (internal use)
  19442. */
  19443. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  19444. /**
  19445. * Custom vertex function (internal use)
  19446. */
  19447. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  19448. /**
  19449. * 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.
  19450. * SPS internal tool, don't use it manually.
  19451. * @hidden
  19452. */
  19453. 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>);
  19454. }
  19455. /**
  19456. * Represents a Depth Sorted Particle in the solid particle system.
  19457. */
  19458. class DepthSortedParticle {
  19459. /**
  19460. * Index of the particle in the "indices" array
  19461. */
  19462. ind: number;
  19463. /**
  19464. * Length of the particle shape in the "indices" array
  19465. */
  19466. indicesLength: number;
  19467. /**
  19468. * Squared distance from the particle to the camera
  19469. */
  19470. sqDistance: number;
  19471. }
  19472. }
  19473. declare module BABYLON {
  19474. /**
  19475. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  19476. *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.
  19477. * The SPS is also a particle system. It provides some methods to manage the particles.
  19478. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  19479. *
  19480. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  19481. */
  19482. class SolidParticleSystem implements IDisposable {
  19483. /**
  19484. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  19485. * Example : var p = SPS.particles[i];
  19486. */
  19487. particles: SolidParticle[];
  19488. /**
  19489. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  19490. */
  19491. nbParticles: number;
  19492. /**
  19493. * If the particles must ever face the camera (default false). Useful for planar particles.
  19494. */
  19495. billboard: boolean;
  19496. /**
  19497. * Recompute normals when adding a shape
  19498. */
  19499. recomputeNormals: boolean;
  19500. /**
  19501. * This a counter ofr your own usage. It's not set by any SPS functions.
  19502. */
  19503. counter: number;
  19504. /**
  19505. * The SPS name. This name is also given to the underlying mesh.
  19506. */
  19507. name: string;
  19508. /**
  19509. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  19510. */
  19511. mesh: Mesh;
  19512. /**
  19513. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  19514. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  19515. */
  19516. vars: any;
  19517. /**
  19518. * This array is populated when the SPS is set as 'pickable'.
  19519. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  19520. * Each element of this array is an object `{idx: int, faceId: int}`.
  19521. * `idx` is the picked particle index in the `SPS.particles` array
  19522. * `faceId` is the picked face index counted within this particle.
  19523. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  19524. */
  19525. pickedParticles: {
  19526. idx: number;
  19527. faceId: number;
  19528. }[];
  19529. /**
  19530. * This array is populated when `enableDepthSort` is set to true.
  19531. * Each element of this array is an instance of the class DepthSortedParticle.
  19532. */
  19533. depthSortedParticles: DepthSortedParticle[];
  19534. /**
  19535. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  19536. */
  19537. _bSphereOnly: boolean;
  19538. /**
  19539. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  19540. */
  19541. _bSphereRadiusFactor: number;
  19542. private _scene;
  19543. private _positions;
  19544. private _indices;
  19545. private _normals;
  19546. private _colors;
  19547. private _uvs;
  19548. private _indices32;
  19549. private _positions32;
  19550. private _normals32;
  19551. private _fixedNormal32;
  19552. private _colors32;
  19553. private _uvs32;
  19554. private _index;
  19555. private _updatable;
  19556. private _pickable;
  19557. private _isVisibilityBoxLocked;
  19558. private _alwaysVisible;
  19559. private _depthSort;
  19560. private _shapeCounter;
  19561. private _copy;
  19562. private _shape;
  19563. private _shapeUV;
  19564. private _color;
  19565. private _computeParticleColor;
  19566. private _computeParticleTexture;
  19567. private _computeParticleRotation;
  19568. private _computeParticleVertex;
  19569. private _computeBoundingBox;
  19570. private _depthSortParticles;
  19571. private _cam_axisZ;
  19572. private _cam_axisY;
  19573. private _cam_axisX;
  19574. private _axisZ;
  19575. private _camera;
  19576. private _particle;
  19577. private _camDir;
  19578. private _camInvertedPosition;
  19579. private _rotMatrix;
  19580. private _invertMatrix;
  19581. private _rotated;
  19582. private _quaternion;
  19583. private _vertex;
  19584. private _normal;
  19585. private _yaw;
  19586. private _pitch;
  19587. private _roll;
  19588. private _halfroll;
  19589. private _halfpitch;
  19590. private _halfyaw;
  19591. private _sinRoll;
  19592. private _cosRoll;
  19593. private _sinPitch;
  19594. private _cosPitch;
  19595. private _sinYaw;
  19596. private _cosYaw;
  19597. private _mustUnrotateFixedNormals;
  19598. private _minimum;
  19599. private _maximum;
  19600. private _minBbox;
  19601. private _maxBbox;
  19602. private _particlesIntersect;
  19603. private _depthSortFunction;
  19604. private _needs32Bits;
  19605. private _pivotBackTranslation;
  19606. private _scaledPivot;
  19607. private _particleHasParent;
  19608. private _parent;
  19609. /**
  19610. * Creates a SPS (Solid Particle System) object.
  19611. * @param name (String) is the SPS name, this will be the underlying mesh name.
  19612. * @param scene (Scene) is the scene in which the SPS is added.
  19613. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  19614. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  19615. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  19616. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  19617. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  19618. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  19619. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  19620. */
  19621. constructor(name: string, scene: Scene, options?: {
  19622. updatable?: boolean;
  19623. isPickable?: boolean;
  19624. enableDepthSort?: boolean;
  19625. particleIntersection?: boolean;
  19626. boundingSphereOnly?: boolean;
  19627. bSphereRadiusFactor?: number;
  19628. });
  19629. /**
  19630. * Builds the SPS underlying mesh. Returns a standard Mesh.
  19631. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  19632. * @returns the created mesh
  19633. */
  19634. buildMesh(): Mesh;
  19635. /**
  19636. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  19637. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  19638. * Thus the particles generated from `digest()` have their property `position` set yet.
  19639. * @param mesh ( Mesh ) is the mesh to be digested
  19640. * @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
  19641. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  19642. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  19643. * @returns the current SPS
  19644. */
  19645. digest(mesh: Mesh, options?: {
  19646. facetNb?: number;
  19647. number?: number;
  19648. delta?: number;
  19649. }): SolidParticleSystem;
  19650. private _unrotateFixedNormals();
  19651. private _resetCopy();
  19652. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  19653. private _posToShape(positions);
  19654. private _uvsToShapeUV(uvs);
  19655. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  19656. /**
  19657. * Adds some particles to the SPS from the model shape. Returns the shape id.
  19658. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  19659. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  19660. * @param nb (positive integer) the number of particles to be created from this model
  19661. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  19662. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  19663. * @returns the number of shapes in the system
  19664. */
  19665. addShape(mesh: Mesh, nb: number, options?: {
  19666. positionFunction?: any;
  19667. vertexFunction?: any;
  19668. }): number;
  19669. private _rebuildParticle(particle);
  19670. /**
  19671. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  19672. * @returns the SPS.
  19673. */
  19674. rebuildMesh(): SolidParticleSystem;
  19675. /**
  19676. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  19677. * This method calls `updateParticle()` for each particle of the SPS.
  19678. * For an animated SPS, it is usually called within the render loop.
  19679. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  19680. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  19681. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  19682. * @returns the SPS.
  19683. */
  19684. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  19685. private _quaternionRotationYPR();
  19686. private _quaternionToRotationMatrix();
  19687. /**
  19688. * Disposes the SPS.
  19689. */
  19690. dispose(): void;
  19691. /**
  19692. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  19693. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19694. * @returns the SPS.
  19695. */
  19696. refreshVisibleSize(): SolidParticleSystem;
  19697. /**
  19698. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  19699. * @param size the size (float) of the visibility box
  19700. * note : this doesn't lock the SPS mesh bounding box.
  19701. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19702. */
  19703. setVisibilityBox(size: number): void;
  19704. /**
  19705. * Gets whether the SPS as always visible or not
  19706. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19707. */
  19708. /**
  19709. * Sets the SPS as always visible or not
  19710. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19711. */
  19712. isAlwaysVisible: boolean;
  19713. /**
  19714. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19715. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19716. */
  19717. /**
  19718. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19719. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19720. */
  19721. isVisibilityBoxLocked: boolean;
  19722. /**
  19723. * Gets if `setParticles()` computes the particle rotations or not.
  19724. * Default value : true. The SPS is faster when it's set to false.
  19725. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19726. */
  19727. /**
  19728. * Tells to `setParticles()` to compute the particle rotations or not.
  19729. * Default value : true. The SPS is faster when it's set to false.
  19730. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19731. */
  19732. computeParticleRotation: boolean;
  19733. /**
  19734. * Gets if `setParticles()` computes the particle colors or not.
  19735. * Default value : true. The SPS is faster when it's set to false.
  19736. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19737. */
  19738. /**
  19739. * Tells to `setParticles()` to compute the particle colors or not.
  19740. * Default value : true. The SPS is faster when it's set to false.
  19741. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19742. */
  19743. computeParticleColor: boolean;
  19744. /**
  19745. * Gets if `setParticles()` computes the particle textures or not.
  19746. * Default value : true. The SPS is faster when it's set to false.
  19747. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19748. */
  19749. computeParticleTexture: boolean;
  19750. /**
  19751. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19752. * Default value : false. The SPS is faster when it's set to false.
  19753. * Note : the particle custom vertex positions aren't stored values.
  19754. */
  19755. /**
  19756. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19757. * Default value : false. The SPS is faster when it's set to false.
  19758. * Note : the particle custom vertex positions aren't stored values.
  19759. */
  19760. computeParticleVertex: boolean;
  19761. /**
  19762. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19763. */
  19764. /**
  19765. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19766. */
  19767. computeBoundingBox: boolean;
  19768. /**
  19769. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19770. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19771. * Default : `true`
  19772. */
  19773. /**
  19774. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19775. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19776. * Default : `true`
  19777. */
  19778. depthSortParticles: boolean;
  19779. /**
  19780. * This function does nothing. It may be overwritten to set all the particle first values.
  19781. * The SPS doesn't call this function, you may have to call it by your own.
  19782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19783. */
  19784. initParticles(): void;
  19785. /**
  19786. * This function does nothing. It may be overwritten to recycle a particle.
  19787. * The SPS doesn't call this function, you may have to call it by your own.
  19788. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19789. * @param particle The particle to recycle
  19790. * @returns the recycled particle
  19791. */
  19792. recycleParticle(particle: SolidParticle): SolidParticle;
  19793. /**
  19794. * Updates a particle : this function should be overwritten by the user.
  19795. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19796. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19797. * @example : just set a particle position or velocity and recycle conditions
  19798. * @param particle The particle to update
  19799. * @returns the updated particle
  19800. */
  19801. updateParticle(particle: SolidParticle): SolidParticle;
  19802. /**
  19803. * Updates a vertex of a particle : it can be overwritten by the user.
  19804. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19805. * @param particle the current particle
  19806. * @param vertex the current index of the current particle
  19807. * @param pt the index of the current vertex in the particle shape
  19808. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19809. * @example : just set a vertex particle position
  19810. * @returns the updated vertex
  19811. */
  19812. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19813. /**
  19814. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19815. * This does nothing and may be overwritten by the user.
  19816. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19817. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19818. * @param update the boolean update value actually passed to setParticles()
  19819. */
  19820. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19821. /**
  19822. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19823. * This will be passed three parameters.
  19824. * This does nothing and may be overwritten by the user.
  19825. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19826. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19827. * @param update the boolean update value actually passed to setParticles()
  19828. */
  19829. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19830. }
  19831. }
  19832. declare module BABYLON {
  19833. /**
  19834. * Class used to store all common mesh properties
  19835. */
  19836. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19837. /** No occlusion */
  19838. static OCCLUSION_TYPE_NONE: number;
  19839. /** Occlusion set to optimisitic */
  19840. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19841. /** Occlusion set to strict */
  19842. static OCCLUSION_TYPE_STRICT: number;
  19843. /** Use an accurante occlusion algorithm */
  19844. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19845. /** Use a conservative occlusion algorithm */
  19846. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19847. /**
  19848. * No billboard
  19849. */
  19850. static readonly BILLBOARDMODE_NONE: number;
  19851. /** Billboard on X axis */
  19852. static readonly BILLBOARDMODE_X: number;
  19853. /** Billboard on Y axis */
  19854. static readonly BILLBOARDMODE_Y: number;
  19855. /** Billboard on Z axis */
  19856. static readonly BILLBOARDMODE_Z: number;
  19857. /** Billboard on all axes */
  19858. static readonly BILLBOARDMODE_ALL: number;
  19859. private _facetPositions;
  19860. private _facetNormals;
  19861. private _facetPartitioning;
  19862. private _facetNb;
  19863. private _partitioningSubdivisions;
  19864. private _partitioningBBoxRatio;
  19865. private _facetDataEnabled;
  19866. private _facetParameters;
  19867. private _bbSize;
  19868. private _subDiv;
  19869. private _facetDepthSort;
  19870. private _facetDepthSortEnabled;
  19871. private _depthSortedIndices;
  19872. private _depthSortedFacets;
  19873. private _facetDepthSortFunction;
  19874. private _facetDepthSortFrom;
  19875. private _facetDepthSortOrigin;
  19876. private _invertedMatrix;
  19877. /**
  19878. * Gets the number of facets in the mesh
  19879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19880. */
  19881. readonly facetNb: number;
  19882. /**
  19883. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19885. */
  19886. partitioningSubdivisions: number;
  19887. /**
  19888. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19889. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19891. */
  19892. partitioningBBoxRatio: number;
  19893. /**
  19894. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19895. * Works only for updatable meshes.
  19896. * Doesn't work with multi-materials
  19897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19898. */
  19899. mustDepthSortFacets: boolean;
  19900. /**
  19901. * The location (Vector3) where the facet depth sort must be computed from.
  19902. * By default, the active camera position.
  19903. * Used only when facet depth sort is enabled
  19904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19905. */
  19906. facetDepthSortFrom: Vector3;
  19907. /**
  19908. * gets a boolean indicating if facetData is enabled
  19909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19910. */
  19911. readonly isFacetDataEnabled: boolean;
  19912. /** @hidden */
  19913. _updateNonUniformScalingState(value: boolean): boolean;
  19914. /**
  19915. * An event triggered when this mesh collides with another one
  19916. */
  19917. onCollideObservable: Observable<AbstractMesh>;
  19918. private _onCollideObserver;
  19919. /** Set a function to call when this mesh collides with another one */
  19920. onCollide: () => void;
  19921. /**
  19922. * An event triggered when the collision's position changes
  19923. */
  19924. onCollisionPositionChangeObservable: Observable<Vector3>;
  19925. private _onCollisionPositionChangeObserver;
  19926. /** Set a function to call when the collision's position changes */
  19927. onCollisionPositionChange: () => void;
  19928. /**
  19929. * An event triggered when material is changed
  19930. */
  19931. onMaterialChangedObservable: Observable<AbstractMesh>;
  19932. /**
  19933. * Gets or sets the orientation for POV movement & rotation
  19934. */
  19935. definedFacingForward: boolean;
  19936. /**
  19937. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19938. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19939. * * 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.
  19940. * @see http://doc.babylonjs.com/features/occlusionquery
  19941. */
  19942. occlusionQueryAlgorithmType: number;
  19943. /**
  19944. * 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:
  19945. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19946. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19947. * * 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.
  19948. * @see http://doc.babylonjs.com/features/occlusionquery
  19949. */
  19950. occlusionType: number;
  19951. /**
  19952. * 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.
  19953. * The default value is -1 which means don't break the query and wait till the result
  19954. * @see http://doc.babylonjs.com/features/occlusionquery
  19955. */
  19956. occlusionRetryCount: number;
  19957. private _occlusionInternalRetryCounter;
  19958. protected _isOccluded: boolean;
  19959. /**
  19960. * 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
  19961. * @see http://doc.babylonjs.com/features/occlusionquery
  19962. */
  19963. isOccluded: boolean;
  19964. private _isOcclusionQueryInProgress;
  19965. /**
  19966. * Flag to check the progress status of the query
  19967. * @see http://doc.babylonjs.com/features/occlusionquery
  19968. */
  19969. readonly isOcclusionQueryInProgress: boolean;
  19970. private _occlusionQuery;
  19971. private _visibility;
  19972. /**
  19973. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19974. */
  19975. /**
  19976. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19977. */
  19978. visibility: number;
  19979. /** Gets or sets the alpha index used to sort transparent meshes
  19980. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19981. */
  19982. alphaIndex: number;
  19983. /**
  19984. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19985. */
  19986. isVisible: boolean;
  19987. /**
  19988. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19989. */
  19990. isPickable: boolean;
  19991. /**
  19992. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  19993. */
  19994. showBoundingBox: boolean;
  19995. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19996. showSubMeshesBoundingBox: boolean;
  19997. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19998. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19999. */
  20000. isBlocker: boolean;
  20001. /**
  20002. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  20003. */
  20004. enablePointerMoveEvents: boolean;
  20005. /**
  20006. * Specifies the rendering group id for this mesh (0 by default)
  20007. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  20008. */
  20009. renderingGroupId: number;
  20010. private _material;
  20011. /** Gets or sets current material */
  20012. material: Nullable<Material>;
  20013. private _receiveShadows;
  20014. /**
  20015. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  20016. * @see http://doc.babylonjs.com/babylon101/shadows
  20017. */
  20018. receiveShadows: boolean;
  20019. /**
  20020. * Gets or sets a boolean indicating if the outline must be rendered as well
  20021. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  20022. */
  20023. renderOutline: boolean;
  20024. /** Defines color to use when rendering outline */
  20025. outlineColor: Color3;
  20026. /** Define width to use when rendering outline */
  20027. outlineWidth: number;
  20028. /**
  20029. * Gets or sets a boolean indicating if the overlay must be rendered as well
  20030. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  20031. */
  20032. renderOverlay: boolean;
  20033. /** Defines color to use when rendering overlay */
  20034. overlayColor: Color3;
  20035. /** Defines alpha to use when rendering overlay */
  20036. overlayAlpha: number;
  20037. private _hasVertexAlpha;
  20038. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  20039. hasVertexAlpha: boolean;
  20040. private _useVertexColors;
  20041. /** 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) */
  20042. useVertexColors: boolean;
  20043. private _computeBonesUsingShaders;
  20044. /**
  20045. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  20046. */
  20047. computeBonesUsingShaders: boolean;
  20048. private _numBoneInfluencers;
  20049. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  20050. numBoneInfluencers: number;
  20051. private _applyFog;
  20052. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  20053. applyFog: boolean;
  20054. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  20055. useOctreeForRenderingSelection: boolean;
  20056. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  20057. useOctreeForPicking: boolean;
  20058. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  20059. useOctreeForCollisions: boolean;
  20060. private _layerMask;
  20061. /**
  20062. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  20063. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  20064. */
  20065. layerMask: number;
  20066. /**
  20067. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  20068. */
  20069. alwaysSelectAsActiveMesh: boolean;
  20070. /**
  20071. * Gets or sets the current action manager
  20072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20073. */
  20074. actionManager: Nullable<ActionManager>;
  20075. /**
  20076. * Gets or sets impostor used for physic simulation
  20077. * @see http://doc.babylonjs.com/features/physics_engine
  20078. */
  20079. physicsImpostor: Nullable<PhysicsImpostor>;
  20080. private _checkCollisions;
  20081. private _collisionMask;
  20082. private _collisionGroup;
  20083. /**
  20084. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  20085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20086. */
  20087. ellipsoid: Vector3;
  20088. /**
  20089. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  20090. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20091. */
  20092. ellipsoidOffset: Vector3;
  20093. private _collider;
  20094. private _oldPositionForCollisions;
  20095. private _diffPositionForCollisions;
  20096. /**
  20097. * Gets or sets a collision mask used to mask collisions (default is -1).
  20098. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20099. */
  20100. collisionMask: number;
  20101. /**
  20102. * Gets or sets the current collision group mask (-1 by default).
  20103. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20104. */
  20105. collisionGroup: number;
  20106. /**
  20107. * Defines edge width used when edgesRenderer is enabled
  20108. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20109. */
  20110. edgesWidth: number;
  20111. /**
  20112. * Defines edge color used when edgesRenderer is enabled
  20113. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20114. */
  20115. edgesColor: Color4;
  20116. /** @hidden */
  20117. _edgesRenderer: Nullable<EdgesRenderer>;
  20118. private _collisionsTransformMatrix;
  20119. private _collisionsScalingMatrix;
  20120. /** @hidden */
  20121. _masterMesh: Nullable<AbstractMesh>;
  20122. /** @hidden */
  20123. _boundingInfo: Nullable<BoundingInfo>;
  20124. /** @hidden */
  20125. _renderId: number;
  20126. /**
  20127. * Gets or sets the list of subMeshes
  20128. * @see http://doc.babylonjs.com/how_to/multi_materials
  20129. */
  20130. subMeshes: SubMesh[];
  20131. /** @hidden */
  20132. _submeshesOctree: Octree<SubMesh>;
  20133. /** @hidden */
  20134. _intersectionsInProgress: AbstractMesh[];
  20135. /** @hidden */
  20136. _unIndexed: boolean;
  20137. /** @hidden */
  20138. _lightSources: Light[];
  20139. /** @hidden */
  20140. readonly _positions: Nullable<Vector3[]>;
  20141. /** @hidden */
  20142. _waitingActions: any;
  20143. /** @hidden */
  20144. _waitingFreezeWorldMatrix: Nullable<boolean>;
  20145. private _skeleton;
  20146. /** @hidden */
  20147. _bonesTransformMatrices: Nullable<Float32Array>;
  20148. /**
  20149. * Gets or sets a skeleton to apply skining transformations
  20150. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  20151. */
  20152. skeleton: Nullable<Skeleton>;
  20153. /**
  20154. * Creates a new AbstractMesh
  20155. * @param name defines the name of the mesh
  20156. * @param scene defines the hosting scene
  20157. */
  20158. constructor(name: string, scene?: Nullable<Scene>);
  20159. /**
  20160. * Returns the string "AbstractMesh"
  20161. * @returns "AbstractMesh"
  20162. */
  20163. getClassName(): string;
  20164. /**
  20165. * Gets a string representation of the current mesh
  20166. * @param fullDetails defines a boolean indicating if full details must be included
  20167. * @returns a string representation of the current mesh
  20168. */
  20169. toString(fullDetails?: boolean): string;
  20170. /** @hidden */
  20171. _rebuild(): void;
  20172. /** @hidden */
  20173. _resyncLightSources(): void;
  20174. /** @hidden */
  20175. _resyncLighSource(light: Light): void;
  20176. /** @hidden */
  20177. _unBindEffect(): void;
  20178. /** @hidden */
  20179. _removeLightSource(light: Light): void;
  20180. private _markSubMeshesAsDirty(func);
  20181. /** @hidden */
  20182. _markSubMeshesAsLightDirty(): void;
  20183. /** @hidden */
  20184. _markSubMeshesAsAttributesDirty(): void;
  20185. /** @hidden */
  20186. _markSubMeshesAsMiscDirty(): void;
  20187. /**
  20188. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  20189. */
  20190. scaling: Vector3;
  20191. /**
  20192. * Disables the mesh edge rendering mode
  20193. * @returns the currentAbstractMesh
  20194. */
  20195. disableEdgesRendering(): AbstractMesh;
  20196. /**
  20197. * Enables the edge rendering mode on the mesh.
  20198. * This mode makes the mesh edges visible
  20199. * @param epsilon defines the maximal distance between two angles to detect a face
  20200. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20201. * @returns the currentAbstractMesh
  20202. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20203. */
  20204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20205. /**
  20206. * Gets the edgesRenderer associated with the mesh
  20207. */
  20208. readonly edgesRenderer: Nullable<EdgesRenderer>;
  20209. /**
  20210. * Returns true if the mesh is blocked. Implemented by child classes
  20211. */
  20212. readonly isBlocked: boolean;
  20213. /**
  20214. * Returns the mesh itself by default. Implemented by child classes
  20215. * @param camera defines the camera to use to pick the right LOD level
  20216. * @returns the currentAbstractMesh
  20217. */
  20218. getLOD(camera: Camera): Nullable<AbstractMesh>;
  20219. /**
  20220. * Returns 0 by default. Implemented by child classes
  20221. * @returns an integer
  20222. */
  20223. getTotalVertices(): number;
  20224. /**
  20225. * Returns null by default. Implemented by child classes
  20226. * @returns null
  20227. */
  20228. getIndices(): Nullable<IndicesArray>;
  20229. /**
  20230. * Returns the array of the requested vertex data kind. Implemented by child classes
  20231. * @param kind defines the vertex data kind to use
  20232. * @returns null
  20233. */
  20234. getVerticesData(kind: string): Nullable<FloatArray>;
  20235. /**
  20236. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20237. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20238. * Note that a new underlying VertexBuffer object is created each call.
  20239. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20240. * @param kind defines vertex data kind:
  20241. * * BABYLON.VertexBuffer.PositionKind
  20242. * * BABYLON.VertexBuffer.UVKind
  20243. * * BABYLON.VertexBuffer.UV2Kind
  20244. * * BABYLON.VertexBuffer.UV3Kind
  20245. * * BABYLON.VertexBuffer.UV4Kind
  20246. * * BABYLON.VertexBuffer.UV5Kind
  20247. * * BABYLON.VertexBuffer.UV6Kind
  20248. * * BABYLON.VertexBuffer.ColorKind
  20249. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20250. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20251. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20252. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20253. * @param data defines the data source
  20254. * @param updatable defines if the data must be flagged as updatable (or static)
  20255. * @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
  20256. * @returns the current mesh
  20257. */
  20258. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  20259. /**
  20260. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20261. * If the mesh has no geometry, it is simply returned as it is.
  20262. * @param kind defines vertex data kind:
  20263. * * BABYLON.VertexBuffer.PositionKind
  20264. * * BABYLON.VertexBuffer.UVKind
  20265. * * BABYLON.VertexBuffer.UV2Kind
  20266. * * BABYLON.VertexBuffer.UV3Kind
  20267. * * BABYLON.VertexBuffer.UV4Kind
  20268. * * BABYLON.VertexBuffer.UV5Kind
  20269. * * BABYLON.VertexBuffer.UV6Kind
  20270. * * BABYLON.VertexBuffer.ColorKind
  20271. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20272. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20273. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20274. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20275. * @param data defines the data source
  20276. * @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
  20277. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  20278. * @returns the current mesh
  20279. */
  20280. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  20281. /**
  20282. * Sets the mesh indices,
  20283. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20284. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20285. * @param totalVertices Defines the total number of vertices
  20286. * @returns the current mesh
  20287. */
  20288. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  20289. /**
  20290. * Gets a boolean indicating if specific vertex data is present
  20291. * @param kind defines the vertex data kind to use
  20292. * @returns true is data kind is present
  20293. */
  20294. isVerticesDataPresent(kind: string): boolean;
  20295. /**
  20296. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  20297. * @returns a BoundingInfo
  20298. */
  20299. getBoundingInfo(): BoundingInfo;
  20300. /**
  20301. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  20302. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  20303. * @returns the current mesh
  20304. */
  20305. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  20306. /**
  20307. * Overwrite the current bounding info
  20308. * @param boundingInfo defines the new bounding info
  20309. * @returns the current mesh
  20310. */
  20311. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  20312. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  20313. readonly useBones: boolean;
  20314. /** @hidden */
  20315. _preActivate(): void;
  20316. /** @hidden */
  20317. _preActivateForIntermediateRendering(renderId: number): void;
  20318. /** @hidden */
  20319. _activate(renderId: number): void;
  20320. /**
  20321. * Gets the current world matrix
  20322. * @returns a Matrix
  20323. */
  20324. getWorldMatrix(): Matrix;
  20325. /** @hidden */
  20326. _getWorldMatrixDeterminant(): number;
  20327. /**
  20328. * Perform relative position change from the point of view of behind the front of the mesh.
  20329. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20330. * Supports definition of mesh facing forward or backward
  20331. * @param amountRight defines the distance on the right axis
  20332. * @param amountUp defines the distance on the up axis
  20333. * @param amountForward defines the distance on the forward axis
  20334. * @returns the current mesh
  20335. */
  20336. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  20337. /**
  20338. * Calculate relative position change from the point of view of behind the front of the mesh.
  20339. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20340. * Supports definition of mesh facing forward or backward
  20341. * @param amountRight defines the distance on the right axis
  20342. * @param amountUp defines the distance on the up axis
  20343. * @param amountForward defines the distance on the forward axis
  20344. * @returns the new displacement vector
  20345. */
  20346. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  20347. /**
  20348. * Perform relative rotation change from the point of view of behind the front of the mesh.
  20349. * Supports definition of mesh facing forward or backward
  20350. * @param flipBack defines the flip
  20351. * @param twirlClockwise defines the twirl
  20352. * @param tiltRight defines the tilt
  20353. * @returns the current mesh
  20354. */
  20355. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  20356. /**
  20357. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  20358. * Supports definition of mesh facing forward or backward.
  20359. * @param flipBack defines the flip
  20360. * @param twirlClockwise defines the twirl
  20361. * @param tiltRight defines the tilt
  20362. * @returns the new rotation vector
  20363. */
  20364. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  20365. /**
  20366. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  20367. * @param includeDescendants Include bounding info from descendants as well (true by default)
  20368. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  20369. * @returns the new bounding vectors
  20370. */
  20371. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  20372. min: Vector3;
  20373. max: Vector3;
  20374. };
  20375. /** @hidden */
  20376. _updateBoundingInfo(): AbstractMesh;
  20377. /** @hidden */
  20378. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  20379. /** @hidden */
  20380. protected _afterComputeWorldMatrix(): void;
  20381. /**
  20382. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20383. * A mesh is in the frustum if its bounding box intersects the frustum
  20384. * @param frustumPlanes defines the frustum to test
  20385. * @returns true if the mesh is in the frustum planes
  20386. */
  20387. isInFrustum(frustumPlanes: Plane[]): boolean;
  20388. /**
  20389. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  20390. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  20391. * @param frustumPlanes defines the frustum to test
  20392. * @returns true if the mesh is completely in the frustum planes
  20393. */
  20394. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20395. /**
  20396. * True if the mesh intersects another mesh or a SolidParticle object
  20397. * @param mesh defines a target mesh or SolidParticle to test
  20398. * @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)
  20399. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  20400. * @returns true if there is an intersection
  20401. */
  20402. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  20403. /**
  20404. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  20405. * @param point defines the point to test
  20406. * @returns true if there is an intersection
  20407. */
  20408. intersectsPoint(point: Vector3): boolean;
  20409. /**
  20410. * Gets the current physics impostor
  20411. * @see http://doc.babylonjs.com/features/physics_engine
  20412. * @returns a physics impostor or null
  20413. */
  20414. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  20415. /**
  20416. * Gets the position of the current mesh in camera space
  20417. * @param camera defines the camera to use
  20418. * @returns a position
  20419. */
  20420. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  20421. /**
  20422. * Returns the distance from the mesh to the active camera
  20423. * @param camera defines the camera to use
  20424. * @returns the distance
  20425. */
  20426. getDistanceToCamera(camera?: Nullable<Camera>): number;
  20427. /**
  20428. * Apply a physic impulse to the mesh
  20429. * @param force defines the force to apply
  20430. * @param contactPoint defines where to apply the force
  20431. * @returns the current mesh
  20432. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20433. */
  20434. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  20435. /**
  20436. * Creates a physic joint between two meshes
  20437. * @param otherMesh defines the other mesh to use
  20438. * @param pivot1 defines the pivot to use on this mesh
  20439. * @param pivot2 defines the pivot to use on the other mesh
  20440. * @param options defines additional options (can be plugin dependent)
  20441. * @returns the current mesh
  20442. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  20443. */
  20444. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  20445. /**
  20446. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  20447. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20448. */
  20449. checkCollisions: boolean;
  20450. /**
  20451. * Gets Collider object used to compute collisions (not physics)
  20452. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20453. */
  20454. readonly collider: Collider;
  20455. /**
  20456. * Move the mesh using collision engine
  20457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20458. * @param displacement defines the requested displacement vector
  20459. * @returns the current mesh
  20460. */
  20461. moveWithCollisions(displacement: Vector3): AbstractMesh;
  20462. private _onCollisionPositionChange;
  20463. /**
  20464. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  20465. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20466. * @param maxCapacity defines the maximum size of each block (64 by default)
  20467. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  20468. * @returns the new octree
  20469. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  20470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  20471. */
  20472. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  20473. /** @hidden */
  20474. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  20475. /** @hidden */
  20476. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  20477. /** @hidden */
  20478. _checkCollision(collider: Collider): AbstractMesh;
  20479. /** @hidden */
  20480. _generatePointsArray(): boolean;
  20481. /**
  20482. * Checks if the passed Ray intersects with the mesh
  20483. * @param ray defines the ray to use
  20484. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  20485. * @returns the picking info
  20486. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  20487. */
  20488. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  20489. /**
  20490. * Clones the current mesh
  20491. * @param name defines the mesh name
  20492. * @param newParent defines the new mesh parent
  20493. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  20494. * @returns the new mesh
  20495. */
  20496. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20497. /**
  20498. * Disposes all the submeshes of the current meshnp
  20499. * @returns the current mesh
  20500. */
  20501. releaseSubMeshes(): AbstractMesh;
  20502. /**
  20503. * Releases resources associated with this abstract mesh.
  20504. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20505. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20506. */
  20507. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20508. /**
  20509. * Adds the passed mesh as a child to the current mesh
  20510. * @param mesh defines the child mesh
  20511. * @returns the current mesh
  20512. */
  20513. addChild(mesh: AbstractMesh): AbstractMesh;
  20514. /**
  20515. * Removes the passed mesh from the current mesh children list
  20516. * @param mesh defines the child mesh
  20517. * @returns the current mesh
  20518. */
  20519. removeChild(mesh: AbstractMesh): AbstractMesh;
  20520. /** @hidden */
  20521. private _initFacetData();
  20522. /**
  20523. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  20524. * This method can be called within the render loop.
  20525. * 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
  20526. * @returns the current mesh
  20527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20528. */
  20529. updateFacetData(): AbstractMesh;
  20530. /**
  20531. * Returns the facetLocalNormals array.
  20532. * The normals are expressed in the mesh local spac
  20533. * @returns an array of Vector3
  20534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20535. */
  20536. getFacetLocalNormals(): Vector3[];
  20537. /**
  20538. * Returns the facetLocalPositions array.
  20539. * The facet positions are expressed in the mesh local space
  20540. * @returns an array of Vector3
  20541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20542. */
  20543. getFacetLocalPositions(): Vector3[];
  20544. /**
  20545. * Returns the facetLocalPartioning array
  20546. * @returns an array of array of numbers
  20547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20548. */
  20549. getFacetLocalPartitioning(): number[][];
  20550. /**
  20551. * Returns the i-th facet position in the world system.
  20552. * This method allocates a new Vector3 per call
  20553. * @param i defines the facet index
  20554. * @returns a new Vector3
  20555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20556. */
  20557. getFacetPosition(i: number): Vector3;
  20558. /**
  20559. * Sets the reference Vector3 with the i-th facet position in the world system
  20560. * @param i defines the facet index
  20561. * @param ref defines the target vector
  20562. * @returns the current mesh
  20563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20564. */
  20565. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20566. /**
  20567. * Returns the i-th facet normal in the world system.
  20568. * This method allocates a new Vector3 per call
  20569. * @param i defines the facet index
  20570. * @returns a new Vector3
  20571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20572. */
  20573. getFacetNormal(i: number): Vector3;
  20574. /**
  20575. * Sets the reference Vector3 with the i-th facet normal in the world system
  20576. * @param i defines the facet index
  20577. * @param ref defines the target vector
  20578. * @returns the current mesh
  20579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20580. */
  20581. getFacetNormalToRef(i: number, ref: Vector3): this;
  20582. /**
  20583. * 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)
  20584. * @param x defines x coordinate
  20585. * @param y defines y coordinate
  20586. * @param z defines z coordinate
  20587. * @returns the array of facet indexes
  20588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20589. */
  20590. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20591. /**
  20592. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20593. * @param projected sets as the (x,y,z) world projection on the facet
  20594. * @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
  20595. * @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
  20596. * @param x defines x coordinate
  20597. * @param y defines y coordinate
  20598. * @param z defines z coordinate
  20599. * @returns the face index if found (or null instead)
  20600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20601. */
  20602. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20603. /**
  20604. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20605. * @param projected sets as the (x,y,z) local projection on the facet
  20606. * @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
  20607. * @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
  20608. * @param x defines x coordinate
  20609. * @param y defines y coordinate
  20610. * @param z defines z coordinate
  20611. * @returns the face index if found (or null instead)
  20612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20613. */
  20614. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20615. /**
  20616. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20617. * @returns the parameters
  20618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20619. */
  20620. getFacetDataParameters(): any;
  20621. /**
  20622. * Disables the feature FacetData and frees the related memory
  20623. * @returns the current mesh
  20624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20625. */
  20626. disableFacetData(): AbstractMesh;
  20627. /**
  20628. * Updates the AbstractMesh indices array
  20629. * @param indices defines the data source
  20630. * @returns the current mesh
  20631. */
  20632. updateIndices(indices: IndicesArray): AbstractMesh;
  20633. /**
  20634. * Creates new normals data for the mesh
  20635. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20636. * @returns the current mesh
  20637. */
  20638. createNormals(updatable: boolean): AbstractMesh;
  20639. /**
  20640. * Align the mesh with a normal
  20641. * @param normal defines the normal to use
  20642. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20643. * @returns the current mesh
  20644. */
  20645. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20646. /** @hidden */
  20647. protected _checkOcclusionQuery(): void;
  20648. }
  20649. }
  20650. declare module BABYLON {
  20651. class Buffer {
  20652. private _engine;
  20653. private _buffer;
  20654. /** @hidden */
  20655. _data: Nullable<DataArray>;
  20656. private _updatable;
  20657. private _instanced;
  20658. /**
  20659. * Gets the byte stride.
  20660. */
  20661. readonly byteStride: number;
  20662. /**
  20663. * Constructor
  20664. * @param engine the engine
  20665. * @param data the data to use for this buffer
  20666. * @param updatable whether the data is updatable
  20667. * @param stride the stride (optional)
  20668. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20669. * @param instanced whether the buffer is instanced (optional)
  20670. * @param useBytes set to true if the stride in in bytes (optional)
  20671. */
  20672. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20673. /**
  20674. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20675. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20676. * @param offset defines offset in the buffer (0 by default)
  20677. * @param size defines the size in floats of attributes (position is 3 for instance)
  20678. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20679. * @param instanced defines if the vertex buffer contains indexed data
  20680. * @param useBytes defines if the offset and stride are in bytes
  20681. * @returns the new vertex buffer
  20682. */
  20683. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20684. isUpdatable(): boolean;
  20685. getData(): Nullable<DataArray>;
  20686. getBuffer(): Nullable<WebGLBuffer>;
  20687. /**
  20688. * Gets the stride in float32 units (i.e. byte stride / 4).
  20689. * May not be an integer if the byte stride is not divisible by 4.
  20690. * DEPRECATED. Use byteStride instead.
  20691. * @returns the stride in float32 units
  20692. */
  20693. getStrideSize(): number;
  20694. create(data?: Nullable<DataArray>): void;
  20695. _rebuild(): void;
  20696. update(data: DataArray): void;
  20697. /**
  20698. * Updates the data directly.
  20699. * @param data the new data
  20700. * @param offset the new offset
  20701. * @param vertexCount the vertex count (optional)
  20702. * @param useBytes set to true if the offset is in bytes
  20703. */
  20704. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20705. dispose(): void;
  20706. }
  20707. }
  20708. declare module BABYLON {
  20709. class CSG {
  20710. private polygons;
  20711. matrix: Matrix;
  20712. position: Vector3;
  20713. rotation: Vector3;
  20714. rotationQuaternion: Nullable<Quaternion>;
  20715. scaling: Vector3;
  20716. static FromMesh(mesh: Mesh): CSG;
  20717. private static FromPolygons(polygons);
  20718. clone(): CSG;
  20719. union(csg: CSG): CSG;
  20720. unionInPlace(csg: CSG): void;
  20721. subtract(csg: CSG): CSG;
  20722. subtractInPlace(csg: CSG): void;
  20723. intersect(csg: CSG): CSG;
  20724. intersectInPlace(csg: CSG): void;
  20725. inverse(): CSG;
  20726. inverseInPlace(): void;
  20727. copyTransformAttributes(csg: CSG): CSG;
  20728. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20729. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20730. }
  20731. }
  20732. declare module BABYLON {
  20733. /**
  20734. * Class used to store geometry data (vertex buffers + index buffer)
  20735. */
  20736. class Geometry implements IGetSetVerticesData {
  20737. /**
  20738. * Gets or sets the unique ID of the geometry
  20739. */
  20740. id: string;
  20741. /**
  20742. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20743. */
  20744. delayLoadState: number;
  20745. /**
  20746. * Gets the file containing the data to load when running in delay load state
  20747. */
  20748. delayLoadingFile: Nullable<string>;
  20749. /**
  20750. * Callback called when the geometry is updated
  20751. */
  20752. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20753. private _scene;
  20754. private _engine;
  20755. private _meshes;
  20756. private _totalVertices;
  20757. /** @hidden */
  20758. _indices: IndicesArray;
  20759. /** @hidden */
  20760. _vertexBuffers: {
  20761. [key: string]: VertexBuffer;
  20762. };
  20763. private _isDisposed;
  20764. private _extend;
  20765. private _boundingBias;
  20766. /** @hidden */
  20767. _delayInfo: Array<string>;
  20768. private _indexBuffer;
  20769. private _indexBufferIsUpdatable;
  20770. /** @hidden */
  20771. _boundingInfo: Nullable<BoundingInfo>;
  20772. /** @hidden */
  20773. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20774. /** @hidden */
  20775. _softwareSkinningRenderId: number;
  20776. private _vertexArrayObjects;
  20777. private _updatable;
  20778. /** @hidden */
  20779. _positions: Nullable<Vector3[]>;
  20780. /**
  20781. * 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
  20782. */
  20783. /**
  20784. * 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
  20785. */
  20786. boundingBias: Vector2;
  20787. /**
  20788. * Static function used to attach a new empty geometry to a mesh
  20789. * @param mesh defines the mesh to attach the geometry to
  20790. * @returns the new {BABYLON.Geometry}
  20791. */
  20792. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20793. /**
  20794. * Creates a new geometry
  20795. * @param id defines the unique ID
  20796. * @param scene defines the hosting scene
  20797. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20798. * @param updatable defines if geometry must be updatable (false by default)
  20799. * @param mesh defines the mesh that will be associated with the geometry
  20800. */
  20801. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20802. /**
  20803. * Gets the current extend of the geometry
  20804. */
  20805. readonly extend: {
  20806. minimum: Vector3;
  20807. maximum: Vector3;
  20808. };
  20809. /**
  20810. * Gets the hosting scene
  20811. * @returns the hosting {BABYLON.Scene}
  20812. */
  20813. getScene(): Scene;
  20814. /**
  20815. * Gets the hosting engine
  20816. * @returns the hosting {BABYLON.Engine}
  20817. */
  20818. getEngine(): Engine;
  20819. /**
  20820. * Defines if the geometry is ready to use
  20821. * @returns true if the geometry is ready to be used
  20822. */
  20823. isReady(): boolean;
  20824. /**
  20825. * Gets a value indicating that the geometry should not be serialized
  20826. */
  20827. readonly doNotSerialize: boolean;
  20828. /** @hidden */
  20829. _rebuild(): void;
  20830. /**
  20831. * Affects all gemetry data in one call
  20832. * @param vertexData defines the geometry data
  20833. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20834. */
  20835. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20836. /**
  20837. * Set specific vertex data
  20838. * @param kind defines the data kind (Position, normal, etc...)
  20839. * @param data defines the vertex data to use
  20840. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20841. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20842. */
  20843. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20844. /**
  20845. * Removes a specific vertex data
  20846. * @param kind defines the data kind (Position, normal, etc...)
  20847. */
  20848. removeVerticesData(kind: string): void;
  20849. /**
  20850. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20851. * @param buffer defines the vertex buffer to use
  20852. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20853. */
  20854. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20855. /**
  20856. * Update a specific vertex buffer
  20857. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20858. * It will do nothing if the buffer is not updatable
  20859. * @param kind defines the data kind (Position, normal, etc...)
  20860. * @param data defines the data to use
  20861. * @param offset defines the offset in the target buffer where to store the data
  20862. * @param useBytes set to true if the offset is in bytes
  20863. */
  20864. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20865. /**
  20866. * Update a specific vertex buffer
  20867. * This function will create a new buffer if the current one is not updatable
  20868. * @param kind defines the data kind (Position, normal, etc...)
  20869. * @param data defines the data to use
  20870. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20871. */
  20872. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20873. private _updateBoundingInfo(updateExtends, data);
  20874. /** @hidden */
  20875. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20876. /**
  20877. * Gets total number of vertices
  20878. * @returns the total number of vertices
  20879. */
  20880. getTotalVertices(): number;
  20881. /**
  20882. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20883. * @param kind defines the data kind (Position, normal, etc...)
  20884. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20885. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20886. * @returns a float array containing vertex data
  20887. */
  20888. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20889. /**
  20890. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20891. * @param kind defines the data kind (Position, normal, etc...)
  20892. * @returns true if the vertex buffer with the specified kind is updatable
  20893. */
  20894. isVertexBufferUpdatable(kind: string): boolean;
  20895. /**
  20896. * Gets a specific vertex buffer
  20897. * @param kind defines the data kind (Position, normal, etc...)
  20898. * @returns a {BABYLON.VertexBuffer}
  20899. */
  20900. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20901. /**
  20902. * Returns all vertex buffers
  20903. * @return an object holding all vertex buffers indexed by kind
  20904. */
  20905. getVertexBuffers(): Nullable<{
  20906. [key: string]: VertexBuffer;
  20907. }>;
  20908. /**
  20909. * Gets a boolean indicating if specific vertex buffer is present
  20910. * @param kind defines the data kind (Position, normal, etc...)
  20911. * @returns true if data is present
  20912. */
  20913. isVerticesDataPresent(kind: string): boolean;
  20914. /**
  20915. * Gets a list of all attached data kinds (Position, normal, etc...)
  20916. * @returns a list of string containing all kinds
  20917. */
  20918. getVerticesDataKinds(): string[];
  20919. /**
  20920. * Update index buffer
  20921. * @param indices defines the indices to store in the index buffer
  20922. * @param offset defines the offset in the target buffer where to store the data
  20923. */
  20924. updateIndices(indices: IndicesArray, offset?: number): void;
  20925. /**
  20926. * Creates a new index buffer
  20927. * @param indices defines the indices to store in the index buffer
  20928. * @param totalVertices defines the total number of vertices (could be null)
  20929. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20930. */
  20931. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20932. /**
  20933. * Return the total number of indices
  20934. * @returns the total number of indices
  20935. */
  20936. getTotalIndices(): number;
  20937. /**
  20938. * Gets the index buffer array
  20939. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20940. * @returns the index buffer array
  20941. */
  20942. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20943. /**
  20944. * Gets the index buffer
  20945. * @return the index buffer
  20946. */
  20947. getIndexBuffer(): Nullable<WebGLBuffer>;
  20948. /** @hidden */
  20949. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20950. /**
  20951. * Release the associated resources for a specific mesh
  20952. * @param mesh defines the source mesh
  20953. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20954. */
  20955. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20956. /**
  20957. * Apply current geometry to a given mesh
  20958. * @param mesh defines the mesh to apply geometry to
  20959. */
  20960. applyToMesh(mesh: Mesh): void;
  20961. private _updateExtend(data?);
  20962. private _applyToMesh(mesh);
  20963. private notifyUpdate(kind?);
  20964. /**
  20965. * Load the geometry if it was flagged as delay loaded
  20966. * @param scene defines the hosting scene
  20967. * @param onLoaded defines a callback called when the geometry is loaded
  20968. */
  20969. load(scene: Scene, onLoaded?: () => void): void;
  20970. private _queueLoad(scene, onLoaded?);
  20971. /**
  20972. * Invert the geometry to move from a right handed system to a left handed one.
  20973. */
  20974. toLeftHanded(): void;
  20975. /** @hidden */
  20976. _resetPointsArrayCache(): void;
  20977. /** @hidden */
  20978. _generatePointsArray(): boolean;
  20979. /**
  20980. * Gets a value indicating if the geometry is disposed
  20981. * @returns true if the geometry was disposed
  20982. */
  20983. isDisposed(): boolean;
  20984. private _disposeVertexArrayObjects();
  20985. /**
  20986. * Free all associated resources
  20987. */
  20988. dispose(): void;
  20989. /**
  20990. * Clone the current geometry into a new geometry
  20991. * @param id defines the unique ID of the new geometry
  20992. * @returns a new geometry object
  20993. */
  20994. copy(id: string): Geometry;
  20995. /**
  20996. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20997. * @return a JSON representation of the current geometry data (without the vertices data)
  20998. */
  20999. serialize(): any;
  21000. private toNumberArray(origin);
  21001. /**
  21002. * Serialize all vertices data into a JSON oject
  21003. * @returns a JSON representation of the current geometry data
  21004. */
  21005. serializeVerticeData(): any;
  21006. /**
  21007. * Extracts a clone of a mesh geometry
  21008. * @param mesh defines the source mesh
  21009. * @param id defines the unique ID of the new geometry object
  21010. * @returns the new geometry object
  21011. */
  21012. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21013. /**
  21014. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21015. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21016. * Be aware Math.random() could cause collisions, but:
  21017. * "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"
  21018. * @returns a string containing a new GUID
  21019. */
  21020. static RandomId(): string;
  21021. /** @hidden */
  21022. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21023. private static _CleanMatricesWeights(parsedGeometry, mesh);
  21024. /**
  21025. * Create a new geometry from persisted data (Using .babylon file format)
  21026. * @param parsedVertexData defines the persisted data
  21027. * @param scene defines the hosting scene
  21028. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21029. * @returns the new geometry object
  21030. */
  21031. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21032. }
  21033. /**
  21034. * Abstract class used to provide common services for all typed geometries
  21035. * @hidden
  21036. */
  21037. class _PrimitiveGeometry extends Geometry {
  21038. private _canBeRegenerated;
  21039. private _beingRegenerated;
  21040. /**
  21041. * Creates a new typed geometry
  21042. * @param id defines the unique ID of the geometry
  21043. * @param scene defines the hosting scene
  21044. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21045. * @param mesh defines the hosting mesh (can be null)
  21046. */
  21047. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21048. /**
  21049. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  21050. * @returns true if the geometry can be regenerated
  21051. */
  21052. canBeRegenerated(): boolean;
  21053. /**
  21054. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  21055. */
  21056. regenerate(): void;
  21057. /**
  21058. * Clone the geometry
  21059. * @param id defines the unique ID of the new geometry
  21060. * @returns the new geometry
  21061. */
  21062. asNewGeometry(id: string): Geometry;
  21063. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21064. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  21065. /** @hidden */
  21066. _regenerateVertexData(): VertexData;
  21067. copy(id: string): Geometry;
  21068. serialize(): any;
  21069. }
  21070. /**
  21071. * Creates a ribbon geometry
  21072. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  21073. */
  21074. class RibbonGeometry extends _PrimitiveGeometry {
  21075. /**
  21076. * Defines the array of paths to use
  21077. */
  21078. pathArray: Vector3[][];
  21079. /**
  21080. * Defines if the last and first points of each path in your pathArray must be joined
  21081. */
  21082. closeArray: boolean;
  21083. /**
  21084. * Defines if the last and first points of each path in your pathArray must be joined
  21085. */
  21086. closePath: boolean;
  21087. /**
  21088. * Defines the offset between points
  21089. */
  21090. offset: number;
  21091. /**
  21092. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21093. */
  21094. side: number;
  21095. /**
  21096. * Creates a ribbon geometry
  21097. * @param id defines the unique ID of the geometry
  21098. * @param scene defines the hosting scene
  21099. * @param pathArray defines the array of paths to use
  21100. * @param closeArray defines if the last path and the first path must be joined
  21101. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  21102. * @param offset defines the offset between points
  21103. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21104. * @param mesh defines the hosting mesh (can be null)
  21105. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21106. */
  21107. constructor(id: string, scene: Scene,
  21108. /**
  21109. * Defines the array of paths to use
  21110. */
  21111. pathArray: Vector3[][],
  21112. /**
  21113. * Defines if the last and first points of each path in your pathArray must be joined
  21114. */
  21115. closeArray: boolean,
  21116. /**
  21117. * Defines if the last and first points of each path in your pathArray must be joined
  21118. */
  21119. closePath: boolean,
  21120. /**
  21121. * Defines the offset between points
  21122. */
  21123. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  21124. /**
  21125. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21126. */
  21127. side?: number);
  21128. /** @hidden */
  21129. _regenerateVertexData(): VertexData;
  21130. copy(id: string): Geometry;
  21131. }
  21132. /**
  21133. * Creates a box geometry
  21134. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  21135. */
  21136. class BoxGeometry extends _PrimitiveGeometry {
  21137. /**
  21138. * Defines the zise of the box (width, height and depth are the same)
  21139. */
  21140. size: number;
  21141. /**
  21142. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21143. */
  21144. side: number;
  21145. /**
  21146. * Creates a box geometry
  21147. * @param id defines the unique ID of the geometry
  21148. * @param scene defines the hosting scene
  21149. * @param size defines the zise of the box (width, height and depth are the same)
  21150. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21151. * @param mesh defines the hosting mesh (can be null)
  21152. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21153. */
  21154. constructor(id: string, scene: Scene,
  21155. /**
  21156. * Defines the zise of the box (width, height and depth are the same)
  21157. */
  21158. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21159. /**
  21160. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21161. */
  21162. side?: number);
  21163. _regenerateVertexData(): VertexData;
  21164. copy(id: string): Geometry;
  21165. serialize(): any;
  21166. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  21167. }
  21168. /**
  21169. * Creates a sphere geometry
  21170. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  21171. */
  21172. class SphereGeometry extends _PrimitiveGeometry {
  21173. /**
  21174. * Defines the number of segments to use to create the sphere
  21175. */
  21176. segments: number;
  21177. /**
  21178. * Defines the diameter of the sphere
  21179. */
  21180. diameter: number;
  21181. /**
  21182. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21183. */
  21184. side: number;
  21185. /**
  21186. * Create a new sphere geometry
  21187. * @param id defines the unique ID of the geometry
  21188. * @param scene defines the hosting scene
  21189. * @param segments defines the number of segments to use to create the sphere
  21190. * @param diameter defines the diameter of the sphere
  21191. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21192. * @param mesh defines the hosting mesh (can be null)
  21193. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21194. */
  21195. constructor(id: string, scene: Scene,
  21196. /**
  21197. * Defines the number of segments to use to create the sphere
  21198. */
  21199. segments: number,
  21200. /**
  21201. * Defines the diameter of the sphere
  21202. */
  21203. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21204. /**
  21205. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21206. */
  21207. side?: number);
  21208. _regenerateVertexData(): VertexData;
  21209. copy(id: string): Geometry;
  21210. serialize(): any;
  21211. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  21212. }
  21213. /**
  21214. * Creates a disc geometry
  21215. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21216. */
  21217. class DiscGeometry extends _PrimitiveGeometry {
  21218. /**
  21219. * Defines the radius of the disc
  21220. */
  21221. radius: number;
  21222. /**
  21223. * Defines the tesselation factor to apply to the disc
  21224. */
  21225. tessellation: number;
  21226. /**
  21227. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21228. */
  21229. side: number;
  21230. /**
  21231. * Creates a new disc geometry
  21232. * @param id defines the unique ID of the geometry
  21233. * @param scene defines the hosting scene
  21234. * @param radius defines the radius of the disc
  21235. * @param tessellation defines the tesselation factor to apply to the disc
  21236. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21237. * @param mesh defines the hosting mesh (can be null)
  21238. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21239. */
  21240. constructor(id: string, scene: Scene,
  21241. /**
  21242. * Defines the radius of the disc
  21243. */
  21244. radius: number,
  21245. /**
  21246. * Defines the tesselation factor to apply to the disc
  21247. */
  21248. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21249. /**
  21250. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21251. */
  21252. side?: number);
  21253. _regenerateVertexData(): VertexData;
  21254. copy(id: string): Geometry;
  21255. }
  21256. /**
  21257. * Creates a new cylinder geometry
  21258. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  21259. */
  21260. class CylinderGeometry extends _PrimitiveGeometry {
  21261. /**
  21262. * Defines the height of the cylinder
  21263. */
  21264. height: number;
  21265. /**
  21266. * Defines the diameter of the cylinder's top cap
  21267. */
  21268. diameterTop: number;
  21269. /**
  21270. * Defines the diameter of the cylinder's bottom cap
  21271. */
  21272. diameterBottom: number;
  21273. /**
  21274. * Defines the tessellation factor to apply to the cylinder
  21275. */
  21276. tessellation: number;
  21277. /**
  21278. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21279. */
  21280. subdivisions: number;
  21281. /**
  21282. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21283. */
  21284. side: number;
  21285. /**
  21286. * Creates a new cylinder geometry
  21287. * @param id defines the unique ID of the geometry
  21288. * @param scene defines the hosting scene
  21289. * @param height defines the height of the cylinder
  21290. * @param diameterTop defines the diameter of the cylinder's top cap
  21291. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  21292. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  21293. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  21294. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21295. * @param mesh defines the hosting mesh (can be null)
  21296. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21297. */
  21298. constructor(id: string, scene: Scene,
  21299. /**
  21300. * Defines the height of the cylinder
  21301. */
  21302. height: number,
  21303. /**
  21304. * Defines the diameter of the cylinder's top cap
  21305. */
  21306. diameterTop: number,
  21307. /**
  21308. * Defines the diameter of the cylinder's bottom cap
  21309. */
  21310. diameterBottom: number,
  21311. /**
  21312. * Defines the tessellation factor to apply to the cylinder
  21313. */
  21314. tessellation: number,
  21315. /**
  21316. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21317. */
  21318. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21319. /**
  21320. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21321. */
  21322. side?: number);
  21323. _regenerateVertexData(): VertexData;
  21324. copy(id: string): Geometry;
  21325. serialize(): any;
  21326. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  21327. }
  21328. /**
  21329. * Creates a new torus geometry
  21330. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  21331. */
  21332. class TorusGeometry extends _PrimitiveGeometry {
  21333. /**
  21334. * Defines the diameter of the torus
  21335. */
  21336. diameter: number;
  21337. /**
  21338. * Defines the thickness of the torus (ie. internal diameter)
  21339. */
  21340. thickness: number;
  21341. /**
  21342. * Defines the tesselation factor to apply to the torus
  21343. */
  21344. tessellation: number;
  21345. /**
  21346. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21347. */
  21348. side: number;
  21349. /**
  21350. * Creates a new torus geometry
  21351. * @param id defines the unique ID of the geometry
  21352. * @param scene defines the hosting scene
  21353. * @param diameter defines the diameter of the torus
  21354. * @param thickness defines the thickness of the torus (ie. internal diameter)
  21355. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  21356. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21357. * @param mesh defines the hosting mesh (can be null)
  21358. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21359. */
  21360. constructor(id: string, scene: Scene,
  21361. /**
  21362. * Defines the diameter of the torus
  21363. */
  21364. diameter: number,
  21365. /**
  21366. * Defines the thickness of the torus (ie. internal diameter)
  21367. */
  21368. thickness: number,
  21369. /**
  21370. * Defines the tesselation factor to apply to the torus
  21371. */
  21372. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21373. /**
  21374. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21375. */
  21376. side?: number);
  21377. _regenerateVertexData(): VertexData;
  21378. copy(id: string): Geometry;
  21379. serialize(): any;
  21380. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  21381. }
  21382. /**
  21383. * Creates a new ground geometry
  21384. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  21385. */
  21386. class GroundGeometry extends _PrimitiveGeometry {
  21387. /**
  21388. * Defines the width of the ground
  21389. */
  21390. width: number;
  21391. /**
  21392. * Defines the height of the ground
  21393. */
  21394. height: number;
  21395. /**
  21396. * Defines the subdivisions to apply to the ground
  21397. */
  21398. subdivisions: number;
  21399. /**
  21400. * Creates a new ground geometry
  21401. * @param id defines the unique ID of the geometry
  21402. * @param scene defines the hosting scene
  21403. * @param width defines the width of the ground
  21404. * @param height defines the height of the ground
  21405. * @param subdivisions defines the subdivisions to apply to the ground
  21406. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21407. * @param mesh defines the hosting mesh (can be null)
  21408. */
  21409. constructor(id: string, scene: Scene,
  21410. /**
  21411. * Defines the width of the ground
  21412. */
  21413. width: number,
  21414. /**
  21415. * Defines the height of the ground
  21416. */
  21417. height: number,
  21418. /**
  21419. * Defines the subdivisions to apply to the ground
  21420. */
  21421. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21422. _regenerateVertexData(): VertexData;
  21423. copy(id: string): Geometry;
  21424. serialize(): any;
  21425. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  21426. }
  21427. /**
  21428. * Creates a tiled ground geometry
  21429. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  21430. */
  21431. class TiledGroundGeometry extends _PrimitiveGeometry {
  21432. /**
  21433. * Defines the minimum value on X axis
  21434. */
  21435. xmin: number;
  21436. /**
  21437. * Defines the minimum value on Z axis
  21438. */
  21439. zmin: number;
  21440. /**
  21441. * Defines the maximum value on X axis
  21442. */
  21443. xmax: number;
  21444. /**
  21445. * Defines the maximum value on Z axis
  21446. */
  21447. zmax: number;
  21448. /**
  21449. * Defines the subdivisions to apply to the ground
  21450. */
  21451. subdivisions: {
  21452. w: number;
  21453. h: number;
  21454. };
  21455. /**
  21456. * Defines the precision to use when computing the tiles
  21457. */
  21458. precision: {
  21459. w: number;
  21460. h: number;
  21461. };
  21462. /**
  21463. * Creates a tiled ground geometry
  21464. * @param id defines the unique ID of the geometry
  21465. * @param scene defines the hosting scene
  21466. * @param xmin defines the minimum value on X axis
  21467. * @param zmin defines the minimum value on Z axis
  21468. * @param xmax defines the maximum value on X axis
  21469. * @param zmax defines the maximum value on Z axis
  21470. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  21471. * @param precision defines the precision to use when computing the tiles
  21472. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21473. * @param mesh defines the hosting mesh (can be null)
  21474. */
  21475. constructor(id: string, scene: Scene,
  21476. /**
  21477. * Defines the minimum value on X axis
  21478. */
  21479. xmin: number,
  21480. /**
  21481. * Defines the minimum value on Z axis
  21482. */
  21483. zmin: number,
  21484. /**
  21485. * Defines the maximum value on X axis
  21486. */
  21487. xmax: number,
  21488. /**
  21489. * Defines the maximum value on Z axis
  21490. */
  21491. zmax: number,
  21492. /**
  21493. * Defines the subdivisions to apply to the ground
  21494. */
  21495. subdivisions: {
  21496. w: number;
  21497. h: number;
  21498. },
  21499. /**
  21500. * Defines the precision to use when computing the tiles
  21501. */
  21502. precision: {
  21503. w: number;
  21504. h: number;
  21505. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21506. _regenerateVertexData(): VertexData;
  21507. copy(id: string): Geometry;
  21508. }
  21509. /**
  21510. * Creates a plane geometry
  21511. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  21512. */
  21513. class PlaneGeometry extends _PrimitiveGeometry {
  21514. /**
  21515. * Defines the size of the plane (width === height)
  21516. */
  21517. size: number;
  21518. /**
  21519. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21520. */
  21521. side: number;
  21522. /**
  21523. * Creates a plane geometry
  21524. * @param id defines the unique ID of the geometry
  21525. * @param scene defines the hosting scene
  21526. * @param size defines the size of the plane (width === height)
  21527. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21528. * @param mesh defines the hosting mesh (can be null)
  21529. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21530. */
  21531. constructor(id: string, scene: Scene,
  21532. /**
  21533. * Defines the size of the plane (width === height)
  21534. */
  21535. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21536. /**
  21537. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21538. */
  21539. side?: number);
  21540. _regenerateVertexData(): VertexData;
  21541. copy(id: string): Geometry;
  21542. serialize(): any;
  21543. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21544. }
  21545. /**
  21546. * Creates a torus knot geometry
  21547. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21548. */
  21549. class TorusKnotGeometry extends _PrimitiveGeometry {
  21550. /**
  21551. * Defines the radius of the torus knot
  21552. */
  21553. radius: number;
  21554. /**
  21555. * Defines the thickness of the torus knot tube
  21556. */
  21557. tube: number;
  21558. /**
  21559. * Defines the number of radial segments
  21560. */
  21561. radialSegments: number;
  21562. /**
  21563. * Defines the number of tubular segments
  21564. */
  21565. tubularSegments: number;
  21566. /**
  21567. * Defines the first number of windings
  21568. */
  21569. p: number;
  21570. /**
  21571. * Defines the second number of windings
  21572. */
  21573. q: number;
  21574. /**
  21575. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21576. */
  21577. side: number;
  21578. /**
  21579. * Creates a torus knot geometry
  21580. * @param id defines the unique ID of the geometry
  21581. * @param scene defines the hosting scene
  21582. * @param radius defines the radius of the torus knot
  21583. * @param tube defines the thickness of the torus knot tube
  21584. * @param radialSegments defines the number of radial segments
  21585. * @param tubularSegments defines the number of tubular segments
  21586. * @param p defines the first number of windings
  21587. * @param q defines the second number of windings
  21588. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21589. * @param mesh defines the hosting mesh (can be null)
  21590. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21591. */
  21592. constructor(id: string, scene: Scene,
  21593. /**
  21594. * Defines the radius of the torus knot
  21595. */
  21596. radius: number,
  21597. /**
  21598. * Defines the thickness of the torus knot tube
  21599. */
  21600. tube: number,
  21601. /**
  21602. * Defines the number of radial segments
  21603. */
  21604. radialSegments: number,
  21605. /**
  21606. * Defines the number of tubular segments
  21607. */
  21608. tubularSegments: number,
  21609. /**
  21610. * Defines the first number of windings
  21611. */
  21612. p: number,
  21613. /**
  21614. * Defines the second number of windings
  21615. */
  21616. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21617. /**
  21618. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21619. */
  21620. side?: number);
  21621. _regenerateVertexData(): VertexData;
  21622. copy(id: string): Geometry;
  21623. serialize(): any;
  21624. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21625. }
  21626. }
  21627. declare module BABYLON {
  21628. class GroundMesh extends Mesh {
  21629. generateOctree: boolean;
  21630. private _heightQuads;
  21631. _subdivisionsX: number;
  21632. _subdivisionsY: number;
  21633. _width: number;
  21634. _height: number;
  21635. _minX: number;
  21636. _maxX: number;
  21637. _minZ: number;
  21638. _maxZ: number;
  21639. constructor(name: string, scene: Scene);
  21640. getClassName(): string;
  21641. readonly subdivisions: number;
  21642. readonly subdivisionsX: number;
  21643. readonly subdivisionsY: number;
  21644. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21645. /**
  21646. * Returns a height (y) value in the Worl system :
  21647. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21648. * Returns the ground y position if (x, z) are outside the ground surface.
  21649. */
  21650. getHeightAtCoordinates(x: number, z: number): number;
  21651. /**
  21652. * Returns a normalized vector (Vector3) orthogonal to the ground
  21653. * at the ground coordinates (x, z) expressed in the World system.
  21654. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21655. */
  21656. getNormalAtCoordinates(x: number, z: number): Vector3;
  21657. /**
  21658. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21659. * at the ground coordinates (x, z) expressed in the World system.
  21660. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21661. * Returns the GroundMesh.
  21662. */
  21663. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21664. /**
  21665. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21666. * if the ground has been updated.
  21667. * This can be used in the render loop.
  21668. * Returns the GroundMesh.
  21669. */
  21670. updateCoordinateHeights(): GroundMesh;
  21671. private _getFacetAt(x, z);
  21672. private _initHeightQuads();
  21673. private _computeHeightQuads();
  21674. serialize(serializationObject: any): void;
  21675. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21676. }
  21677. }
  21678. declare module BABYLON {
  21679. /**
  21680. * Creates an instance based on a source mesh.
  21681. */
  21682. class InstancedMesh extends AbstractMesh {
  21683. private _sourceMesh;
  21684. private _currentLOD;
  21685. constructor(name: string, source: Mesh);
  21686. /**
  21687. * Returns the string "InstancedMesh".
  21688. */
  21689. getClassName(): string;
  21690. readonly receiveShadows: boolean;
  21691. readonly material: Nullable<Material>;
  21692. readonly visibility: number;
  21693. readonly skeleton: Nullable<Skeleton>;
  21694. renderingGroupId: number;
  21695. /**
  21696. * Returns the total number of vertices (integer).
  21697. */
  21698. getTotalVertices(): number;
  21699. readonly sourceMesh: Mesh;
  21700. /**
  21701. * Is this node ready to be used/rendered
  21702. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21703. * @return {boolean} is it ready
  21704. */
  21705. isReady(completeCheck?: boolean): boolean;
  21706. /**
  21707. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21708. */
  21709. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21710. /**
  21711. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21712. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21713. * The `data` are either a numeric array either a Float32Array.
  21714. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21715. * 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).
  21716. * Note that a new underlying VertexBuffer object is created each call.
  21717. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21718. *
  21719. * Possible `kind` values :
  21720. * - BABYLON.VertexBuffer.PositionKind
  21721. * - BABYLON.VertexBuffer.UVKind
  21722. * - BABYLON.VertexBuffer.UV2Kind
  21723. * - BABYLON.VertexBuffer.UV3Kind
  21724. * - BABYLON.VertexBuffer.UV4Kind
  21725. * - BABYLON.VertexBuffer.UV5Kind
  21726. * - BABYLON.VertexBuffer.UV6Kind
  21727. * - BABYLON.VertexBuffer.ColorKind
  21728. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21729. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21730. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21731. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21732. *
  21733. * Returns the Mesh.
  21734. */
  21735. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21736. /**
  21737. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21738. * If the mesh has no geometry, it is simply returned as it is.
  21739. * The `data` are either a numeric array either a Float32Array.
  21740. * No new underlying VertexBuffer object is created.
  21741. * 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.
  21742. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21743. *
  21744. * Possible `kind` values :
  21745. * - BABYLON.VertexBuffer.PositionKind
  21746. * - BABYLON.VertexBuffer.UVKind
  21747. * - BABYLON.VertexBuffer.UV2Kind
  21748. * - BABYLON.VertexBuffer.UV3Kind
  21749. * - BABYLON.VertexBuffer.UV4Kind
  21750. * - BABYLON.VertexBuffer.UV5Kind
  21751. * - BABYLON.VertexBuffer.UV6Kind
  21752. * - BABYLON.VertexBuffer.ColorKind
  21753. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21754. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21755. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21756. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21757. *
  21758. * Returns the Mesh.
  21759. */
  21760. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21761. /**
  21762. * Sets the mesh indices.
  21763. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21764. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21765. * This method creates a new index buffer each call.
  21766. * Returns the Mesh.
  21767. */
  21768. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21769. /**
  21770. * Boolean : True if the mesh owns the requested kind of data.
  21771. */
  21772. isVerticesDataPresent(kind: string): boolean;
  21773. /**
  21774. * Returns an array of indices (IndicesArray).
  21775. */
  21776. getIndices(): Nullable<IndicesArray>;
  21777. readonly _positions: Nullable<Vector3[]>;
  21778. /**
  21779. * Sets a new updated BoundingInfo to the mesh.
  21780. * Returns the mesh.
  21781. */
  21782. refreshBoundingInfo(): InstancedMesh;
  21783. _preActivate(): InstancedMesh;
  21784. _activate(renderId: number): InstancedMesh;
  21785. /**
  21786. * Returns the current associated LOD AbstractMesh.
  21787. */
  21788. getLOD(camera: Camera): AbstractMesh;
  21789. _syncSubMeshes(): InstancedMesh;
  21790. _generatePointsArray(): boolean;
  21791. /**
  21792. * Creates a new InstancedMesh from the current mesh.
  21793. * - name (string) : the cloned mesh name
  21794. * - newParent (optional Node) : the optional Node to parent the clone to.
  21795. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21796. *
  21797. * Returns the clone.
  21798. */
  21799. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21800. /**
  21801. * Disposes the InstancedMesh.
  21802. * Returns nothing.
  21803. */
  21804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21805. }
  21806. }
  21807. declare module BABYLON {
  21808. class LinesMesh extends Mesh {
  21809. useVertexColor: boolean | undefined;
  21810. useVertexAlpha: boolean | undefined;
  21811. color: Color3;
  21812. alpha: number;
  21813. /**
  21814. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21815. * This margin is expressed in world space coordinates, so its value may vary.
  21816. * Default value is 0.1
  21817. * @returns the intersection Threshold value.
  21818. */
  21819. /**
  21820. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21821. * This margin is expressed in world space coordinates, so its value may vary.
  21822. * @param value the new threshold to apply
  21823. */
  21824. intersectionThreshold: number;
  21825. private _intersectionThreshold;
  21826. private _colorShader;
  21827. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21828. /**
  21829. * Returns the string "LineMesh"
  21830. */
  21831. getClassName(): string;
  21832. material: Material;
  21833. readonly checkCollisions: boolean;
  21834. createInstance(name: string): InstancedMesh;
  21835. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21836. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21837. dispose(doNotRecurse?: boolean): void;
  21838. /**
  21839. * Returns a new LineMesh object cloned from the current one.
  21840. */
  21841. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21842. }
  21843. }
  21844. declare module BABYLON {
  21845. /**
  21846. * @hidden
  21847. **/
  21848. class _InstancesBatch {
  21849. mustReturn: boolean;
  21850. visibleInstances: Nullable<InstancedMesh[]>[];
  21851. renderSelf: boolean[];
  21852. }
  21853. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21854. static _FRONTSIDE: number;
  21855. static _BACKSIDE: number;
  21856. static _DOUBLESIDE: number;
  21857. static _DEFAULTSIDE: number;
  21858. static _NO_CAP: number;
  21859. static _CAP_START: number;
  21860. static _CAP_END: number;
  21861. static _CAP_ALL: number;
  21862. /**
  21863. * Mesh side orientation : usually the external or front surface
  21864. */
  21865. static readonly FRONTSIDE: number;
  21866. /**
  21867. * Mesh side orientation : usually the internal or back surface
  21868. */
  21869. static readonly BACKSIDE: number;
  21870. /**
  21871. * Mesh side orientation : both internal and external or front and back surfaces
  21872. */
  21873. static readonly DOUBLESIDE: number;
  21874. /**
  21875. * Mesh side orientation : by default, `FRONTSIDE`
  21876. */
  21877. static readonly DEFAULTSIDE: number;
  21878. /**
  21879. * Mesh cap setting : no cap
  21880. */
  21881. static readonly NO_CAP: number;
  21882. /**
  21883. * Mesh cap setting : one cap at the beginning of the mesh
  21884. */
  21885. static readonly CAP_START: number;
  21886. /**
  21887. * Mesh cap setting : one cap at the end of the mesh
  21888. */
  21889. static readonly CAP_END: number;
  21890. /**
  21891. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21892. */
  21893. static readonly CAP_ALL: number;
  21894. /**
  21895. * An event triggered before rendering the mesh
  21896. */
  21897. onBeforeRenderObservable: Observable<Mesh>;
  21898. /**
  21899. * An event triggered after rendering the mesh
  21900. */
  21901. onAfterRenderObservable: Observable<Mesh>;
  21902. /**
  21903. * An event triggered before drawing the mesh
  21904. */
  21905. onBeforeDrawObservable: Observable<Mesh>;
  21906. private _onBeforeDrawObserver;
  21907. onBeforeDraw: () => void;
  21908. delayLoadState: number;
  21909. instances: InstancedMesh[];
  21910. delayLoadingFile: string;
  21911. _binaryInfo: any;
  21912. private _LODLevels;
  21913. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21914. private _morphTargetManager;
  21915. morphTargetManager: Nullable<MorphTargetManager>;
  21916. _geometry: Nullable<Geometry>;
  21917. _delayInfo: Array<string>;
  21918. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21919. _visibleInstances: any;
  21920. private _renderIdForInstances;
  21921. private _batchCache;
  21922. private _instancesBufferSize;
  21923. private _instancesBuffer;
  21924. private _instancesData;
  21925. private _overridenInstanceCount;
  21926. private _effectiveMaterial;
  21927. _shouldGenerateFlatShading: boolean;
  21928. private _preActivateId;
  21929. _originalBuilderSideOrientation: number;
  21930. overrideMaterialSideOrientation: Nullable<number>;
  21931. private _areNormalsFrozen;
  21932. private _sourcePositions;
  21933. private _sourceNormals;
  21934. private _source;
  21935. readonly source: Nullable<Mesh>;
  21936. isUnIndexed: boolean;
  21937. /**
  21938. * @constructor
  21939. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21940. * @param {Scene} scene The scene to add this mesh to.
  21941. * @param {Node} parent The parent of this mesh, if it has one
  21942. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21943. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21944. * When false, achieved by calling a clone(), also passing False.
  21945. * This will make creation of children, recursive.
  21946. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21947. */
  21948. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21949. /**
  21950. * Returns the string "Mesh".
  21951. */
  21952. getClassName(): string;
  21953. /**
  21954. * Returns a string.
  21955. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21956. */
  21957. toString(fullDetails?: boolean): string;
  21958. _unBindEffect(): void;
  21959. /**
  21960. * True if the mesh has some Levels Of Details (LOD).
  21961. * Returns a boolean.
  21962. */
  21963. readonly hasLODLevels: boolean;
  21964. /**
  21965. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21966. * @returns an array of {BABYLON.MeshLODLevel}
  21967. */
  21968. getLODLevels(): MeshLODLevel[];
  21969. private _sortLODLevels();
  21970. /**
  21971. * Add a mesh as LOD level triggered at the given distance.
  21972. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21973. * @param distance The distance from the center of the object to show this level
  21974. * @param mesh The mesh to be added as LOD level (can be null)
  21975. * @return This mesh (for chaining)
  21976. */
  21977. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21978. /**
  21979. * Returns the LOD level mesh at the passed distance or null if not found.
  21980. * It is related to the method `addLODLevel(distance, mesh)`.
  21981. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21982. * Returns an object Mesh or `null`.
  21983. */
  21984. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21985. /**
  21986. * Remove a mesh from the LOD array
  21987. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21988. * @param {Mesh} mesh The mesh to be removed.
  21989. * @return {Mesh} This mesh (for chaining)
  21990. */
  21991. removeLODLevel(mesh: Mesh): Mesh;
  21992. /**
  21993. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21994. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21995. */
  21996. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21997. /**
  21998. * Returns the mesh internal Geometry object.
  21999. */
  22000. readonly geometry: Nullable<Geometry>;
  22001. /**
  22002. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  22003. */
  22004. getTotalVertices(): number;
  22005. /**
  22006. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  22007. * 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.
  22008. * You can force the copy with forceCopy === true
  22009. * Returns null if the mesh has no geometry or no vertex buffer.
  22010. * Possible `kind` values :
  22011. * - BABYLON.VertexBuffer.PositionKind
  22012. * - BABYLON.VertexBuffer.UVKind
  22013. * - BABYLON.VertexBuffer.UV2Kind
  22014. * - BABYLON.VertexBuffer.UV3Kind
  22015. * - BABYLON.VertexBuffer.UV4Kind
  22016. * - BABYLON.VertexBuffer.UV5Kind
  22017. * - BABYLON.VertexBuffer.UV6Kind
  22018. * - BABYLON.VertexBuffer.ColorKind
  22019. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22020. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22021. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22022. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22023. */
  22024. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22025. /**
  22026. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  22027. * Returns `null` if the mesh has no geometry.
  22028. * Possible `kind` values :
  22029. * - BABYLON.VertexBuffer.PositionKind
  22030. * - BABYLON.VertexBuffer.UVKind
  22031. * - BABYLON.VertexBuffer.UV2Kind
  22032. * - BABYLON.VertexBuffer.UV3Kind
  22033. * - BABYLON.VertexBuffer.UV4Kind
  22034. * - BABYLON.VertexBuffer.UV5Kind
  22035. * - BABYLON.VertexBuffer.UV6Kind
  22036. * - BABYLON.VertexBuffer.ColorKind
  22037. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22038. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22039. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22040. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22041. */
  22042. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22043. isVerticesDataPresent(kind: string): boolean;
  22044. /**
  22045. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  22046. * Possible `kind` values :
  22047. * - BABYLON.VertexBuffer.PositionKind
  22048. * - BABYLON.VertexBuffer.UVKind
  22049. * - BABYLON.VertexBuffer.UV2Kind
  22050. * - BABYLON.VertexBuffer.UV3Kind
  22051. * - BABYLON.VertexBuffer.UV4Kind
  22052. * - BABYLON.VertexBuffer.UV5Kind
  22053. * - BABYLON.VertexBuffer.UV6Kind
  22054. * - BABYLON.VertexBuffer.ColorKind
  22055. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22056. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22057. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22058. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22059. */
  22060. isVertexBufferUpdatable(kind: string): boolean;
  22061. /**
  22062. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  22063. * Possible `kind` values :
  22064. * - BABYLON.VertexBuffer.PositionKind
  22065. * - BABYLON.VertexBuffer.UVKind
  22066. * - BABYLON.VertexBuffer.UV2Kind
  22067. * - BABYLON.VertexBuffer.UV3Kind
  22068. * - BABYLON.VertexBuffer.UV4Kind
  22069. * - BABYLON.VertexBuffer.UV5Kind
  22070. * - BABYLON.VertexBuffer.UV6Kind
  22071. * - BABYLON.VertexBuffer.ColorKind
  22072. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22073. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22074. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22075. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22076. */
  22077. getVerticesDataKinds(): string[];
  22078. /**
  22079. * Returns a positive integer : the total number of indices in this mesh geometry.
  22080. * Returns zero if the mesh has no geometry.
  22081. */
  22082. getTotalIndices(): number;
  22083. /**
  22084. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22085. * 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.
  22086. * Returns an empty array if the mesh has no geometry.
  22087. */
  22088. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22089. readonly isBlocked: boolean;
  22090. /**
  22091. * Determine if the current mesh is ready to be rendered
  22092. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  22093. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  22094. * @returns true if all associated assets are ready (material, textures, shaders)
  22095. */
  22096. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  22097. /**
  22098. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  22099. * This property is pertinent only for updatable parametric shapes.
  22100. */
  22101. readonly areNormalsFrozen: boolean;
  22102. /**
  22103. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22104. * It has no effect at all on other shapes.
  22105. * It prevents the mesh normals from being recomputed on next `positions` array update.
  22106. * Returns the Mesh.
  22107. */
  22108. freezeNormals(): Mesh;
  22109. /**
  22110. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22111. * It has no effect at all on other shapes.
  22112. * It reactivates the mesh normals computation if it was previously frozen.
  22113. * Returns the Mesh.
  22114. */
  22115. unfreezeNormals(): Mesh;
  22116. /**
  22117. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  22118. */
  22119. overridenInstanceCount: number;
  22120. _preActivate(): Mesh;
  22121. _preActivateForIntermediateRendering(renderId: number): Mesh;
  22122. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  22123. /**
  22124. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22125. * This means the mesh underlying bounding box and sphere are recomputed.
  22126. * Returns the Mesh.
  22127. */
  22128. refreshBoundingInfo(): Mesh;
  22129. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  22130. private _getPositionData(applySkeleton);
  22131. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  22132. subdivide(count: number): void;
  22133. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  22134. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  22135. /**
  22136. * Sets the mesh VertexBuffer.
  22137. * Returns the Mesh.
  22138. */
  22139. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  22140. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  22141. /**
  22142. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  22143. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  22144. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  22145. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  22146. * Returns the Mesh.
  22147. */
  22148. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  22149. /**
  22150. * Creates a un-shared specific occurence of the geometry for the mesh.
  22151. * Returns the Mesh.
  22152. */
  22153. makeGeometryUnique(): Mesh;
  22154. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  22155. /**
  22156. * Update the current index buffer
  22157. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22158. * Returns the Mesh.
  22159. */
  22160. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  22161. /**
  22162. * Invert the geometry to move from a right handed system to a left handed one.
  22163. * Returns the Mesh.
  22164. */
  22165. toLeftHanded(): Mesh;
  22166. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  22167. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  22168. /**
  22169. * Registers for this mesh a javascript function called just before the rendering process.
  22170. * This function is passed the current mesh.
  22171. * Return the Mesh.
  22172. */
  22173. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22174. /**
  22175. * Disposes a previously registered javascript function called before the rendering.
  22176. * This function is passed the current mesh.
  22177. * Returns the Mesh.
  22178. */
  22179. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22180. /**
  22181. * Registers for this mesh a javascript function called just after the rendering is complete.
  22182. * This function is passed the current mesh.
  22183. * Returns the Mesh.
  22184. */
  22185. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22186. /**
  22187. * Disposes a previously registered javascript function called after the rendering.
  22188. * This function is passed the current mesh.
  22189. * Return the Mesh.
  22190. */
  22191. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22192. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  22193. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  22194. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  22195. /**
  22196. * Triggers the draw call for the mesh.
  22197. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  22198. * Returns the Mesh.
  22199. */
  22200. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  22201. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  22202. /**
  22203. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  22204. */
  22205. getEmittedParticleSystems(): IParticleSystem[];
  22206. /**
  22207. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  22208. */
  22209. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  22210. /**
  22211. * Normalize matrix weights so that all vertices have a total weight set to 1
  22212. */
  22213. cleanMatrixWeights(): void;
  22214. _checkDelayState(): Mesh;
  22215. private _queueLoad(scene);
  22216. /**
  22217. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  22218. */
  22219. isInFrustum(frustumPlanes: Plane[]): boolean;
  22220. /**
  22221. * Sets the mesh material by the material or multiMaterial `id` property.
  22222. * The material `id` is a string identifying the material or the multiMaterial.
  22223. * This method returns the Mesh.
  22224. */
  22225. setMaterialByID(id: string): Mesh;
  22226. /**
  22227. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  22228. */
  22229. getAnimatables(): IAnimatable[];
  22230. /**
  22231. * Modifies the mesh geometry according to the passed transformation matrix.
  22232. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  22233. * The mesh normals are modified accordingly the same transformation.
  22234. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  22235. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22236. * Returns the Mesh.
  22237. */
  22238. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22239. /**
  22240. * Modifies the mesh geometry according to its own current World Matrix.
  22241. * The mesh World Matrix is then reset.
  22242. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22243. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  22244. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22245. * Returns the Mesh.
  22246. */
  22247. bakeCurrentTransformIntoVertices(): Mesh;
  22248. readonly _positions: Nullable<Vector3[]>;
  22249. _resetPointsArrayCache(): Mesh;
  22250. _generatePointsArray(): boolean;
  22251. /**
  22252. * Returns a new Mesh object generated from the current mesh properties.
  22253. * This method must not get confused with createInstance().
  22254. * The parameter `name` is a string, the name given to the new mesh.
  22255. * The optional parameter `newParent` can be any Node object (default `null`).
  22256. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  22257. * 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.
  22258. */
  22259. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22260. /**
  22261. * Releases resources associated with this mesh.
  22262. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22263. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22264. */
  22265. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22266. /**
  22267. * Modifies the mesh geometry according to a displacement map.
  22268. * 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.
  22269. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22270. * This method returns nothing.
  22271. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  22272. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  22273. * 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.
  22274. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  22275. * The parameter `uvScale` is an optional vector2 used to scale UV.
  22276. *
  22277. * Returns the Mesh.
  22278. */
  22279. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  22280. /**
  22281. * Modifies the mesh geometry according to a displacementMap buffer.
  22282. * 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.
  22283. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22284. * This method returns nothing.
  22285. * 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.
  22286. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  22287. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  22288. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  22289. * The parameter `uvScale` is an optional vector2 used to scale UV.
  22290. *
  22291. * Returns the Mesh.
  22292. */
  22293. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  22294. /**
  22295. * Modify the mesh to get a flat shading rendering.
  22296. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22297. * This method returns the Mesh.
  22298. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22299. */
  22300. convertToFlatShadedMesh(): Mesh;
  22301. /**
  22302. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22303. * In other words, more vertices, no more indices and a single bigger VBO.
  22304. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22305. * Returns the Mesh.
  22306. */
  22307. convertToUnIndexedMesh(): Mesh;
  22308. /**
  22309. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  22310. * This method returns the Mesh.
  22311. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22312. */
  22313. flipFaces(flipNormals?: boolean): Mesh;
  22314. /**
  22315. * Creates a new InstancedMesh object from the mesh model.
  22316. * An instance shares the same properties and the same material than its model.
  22317. * Only these properties of each instance can then be set individually :
  22318. * - position
  22319. * - rotation
  22320. * - rotationQuaternion
  22321. * - setPivotMatrix
  22322. * - scaling
  22323. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  22324. * Warning : this method is not supported for Line mesh and LineSystem
  22325. */
  22326. createInstance(name: string): InstancedMesh;
  22327. /**
  22328. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22329. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22330. * This method returns the Mesh.
  22331. */
  22332. synchronizeInstances(): Mesh;
  22333. /**
  22334. * Simplify the mesh according to the given array of settings.
  22335. * Function will return immediately and will simplify async. It returns the Mesh.
  22336. * @param settings a collection of simplification settings.
  22337. * @param parallelProcessing should all levels calculate parallel or one after the other.
  22338. * @param type the type of simplification to run.
  22339. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  22340. */
  22341. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  22342. /**
  22343. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22344. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22345. * This should be used together with the simplification to avoid disappearing triangles.
  22346. * Returns the Mesh.
  22347. * @param successCallback an optional success callback to be called after the optimization finished.
  22348. */
  22349. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22350. serialize(serializationObject: any): void;
  22351. _syncGeometryWithMorphTargetManager(): void;
  22352. /**
  22353. * Returns a new Mesh object parsed from the source provided.
  22354. * The parameter `parsedMesh` is the source.
  22355. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22356. */
  22357. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22358. /**
  22359. * Creates a ribbon mesh.
  22360. * Please consider using the same method from the MeshBuilder class instead.
  22361. * 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.
  22362. *
  22363. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22364. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22365. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  22366. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  22367. * 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.
  22368. * 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.
  22369. * 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
  22370. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22371. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22372. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22373. */
  22374. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22375. /**
  22376. * Creates a plane polygonal mesh. By default, this is a disc.
  22377. * Please consider using the same method from the MeshBuilder class instead.
  22378. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  22379. * 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.
  22380. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22381. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22382. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22383. */
  22384. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22385. /**
  22386. * Creates a box mesh.
  22387. * Please consider using the same method from the MeshBuilder class instead.
  22388. * The parameter `size` sets the size (float) of each box side (default 1).
  22389. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22390. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22391. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22392. */
  22393. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22394. /**
  22395. * Creates a sphere mesh.
  22396. * Please consider using the same method from the MeshBuilder class instead.
  22397. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  22398. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  22399. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22400. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22401. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22402. */
  22403. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22404. /**
  22405. * Creates a cylinder or a cone mesh.
  22406. * Please consider using the same method from the MeshBuilder class instead.
  22407. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22408. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22409. * 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.
  22410. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22411. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22412. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22413. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22414. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22415. */
  22416. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22417. /**
  22418. * Creates a torus mesh.
  22419. * Please consider using the same method from the MeshBuilder class instead.
  22420. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  22421. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  22422. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  22423. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22424. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22425. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22426. */
  22427. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22428. /**
  22429. * Creates a torus knot mesh.
  22430. * Please consider using the same method from the MeshBuilder class instead.
  22431. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  22432. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  22433. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  22434. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  22435. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22436. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22438. */
  22439. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22440. /**
  22441. * Creates a line mesh.
  22442. * Please consider using the same method from the MeshBuilder class instead.
  22443. * 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.
  22444. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22445. * The parameter `points` is an array successive Vector3.
  22446. * 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
  22447. * When updating an instance, remember that only point positions can change, not the number of points.
  22448. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22449. */
  22450. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22451. /**
  22452. * Creates a dashed line mesh.
  22453. * Please consider using the same method from the MeshBuilder class instead.
  22454. * 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.
  22455. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22456. * The parameter `points` is an array successive Vector3.
  22457. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  22458. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22459. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22460. * 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
  22461. * When updating an instance, remember that only point positions can change, not the number of points.
  22462. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22463. */
  22464. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22465. /**
  22466. * Creates a polygon mesh.
  22467. * Please consider using the same method from the MeshBuilder class instead.
  22468. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22469. * 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.
  22470. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22471. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22472. * Remember you can only change the shape positions, not their number when updating a polygon.
  22473. */
  22474. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22475. /**
  22476. * Creates an extruded polygon mesh, with depth in the Y direction.
  22477. * Please consider using the same method from the MeshBuilder class instead.
  22478. */
  22479. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22480. /**
  22481. * Creates an extruded shape mesh.
  22482. * 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.
  22483. * Please consider using the same method from the MeshBuilder class instead.
  22484. *
  22485. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22486. * 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
  22487. * extruded along the Z axis.
  22488. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22489. * 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.
  22490. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22491. * 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
  22492. * 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
  22493. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22494. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22495. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22496. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22497. */
  22498. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22499. /**
  22500. * Creates an custom extruded shape mesh.
  22501. * 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.
  22502. * Please consider using the same method from the MeshBuilder class instead.
  22503. *
  22504. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22505. * 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
  22506. * extruded along the Z axis.
  22507. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22508. * 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
  22509. * and the distance of this point from the begining of the path :
  22510. * ```javascript
  22511. * var rotationFunction = function(i, distance) {
  22512. * // do things
  22513. * return rotationValue; }
  22514. * ```
  22515. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22516. * 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
  22517. * and the distance of this point from the begining of the path :
  22518. * ```javascript
  22519. * var scaleFunction = function(i, distance) {
  22520. * // do things
  22521. * return scaleValue;}
  22522. * ```
  22523. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22524. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22525. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22526. * 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
  22527. * 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
  22528. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22529. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22530. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22531. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22532. */
  22533. 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;
  22534. /**
  22535. * Creates lathe mesh.
  22536. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22537. * Please consider using the same method from the MeshBuilder class instead.
  22538. * 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
  22539. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22540. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22541. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22542. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22543. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22544. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22545. */
  22546. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22547. /**
  22548. * Creates a plane mesh.
  22549. * Please consider using the same method from the MeshBuilder class instead.
  22550. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22551. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22552. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22553. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22554. */
  22555. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22556. /**
  22557. * Creates a ground mesh.
  22558. * Please consider using the same method from the MeshBuilder class instead.
  22559. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22560. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22561. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22562. */
  22563. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22564. /**
  22565. * Creates a tiled ground mesh.
  22566. * Please consider using the same method from the MeshBuilder class instead.
  22567. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22568. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22569. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22570. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22571. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22572. * numbers of subdivisions on the ground width and height of each tile.
  22573. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22574. */
  22575. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22576. w: number;
  22577. h: number;
  22578. }, precision: {
  22579. w: number;
  22580. h: number;
  22581. }, scene: Scene, updatable?: boolean): Mesh;
  22582. /**
  22583. * Creates a ground mesh from a height map.
  22584. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22585. * Please consider using the same method from the MeshBuilder class instead.
  22586. * The parameter `url` sets the URL of the height map image resource.
  22587. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22588. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22589. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22590. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22591. * 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).
  22592. * This function is passed the newly built mesh :
  22593. * ```javascript
  22594. * function(mesh) { // do things
  22595. * return; }
  22596. * ```
  22597. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22598. */
  22599. 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;
  22600. /**
  22601. * Creates a tube mesh.
  22602. * 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.
  22603. * Please consider using the same method from the MeshBuilder class instead.
  22604. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22605. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22606. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22607. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22608. * 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.
  22609. * It must return a radius value (positive float) :
  22610. * ```javascript
  22611. * var radiusFunction = function(i, distance) {
  22612. * // do things
  22613. * return radius; }
  22614. * ```
  22615. * 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
  22616. * 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
  22617. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22618. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22619. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22620. */
  22621. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22622. (i: number, distance: number): number;
  22623. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22624. /**
  22625. * Creates a polyhedron mesh.
  22626. * Please consider using the same method from the MeshBuilder class instead.
  22627. * 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
  22628. * to choose the wanted type.
  22629. * The parameter `size` (positive float, default 1) sets the polygon size.
  22630. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22631. * 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`.
  22632. * 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
  22633. * 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)`).
  22634. * 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
  22635. * 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.
  22636. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22637. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22638. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22639. */
  22640. static CreatePolyhedron(name: string, options: {
  22641. type?: number;
  22642. size?: number;
  22643. sizeX?: number;
  22644. sizeY?: number;
  22645. sizeZ?: number;
  22646. custom?: any;
  22647. faceUV?: Vector4[];
  22648. faceColors?: Color4[];
  22649. updatable?: boolean;
  22650. sideOrientation?: number;
  22651. }, scene: Scene): Mesh;
  22652. /**
  22653. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22654. * Please consider using the same method from the MeshBuilder class instead.
  22655. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22656. * 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`).
  22657. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22658. * 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.
  22659. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22660. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22661. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22662. */
  22663. static CreateIcoSphere(name: string, options: {
  22664. radius?: number;
  22665. flat?: boolean;
  22666. subdivisions?: number;
  22667. sideOrientation?: number;
  22668. updatable?: boolean;
  22669. }, scene: Scene): Mesh;
  22670. /**
  22671. * Creates a decal mesh.
  22672. * Please consider using the same method from the MeshBuilder class instead.
  22673. * 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.
  22674. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22675. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22676. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22677. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22678. */
  22679. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22680. /**
  22681. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22682. */
  22683. setPositionsForCPUSkinning(): Float32Array;
  22684. /**
  22685. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22686. */
  22687. setNormalsForCPUSkinning(): Float32Array;
  22688. /**
  22689. * Updates the vertex buffer by applying transformation from the bones.
  22690. * Returns the Mesh.
  22691. *
  22692. * @param {skeleton} skeleton to apply
  22693. */
  22694. applySkeleton(skeleton: Skeleton): Mesh;
  22695. /**
  22696. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22697. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22698. */
  22699. static MinMax(meshes: AbstractMesh[]): {
  22700. min: Vector3;
  22701. max: Vector3;
  22702. };
  22703. /**
  22704. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22705. */
  22706. static Center(meshesOrMinMaxVector: {
  22707. min: Vector3;
  22708. max: Vector3;
  22709. } | AbstractMesh[]): Vector3;
  22710. /**
  22711. * Merge the array of meshes into a single mesh for performance reasons.
  22712. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  22713. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  22714. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22715. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22716. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22717. */
  22718. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22719. }
  22720. }
  22721. declare module BABYLON {
  22722. /**
  22723. * Define an interface for all classes that will get and set the data on vertices
  22724. */
  22725. interface IGetSetVerticesData {
  22726. isVerticesDataPresent(kind: string): boolean;
  22727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22728. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22729. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22730. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22731. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22732. }
  22733. /**
  22734. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22735. */
  22736. class VertexData {
  22737. /**
  22738. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22739. */
  22740. positions: Nullable<FloatArray>;
  22741. /**
  22742. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22743. */
  22744. normals: Nullable<FloatArray>;
  22745. /**
  22746. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22747. */
  22748. tangents: Nullable<FloatArray>;
  22749. /**
  22750. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22751. */
  22752. uvs: Nullable<FloatArray>;
  22753. /**
  22754. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22755. */
  22756. uvs2: Nullable<FloatArray>;
  22757. /**
  22758. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22759. */
  22760. uvs3: Nullable<FloatArray>;
  22761. /**
  22762. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22763. */
  22764. uvs4: Nullable<FloatArray>;
  22765. /**
  22766. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22767. */
  22768. uvs5: Nullable<FloatArray>;
  22769. /**
  22770. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22771. */
  22772. uvs6: Nullable<FloatArray>;
  22773. /**
  22774. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22775. */
  22776. colors: Nullable<FloatArray>;
  22777. /**
  22778. * 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).
  22779. */
  22780. matricesIndices: Nullable<FloatArray>;
  22781. /**
  22782. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22783. */
  22784. matricesWeights: Nullable<FloatArray>;
  22785. /**
  22786. * An array extending the number of possible indices
  22787. */
  22788. matricesIndicesExtra: Nullable<FloatArray>;
  22789. /**
  22790. * An array extending the number of possible weights when the number of indices is extended
  22791. */
  22792. matricesWeightsExtra: Nullable<FloatArray>;
  22793. /**
  22794. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22795. */
  22796. indices: Nullable<IndicesArray>;
  22797. /**
  22798. * Uses the passed data array to set the set the values for the specified kind of data
  22799. * @param data a linear array of floating numbers
  22800. * @param kind the type of data that is being set, eg positions, colors etc
  22801. */
  22802. set(data: FloatArray, kind: string): void;
  22803. /**
  22804. * Associates the vertexData to the passed Mesh.
  22805. * Sets it as updatable or not (default `false`)
  22806. * @param mesh the mesh the vertexData is applied to
  22807. * @param updatable when used and having the value true allows new data to update the vertexData
  22808. * @returns the VertexData
  22809. */
  22810. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22811. /**
  22812. * Associates the vertexData to the passed Geometry.
  22813. * Sets it as updatable or not (default `false`)
  22814. * @param geometry the geometry the vertexData is applied to
  22815. * @param updatable when used and having the value true allows new data to update the vertexData
  22816. * @returns VertexData
  22817. */
  22818. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22819. /**
  22820. * Updates the associated mesh
  22821. * @param mesh the mesh to be updated
  22822. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22823. * @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
  22824. * @returns VertexData
  22825. */
  22826. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22827. /**
  22828. * Updates the associated geometry
  22829. * @param geometry the geometry to be updated
  22830. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22831. * @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
  22832. * @returns VertexData.
  22833. */
  22834. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22835. private _applyTo(meshOrGeometry, updatable?);
  22836. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  22837. /**
  22838. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22839. * @param matrix the transforming matrix
  22840. * @returns the VertexData
  22841. */
  22842. transform(matrix: Matrix): VertexData;
  22843. /**
  22844. * Merges the passed VertexData into the current one
  22845. * @param other the VertexData to be merged into the current one
  22846. * @returns the modified VertexData
  22847. */
  22848. merge(other: VertexData): VertexData;
  22849. private _mergeElement(source, other);
  22850. private _validate();
  22851. /**
  22852. * Serializes the VertexData
  22853. * @returns a serialized object
  22854. */
  22855. serialize(): any;
  22856. /**
  22857. * Extracts the vertexData from a mesh
  22858. * @param mesh the mesh from which to extract the VertexData
  22859. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22860. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22861. * @returns the object VertexData associated to the passed mesh
  22862. */
  22863. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22864. /**
  22865. * Extracts the vertexData from the geometry
  22866. * @param geometry the geometry from which to extract the VertexData
  22867. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22868. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22869. * @returns the object VertexData associated to the passed mesh
  22870. */
  22871. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22872. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  22873. /**
  22874. * Creates the VertexData for a Ribbon
  22875. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22876. * * pathArray array of paths, each of which an array of successive Vector3
  22877. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22878. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22879. * * 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
  22880. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22881. * * 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)
  22882. * * 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)
  22883. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22884. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22885. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22886. * @returns the VertexData of the ribbon
  22887. */
  22888. static CreateRibbon(options: {
  22889. pathArray: Vector3[][];
  22890. closeArray?: boolean;
  22891. closePath?: boolean;
  22892. offset?: number;
  22893. sideOrientation?: number;
  22894. frontUVs?: Vector4;
  22895. backUVs?: Vector4;
  22896. invertUV?: boolean;
  22897. uvs?: Vector2[];
  22898. colors?: Color4[];
  22899. }): VertexData;
  22900. /**
  22901. * Creates the VertexData for a box
  22902. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22903. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22904. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22905. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22906. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22907. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22908. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22909. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22910. * * 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)
  22911. * * 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)
  22912. * @returns the VertexData of the box
  22913. */
  22914. static CreateBox(options: {
  22915. size?: number;
  22916. width?: number;
  22917. height?: number;
  22918. depth?: number;
  22919. faceUV?: Vector4[];
  22920. faceColors?: Color4[];
  22921. sideOrientation?: number;
  22922. frontUVs?: Vector4;
  22923. backUVs?: Vector4;
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * segments sets the number of horizontal strips optional, default 32
  22929. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22930. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22931. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22932. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22933. * * 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
  22934. * * 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
  22935. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22936. * * 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)
  22937. * * 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)
  22938. * @returns the VertexData of the ellipsoid
  22939. */
  22940. static CreateSphere(options: {
  22941. segments?: number;
  22942. diameter?: number;
  22943. diameterX?: number;
  22944. diameterY?: number;
  22945. diameterZ?: number;
  22946. arc?: number;
  22947. slice?: number;
  22948. sideOrientation?: number;
  22949. frontUVs?: Vector4;
  22950. backUVs?: Vector4;
  22951. }): VertexData;
  22952. /**
  22953. * Creates the VertexData for a cylinder, cone or prism
  22954. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22955. * * height sets the height (y direction) of the cylinder, optional, default 2
  22956. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22957. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22958. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22959. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22960. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22961. * * 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
  22962. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22963. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22964. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22965. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22966. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22967. * * 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)
  22968. * * 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)
  22969. * @returns the VertexData of the cylinder, cone or prism
  22970. */
  22971. static CreateCylinder(options: {
  22972. height?: number;
  22973. diameterTop?: number;
  22974. diameterBottom?: number;
  22975. diameter?: number;
  22976. tessellation?: number;
  22977. subdivisions?: number;
  22978. arc?: number;
  22979. faceColors?: Color4[];
  22980. faceUV?: Vector4[];
  22981. hasRings?: boolean;
  22982. enclose?: boolean;
  22983. sideOrientation?: number;
  22984. frontUVs?: Vector4;
  22985. backUVs?: Vector4;
  22986. }): VertexData;
  22987. /**
  22988. * Creates the VertexData for a torus
  22989. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22990. * * diameter the diameter of the torus, optional default 1
  22991. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22992. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22993. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22994. * * 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)
  22995. * * 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)
  22996. * @returns the VertexData of the torus
  22997. */
  22998. static CreateTorus(options: {
  22999. diameter?: number;
  23000. thickness?: number;
  23001. tessellation?: number;
  23002. sideOrientation?: number;
  23003. frontUVs?: Vector4;
  23004. backUVs?: Vector4;
  23005. }): VertexData;
  23006. /**
  23007. * Creates the VertexData of the LineSystem
  23008. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23009. * - lines an array of lines, each line being an array of successive Vector3
  23010. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23011. * @returns the VertexData of the LineSystem
  23012. */
  23013. static CreateLineSystem(options: {
  23014. lines: Vector3[][];
  23015. colors?: Nullable<Color4[][]>;
  23016. }): VertexData;
  23017. /**
  23018. * Create the VertexData for a DashedLines
  23019. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23020. * - points an array successive Vector3
  23021. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23022. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23023. * - dashNb the intended total number of dashes, optional, default 200
  23024. * @returns the VertexData for the DashedLines
  23025. */
  23026. static CreateDashedLines(options: {
  23027. points: Vector3[];
  23028. dashSize?: number;
  23029. gapSize?: number;
  23030. dashNb?: number;
  23031. }): VertexData;
  23032. /**
  23033. * Creates the VertexData for a Ground
  23034. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23035. * - width the width (x direction) of the ground, optional, default 1
  23036. * - height the height (z direction) of the ground, optional, default 1
  23037. * - subdivisions the number of subdivisions per side, optional, default 1
  23038. * @returns the VertexData of the Ground
  23039. */
  23040. static CreateGround(options: {
  23041. width?: number;
  23042. height?: number;
  23043. subdivisions?: number;
  23044. subdivisionsX?: number;
  23045. subdivisionsY?: number;
  23046. }): VertexData;
  23047. /**
  23048. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23049. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23050. * * xmin the ground minimum X coordinate, optional, default -1
  23051. * * zmin the ground minimum Z coordinate, optional, default -1
  23052. * * xmax the ground maximum X coordinate, optional, default 1
  23053. * * zmax the ground maximum Z coordinate, optional, default 1
  23054. * * 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}
  23055. * * 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}
  23056. * @returns the VertexData of the TiledGround
  23057. */
  23058. static CreateTiledGround(options: {
  23059. xmin: number;
  23060. zmin: number;
  23061. xmax: number;
  23062. zmax: number;
  23063. subdivisions?: {
  23064. w: number;
  23065. h: number;
  23066. };
  23067. precision?: {
  23068. w: number;
  23069. h: number;
  23070. };
  23071. }): VertexData;
  23072. /**
  23073. * Creates the VertexData of the Ground designed from a heightmap
  23074. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23075. * * width the width (x direction) of the ground
  23076. * * height the height (z direction) of the ground
  23077. * * subdivisions the number of subdivisions per side
  23078. * * minHeight the minimum altitude on the ground, optional, default 0
  23079. * * maxHeight the maximum altitude on the ground, optional default 1
  23080. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23081. * * buffer the array holding the image color data
  23082. * * bufferWidth the width of image
  23083. * * bufferHeight the height of image
  23084. * @returns the VertexData of the Ground designed from a heightmap
  23085. */
  23086. static CreateGroundFromHeightMap(options: {
  23087. width: number;
  23088. height: number;
  23089. subdivisions: number;
  23090. minHeight: number;
  23091. maxHeight: number;
  23092. colorFilter: Color3;
  23093. buffer: Uint8Array;
  23094. bufferWidth: number;
  23095. bufferHeight: number;
  23096. }): VertexData;
  23097. /**
  23098. * Creates the VertexData for a Plane
  23099. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23100. * * size sets the width and height of the plane to the value of size, optional default 1
  23101. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23102. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23103. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23104. * * 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)
  23105. * * 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)
  23106. * @returns the VertexData of the box
  23107. */
  23108. static CreatePlane(options: {
  23109. size?: number;
  23110. width?: number;
  23111. height?: number;
  23112. sideOrientation?: number;
  23113. frontUVs?: Vector4;
  23114. backUVs?: Vector4;
  23115. }): VertexData;
  23116. /**
  23117. * Creates the VertexData of the Disc or regular Polygon
  23118. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23119. * * radius the radius of the disc, optional default 0.5
  23120. * * tessellation the number of polygon sides, optional, default 64
  23121. * * 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
  23122. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23123. * * 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)
  23124. * * 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)
  23125. * @returns the VertexData of the box
  23126. */
  23127. static CreateDisc(options: {
  23128. radius?: number;
  23129. tessellation?: number;
  23130. arc?: number;
  23131. sideOrientation?: number;
  23132. frontUVs?: Vector4;
  23133. backUVs?: Vector4;
  23134. }): VertexData;
  23135. /**
  23136. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23137. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23138. * @param polygon a mesh built from polygonTriangulation.build()
  23139. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23140. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23141. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23142. * @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)
  23143. * @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)
  23144. * @returns the VertexData of the Polygon
  23145. */
  23146. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23147. /**
  23148. * Creates the VertexData of the IcoSphere
  23149. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23150. * * radius the radius of the IcoSphere, optional default 1
  23151. * * radiusX allows stretching in the x direction, optional, default radius
  23152. * * radiusY allows stretching in the y direction, optional, default radius
  23153. * * radiusZ allows stretching in the z direction, optional, default radius
  23154. * * flat when true creates a flat shaded mesh, optional, default true
  23155. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23156. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23157. * * 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)
  23158. * * 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)
  23159. * @returns the VertexData of the IcoSphere
  23160. */
  23161. static CreateIcoSphere(options: {
  23162. radius?: number;
  23163. radiusX?: number;
  23164. radiusY?: number;
  23165. radiusZ?: number;
  23166. flat?: boolean;
  23167. subdivisions?: number;
  23168. sideOrientation?: number;
  23169. frontUVs?: Vector4;
  23170. backUVs?: Vector4;
  23171. }): VertexData;
  23172. /**
  23173. * Creates the VertexData for a Polyhedron
  23174. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23175. * * type provided types are:
  23176. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23177. * * 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)
  23178. * * size the size of the IcoSphere, optional default 1
  23179. * * sizeX allows stretching in the x direction, optional, default size
  23180. * * sizeY allows stretching in the y direction, optional, default size
  23181. * * sizeZ allows stretching in the z direction, optional, default size
  23182. * * 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
  23183. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23184. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23185. * * flat when true creates a flat shaded mesh, optional, default true
  23186. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23187. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23188. * * 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)
  23189. * * 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)
  23190. * @returns the VertexData of the Polyhedron
  23191. */
  23192. static CreatePolyhedron(options: {
  23193. type?: number;
  23194. size?: number;
  23195. sizeX?: number;
  23196. sizeY?: number;
  23197. sizeZ?: number;
  23198. custom?: any;
  23199. faceUV?: Vector4[];
  23200. faceColors?: Color4[];
  23201. flat?: boolean;
  23202. sideOrientation?: number;
  23203. frontUVs?: Vector4;
  23204. backUVs?: Vector4;
  23205. }): VertexData;
  23206. /**
  23207. * Creates the VertexData for a TorusKnot
  23208. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23209. * * radius the radius of the torus knot, optional, default 2
  23210. * * tube the thickness of the tube, optional, default 0.5
  23211. * * radialSegments the number of sides on each tube segments, optional, default 32
  23212. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23213. * * p the number of windings around the z axis, optional, default 2
  23214. * * q the number of windings around the x axis, optional, default 3
  23215. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23216. * * 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)
  23217. * * 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)
  23218. * @returns the VertexData of the Torus Knot
  23219. */
  23220. static CreateTorusKnot(options: {
  23221. radius?: number;
  23222. tube?: number;
  23223. radialSegments?: number;
  23224. tubularSegments?: number;
  23225. p?: number;
  23226. q?: number;
  23227. sideOrientation?: number;
  23228. frontUVs?: Vector4;
  23229. backUVs?: Vector4;
  23230. }): VertexData;
  23231. /**
  23232. * Compute normals for given positions and indices
  23233. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23234. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23235. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23236. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23237. * * facetNormals : optional array of facet normals (vector3)
  23238. * * facetPositions : optional array of facet positions (vector3)
  23239. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23240. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23241. * * bInfo : optional bounding info, required for facetPartitioning computation
  23242. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23243. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23244. * * useRightHandedSystem: optional boolean to for right handed system computation
  23245. * * depthSort : optional boolean to enable the facet depth sort computation
  23246. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23247. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23248. */
  23249. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23250. facetNormals?: any;
  23251. facetPositions?: any;
  23252. facetPartitioning?: any;
  23253. ratio?: number;
  23254. bInfo?: any;
  23255. bbSize?: Vector3;
  23256. subDiv?: any;
  23257. useRightHandedSystem?: boolean;
  23258. depthSort?: boolean;
  23259. distanceTo?: Vector3;
  23260. depthSortedFacets?: any;
  23261. }): void;
  23262. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  23263. /**
  23264. * Applies VertexData created from the imported parameters to the geometry
  23265. * @param parsedVertexData the parsed data from an imported file
  23266. * @param geometry the geometry to apply the VertexData to
  23267. */
  23268. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23269. }
  23270. }
  23271. declare module BABYLON {
  23272. /**
  23273. * Class containing static functions to help procedurally build meshes
  23274. */
  23275. class MeshBuilder {
  23276. private static updateSideOrientation(orientation?);
  23277. /**
  23278. * Creates a box mesh
  23279. * * The parameter `size` sets the size (float) of each box side (default 1)
  23280. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  23281. * * 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)
  23282. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23284. * * 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
  23285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23286. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  23287. * @param name defines the name of the mesh
  23288. * @param options defines the options used to create the mesh
  23289. * @param scene defines the hosting scene
  23290. * @returns the box mesh
  23291. */
  23292. static CreateBox(name: string, options: {
  23293. size?: number;
  23294. width?: number;
  23295. height?: number;
  23296. depth?: number;
  23297. faceUV?: Vector4[];
  23298. faceColors?: Color4[];
  23299. sideOrientation?: number;
  23300. frontUVs?: Vector4;
  23301. backUVs?: Vector4;
  23302. updatable?: boolean;
  23303. }, scene?: Nullable<Scene>): Mesh;
  23304. /**
  23305. * Creates a sphere mesh
  23306. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23307. * * 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`)
  23308. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23309. * * 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
  23310. * * 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)
  23311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23312. * * 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
  23313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23314. * @param name defines the name of the mesh
  23315. * @param options defines the options used to create the mesh
  23316. * @param scene defines the hosting scene
  23317. * @returns the sphere mesh
  23318. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  23319. */
  23320. static CreateSphere(name: string, options: {
  23321. segments?: number;
  23322. diameter?: number;
  23323. diameterX?: number;
  23324. diameterY?: number;
  23325. diameterZ?: number;
  23326. arc?: number;
  23327. slice?: number;
  23328. sideOrientation?: number;
  23329. frontUVs?: Vector4;
  23330. backUVs?: Vector4;
  23331. updatable?: boolean;
  23332. }, scene: any): Mesh;
  23333. /**
  23334. * Creates a plane polygonal mesh. By default, this is a disc
  23335. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23336. * * 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
  23337. * * 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
  23338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23339. * * 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
  23340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23341. * @param name defines the name of the mesh
  23342. * @param options defines the options used to create the mesh
  23343. * @param scene defines the hosting scene
  23344. * @returns the plane polygonal mesh
  23345. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23346. */
  23347. static CreateDisc(name: string, options: {
  23348. radius?: number;
  23349. tessellation?: number;
  23350. arc?: number;
  23351. updatable?: boolean;
  23352. sideOrientation?: number;
  23353. frontUVs?: Vector4;
  23354. backUVs?: Vector4;
  23355. }, scene?: Nullable<Scene>): Mesh;
  23356. /**
  23357. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23358. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23359. * * 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`)
  23360. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23361. * * 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
  23362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23363. * * 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
  23364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23365. * @param name defines the name of the mesh
  23366. * @param options defines the options used to create the mesh
  23367. * @param scene defines the hosting scene
  23368. * @returns the icosahedron mesh
  23369. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23370. */
  23371. static CreateIcoSphere(name: string, options: {
  23372. radius?: number;
  23373. radiusX?: number;
  23374. radiusY?: number;
  23375. radiusZ?: number;
  23376. flat?: boolean;
  23377. subdivisions?: number;
  23378. sideOrientation?: number;
  23379. frontUVs?: Vector4;
  23380. backUVs?: Vector4;
  23381. updatable?: boolean;
  23382. }, scene: Scene): Mesh;
  23383. /**
  23384. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23385. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23386. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23387. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23388. * * 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
  23389. * * 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
  23390. * * 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
  23391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23392. * * 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
  23393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23394. * * 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
  23395. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23396. * * 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
  23397. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23399. * @param name defines the name of the mesh
  23400. * @param options defines the options used to create the mesh
  23401. * @param scene defines the hosting scene
  23402. * @returns the ribbon mesh
  23403. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23404. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23405. */
  23406. static CreateRibbon(name: string, options: {
  23407. pathArray: Vector3[][];
  23408. closeArray?: boolean;
  23409. closePath?: boolean;
  23410. offset?: number;
  23411. updatable?: boolean;
  23412. sideOrientation?: number;
  23413. frontUVs?: Vector4;
  23414. backUVs?: Vector4;
  23415. instance?: Mesh;
  23416. invertUV?: boolean;
  23417. uvs?: Vector2[];
  23418. colors?: Color4[];
  23419. }, scene?: Nullable<Scene>): Mesh;
  23420. /**
  23421. * Creates a cylinder or a cone mesh
  23422. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23423. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23424. * * 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.
  23425. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23426. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23427. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23428. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23429. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23430. * * 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).
  23431. * * 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
  23432. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23433. * * 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
  23434. * * 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.
  23435. * * If `enclose` is false, a ring surface is one element.
  23436. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23437. * * 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
  23438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23439. * * 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
  23440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23441. * @param name defines the name of the mesh
  23442. * @param options defines the options used to create the mesh
  23443. * @param scene defines the hosting scene
  23444. * @returns the cylinder mesh
  23445. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  23446. */
  23447. static CreateCylinder(name: string, options: {
  23448. height?: number;
  23449. diameterTop?: number;
  23450. diameterBottom?: number;
  23451. diameter?: number;
  23452. tessellation?: number;
  23453. subdivisions?: number;
  23454. arc?: number;
  23455. faceColors?: Color4[];
  23456. faceUV?: Vector4[];
  23457. updatable?: boolean;
  23458. hasRings?: boolean;
  23459. enclose?: boolean;
  23460. sideOrientation?: number;
  23461. frontUVs?: Vector4;
  23462. backUVs?: Vector4;
  23463. }, scene: any): Mesh;
  23464. /**
  23465. * Creates a torus mesh
  23466. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23467. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23468. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23470. * * 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
  23471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23472. * @param name defines the name of the mesh
  23473. * @param options defines the options used to create the mesh
  23474. * @param scene defines the hosting scene
  23475. * @returns the torus mesh
  23476. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23477. */
  23478. static CreateTorus(name: string, options: {
  23479. diameter?: number;
  23480. thickness?: number;
  23481. tessellation?: number;
  23482. updatable?: boolean;
  23483. sideOrientation?: number;
  23484. frontUVs?: Vector4;
  23485. backUVs?: Vector4;
  23486. }, scene: any): Mesh;
  23487. /**
  23488. * Creates a torus knot mesh
  23489. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23490. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23491. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23492. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23494. * * 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
  23495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23496. * @param name defines the name of the mesh
  23497. * @param options defines the options used to create the mesh
  23498. * @param scene defines the hosting scene
  23499. * @returns the torus knot mesh
  23500. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23501. */
  23502. static CreateTorusKnot(name: string, options: {
  23503. radius?: number;
  23504. tube?: number;
  23505. radialSegments?: number;
  23506. tubularSegments?: number;
  23507. p?: number;
  23508. q?: number;
  23509. updatable?: boolean;
  23510. sideOrientation?: number;
  23511. frontUVs?: Vector4;
  23512. backUVs?: Vector4;
  23513. }, scene: any): Mesh;
  23514. /**
  23515. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23516. * * 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
  23517. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23518. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23519. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23520. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23521. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23522. * * 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
  23523. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23525. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23526. * @param name defines the name of the new line system
  23527. * @param options defines the options used to create the line system
  23528. * @param scene defines the hosting scene
  23529. * @returns a new line system mesh
  23530. */
  23531. static CreateLineSystem(name: string, options: {
  23532. lines: Vector3[][];
  23533. updatable?: boolean;
  23534. instance?: Nullable<LinesMesh>;
  23535. colors?: Nullable<Color4[][]>;
  23536. useVertexAlpha?: boolean;
  23537. }, scene: Nullable<Scene>): LinesMesh;
  23538. /**
  23539. * Creates a line mesh
  23540. * 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
  23541. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23542. * * The parameter `points` is an array successive Vector3
  23543. * * 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
  23544. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23545. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23546. * * When updating an instance, remember that only point positions can change, not the number of points
  23547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23548. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23549. * @param name defines the name of the new line system
  23550. * @param options defines the options used to create the line system
  23551. * @param scene defines the hosting scene
  23552. * @returns a new line mesh
  23553. */
  23554. static CreateLines(name: string, options: {
  23555. points: Vector3[];
  23556. updatable?: boolean;
  23557. instance?: Nullable<LinesMesh>;
  23558. colors?: Color4[];
  23559. useVertexAlpha?: boolean;
  23560. }, scene?: Nullable<Scene>): LinesMesh;
  23561. /**
  23562. * Creates a dashed line mesh
  23563. * * 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
  23564. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23565. * * The parameter `points` is an array successive Vector3
  23566. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23567. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23568. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23569. * * 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
  23570. * * When updating an instance, remember that only point positions can change, not the number of points
  23571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23572. * @param name defines the name of the mesh
  23573. * @param options defines the options used to create the mesh
  23574. * @param scene defines the hosting scene
  23575. * @returns the dashed line mesh
  23576. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23577. */
  23578. static CreateDashedLines(name: string, options: {
  23579. points: Vector3[];
  23580. dashSize?: number;
  23581. gapSize?: number;
  23582. dashNb?: number;
  23583. updatable?: boolean;
  23584. instance?: LinesMesh;
  23585. }, scene?: Nullable<Scene>): LinesMesh;
  23586. /**
  23587. * 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.
  23588. * * 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.
  23589. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23590. * * 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.
  23591. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23592. * * 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
  23593. * * 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
  23594. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23596. * * 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
  23597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23599. * @param name defines the name of the mesh
  23600. * @param options defines the options used to create the mesh
  23601. * @param scene defines the hosting scene
  23602. * @returns the extruded shape mesh
  23603. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23604. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23605. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23606. */
  23607. static ExtrudeShape(name: string, options: {
  23608. shape: Vector3[];
  23609. path: Vector3[];
  23610. scale?: number;
  23611. rotation?: number;
  23612. cap?: number;
  23613. updatable?: boolean;
  23614. sideOrientation?: number;
  23615. frontUVs?: Vector4;
  23616. backUVs?: Vector4;
  23617. instance?: Mesh;
  23618. invertUV?: boolean;
  23619. }, scene?: Nullable<Scene>): Mesh;
  23620. /**
  23621. * Creates an custom extruded shape mesh.
  23622. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23623. * * 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.
  23624. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23625. * * 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
  23626. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23627. * * 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
  23628. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23629. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23630. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23631. * * 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
  23632. * * 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
  23633. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23635. * * 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
  23636. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23638. * @param name defines the name of the mesh
  23639. * @param options defines the options used to create the mesh
  23640. * @param scene defines the hosting scene
  23641. * @returns the custom extruded shape mesh
  23642. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23643. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23644. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23645. */
  23646. static ExtrudeShapeCustom(name: string, options: {
  23647. shape: Vector3[];
  23648. path: Vector3[];
  23649. scaleFunction?: any;
  23650. rotationFunction?: any;
  23651. ribbonCloseArray?: boolean;
  23652. ribbonClosePath?: boolean;
  23653. cap?: number;
  23654. updatable?: boolean;
  23655. sideOrientation?: number;
  23656. frontUVs?: Vector4;
  23657. backUVs?: Vector4;
  23658. instance?: Mesh;
  23659. invertUV?: boolean;
  23660. }, scene: Scene): Mesh;
  23661. /**
  23662. * Creates lathe mesh.
  23663. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23664. * * 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
  23665. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23666. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23667. * * 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
  23668. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23669. * * 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
  23670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23671. * * 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
  23672. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23674. * @param name defines the name of the mesh
  23675. * @param options defines the options used to create the mesh
  23676. * @param scene defines the hosting scene
  23677. * @returns the lathe mesh
  23678. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23679. */
  23680. static CreateLathe(name: string, options: {
  23681. shape: Vector3[];
  23682. radius?: number;
  23683. tessellation?: number;
  23684. arc?: number;
  23685. closed?: boolean;
  23686. updatable?: boolean;
  23687. sideOrientation?: number;
  23688. frontUVs?: Vector4;
  23689. backUVs?: Vector4;
  23690. cap?: number;
  23691. invertUV?: boolean;
  23692. }, scene: Scene): Mesh;
  23693. /**
  23694. * Creates a plane mesh
  23695. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23696. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23697. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23699. * * 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
  23700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23701. * @param name defines the name of the mesh
  23702. * @param options defines the options used to create the mesh
  23703. * @param scene defines the hosting scene
  23704. * @returns the plane mesh
  23705. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23706. */
  23707. static CreatePlane(name: string, options: {
  23708. size?: number;
  23709. width?: number;
  23710. height?: number;
  23711. sideOrientation?: number;
  23712. frontUVs?: Vector4;
  23713. backUVs?: Vector4;
  23714. updatable?: boolean;
  23715. sourcePlane?: Plane;
  23716. }, scene: Scene): Mesh;
  23717. /**
  23718. * Creates a ground mesh
  23719. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23720. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23722. * @param name defines the name of the mesh
  23723. * @param options defines the options used to create the mesh
  23724. * @param scene defines the hosting scene
  23725. * @returns the ground mesh
  23726. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23727. */
  23728. static CreateGround(name: string, options: {
  23729. width?: number;
  23730. height?: number;
  23731. subdivisions?: number;
  23732. subdivisionsX?: number;
  23733. subdivisionsY?: number;
  23734. updatable?: boolean;
  23735. }, scene: any): Mesh;
  23736. /**
  23737. * Creates a tiled ground mesh
  23738. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23739. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23740. * * 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
  23741. * * 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
  23742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23743. * @param name defines the name of the mesh
  23744. * @param options defines the options used to create the mesh
  23745. * @param scene defines the hosting scene
  23746. * @returns the tiled ground mesh
  23747. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23748. */
  23749. static CreateTiledGround(name: string, options: {
  23750. xmin: number;
  23751. zmin: number;
  23752. xmax: number;
  23753. zmax: number;
  23754. subdivisions?: {
  23755. w: number;
  23756. h: number;
  23757. };
  23758. precision?: {
  23759. w: number;
  23760. h: number;
  23761. };
  23762. updatable?: boolean;
  23763. }, scene: Scene): Mesh;
  23764. /**
  23765. * Creates a ground mesh from a height map
  23766. * * The parameter `url` sets the URL of the height map image resource.
  23767. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23768. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23769. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23770. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23771. * * 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.
  23772. * * 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).
  23773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23774. * @param name defines the name of the mesh
  23775. * @param url defines the url to the height map
  23776. * @param options defines the options used to create the mesh
  23777. * @param scene defines the hosting scene
  23778. * @returns the ground mesh
  23779. * @see http://doc.babylonjs.com/babylon101/height_map
  23780. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23781. */
  23782. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23783. width?: number;
  23784. height?: number;
  23785. subdivisions?: number;
  23786. minHeight?: number;
  23787. maxHeight?: number;
  23788. colorFilter?: Color3;
  23789. updatable?: boolean;
  23790. onReady?: (mesh: GroundMesh) => void;
  23791. }, scene: Scene): GroundMesh;
  23792. /**
  23793. * Creates a polygon mesh
  23794. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23795. * * 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
  23796. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23798. * * 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)
  23799. * * Remember you can only change the shape positions, not their number when updating a polygon
  23800. * @param name defines the name of the mesh
  23801. * @param options defines the options used to create the mesh
  23802. * @param scene defines the hosting scene
  23803. * @returns the polygon mesh
  23804. */
  23805. static CreatePolygon(name: string, options: {
  23806. shape: Vector3[];
  23807. holes?: Vector3[][];
  23808. depth?: number;
  23809. faceUV?: Vector4[];
  23810. faceColors?: Color4[];
  23811. updatable?: boolean;
  23812. sideOrientation?: number;
  23813. frontUVs?: Vector4;
  23814. backUVs?: Vector4;
  23815. }, scene: Scene): Mesh;
  23816. /**
  23817. * Creates an extruded polygon mesh, with depth in the Y direction.
  23818. * * 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)
  23819. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23820. * @param name defines the name of the mesh
  23821. * @param options defines the options used to create the mesh
  23822. * @param scene defines the hosting scene
  23823. * @returns the polygon mesh
  23824. */
  23825. static ExtrudePolygon(name: string, options: {
  23826. shape: Vector3[];
  23827. holes?: Vector3[][];
  23828. depth?: number;
  23829. faceUV?: Vector4[];
  23830. faceColors?: Color4[];
  23831. updatable?: boolean;
  23832. sideOrientation?: number;
  23833. frontUVs?: Vector4;
  23834. backUVs?: Vector4;
  23835. }, scene: Scene): Mesh;
  23836. /**
  23837. * Creates a tube mesh.
  23838. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23839. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23840. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23841. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23842. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23843. * * 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)
  23844. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23845. * * 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
  23846. * * 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
  23847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23848. * * 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
  23849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23851. * @param name defines the name of the mesh
  23852. * @param options defines the options used to create the mesh
  23853. * @param scene defines the hosting scene
  23854. * @returns the tube mesh
  23855. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23856. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23857. */
  23858. static CreateTube(name: string, options: {
  23859. path: Vector3[];
  23860. radius?: number;
  23861. tessellation?: number;
  23862. radiusFunction?: {
  23863. (i: number, distance: number): number;
  23864. };
  23865. cap?: number;
  23866. arc?: number;
  23867. updatable?: boolean;
  23868. sideOrientation?: number;
  23869. frontUVs?: Vector4;
  23870. backUVs?: Vector4;
  23871. instance?: Mesh;
  23872. invertUV?: boolean;
  23873. }, scene: Scene): Mesh;
  23874. /**
  23875. * Creates a polyhedron mesh
  23876. * * 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
  23877. * * The parameter `size` (positive float, default 1) sets the polygon size
  23878. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23879. * * 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`
  23880. * * 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
  23881. * * 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)`)
  23882. * * 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
  23883. * * 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
  23884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23885. * * 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
  23886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23887. * @param name defines the name of the mesh
  23888. * @param options defines the options used to create the mesh
  23889. * @param scene defines the hosting scene
  23890. * @returns the polyhedron mesh
  23891. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23892. */
  23893. static CreatePolyhedron(name: string, options: {
  23894. type?: number;
  23895. size?: number;
  23896. sizeX?: number;
  23897. sizeY?: number;
  23898. sizeZ?: number;
  23899. custom?: any;
  23900. faceUV?: Vector4[];
  23901. faceColors?: Color4[];
  23902. flat?: boolean;
  23903. updatable?: boolean;
  23904. sideOrientation?: number;
  23905. frontUVs?: Vector4;
  23906. backUVs?: Vector4;
  23907. }, scene: Scene): Mesh;
  23908. /**
  23909. * Creates a decal mesh.
  23910. * 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
  23911. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23912. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23913. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23914. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23915. * @param name defines the name of the mesh
  23916. * @param sourceMesh defines the mesh where the decal must be applied
  23917. * @param options defines the options used to create the mesh
  23918. * @param scene defines the hosting scene
  23919. * @returns the decal mesh
  23920. * @see http://doc.babylonjs.com/how_to/decals
  23921. */
  23922. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23923. position?: Vector3;
  23924. normal?: Vector3;
  23925. size?: Vector3;
  23926. angle?: number;
  23927. }): Mesh;
  23928. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  23929. }
  23930. }
  23931. declare module BABYLON {
  23932. class MeshLODLevel {
  23933. distance: number;
  23934. mesh: Nullable<Mesh>;
  23935. constructor(distance: number, mesh: Nullable<Mesh>);
  23936. }
  23937. }
  23938. declare module BABYLON {
  23939. /**
  23940. * A simplifier interface for future simplification implementations.
  23941. */
  23942. interface ISimplifier {
  23943. /**
  23944. * Simplification of a given mesh according to the given settings.
  23945. * Since this requires computation, it is assumed that the function runs async.
  23946. * @param settings The settings of the simplification, including quality and distance
  23947. * @param successCallback A callback that will be called after the mesh was simplified.
  23948. * @param errorCallback in case of an error, this callback will be called. optional.
  23949. */
  23950. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23951. }
  23952. /**
  23953. * Expected simplification settings.
  23954. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23955. */
  23956. interface ISimplificationSettings {
  23957. quality: number;
  23958. distance: number;
  23959. optimizeMesh?: boolean;
  23960. }
  23961. class SimplificationSettings implements ISimplificationSettings {
  23962. quality: number;
  23963. distance: number;
  23964. optimizeMesh: boolean | undefined;
  23965. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23966. }
  23967. interface ISimplificationTask {
  23968. settings: Array<ISimplificationSettings>;
  23969. simplificationType: SimplificationType;
  23970. mesh: Mesh;
  23971. successCallback?: () => void;
  23972. parallelProcessing: boolean;
  23973. }
  23974. class SimplificationQueue {
  23975. private _simplificationArray;
  23976. running: boolean;
  23977. constructor();
  23978. addTask(task: ISimplificationTask): void;
  23979. executeNext(): void;
  23980. runSimplification(task: ISimplificationTask): void;
  23981. private getSimplifier(task);
  23982. }
  23983. /**
  23984. * The implemented types of simplification
  23985. * At the moment only Quadratic Error Decimation is implemented
  23986. */
  23987. enum SimplificationType {
  23988. /** Quadratic error decimation */
  23989. QUADRATIC = 0,
  23990. }
  23991. class DecimationTriangle {
  23992. vertices: Array<DecimationVertex>;
  23993. normal: Vector3;
  23994. error: Array<number>;
  23995. deleted: boolean;
  23996. isDirty: boolean;
  23997. borderFactor: number;
  23998. deletePending: boolean;
  23999. originalOffset: number;
  24000. constructor(vertices: Array<DecimationVertex>);
  24001. }
  24002. class DecimationVertex {
  24003. position: Vector3;
  24004. id: number;
  24005. q: QuadraticMatrix;
  24006. isBorder: boolean;
  24007. triangleStart: number;
  24008. triangleCount: number;
  24009. originalOffsets: Array<number>;
  24010. constructor(position: Vector3, id: number);
  24011. updatePosition(newPosition: Vector3): void;
  24012. }
  24013. class QuadraticMatrix {
  24014. data: Array<number>;
  24015. constructor(data?: Array<number>);
  24016. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  24017. addInPlace(matrix: QuadraticMatrix): void;
  24018. addArrayInPlace(data: Array<number>): void;
  24019. add(matrix: QuadraticMatrix): QuadraticMatrix;
  24020. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  24021. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  24022. }
  24023. class Reference {
  24024. vertexId: number;
  24025. triangleId: number;
  24026. constructor(vertexId: number, triangleId: number);
  24027. }
  24028. /**
  24029. * An implementation of the Quadratic Error simplification algorithm.
  24030. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  24031. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  24032. * @author RaananW
  24033. */
  24034. class QuadraticErrorSimplification implements ISimplifier {
  24035. private _mesh;
  24036. private triangles;
  24037. private vertices;
  24038. private references;
  24039. private _reconstructedMesh;
  24040. syncIterations: number;
  24041. aggressiveness: number;
  24042. decimationIterations: number;
  24043. boundingBoxEpsilon: number;
  24044. constructor(_mesh: Mesh);
  24045. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  24046. private runDecimation(settings, submeshIndex, successCallback);
  24047. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  24048. private init(callback);
  24049. private reconstructMesh(submeshIndex);
  24050. private initDecimatedMesh();
  24051. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  24052. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  24053. private identifyBorder();
  24054. private updateMesh(identifyBorders?);
  24055. private vertexError(q, point);
  24056. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  24057. }
  24058. }
  24059. declare module BABYLON {
  24060. class Polygon {
  24061. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  24062. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  24063. static Parse(input: string): Vector2[];
  24064. static StartingAt(x: number, y: number): Path2;
  24065. }
  24066. class PolygonMeshBuilder {
  24067. private _points;
  24068. private _outlinepoints;
  24069. private _holes;
  24070. private _name;
  24071. private _scene;
  24072. private _epoints;
  24073. private _eholes;
  24074. private _addToepoint(points);
  24075. constructor(name: string, contours: Path2, scene: Scene);
  24076. constructor(name: string, contours: Vector2[], scene: Scene);
  24077. addHole(hole: Vector2[]): PolygonMeshBuilder;
  24078. build(updatable?: boolean, depth?: number): Mesh;
  24079. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  24080. }
  24081. }
  24082. declare module BABYLON {
  24083. class BaseSubMesh {
  24084. _materialDefines: Nullable<MaterialDefines>;
  24085. _materialEffect: Nullable<Effect>;
  24086. readonly effect: Nullable<Effect>;
  24087. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24088. }
  24089. class SubMesh extends BaseSubMesh implements ICullable {
  24090. materialIndex: number;
  24091. verticesStart: number;
  24092. verticesCount: number;
  24093. indexStart: number;
  24094. indexCount: number;
  24095. linesIndexCount: number;
  24096. private _mesh;
  24097. private _renderingMesh;
  24098. private _boundingInfo;
  24099. private _linesIndexBuffer;
  24100. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24101. _trianglePlanes: Plane[];
  24102. _lastColliderTransformMatrix: Matrix;
  24103. _renderId: number;
  24104. _alphaIndex: number;
  24105. _distanceToCamera: number;
  24106. _id: number;
  24107. private _currentMaterial;
  24108. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24109. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24110. readonly IsGlobal: boolean;
  24111. /**
  24112. * Returns the submesh BoudingInfo object.
  24113. */
  24114. getBoundingInfo(): BoundingInfo;
  24115. /**
  24116. * Sets the submesh BoundingInfo.
  24117. * Return the SubMesh.
  24118. */
  24119. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24120. /**
  24121. * Returns the mesh of the current submesh.
  24122. */
  24123. getMesh(): AbstractMesh;
  24124. /**
  24125. * Returns the rendering mesh of the submesh.
  24126. */
  24127. getRenderingMesh(): Mesh;
  24128. /**
  24129. * Returns the submesh material.
  24130. */
  24131. getMaterial(): Nullable<Material>;
  24132. /**
  24133. * Sets a new updated BoundingInfo object to the submesh.
  24134. * Returns the SubMesh.
  24135. */
  24136. refreshBoundingInfo(): SubMesh;
  24137. _checkCollision(collider: Collider): boolean;
  24138. /**
  24139. * Updates the submesh BoundingInfo.
  24140. * Returns the Submesh.
  24141. */
  24142. updateBoundingInfo(world: Matrix): SubMesh;
  24143. /**
  24144. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24145. * Boolean returned.
  24146. */
  24147. isInFrustum(frustumPlanes: Plane[]): boolean;
  24148. /**
  24149. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  24150. * Boolean returned.
  24151. */
  24152. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24153. /**
  24154. * Renders the submesh.
  24155. * Returns it.
  24156. */
  24157. render(enableAlphaMode: boolean): SubMesh;
  24158. /**
  24159. * Returns a new Index Buffer.
  24160. * Type returned : WebGLBuffer.
  24161. */
  24162. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  24163. /**
  24164. * True is the passed Ray intersects the submesh bounding box.
  24165. * Boolean returned.
  24166. */
  24167. canIntersects(ray: Ray): boolean;
  24168. /**
  24169. * Returns an object IntersectionInfo.
  24170. */
  24171. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  24172. _rebuild(): void;
  24173. /**
  24174. * Creates a new Submesh from the passed Mesh.
  24175. */
  24176. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24177. /**
  24178. * Disposes the Submesh.
  24179. * Returns nothing.
  24180. */
  24181. dispose(): void;
  24182. /**
  24183. * Creates a new Submesh from the passed parameters :
  24184. * - materialIndex (integer) : the index of the main mesh material.
  24185. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  24186. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  24187. * - mesh (Mesh) : the main mesh to create the submesh from.
  24188. * - renderingMesh (optional Mesh) : rendering mesh.
  24189. */
  24190. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24191. }
  24192. }
  24193. declare module BABYLON {
  24194. class TransformNode extends Node {
  24195. static BILLBOARDMODE_NONE: number;
  24196. static BILLBOARDMODE_X: number;
  24197. static BILLBOARDMODE_Y: number;
  24198. static BILLBOARDMODE_Z: number;
  24199. static BILLBOARDMODE_ALL: number;
  24200. private _forward;
  24201. private _forwardInverted;
  24202. private _up;
  24203. private _right;
  24204. private _rightInverted;
  24205. private _rotation;
  24206. private _rotationQuaternion;
  24207. protected _scaling: Vector3;
  24208. protected _isDirty: boolean;
  24209. private _transformToBoneReferal;
  24210. /**
  24211. * Set the billboard mode. Default is 0.
  24212. *
  24213. * | Value | Type | Description |
  24214. * | --- | --- | --- |
  24215. * | 0 | BILLBOARDMODE_NONE | |
  24216. * | 1 | BILLBOARDMODE_X | |
  24217. * | 2 | BILLBOARDMODE_Y | |
  24218. * | 4 | BILLBOARDMODE_Z | |
  24219. * | 7 | BILLBOARDMODE_ALL | |
  24220. *
  24221. */
  24222. billboardMode: number;
  24223. scalingDeterminant: number;
  24224. infiniteDistance: boolean;
  24225. /**
  24226. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  24227. * By default the system will update normals to compensate
  24228. */
  24229. ignoreNonUniformScaling: boolean;
  24230. position: Vector3;
  24231. _poseMatrix: Matrix;
  24232. private _localWorld;
  24233. _worldMatrix: Matrix;
  24234. _worldMatrixDeterminant: number;
  24235. private _absolutePosition;
  24236. private _pivotMatrix;
  24237. private _pivotMatrixInverse;
  24238. private _postMultiplyPivotMatrix;
  24239. protected _isWorldMatrixFrozen: boolean;
  24240. /**
  24241. * An event triggered after the world matrix is updated
  24242. */
  24243. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  24244. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  24245. /**
  24246. * Gets a string idenfifying the name of the class
  24247. * @returns "TransformNode" string
  24248. */
  24249. getClassName(): string;
  24250. /**
  24251. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  24252. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  24253. * Default : (0.0, 0.0, 0.0)
  24254. */
  24255. rotation: Vector3;
  24256. /**
  24257. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24258. * Default : (1.0, 1.0, 1.0)
  24259. */
  24260. /**
  24261. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24262. * Default : (1.0, 1.0, 1.0)
  24263. */
  24264. scaling: Vector3;
  24265. /**
  24266. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  24267. * It's null by default.
  24268. * 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)
  24269. */
  24270. rotationQuaternion: Nullable<Quaternion>;
  24271. /**
  24272. * The forward direction of that transform in world space.
  24273. */
  24274. readonly forward: Vector3;
  24275. /**
  24276. * The up direction of that transform in world space.
  24277. */
  24278. readonly up: Vector3;
  24279. /**
  24280. * The right direction of that transform in world space.
  24281. */
  24282. readonly right: Vector3;
  24283. /**
  24284. * Returns the latest update of the World matrix
  24285. * Returns a Matrix.
  24286. */
  24287. getWorldMatrix(): Matrix;
  24288. /** @hidden */
  24289. _getWorldMatrixDeterminant(): number;
  24290. /**
  24291. * Returns directly the latest state of the mesh World matrix.
  24292. * A Matrix is returned.
  24293. */
  24294. readonly worldMatrixFromCache: Matrix;
  24295. /**
  24296. * Copies the paramater passed Matrix into the mesh Pose matrix.
  24297. * Returns the TransformNode.
  24298. */
  24299. updatePoseMatrix(matrix: Matrix): TransformNode;
  24300. /**
  24301. * Returns the mesh Pose matrix.
  24302. * Returned object : Matrix
  24303. */
  24304. getPoseMatrix(): Matrix;
  24305. _isSynchronized(): boolean;
  24306. _initCache(): void;
  24307. markAsDirty(property: string): TransformNode;
  24308. /**
  24309. * Returns the current mesh absolute position.
  24310. * Retuns a Vector3.
  24311. */
  24312. readonly absolutePosition: Vector3;
  24313. /**
  24314. * Sets a new matrix to apply before all other transformation
  24315. * @param matrix defines the transform matrix
  24316. * @returns the current TransformNode
  24317. */
  24318. setPreTransformMatrix(matrix: Matrix): TransformNode;
  24319. /**
  24320. * Sets a new pivot matrix to the current node
  24321. * @param matrix defines the new pivot matrix to use
  24322. * @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
  24323. * @returns the current TransformNode
  24324. */
  24325. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  24326. /**
  24327. * Returns the mesh pivot matrix.
  24328. * Default : Identity.
  24329. * A Matrix is returned.
  24330. */
  24331. getPivotMatrix(): Matrix;
  24332. /**
  24333. * Prevents the World matrix to be computed any longer.
  24334. * Returns the TransformNode.
  24335. */
  24336. freezeWorldMatrix(): TransformNode;
  24337. /**
  24338. * Allows back the World matrix computation.
  24339. * Returns the TransformNode.
  24340. */
  24341. unfreezeWorldMatrix(): this;
  24342. /**
  24343. * True if the World matrix has been frozen.
  24344. * Returns a boolean.
  24345. */
  24346. readonly isWorldMatrixFrozen: boolean;
  24347. /**
  24348. * Retuns the mesh absolute position in the World.
  24349. * Returns a Vector3.
  24350. */
  24351. getAbsolutePosition(): Vector3;
  24352. /**
  24353. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  24354. * Returns the TransformNode.
  24355. */
  24356. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24357. /**
  24358. * Sets the mesh position in its local space.
  24359. * Returns the TransformNode.
  24360. */
  24361. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24362. /**
  24363. * Returns the mesh position in the local space from the current World matrix values.
  24364. * Returns a new Vector3.
  24365. */
  24366. getPositionExpressedInLocalSpace(): Vector3;
  24367. /**
  24368. * Translates the mesh along the passed Vector3 in its local space.
  24369. * Returns the TransformNode.
  24370. */
  24371. locallyTranslate(vector3: Vector3): TransformNode;
  24372. private static _lookAtVectorCache;
  24373. /**
  24374. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  24375. * @param targetPoint the position (must be in same space as current mesh) to look at
  24376. * @param yawCor optional yaw (y-axis) correction in radians
  24377. * @param pitchCor optional pitch (x-axis) correction in radians
  24378. * @param rollCor optional roll (z-axis) correction in radians
  24379. * @param space the choosen space of the target
  24380. * @returns the TransformNode.
  24381. */
  24382. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24383. /**
  24384. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24385. * This Vector3 is expressed in the World space.
  24386. */
  24387. getDirection(localAxis: Vector3): Vector3;
  24388. /**
  24389. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24390. * localAxis is expressed in the mesh local space.
  24391. * result is computed in the Wordl space from the mesh World matrix.
  24392. * Returns the TransformNode.
  24393. */
  24394. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24395. /**
  24396. * Sets a new pivot point to the current node
  24397. * @param point defines the new pivot point to use
  24398. * @param space defines if the point is in world or local space (local by default)
  24399. * @returns the current TransformNode
  24400. */
  24401. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24402. /**
  24403. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24404. */
  24405. getPivotPoint(): Vector3;
  24406. /**
  24407. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24408. * Returns the TransformNode.
  24409. */
  24410. getPivotPointToRef(result: Vector3): TransformNode;
  24411. /**
  24412. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24413. */
  24414. getAbsolutePivotPoint(): Vector3;
  24415. /**
  24416. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24417. * Returns the TransformNode.
  24418. */
  24419. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24420. /**
  24421. * Defines the passed node as the parent of the current node.
  24422. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24423. * Returns the TransformNode.
  24424. */
  24425. setParent(node: Nullable<Node>): TransformNode;
  24426. private _nonUniformScaling;
  24427. readonly nonUniformScaling: boolean;
  24428. _updateNonUniformScalingState(value: boolean): boolean;
  24429. /**
  24430. * Attach the current TransformNode to another TransformNode associated with a bone
  24431. * @param bone Bone affecting the TransformNode
  24432. * @param affectedTransformNode TransformNode associated with the bone
  24433. */
  24434. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24435. detachFromBone(): TransformNode;
  24436. private static _rotationAxisCache;
  24437. /**
  24438. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24439. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24440. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24441. * The passed axis is also normalized.
  24442. * Returns the TransformNode.
  24443. */
  24444. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24445. /**
  24446. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24447. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24448. * The passed axis is also normalized.
  24449. * Returns the TransformNode.
  24450. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24451. */
  24452. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24453. /**
  24454. * Translates the mesh along the axis vector for the passed distance in the given space.
  24455. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24456. * Returns the TransformNode.
  24457. */
  24458. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24459. /**
  24460. * Adds a rotation step to the mesh current rotation.
  24461. * x, y, z are Euler angles expressed in radians.
  24462. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24463. * This means this rotation is made in the mesh local space only.
  24464. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24465. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24466. * ```javascript
  24467. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24468. * ```
  24469. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24470. * 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.
  24471. * Returns the TransformNode.
  24472. */
  24473. addRotation(x: number, y: number, z: number): TransformNode;
  24474. /**
  24475. * Computes the mesh World matrix and returns it.
  24476. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24477. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24478. * If the parameter `force`is set to `true`, the actual computation is done.
  24479. * Returns the mesh World Matrix.
  24480. */
  24481. computeWorldMatrix(force?: boolean): Matrix;
  24482. protected _afterComputeWorldMatrix(): void;
  24483. /**
  24484. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24485. * @param func: callback function to add
  24486. *
  24487. * Returns the TransformNode.
  24488. */
  24489. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24490. /**
  24491. * Removes a registered callback function.
  24492. * Returns the TransformNode.
  24493. */
  24494. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24495. /**
  24496. * Clone the current transform node
  24497. * Returns the new transform node
  24498. * @param name Name of the new clone
  24499. * @param newParent New parent for the clone
  24500. * @param doNotCloneChildren Do not clone children hierarchy
  24501. */
  24502. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24503. serialize(currentSerializationObject?: any): any;
  24504. /**
  24505. * Returns a new TransformNode object parsed from the source provided.
  24506. * The parameter `parsedMesh` is the source.
  24507. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24508. */
  24509. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24510. /**
  24511. * Releases resources associated with this transform node.
  24512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24514. */
  24515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24516. }
  24517. }
  24518. declare module BABYLON {
  24519. class VertexBuffer {
  24520. /** @hidden */
  24521. _buffer: Buffer;
  24522. private _kind;
  24523. private _size;
  24524. private _ownsBuffer;
  24525. private _instanced;
  24526. private _instanceDivisor;
  24527. /**
  24528. * The byte type.
  24529. */
  24530. static readonly BYTE: number;
  24531. /**
  24532. * The unsigned byte type.
  24533. */
  24534. static readonly UNSIGNED_BYTE: number;
  24535. /**
  24536. * The short type.
  24537. */
  24538. static readonly SHORT: number;
  24539. /**
  24540. * The unsigned short type.
  24541. */
  24542. static readonly UNSIGNED_SHORT: number;
  24543. /**
  24544. * The integer type.
  24545. */
  24546. static readonly INT: number;
  24547. /**
  24548. * The unsigned integer type.
  24549. */
  24550. static readonly UNSIGNED_INT: number;
  24551. /**
  24552. * The float type.
  24553. */
  24554. static readonly FLOAT: number;
  24555. /**
  24556. * Gets or sets the instance divisor when in instanced mode
  24557. */
  24558. instanceDivisor: number;
  24559. /**
  24560. * Gets the byte stride.
  24561. */
  24562. readonly byteStride: number;
  24563. /**
  24564. * Gets the byte offset.
  24565. */
  24566. readonly byteOffset: number;
  24567. /**
  24568. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24569. */
  24570. readonly normalized: boolean;
  24571. /**
  24572. * Gets the data type of each component in the array.
  24573. */
  24574. readonly type: number;
  24575. /**
  24576. * Constructor
  24577. * @param engine the engine
  24578. * @param data the data to use for this vertex buffer
  24579. * @param kind the vertex buffer kind
  24580. * @param updatable whether the data is updatable
  24581. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24582. * @param stride the stride (optional)
  24583. * @param instanced whether the buffer is instanced (optional)
  24584. * @param offset the offset of the data (optional)
  24585. * @param size the number of components (optional)
  24586. * @param type the type of the component (optional)
  24587. * @param normalized whether the data contains normalized data (optional)
  24588. * @param useBytes set to true if stride and offset are in bytes (optional)
  24589. */
  24590. 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);
  24591. _rebuild(): void;
  24592. /**
  24593. * Returns the kind of the VertexBuffer (string).
  24594. */
  24595. getKind(): string;
  24596. /**
  24597. * Boolean : is the VertexBuffer updatable ?
  24598. */
  24599. isUpdatable(): boolean;
  24600. /**
  24601. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24602. */
  24603. getData(): Nullable<DataArray>;
  24604. /**
  24605. * Returns the WebGLBuffer associated to the VertexBuffer.
  24606. */
  24607. getBuffer(): Nullable<WebGLBuffer>;
  24608. /**
  24609. * Returns the stride as a multiple of the type byte length.
  24610. * DEPRECATED. Use byteStride instead.
  24611. */
  24612. getStrideSize(): number;
  24613. /**
  24614. * Returns the offset as a multiple of the type byte length.
  24615. * DEPRECATED. Use byteOffset instead.
  24616. */
  24617. getOffset(): number;
  24618. /**
  24619. * Returns the number of components per vertex attribute (integer).
  24620. */
  24621. getSize(): number;
  24622. /**
  24623. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24624. */
  24625. getIsInstanced(): boolean;
  24626. /**
  24627. * Returns the instancing divisor, zero for non-instanced (integer).
  24628. */
  24629. getInstanceDivisor(): number;
  24630. /**
  24631. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24632. * Returns the created WebGLBuffer.
  24633. */
  24634. create(data?: DataArray): void;
  24635. /**
  24636. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24637. * This function will create a new buffer if the current one is not updatable
  24638. * Returns the updated WebGLBuffer.
  24639. */
  24640. update(data: DataArray): void;
  24641. /**
  24642. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24643. * Returns the directly updated WebGLBuffer.
  24644. * @param data the new data
  24645. * @param offset the new offset
  24646. * @param useBytes set to true if the offset is in bytes
  24647. */
  24648. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24649. /**
  24650. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24651. */
  24652. dispose(): void;
  24653. /**
  24654. * Enumerates each value of this vertex buffer as numbers.
  24655. * @param count the number of values to enumerate
  24656. * @param callback the callback function called for each value
  24657. */
  24658. forEach(count: number, callback: (value: number, index: number) => void): void;
  24659. private static _PositionKind;
  24660. private static _NormalKind;
  24661. private static _TangentKind;
  24662. private static _UVKind;
  24663. private static _UV2Kind;
  24664. private static _UV3Kind;
  24665. private static _UV4Kind;
  24666. private static _UV5Kind;
  24667. private static _UV6Kind;
  24668. private static _ColorKind;
  24669. private static _MatricesIndicesKind;
  24670. private static _MatricesWeightsKind;
  24671. private static _MatricesIndicesExtraKind;
  24672. private static _MatricesWeightsExtraKind;
  24673. static readonly PositionKind: string;
  24674. static readonly NormalKind: string;
  24675. static readonly TangentKind: string;
  24676. static readonly UVKind: string;
  24677. static readonly UV2Kind: string;
  24678. static readonly UV3Kind: string;
  24679. static readonly UV4Kind: string;
  24680. static readonly UV5Kind: string;
  24681. static readonly UV6Kind: string;
  24682. static readonly ColorKind: string;
  24683. static readonly MatricesIndicesKind: string;
  24684. static readonly MatricesWeightsKind: string;
  24685. static readonly MatricesIndicesExtraKind: string;
  24686. static readonly MatricesWeightsExtraKind: string;
  24687. /**
  24688. * Deduces the stride given a kind.
  24689. * @param kind The kind string to deduce
  24690. * @returns The deduced stride
  24691. */
  24692. static DeduceStride(kind: string): number;
  24693. /**
  24694. * Gets the byte length of the given type.
  24695. * @param type the type
  24696. * @returns the number of bytes
  24697. */
  24698. static GetTypeByteLength(type: number): number;
  24699. /**
  24700. * Enumerates each value of the given parameters as numbers.
  24701. * @param data the data to enumerate
  24702. * @param byteOffset the byte offset of the data
  24703. * @param byteStride the byte stride of the data
  24704. * @param componentCount the number of components per element
  24705. * @param componentType the type of the component
  24706. * @param count the total number of components
  24707. * @param normalized whether the data is normalized
  24708. * @param callback the callback function called for each value
  24709. */
  24710. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24711. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  24712. }
  24713. }
  24714. declare module BABYLON {
  24715. /**
  24716. * Defines a target to use with MorphTargetManager
  24717. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24718. */
  24719. class MorphTarget implements IAnimatable {
  24720. /** defines the name of the target */
  24721. name: string;
  24722. /**
  24723. * Gets or sets the list of animations
  24724. */
  24725. animations: Animation[];
  24726. private _scene;
  24727. private _positions;
  24728. private _normals;
  24729. private _tangents;
  24730. private _influence;
  24731. /**
  24732. * Observable raised when the influence changes
  24733. */
  24734. onInfluenceChanged: Observable<boolean>;
  24735. /**
  24736. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24737. */
  24738. influence: number;
  24739. private _animationPropertiesOverride;
  24740. /**
  24741. * Gets or sets the animation properties override
  24742. */
  24743. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24744. /**
  24745. * Creates a new MorphTarget
  24746. * @param name defines the name of the target
  24747. * @param influence defines the influence to use
  24748. */
  24749. constructor(
  24750. /** defines the name of the target */
  24751. name: string, influence?: number, scene?: Nullable<Scene>);
  24752. /**
  24753. * Gets a boolean defining if the target contains position data
  24754. */
  24755. readonly hasPositions: boolean;
  24756. /**
  24757. * Gets a boolean defining if the target contains normal data
  24758. */
  24759. readonly hasNormals: boolean;
  24760. /**
  24761. * Gets a boolean defining if the target contains tangent data
  24762. */
  24763. readonly hasTangents: boolean;
  24764. /**
  24765. * Affects position data to this target
  24766. * @param data defines the position data to use
  24767. */
  24768. setPositions(data: Nullable<FloatArray>): void;
  24769. /**
  24770. * Gets the position data stored in this target
  24771. * @returns a FloatArray containing the position data (or null if not present)
  24772. */
  24773. getPositions(): Nullable<FloatArray>;
  24774. /**
  24775. * Affects normal data to this target
  24776. * @param data defines the normal data to use
  24777. */
  24778. setNormals(data: Nullable<FloatArray>): void;
  24779. /**
  24780. * Gets the normal data stored in this target
  24781. * @returns a FloatArray containing the normal data (or null if not present)
  24782. */
  24783. getNormals(): Nullable<FloatArray>;
  24784. /**
  24785. * Affects tangent data to this target
  24786. * @param data defines the tangent data to use
  24787. */
  24788. setTangents(data: Nullable<FloatArray>): void;
  24789. /**
  24790. * Gets the tangent data stored in this target
  24791. * @returns a FloatArray containing the tangent data (or null if not present)
  24792. */
  24793. getTangents(): Nullable<FloatArray>;
  24794. /**
  24795. * Serializes the current target into a Serialization object
  24796. * @returns the serialized object
  24797. */
  24798. serialize(): any;
  24799. /**
  24800. * Creates a new target from serialized data
  24801. * @param serializationObject defines the serialized data to use
  24802. * @returns a new MorphTarget
  24803. */
  24804. static Parse(serializationObject: any): MorphTarget;
  24805. /**
  24806. * Creates a MorphTarget from mesh data
  24807. * @param mesh defines the source mesh
  24808. * @param name defines the name to use for the new target
  24809. * @param influence defines the influence to attach to the target
  24810. * @returns a new MorphTarget
  24811. */
  24812. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24813. }
  24814. }
  24815. declare module BABYLON {
  24816. /**
  24817. * This class is used to deform meshes using morphing between different targets
  24818. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24819. */
  24820. class MorphTargetManager {
  24821. private _targets;
  24822. private _targetObservable;
  24823. private _activeTargets;
  24824. private _scene;
  24825. private _influences;
  24826. private _supportsNormals;
  24827. private _supportsTangents;
  24828. private _vertexCount;
  24829. private _uniqueId;
  24830. private _tempInfluences;
  24831. /**
  24832. * Creates a new MorphTargetManager
  24833. * @param scene defines the current scene
  24834. */
  24835. constructor(scene?: Nullable<Scene>);
  24836. /**
  24837. * Gets the unique ID of this manager
  24838. */
  24839. readonly uniqueId: number;
  24840. /**
  24841. * Gets the number of vertices handled by this manager
  24842. */
  24843. readonly vertexCount: number;
  24844. /**
  24845. * Gets a boolean indicating if this manager supports morphing of normals
  24846. */
  24847. readonly supportsNormals: boolean;
  24848. /**
  24849. * Gets a boolean indicating if this manager supports morphing of tangents
  24850. */
  24851. readonly supportsTangents: boolean;
  24852. /**
  24853. * Gets the number of targets stored in this manager
  24854. */
  24855. readonly numTargets: number;
  24856. /**
  24857. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24858. */
  24859. readonly numInfluencers: number;
  24860. /**
  24861. * Gets the list of influences (one per target)
  24862. */
  24863. readonly influences: Float32Array;
  24864. /**
  24865. * Gets the active target at specified index. An active target is a target with an influence > 0
  24866. * @param index defines the index to check
  24867. * @returns the requested target
  24868. */
  24869. getActiveTarget(index: number): MorphTarget;
  24870. /**
  24871. * Gets the target at specified index
  24872. * @param index defines the index to check
  24873. * @returns the requested target
  24874. */
  24875. getTarget(index: number): MorphTarget;
  24876. /**
  24877. * Add a new target to this manager
  24878. * @param target defines the target to add
  24879. */
  24880. addTarget(target: MorphTarget): void;
  24881. /**
  24882. * Removes a target from the manager
  24883. * @param target defines the target to remove
  24884. */
  24885. removeTarget(target: MorphTarget): void;
  24886. /**
  24887. * Serializes the current manager into a Serialization object
  24888. * @returns the serialized object
  24889. */
  24890. serialize(): any;
  24891. private _syncActiveTargets(needUpdate);
  24892. /**
  24893. * Syncrhonize the targets with all the meshes using this morph target manager
  24894. */
  24895. synchronize(): void;
  24896. /**
  24897. * Creates a new MorphTargetManager from serialized data
  24898. * @param serializationObject defines the serialized data
  24899. * @param scene defines the hosting scene
  24900. * @returns the new MorphTargetManager
  24901. */
  24902. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24903. }
  24904. }
  24905. declare module BABYLON {
  24906. interface PhysicsImpostorJoint {
  24907. mainImpostor: PhysicsImpostor;
  24908. connectedImpostor: PhysicsImpostor;
  24909. joint: PhysicsJoint;
  24910. }
  24911. class PhysicsEngine {
  24912. private _physicsPlugin;
  24913. gravity: Vector3;
  24914. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24915. setGravity(gravity: Vector3): void;
  24916. /**
  24917. * Set the time step of the physics engine.
  24918. * default is 1/60.
  24919. * To slow it down, enter 1/600 for example.
  24920. * To speed it up, 1/30
  24921. * @param {number} newTimeStep the new timestep to apply to this world.
  24922. */
  24923. setTimeStep(newTimeStep?: number): void;
  24924. /**
  24925. * Get the time step of the physics engine.
  24926. */
  24927. getTimeStep(): number;
  24928. dispose(): void;
  24929. getPhysicsPluginName(): string;
  24930. static Epsilon: number;
  24931. private _impostors;
  24932. private _joints;
  24933. /**
  24934. * Adding a new impostor for the impostor tracking.
  24935. * This will be done by the impostor itself.
  24936. * @param {PhysicsImpostor} impostor the impostor to add
  24937. */
  24938. addImpostor(impostor: PhysicsImpostor): void;
  24939. /**
  24940. * Remove an impostor from the engine.
  24941. * This impostor and its mesh will not longer be updated by the physics engine.
  24942. * @param {PhysicsImpostor} impostor the impostor to remove
  24943. */
  24944. removeImpostor(impostor: PhysicsImpostor): void;
  24945. /**
  24946. * Add a joint to the physics engine
  24947. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24948. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24949. * @param {PhysicsJoint} the joint that will connect both impostors.
  24950. */
  24951. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24952. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24953. /**
  24954. * Called by the scene. no need to call it.
  24955. */
  24956. _step(delta: number): void;
  24957. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24958. getImpostors(): Array<PhysicsImpostor>;
  24959. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24960. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24961. }
  24962. interface IPhysicsEnginePlugin {
  24963. world: any;
  24964. name: string;
  24965. setGravity(gravity: Vector3): void;
  24966. setTimeStep(timeStep: number): void;
  24967. getTimeStep(): number;
  24968. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24969. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24970. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24971. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24972. removePhysicsBody(impostor: PhysicsImpostor): void;
  24973. generateJoint(joint: PhysicsImpostorJoint): void;
  24974. removeJoint(joint: PhysicsImpostorJoint): void;
  24975. isSupported(): boolean;
  24976. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24977. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24978. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24979. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24980. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24981. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24982. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24983. getBodyMass(impostor: PhysicsImpostor): number;
  24984. getBodyFriction(impostor: PhysicsImpostor): number;
  24985. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24986. getBodyRestitution(impostor: PhysicsImpostor): number;
  24987. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24988. sleepBody(impostor: PhysicsImpostor): void;
  24989. wakeUpBody(impostor: PhysicsImpostor): void;
  24990. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24991. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24992. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24993. getRadius(impostor: PhysicsImpostor): number;
  24994. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24995. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24996. dispose(): void;
  24997. }
  24998. }
  24999. declare module BABYLON {
  25000. class PhysicsHelper {
  25001. private _scene;
  25002. private _physicsEngine;
  25003. constructor(scene: Scene);
  25004. /**
  25005. * @param {Vector3} origin the origin of the explosion
  25006. * @param {number} radius the explosion radius
  25007. * @param {number} strength the explosion strength
  25008. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25009. */
  25010. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25011. /**
  25012. * @param {Vector3} origin the origin of the explosion
  25013. * @param {number} radius the explosion radius
  25014. * @param {number} strength the explosion strength
  25015. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25016. */
  25017. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25018. /**
  25019. * @param {Vector3} origin the origin of the explosion
  25020. * @param {number} radius the explosion radius
  25021. * @param {number} strength the explosion strength
  25022. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25023. */
  25024. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  25025. /**
  25026. * @param {Vector3} origin the origin of the updraft
  25027. * @param {number} radius the radius of the updraft
  25028. * @param {number} strength the strength of the updraft
  25029. * @param {number} height the height of the updraft
  25030. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  25031. */
  25032. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  25033. /**
  25034. * @param {Vector3} origin the of the vortex
  25035. * @param {number} radius the radius of the vortex
  25036. * @param {number} strength the strength of the vortex
  25037. * @param {number} height the height of the vortex
  25038. */
  25039. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  25040. }
  25041. /***** Radial explosion *****/
  25042. class PhysicsRadialExplosionEvent {
  25043. private _scene;
  25044. private _sphere;
  25045. private _sphereOptions;
  25046. private _rays;
  25047. private _dataFetched;
  25048. constructor(scene: Scene);
  25049. /**
  25050. * Returns the data related to the radial explosion event (sphere & rays).
  25051. * @returns {PhysicsRadialExplosionEventData}
  25052. */
  25053. getData(): PhysicsRadialExplosionEventData;
  25054. /**
  25055. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  25056. * @param impostor
  25057. * @param {Vector3} origin the origin of the explosion
  25058. * @param {number} radius the explosion radius
  25059. * @param {number} strength the explosion strength
  25060. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  25061. * @returns {Nullable<PhysicsForceAndContactPoint>}
  25062. */
  25063. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  25064. /**
  25065. * Disposes the sphere.
  25066. * @param {bolean} force
  25067. */
  25068. dispose(force?: boolean): void;
  25069. /*** Helpers ***/
  25070. private _prepareSphere();
  25071. private _intersectsWithSphere(impostor, origin, radius);
  25072. }
  25073. /***** Gravitational Field *****/
  25074. class PhysicsGravitationalFieldEvent {
  25075. private _physicsHelper;
  25076. private _scene;
  25077. private _origin;
  25078. private _radius;
  25079. private _strength;
  25080. private _falloff;
  25081. private _tickCallback;
  25082. private _sphere;
  25083. private _dataFetched;
  25084. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  25085. /**
  25086. * Returns the data related to the gravitational field event (sphere).
  25087. * @returns {PhysicsGravitationalFieldEventData}
  25088. */
  25089. getData(): PhysicsGravitationalFieldEventData;
  25090. /**
  25091. * Enables the gravitational field.
  25092. */
  25093. enable(): void;
  25094. /**
  25095. * Disables the gravitational field.
  25096. */
  25097. disable(): void;
  25098. /**
  25099. * Disposes the sphere.
  25100. * @param {bolean} force
  25101. */
  25102. dispose(force?: boolean): void;
  25103. private _tick();
  25104. }
  25105. /***** Updraft *****/
  25106. class PhysicsUpdraftEvent {
  25107. private _scene;
  25108. private _origin;
  25109. private _radius;
  25110. private _strength;
  25111. private _height;
  25112. private _updraftMode;
  25113. private _physicsEngine;
  25114. private _originTop;
  25115. private _originDirection;
  25116. private _tickCallback;
  25117. private _cylinder;
  25118. private _cylinderPosition;
  25119. private _dataFetched;
  25120. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  25121. /**
  25122. * Returns the data related to the updraft event (cylinder).
  25123. * @returns {PhysicsUpdraftEventData}
  25124. */
  25125. getData(): PhysicsUpdraftEventData;
  25126. /**
  25127. * Enables the updraft.
  25128. */
  25129. enable(): void;
  25130. /**
  25131. * Disables the cortex.
  25132. */
  25133. disable(): void;
  25134. /**
  25135. * Disposes the sphere.
  25136. * @param {bolean} force
  25137. */
  25138. dispose(force?: boolean): void;
  25139. private getImpostorForceAndContactPoint(impostor);
  25140. private _tick();
  25141. /*** Helpers ***/
  25142. private _prepareCylinder();
  25143. private _intersectsWithCylinder(impostor);
  25144. }
  25145. /***** Vortex *****/
  25146. class PhysicsVortexEvent {
  25147. private _scene;
  25148. private _origin;
  25149. private _radius;
  25150. private _strength;
  25151. private _height;
  25152. private _physicsEngine;
  25153. private _originTop;
  25154. private _centripetalForceThreshold;
  25155. private _updraftMultiplier;
  25156. private _tickCallback;
  25157. private _cylinder;
  25158. private _cylinderPosition;
  25159. private _dataFetched;
  25160. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  25161. /**
  25162. * Returns the data related to the vortex event (cylinder).
  25163. * @returns {PhysicsVortexEventData}
  25164. */
  25165. getData(): PhysicsVortexEventData;
  25166. /**
  25167. * Enables the vortex.
  25168. */
  25169. enable(): void;
  25170. /**
  25171. * Disables the cortex.
  25172. */
  25173. disable(): void;
  25174. /**
  25175. * Disposes the sphere.
  25176. * @param {bolean} force
  25177. */
  25178. dispose(force?: boolean): void;
  25179. private getImpostorForceAndContactPoint(impostor);
  25180. private _tick();
  25181. /*** Helpers ***/
  25182. private _prepareCylinder();
  25183. private _intersectsWithCylinder(impostor);
  25184. }
  25185. /***** Enums *****/
  25186. /**
  25187. * The strenght of the force in correspondence to the distance of the affected object
  25188. */
  25189. enum PhysicsRadialImpulseFalloff {
  25190. /** Defines that impulse is constant in strength across it's whole radius */
  25191. Constant = 0,
  25192. /** DEfines that impulse gets weaker if it's further from the origin */
  25193. Linear = 1,
  25194. }
  25195. /**
  25196. * The strenght of the force in correspondence to the distance of the affected object
  25197. */
  25198. enum PhysicsUpdraftMode {
  25199. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  25200. Center = 0,
  25201. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  25202. Perpendicular = 1,
  25203. }
  25204. /***** Data interfaces *****/
  25205. interface PhysicsForceAndContactPoint {
  25206. force: Vector3;
  25207. contactPoint: Vector3;
  25208. }
  25209. interface PhysicsRadialExplosionEventData {
  25210. sphere: Mesh;
  25211. rays: Array<Ray>;
  25212. }
  25213. interface PhysicsGravitationalFieldEventData {
  25214. sphere: Mesh;
  25215. }
  25216. interface PhysicsUpdraftEventData {
  25217. cylinder: Mesh;
  25218. }
  25219. interface PhysicsVortexEventData {
  25220. cylinder: Mesh;
  25221. }
  25222. }
  25223. declare module BABYLON {
  25224. interface PhysicsImpostorParameters {
  25225. mass: number;
  25226. friction?: number;
  25227. restitution?: number;
  25228. nativeOptions?: any;
  25229. ignoreParent?: boolean;
  25230. disableBidirectionalTransformation?: boolean;
  25231. }
  25232. interface IPhysicsEnabledObject {
  25233. position: Vector3;
  25234. rotationQuaternion: Nullable<Quaternion>;
  25235. scaling: Vector3;
  25236. rotation?: Vector3;
  25237. parent?: any;
  25238. getBoundingInfo(): BoundingInfo;
  25239. computeWorldMatrix(force: boolean): Matrix;
  25240. getWorldMatrix?(): Matrix;
  25241. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  25242. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  25243. getIndices?(): Nullable<IndicesArray>;
  25244. getScene?(): Scene;
  25245. getAbsolutePosition(): Vector3;
  25246. getAbsolutePivotPoint(): Vector3;
  25247. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  25248. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  25249. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25250. getClassName(): string;
  25251. }
  25252. class PhysicsImpostor {
  25253. object: IPhysicsEnabledObject;
  25254. type: number;
  25255. private _options;
  25256. private _scene;
  25257. static DEFAULT_OBJECT_SIZE: Vector3;
  25258. static IDENTITY_QUATERNION: Quaternion;
  25259. private _physicsEngine;
  25260. private _physicsBody;
  25261. private _bodyUpdateRequired;
  25262. private _onBeforePhysicsStepCallbacks;
  25263. private _onAfterPhysicsStepCallbacks;
  25264. private _onPhysicsCollideCallbacks;
  25265. private _deltaPosition;
  25266. private _deltaRotation;
  25267. private _deltaRotationConjugated;
  25268. private _parent;
  25269. private _isDisposed;
  25270. private static _tmpVecs;
  25271. private static _tmpQuat;
  25272. readonly isDisposed: boolean;
  25273. mass: number;
  25274. friction: number;
  25275. restitution: number;
  25276. uniqueId: number;
  25277. private _joints;
  25278. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25279. /**
  25280. * This function will completly initialize this impostor.
  25281. * It will create a new body - but only if this mesh has no parent.
  25282. * If it has, this impostor will not be used other than to define the impostor
  25283. * of the child mesh.
  25284. */
  25285. _init(): void;
  25286. private _getPhysicsParent();
  25287. /**
  25288. * Should a new body be generated.
  25289. */
  25290. isBodyInitRequired(): boolean;
  25291. setScalingUpdated(updated: boolean): void;
  25292. /**
  25293. * Force a regeneration of this or the parent's impostor's body.
  25294. * Use under cautious - This will remove all joints already implemented.
  25295. */
  25296. forceUpdate(): void;
  25297. /**
  25298. * Gets the body that holds this impostor. Either its own, or its parent.
  25299. */
  25300. /**
  25301. * Set the physics body. Used mainly by the physics engine/plugin
  25302. */
  25303. physicsBody: any;
  25304. parent: Nullable<PhysicsImpostor>;
  25305. resetUpdateFlags(): void;
  25306. getObjectExtendSize(): Vector3;
  25307. getObjectCenter(): Vector3;
  25308. /**
  25309. * Get a specific parametes from the options parameter.
  25310. */
  25311. getParam(paramName: string): any;
  25312. /**
  25313. * Sets a specific parameter in the options given to the physics plugin
  25314. */
  25315. setParam(paramName: string, value: number): void;
  25316. /**
  25317. * Specifically change the body's mass option. Won't recreate the physics body object
  25318. */
  25319. setMass(mass: number): void;
  25320. getLinearVelocity(): Nullable<Vector3>;
  25321. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25322. getAngularVelocity(): Nullable<Vector3>;
  25323. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25324. /**
  25325. * Execute a function with the physics plugin native code.
  25326. * Provide a function the will have two variables - the world object and the physics body object.
  25327. */
  25328. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25329. /**
  25330. * Register a function that will be executed before the physics world is stepping forward.
  25331. */
  25332. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25333. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25334. /**
  25335. * Register a function that will be executed after the physics step
  25336. */
  25337. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25338. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25339. /**
  25340. * register a function that will be executed when this impostor collides against a different body.
  25341. */
  25342. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25343. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25344. private _tmpQuat;
  25345. private _tmpQuat2;
  25346. getParentsRotation(): Quaternion;
  25347. /**
  25348. * this function is executed by the physics engine.
  25349. */
  25350. beforeStep: () => void;
  25351. /**
  25352. * this function is executed by the physics engine.
  25353. */
  25354. afterStep: () => void;
  25355. /**
  25356. * Legacy collision detection event support
  25357. */
  25358. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25359. onCollide: (e: {
  25360. body: any;
  25361. }) => void;
  25362. /**
  25363. * Apply a force
  25364. */
  25365. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25366. /**
  25367. * Apply an impulse
  25368. */
  25369. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25370. /**
  25371. * A help function to create a joint.
  25372. */
  25373. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25374. /**
  25375. * Add a joint to this impostor with a different impostor.
  25376. */
  25377. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25378. /**
  25379. * Will keep this body still, in a sleep mode.
  25380. */
  25381. sleep(): PhysicsImpostor;
  25382. /**
  25383. * Wake the body up.
  25384. */
  25385. wakeUp(): PhysicsImpostor;
  25386. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25387. dispose(): void;
  25388. setDeltaPosition(position: Vector3): void;
  25389. setDeltaRotation(rotation: Quaternion): void;
  25390. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25391. getRadius(): number;
  25392. /**
  25393. * Sync a bone with this impostor
  25394. * @param bone The bone to sync to the impostor.
  25395. * @param boneMesh The mesh that the bone is influencing.
  25396. * @param jointPivot The pivot of the joint / bone in local space.
  25397. * @param distToJoint Optional distance from the impostor to the joint.
  25398. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25399. */
  25400. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25401. /**
  25402. * Sync impostor to a bone
  25403. * @param bone The bone that the impostor will be synced to.
  25404. * @param boneMesh The mesh that the bone is influencing.
  25405. * @param jointPivot The pivot of the joint / bone in local space.
  25406. * @param distToJoint Optional distance from the impostor to the joint.
  25407. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25408. * @param boneAxis Optional vector3 axis the bone is aligned with
  25409. */
  25410. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25411. static NoImpostor: number;
  25412. static SphereImpostor: number;
  25413. static BoxImpostor: number;
  25414. static PlaneImpostor: number;
  25415. static MeshImpostor: number;
  25416. static CylinderImpostor: number;
  25417. static ParticleImpostor: number;
  25418. static HeightmapImpostor: number;
  25419. }
  25420. }
  25421. declare module BABYLON {
  25422. interface PhysicsJointData {
  25423. mainPivot?: Vector3;
  25424. connectedPivot?: Vector3;
  25425. mainAxis?: Vector3;
  25426. connectedAxis?: Vector3;
  25427. collision?: boolean;
  25428. nativeParams?: any;
  25429. }
  25430. /**
  25431. * This is a holder class for the physics joint created by the physics plugin.
  25432. * It holds a set of functions to control the underlying joint.
  25433. */
  25434. class PhysicsJoint {
  25435. type: number;
  25436. jointData: PhysicsJointData;
  25437. private _physicsJoint;
  25438. protected _physicsPlugin: IPhysicsEnginePlugin;
  25439. constructor(type: number, jointData: PhysicsJointData);
  25440. physicsJoint: any;
  25441. physicsPlugin: IPhysicsEnginePlugin;
  25442. /**
  25443. * Execute a function that is physics-plugin specific.
  25444. * @param {Function} func the function that will be executed.
  25445. * It accepts two parameters: the physics world and the physics joint.
  25446. */
  25447. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25448. static DistanceJoint: number;
  25449. static HingeJoint: number;
  25450. static BallAndSocketJoint: number;
  25451. static WheelJoint: number;
  25452. static SliderJoint: number;
  25453. static PrismaticJoint: number;
  25454. static UniversalJoint: number;
  25455. static Hinge2Joint: number;
  25456. static PointToPointJoint: number;
  25457. static SpringJoint: number;
  25458. static LockJoint: number;
  25459. }
  25460. /**
  25461. * A class representing a physics distance joint.
  25462. */
  25463. class DistanceJoint extends PhysicsJoint {
  25464. constructor(jointData: DistanceJointData);
  25465. /**
  25466. * Update the predefined distance.
  25467. */
  25468. updateDistance(maxDistance: number, minDistance?: number): void;
  25469. }
  25470. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  25471. constructor(type: number, jointData: PhysicsJointData);
  25472. /**
  25473. * Set the motor values.
  25474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25475. * @param {number} force the force to apply
  25476. * @param {number} maxForce max force for this motor.
  25477. */
  25478. setMotor(force?: number, maxForce?: number): void;
  25479. /**
  25480. * Set the motor's limits.
  25481. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25482. */
  25483. setLimit(upperLimit: number, lowerLimit?: number): void;
  25484. }
  25485. /**
  25486. * This class represents a single hinge physics joint
  25487. */
  25488. class HingeJoint extends MotorEnabledJoint {
  25489. constructor(jointData: PhysicsJointData);
  25490. /**
  25491. * Set the motor values.
  25492. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25493. * @param {number} force the force to apply
  25494. * @param {number} maxForce max force for this motor.
  25495. */
  25496. setMotor(force?: number, maxForce?: number): void;
  25497. /**
  25498. * Set the motor's limits.
  25499. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25500. */
  25501. setLimit(upperLimit: number, lowerLimit?: number): void;
  25502. }
  25503. /**
  25504. * This class represents a dual hinge physics joint (same as wheel joint)
  25505. */
  25506. class Hinge2Joint extends MotorEnabledJoint {
  25507. constructor(jointData: PhysicsJointData);
  25508. /**
  25509. * Set the motor values.
  25510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25511. * @param {number} force the force to apply
  25512. * @param {number} maxForce max force for this motor.
  25513. * @param {motorIndex} the motor's index, 0 or 1.
  25514. */
  25515. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25516. /**
  25517. * Set the motor limits.
  25518. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25519. * @param {number} upperLimit the upper limit
  25520. * @param {number} lowerLimit lower limit
  25521. * @param {motorIndex} the motor's index, 0 or 1.
  25522. */
  25523. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25524. }
  25525. interface IMotorEnabledJoint {
  25526. physicsJoint: any;
  25527. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25528. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25529. }
  25530. interface DistanceJointData extends PhysicsJointData {
  25531. maxDistance: number;
  25532. }
  25533. interface SpringJointData extends PhysicsJointData {
  25534. length: number;
  25535. stiffness: number;
  25536. damping: number;
  25537. }
  25538. }
  25539. declare module BABYLON {
  25540. class BoundingBoxRenderer {
  25541. frontColor: Color3;
  25542. backColor: Color3;
  25543. showBackLines: boolean;
  25544. renderList: SmartArray<BoundingBox>;
  25545. private _scene;
  25546. private _colorShader;
  25547. private _vertexBuffers;
  25548. private _indexBuffer;
  25549. constructor(scene: Scene);
  25550. private _prepareRessources();
  25551. private _createIndexBuffer();
  25552. _rebuild(): void;
  25553. reset(): void;
  25554. render(): void;
  25555. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  25556. dispose(): void;
  25557. }
  25558. }
  25559. declare module BABYLON {
  25560. /**
  25561. * This represents a depth renderer in Babylon.
  25562. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  25563. */
  25564. class DepthRenderer {
  25565. private _scene;
  25566. private _depthMap;
  25567. private _effect;
  25568. private _cachedDefines;
  25569. private _camera;
  25570. /**
  25571. * Instantiates a depth renderer
  25572. * @param scene The scene the renderer belongs to
  25573. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  25574. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  25575. */
  25576. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  25577. /**
  25578. * Creates the depth rendering effect and checks if the effect is ready.
  25579. * @param subMesh The submesh to be used to render the depth map of
  25580. * @param useInstances If multiple world instances should be used
  25581. * @returns if the depth renderer is ready to render the depth map
  25582. */
  25583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25584. /**
  25585. * Gets the texture which the depth map will be written to.
  25586. * @returns The depth map texture
  25587. */
  25588. getDepthMap(): RenderTargetTexture;
  25589. /**
  25590. * Disposes of the depth renderer.
  25591. */
  25592. dispose(): void;
  25593. }
  25594. }
  25595. declare module BABYLON {
  25596. class EdgesRenderer {
  25597. edgesWidthScalerForOrthographic: number;
  25598. edgesWidthScalerForPerspective: number;
  25599. private _source;
  25600. private _linesPositions;
  25601. private _linesNormals;
  25602. private _linesIndices;
  25603. private _epsilon;
  25604. private _indicesCount;
  25605. private _lineShader;
  25606. private _ib;
  25607. private _buffers;
  25608. private _checkVerticesInsteadOfIndices;
  25609. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  25610. isEnabled: boolean;
  25611. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  25612. private _prepareRessources();
  25613. _rebuild(): void;
  25614. dispose(): void;
  25615. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  25616. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  25617. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  25618. _generateEdgesLines(): void;
  25619. render(): void;
  25620. }
  25621. }
  25622. declare module BABYLON {
  25623. /**
  25624. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  25625. */
  25626. class GeometryBufferRenderer {
  25627. private _scene;
  25628. private _multiRenderTarget;
  25629. private _ratio;
  25630. private _enablePosition;
  25631. protected _effect: Effect;
  25632. protected _cachedDefines: string;
  25633. /**
  25634. * Set the render list (meshes to be rendered) used in the G buffer.
  25635. */
  25636. renderList: Mesh[];
  25637. /**
  25638. * Gets wether or not G buffer are supported by the running hardware.
  25639. * This requires draw buffer supports
  25640. */
  25641. readonly isSupported: boolean;
  25642. /**
  25643. * Gets wether or not position are enabled for the G buffer.
  25644. */
  25645. /**
  25646. * Sets wether or not position are enabled for the G buffer.
  25647. */
  25648. enablePosition: boolean;
  25649. /**
  25650. * Gets the scene associated with the buffer.
  25651. */
  25652. readonly scene: Scene;
  25653. /**
  25654. * Gets the ratio used by the buffer during its creation.
  25655. * How big is the buffer related to the main canvas.
  25656. */
  25657. readonly ratio: number;
  25658. /**
  25659. * Creates a new G Buffer for the scene
  25660. * @param scene The scene the buffer belongs to
  25661. * @param ratio How big is the buffer related to the main canvas.
  25662. */
  25663. constructor(scene: Scene, ratio?: number);
  25664. /**
  25665. * Checks wether everything is ready to render a submesh to the G buffer.
  25666. * @param subMesh the submesh to check readiness for
  25667. * @param useInstances is the mesh drawn using instance or not
  25668. * @returns true if ready otherwise false
  25669. */
  25670. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25671. /**
  25672. * Gets the current underlying G Buffer.
  25673. * @returns the buffer
  25674. */
  25675. getGBuffer(): MultiRenderTarget;
  25676. /**
  25677. * Gets the number of samples used to render the buffer (anti aliasing).
  25678. */
  25679. /**
  25680. * Sets the number of samples used to render the buffer (anti aliasing).
  25681. */
  25682. samples: number;
  25683. /**
  25684. * Disposes the renderer and frees up associated resources.
  25685. */
  25686. dispose(): void;
  25687. protected _createRenderTargets(): void;
  25688. }
  25689. }
  25690. declare module BABYLON {
  25691. class OutlineRenderer {
  25692. private _scene;
  25693. private _effect;
  25694. private _cachedDefines;
  25695. zOffset: number;
  25696. constructor(scene: Scene);
  25697. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  25698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25699. }
  25700. }
  25701. declare module BABYLON {
  25702. class RenderingGroup {
  25703. index: number;
  25704. private _scene;
  25705. private _opaqueSubMeshes;
  25706. private _transparentSubMeshes;
  25707. private _alphaTestSubMeshes;
  25708. private _depthOnlySubMeshes;
  25709. private _particleSystems;
  25710. private _spriteManagers;
  25711. private _opaqueSortCompareFn;
  25712. private _alphaTestSortCompareFn;
  25713. private _transparentSortCompareFn;
  25714. private _renderOpaque;
  25715. private _renderAlphaTest;
  25716. private _renderTransparent;
  25717. private _edgesRenderers;
  25718. onBeforeTransparentRendering: () => void;
  25719. /**
  25720. * Set the opaque sort comparison function.
  25721. * If null the sub meshes will be render in the order they were created
  25722. */
  25723. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25724. /**
  25725. * Set the alpha test sort comparison function.
  25726. * If null the sub meshes will be render in the order they were created
  25727. */
  25728. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25729. /**
  25730. * Set the transparent sort comparison function.
  25731. * If null the sub meshes will be render in the order they were created
  25732. */
  25733. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25734. /**
  25735. * Creates a new rendering group.
  25736. * @param index The rendering group index
  25737. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  25738. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  25739. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  25740. */
  25741. 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>);
  25742. /**
  25743. * Render all the sub meshes contained in the group.
  25744. * @param customRenderFunction Used to override the default render behaviour of the group.
  25745. * @returns true if rendered some submeshes.
  25746. */
  25747. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  25748. /**
  25749. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  25750. * @param subMeshes The submeshes to render
  25751. */
  25752. private renderOpaqueSorted(subMeshes);
  25753. /**
  25754. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25755. * @param subMeshes The submeshes to render
  25756. */
  25757. private renderAlphaTestSorted(subMeshes);
  25758. /**
  25759. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25760. * @param subMeshes The submeshes to render
  25761. */
  25762. private renderTransparentSorted(subMeshes);
  25763. /**
  25764. * Renders the submeshes in a specified order.
  25765. * @param subMeshes The submeshes to sort before render
  25766. * @param sortCompareFn The comparison function use to sort
  25767. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25768. * @param transparent Specifies to activate blending if true
  25769. */
  25770. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25771. /**
  25772. * Renders the submeshes in the order they were dispatched (no sort applied).
  25773. * @param subMeshes The submeshes to render
  25774. */
  25775. private static renderUnsorted(subMeshes);
  25776. /**
  25777. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25778. * are rendered back to front if in the same alpha index.
  25779. *
  25780. * @param a The first submesh
  25781. * @param b The second submesh
  25782. * @returns The result of the comparison
  25783. */
  25784. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25785. /**
  25786. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25787. * are rendered back to front.
  25788. *
  25789. * @param a The first submesh
  25790. * @param b The second submesh
  25791. * @returns The result of the comparison
  25792. */
  25793. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25794. /**
  25795. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25796. * are rendered front to back (prevent overdraw).
  25797. *
  25798. * @param a The first submesh
  25799. * @param b The second submesh
  25800. * @returns The result of the comparison
  25801. */
  25802. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25803. /**
  25804. * Resets the different lists of submeshes to prepare a new frame.
  25805. */
  25806. prepare(): void;
  25807. dispose(): void;
  25808. /**
  25809. * Inserts the submesh in its correct queue depending on its material.
  25810. * @param subMesh The submesh to dispatch
  25811. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25812. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25813. */
  25814. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25815. dispatchSprites(spriteManager: SpriteManager): void;
  25816. dispatchParticles(particleSystem: IParticleSystem): void;
  25817. private _renderParticles(activeMeshes);
  25818. private _renderSprites();
  25819. }
  25820. }
  25821. declare module BABYLON {
  25822. class RenderingManager {
  25823. /**
  25824. * The max id used for rendering groups (not included)
  25825. */
  25826. static MAX_RENDERINGGROUPS: number;
  25827. /**
  25828. * The min id used for rendering groups (included)
  25829. */
  25830. static MIN_RENDERINGGROUPS: number;
  25831. /**
  25832. * Used to globally prevent autoclearing scenes.
  25833. */
  25834. static AUTOCLEAR: boolean;
  25835. private _scene;
  25836. private _renderingGroups;
  25837. private _depthStencilBufferAlreadyCleaned;
  25838. private _autoClearDepthStencil;
  25839. private _customOpaqueSortCompareFn;
  25840. private _customAlphaTestSortCompareFn;
  25841. private _customTransparentSortCompareFn;
  25842. private _renderinGroupInfo;
  25843. constructor(scene: Scene);
  25844. private _clearDepthStencilBuffer(depth?, stencil?);
  25845. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25846. reset(): void;
  25847. dispose(): void;
  25848. /**
  25849. * Clear the info related to rendering groups preventing retention points during dispose.
  25850. */
  25851. freeRenderingGroups(): void;
  25852. private _prepareRenderingGroup(renderingGroupId);
  25853. dispatchSprites(spriteManager: SpriteManager): void;
  25854. dispatchParticles(particleSystem: IParticleSystem): void;
  25855. /**
  25856. * @param subMesh The submesh to dispatch
  25857. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25858. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25859. */
  25860. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25861. /**
  25862. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25863. * This allowed control for front to back rendering or reversly depending of the special needs.
  25864. *
  25865. * @param renderingGroupId The rendering group id corresponding to its index
  25866. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25867. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25868. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25869. */
  25870. 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;
  25871. /**
  25872. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25873. *
  25874. * @param renderingGroupId The rendering group id corresponding to its index
  25875. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25876. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25877. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25878. */
  25879. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25880. }
  25881. }
  25882. declare module BABYLON {
  25883. /**
  25884. * Renders a layer on top of an existing scene
  25885. */
  25886. class UtilityLayerRenderer implements IDisposable {
  25887. /** the original scene that will be rendered on top of */ originalScene: Scene;
  25888. private _pointerCaptures;
  25889. private _lastPointerEvents;
  25890. /**
  25891. * The scene that is rendered on top of the original scene
  25892. */
  25893. utilityLayerScene: Scene;
  25894. /**
  25895. * If the utility layer should automatically be rendered on top of existing scene
  25896. */
  25897. shouldRender: boolean;
  25898. /**
  25899. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  25900. */
  25901. onlyCheckPointerDownEvents: boolean;
  25902. /**
  25903. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  25904. */
  25905. processAllEvents: boolean;
  25906. /**
  25907. * Observable raised when the pointer move from the utility layer scene to the main scene
  25908. */
  25909. onPointerOutObservable: Observable<number>;
  25910. private _afterRenderObserver;
  25911. private _sceneDisposeObserver;
  25912. private _originalPointerObserver;
  25913. /**
  25914. * Instantiates a UtilityLayerRenderer
  25915. * @param originalScene the original scene that will be rendered on top of
  25916. */
  25917. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  25918. /**
  25919. * Renders the utility layers scene on top of the original scene
  25920. */
  25921. render(): void;
  25922. /**
  25923. * Disposes of the renderer
  25924. */
  25925. dispose(): void;
  25926. private _updateCamera();
  25927. }
  25928. }
  25929. declare module BABYLON {
  25930. class ReflectionProbe {
  25931. name: string;
  25932. private _scene;
  25933. private _renderTargetTexture;
  25934. private _projectionMatrix;
  25935. private _viewMatrix;
  25936. private _target;
  25937. private _add;
  25938. private _attachedMesh;
  25939. private _invertYAxis;
  25940. position: Vector3;
  25941. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  25942. samples: number;
  25943. refreshRate: number;
  25944. getScene(): Scene;
  25945. readonly cubeTexture: RenderTargetTexture;
  25946. readonly renderList: Nullable<AbstractMesh[]>;
  25947. attachToMesh(mesh: AbstractMesh): void;
  25948. /**
  25949. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25950. *
  25951. * @param renderingGroupId The rendering group id corresponding to its index
  25952. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25953. */
  25954. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25955. dispose(): void;
  25956. }
  25957. }
  25958. declare module BABYLON {
  25959. /**
  25960. * Postprocess used to generate anaglyphic rendering
  25961. */
  25962. class AnaglyphPostProcess extends PostProcess {
  25963. private _passedProcess;
  25964. /**
  25965. * Creates a new AnaglyphPostProcess
  25966. * @param name defines postprocess name
  25967. * @param options defines creation options or target ratio scale
  25968. * @param rigCameras defines cameras using this postprocess
  25969. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25970. * @param engine defines hosting engine
  25971. * @param reusable defines if the postprocess will be reused multiple times per frame
  25972. */
  25973. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25974. }
  25975. }
  25976. declare module BABYLON {
  25977. class BlackAndWhitePostProcess extends PostProcess {
  25978. degree: number;
  25979. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25980. }
  25981. }
  25982. declare module BABYLON {
  25983. /**
  25984. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25985. */
  25986. class BloomEffect extends PostProcessRenderEffect {
  25987. private bloomScale;
  25988. /**
  25989. * Internal
  25990. */
  25991. _effects: Array<PostProcess>;
  25992. /**
  25993. * Internal
  25994. */
  25995. _downscale: ExtractHighlightsPostProcess;
  25996. private _blurX;
  25997. private _blurY;
  25998. private _merge;
  25999. /**
  26000. * The luminance threshold to find bright areas of the image to bloom.
  26001. */
  26002. threshold: number;
  26003. /**
  26004. * The strength of the bloom.
  26005. */
  26006. weight: number;
  26007. /**
  26008. * Specifies the size of the bloom blur kernel, relative to the final output size
  26009. */
  26010. kernel: number;
  26011. /**
  26012. * Creates a new instance of @see BloomEffect
  26013. * @param scene The scene the effect belongs to.
  26014. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  26015. * @param bloomKernel The size of the kernel to be used when applying the blur.
  26016. * @param bloomWeight The the strength of bloom.
  26017. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26018. * @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)
  26019. */
  26020. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  26021. /**
  26022. * Disposes each of the internal effects for a given camera.
  26023. * @param camera The camera to dispose the effect on.
  26024. */
  26025. disposeEffects(camera: Camera): void;
  26026. /**
  26027. * Internal
  26028. */
  26029. _updateEffects(): void;
  26030. /**
  26031. * Internal
  26032. * @returns if all the contained post processes are ready.
  26033. */
  26034. _isReady(): boolean;
  26035. }
  26036. }
  26037. declare module BABYLON {
  26038. /**
  26039. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26040. */
  26041. class BloomMergePostProcess extends PostProcess {
  26042. /** Weight of the bloom to be added to the original input. */ weight: number;
  26043. /**
  26044. * Creates a new instance of @see BloomMergePostProcess
  26045. * @param name The name of the effect.
  26046. * @param originalFromInput Post process which's input will be used for the merge.
  26047. * @param blurred Blurred highlights post process which's output will be used.
  26048. * @param weight Weight of the bloom to be added to the original input.
  26049. * @param options The required width/height ratio to downsize to before computing the render pass.
  26050. * @param camera The camera to apply the render pass to.
  26051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26052. * @param engine The engine which the post process will be applied. (default: current engine)
  26053. * @param reusable If the post process can be reused on the same frame. (default: false)
  26054. * @param textureType Type of textures used when performing the post process. (default: 0)
  26055. * @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)
  26056. */
  26057. 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);
  26058. }
  26059. }
  26060. declare module BABYLON {
  26061. /**
  26062. * The Blur Post Process which blurs an image based on a kernel and direction.
  26063. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  26064. */
  26065. class BlurPostProcess extends PostProcess {
  26066. /** The direction in which to blur the image. */ direction: Vector2;
  26067. private blockCompilation;
  26068. protected _kernel: number;
  26069. protected _idealKernel: number;
  26070. protected _packedFloat: boolean;
  26071. private _staticDefines;
  26072. /**
  26073. * Gets the length in pixels of the blur sample region
  26074. */
  26075. /**
  26076. * Sets the length in pixels of the blur sample region
  26077. */
  26078. kernel: number;
  26079. /**
  26080. * Gets wether or not the blur is unpacking/repacking floats
  26081. */
  26082. /**
  26083. * Sets wether or not the blur needs to unpack/repack floats
  26084. */
  26085. packedFloat: boolean;
  26086. /**
  26087. * Creates a new instance BlurPostProcess
  26088. * @param name The name of the effect.
  26089. * @param direction The direction in which to blur the image.
  26090. * @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.
  26091. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26092. * @param camera The camera to apply the render pass to.
  26093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26094. * @param engine The engine which the post process will be applied. (default: current engine)
  26095. * @param reusable If the post process can be reused on the same frame. (default: false)
  26096. * @param textureType Type of textures used when performing the post process. (default: 0)
  26097. * @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)
  26098. */
  26099. 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);
  26100. /**
  26101. * Updates the effect with the current post process compile time values and recompiles the shader.
  26102. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26103. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26104. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26105. * @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
  26106. * @param onCompiled Called when the shader has been compiled.
  26107. * @param onError Called if there is an error when compiling a shader.
  26108. */
  26109. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26110. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26111. /**
  26112. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  26113. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  26114. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  26115. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  26116. * The gaps between physical kernels are compensated for in the weighting of the samples
  26117. * @param idealKernel Ideal blur kernel.
  26118. * @return Nearest best kernel.
  26119. */
  26120. protected _nearestBestKernel(idealKernel: number): number;
  26121. /**
  26122. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  26123. * @param x The point on the Gaussian distribution to sample.
  26124. * @return the value of the Gaussian function at x.
  26125. */
  26126. protected _gaussianWeight(x: number): number;
  26127. /**
  26128. * Generates a string that can be used as a floating point number in GLSL.
  26129. * @param x Value to print.
  26130. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  26131. * @return GLSL float string.
  26132. */
  26133. protected _glslFloat(x: number, decimalFigures?: number): string;
  26134. }
  26135. }
  26136. declare module BABYLON {
  26137. /**
  26138. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  26139. */
  26140. class ChromaticAberrationPostProcess extends PostProcess {
  26141. /**
  26142. * The amount of seperation of rgb channels (default: 30)
  26143. */
  26144. aberrationAmount: number;
  26145. /**
  26146. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  26147. */
  26148. radialIntensity: number;
  26149. /**
  26150. * 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))
  26151. */
  26152. direction: Vector2;
  26153. /**
  26154. * 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))
  26155. */
  26156. centerPosition: Vector2;
  26157. /**
  26158. * Creates a new instance ChromaticAberrationPostProcess
  26159. * @param name The name of the effect.
  26160. * @param screenWidth The width of the screen to apply the effect on.
  26161. * @param screenHeight The height of the screen to apply the effect on.
  26162. * @param options The required width/height ratio to downsize to before computing the render pass.
  26163. * @param camera The camera to apply the render pass to.
  26164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26165. * @param engine The engine which the post process will be applied. (default: current engine)
  26166. * @param reusable If the post process can be reused on the same frame. (default: false)
  26167. * @param textureType Type of textures used when performing the post process. (default: 0)
  26168. * @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)
  26169. */
  26170. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26171. }
  26172. }
  26173. declare module BABYLON {
  26174. /**
  26175. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  26176. */
  26177. class CircleOfConfusionPostProcess extends PostProcess {
  26178. /**
  26179. * 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.
  26180. */
  26181. lensSize: number;
  26182. /**
  26183. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26184. */
  26185. fStop: number;
  26186. /**
  26187. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26188. */
  26189. focusDistance: number;
  26190. /**
  26191. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  26192. */
  26193. focalLength: number;
  26194. private _depthTexture;
  26195. /**
  26196. * Creates a new instance CircleOfConfusionPostProcess
  26197. * @param name The name of the effect.
  26198. * @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.
  26199. * @param options The required width/height ratio to downsize to before computing the render pass.
  26200. * @param camera The camera to apply the render pass to.
  26201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26202. * @param engine The engine which the post process will be applied. (default: current engine)
  26203. * @param reusable If the post process can be reused on the same frame. (default: false)
  26204. * @param textureType Type of textures used when performing the post process. (default: 0)
  26205. * @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)
  26206. */
  26207. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26208. /**
  26209. * 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.
  26210. */
  26211. depthTexture: RenderTargetTexture;
  26212. }
  26213. }
  26214. declare module BABYLON {
  26215. class ColorCorrectionPostProcess extends PostProcess {
  26216. private _colorTableTexture;
  26217. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26218. }
  26219. }
  26220. declare module BABYLON {
  26221. /**
  26222. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  26223. * input texture to perform effects such as edge detection or sharpening
  26224. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26225. */
  26226. class ConvolutionPostProcess extends PostProcess {
  26227. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  26228. /**
  26229. * Creates a new instance ConvolutionPostProcess
  26230. * @param name The name of the effect.
  26231. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  26232. * @param options The required width/height ratio to downsize to before computing the render pass.
  26233. * @param camera The camera to apply the render pass to.
  26234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26235. * @param engine The engine which the post process will be applied. (default: current engine)
  26236. * @param reusable If the post process can be reused on the same frame. (default: false)
  26237. * @param textureType Type of textures used when performing the post process. (default: 0)
  26238. */
  26239. 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);
  26240. /**
  26241. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26242. */
  26243. static EdgeDetect0Kernel: number[];
  26244. /**
  26245. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26246. */
  26247. static EdgeDetect1Kernel: number[];
  26248. /**
  26249. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26250. */
  26251. static EdgeDetect2Kernel: number[];
  26252. /**
  26253. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26254. */
  26255. static SharpenKernel: number[];
  26256. /**
  26257. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26258. */
  26259. static EmbossKernel: number[];
  26260. /**
  26261. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26262. */
  26263. static GaussianKernel: number[];
  26264. }
  26265. }
  26266. declare module BABYLON {
  26267. /**
  26268. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  26269. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  26270. * based on samples that have a large difference in distance than the center pixel.
  26271. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  26272. */
  26273. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  26274. direction: Vector2;
  26275. /**
  26276. * Creates a new instance CircleOfConfusionPostProcess
  26277. * @param name The name of the effect.
  26278. * @param scene The scene the effect belongs to.
  26279. * @param direction The direction the blur should be applied.
  26280. * @param kernel The size of the kernel used to blur.
  26281. * @param options The required width/height ratio to downsize to before computing the render pass.
  26282. * @param camera The camera to apply the render pass to.
  26283. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  26284. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  26285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26286. * @param engine The engine which the post process will be applied. (default: current engine)
  26287. * @param reusable If the post process can be reused on the same frame. (default: false)
  26288. * @param textureType Type of textures used when performing the post process. (default: 0)
  26289. * @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)
  26290. */
  26291. 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);
  26292. }
  26293. }
  26294. declare module BABYLON {
  26295. /**
  26296. * Specifies the level of max blur that should be applied when using the depth of field effect
  26297. */
  26298. enum DepthOfFieldEffectBlurLevel {
  26299. /**
  26300. * Subtle blur
  26301. */
  26302. Low = 0,
  26303. /**
  26304. * Medium blur
  26305. */
  26306. Medium = 1,
  26307. /**
  26308. * Large blur
  26309. */
  26310. High = 2,
  26311. }
  26312. /**
  26313. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  26314. */
  26315. class DepthOfFieldEffect extends PostProcessRenderEffect {
  26316. private _circleOfConfusion;
  26317. /**
  26318. * Internal, blurs from high to low
  26319. */
  26320. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  26321. private _depthOfFieldBlurY;
  26322. private _dofMerge;
  26323. /**
  26324. * Internal post processes in depth of field effect
  26325. */
  26326. _effects: Array<PostProcess>;
  26327. /**
  26328. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  26329. */
  26330. focalLength: number;
  26331. /**
  26332. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26333. */
  26334. fStop: number;
  26335. /**
  26336. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26337. */
  26338. focusDistance: number;
  26339. /**
  26340. * 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.
  26341. */
  26342. lensSize: number;
  26343. /**
  26344. * Creates a new instance DepthOfFieldEffect
  26345. * @param scene The scene the effect belongs to.
  26346. * @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.
  26347. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26348. * @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)
  26349. */
  26350. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  26351. /**
  26352. * 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.
  26353. */
  26354. depthTexture: RenderTargetTexture;
  26355. /**
  26356. * Disposes each of the internal effects for a given camera.
  26357. * @param camera The camera to dispose the effect on.
  26358. */
  26359. disposeEffects(camera: Camera): void;
  26360. /**
  26361. * Internal
  26362. */
  26363. _updateEffects(): void;
  26364. /**
  26365. * Internal
  26366. * @returns if all the contained post processes are ready.
  26367. */
  26368. _isReady(): boolean;
  26369. }
  26370. }
  26371. declare module BABYLON {
  26372. /**
  26373. * Options to be set when merging outputs from the default pipeline.
  26374. */
  26375. class DepthOfFieldMergePostProcessOptions {
  26376. /**
  26377. * The original image to merge on top of
  26378. */
  26379. originalFromInput: PostProcess;
  26380. /**
  26381. * Parameters to perform the merge of the depth of field effect
  26382. */
  26383. depthOfField?: {
  26384. circleOfConfusion: PostProcess;
  26385. blurSteps: Array<PostProcess>;
  26386. };
  26387. /**
  26388. * Parameters to perform the merge of bloom effect
  26389. */
  26390. bloom?: {
  26391. blurred: PostProcess;
  26392. weight: number;
  26393. };
  26394. }
  26395. /**
  26396. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26397. */
  26398. class DepthOfFieldMergePostProcess extends PostProcess {
  26399. private blurSteps;
  26400. /**
  26401. * Creates a new instance of DepthOfFieldMergePostProcess
  26402. * @param name The name of the effect.
  26403. * @param originalFromInput Post process which's input will be used for the merge.
  26404. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  26405. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  26406. * @param options The required width/height ratio to downsize to before computing the render pass.
  26407. * @param camera The camera to apply the render pass to.
  26408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26409. * @param engine The engine which the post process will be applied. (default: current engine)
  26410. * @param reusable If the post process can be reused on the same frame. (default: false)
  26411. * @param textureType Type of textures used when performing the post process. (default: 0)
  26412. * @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)
  26413. */
  26414. 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);
  26415. /**
  26416. * Updates the effect with the current post process compile time values and recompiles the shader.
  26417. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26418. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26419. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26420. * @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
  26421. * @param onCompiled Called when the shader has been compiled.
  26422. * @param onError Called if there is an error when compiling a shader.
  26423. */
  26424. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26425. }
  26426. }
  26427. declare module BABYLON {
  26428. class DisplayPassPostProcess extends PostProcess {
  26429. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26430. }
  26431. }
  26432. declare module BABYLON {
  26433. /**
  26434. * 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.
  26435. */
  26436. class ExtractHighlightsPostProcess extends PostProcess {
  26437. /**
  26438. * The luminance threshold, pixels below this value will be set to black.
  26439. */
  26440. threshold: number;
  26441. /**
  26442. * Internal
  26443. */
  26444. _exposure: number;
  26445. /**
  26446. * Post process which has the input texture to be used when performing highlight extraction
  26447. */
  26448. _inputPostProcess: Nullable<PostProcess>;
  26449. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26450. }
  26451. }
  26452. declare module BABYLON {
  26453. class FilterPostProcess extends PostProcess {
  26454. kernelMatrix: Matrix;
  26455. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26456. }
  26457. }
  26458. declare module BABYLON {
  26459. class FxaaPostProcess extends PostProcess {
  26460. texelWidth: number;
  26461. texelHeight: number;
  26462. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26463. private _getDefines();
  26464. }
  26465. }
  26466. declare module BABYLON {
  26467. /**
  26468. * The GrainPostProcess adds noise to the image at mid luminance levels
  26469. */
  26470. class GrainPostProcess extends PostProcess {
  26471. /**
  26472. * The intensity of the grain added (default: 30)
  26473. */
  26474. intensity: number;
  26475. /**
  26476. * If the grain should be randomized on every frame
  26477. */
  26478. animated: boolean;
  26479. /**
  26480. * Creates a new instance of @see GrainPostProcess
  26481. * @param name The name of the effect.
  26482. * @param options The required width/height ratio to downsize to before computing the render pass.
  26483. * @param camera The camera to apply the render pass to.
  26484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26485. * @param engine The engine which the post process will be applied. (default: current engine)
  26486. * @param reusable If the post process can be reused on the same frame. (default: false)
  26487. * @param textureType Type of textures used when performing the post process. (default: 0)
  26488. * @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)
  26489. */
  26490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26491. }
  26492. }
  26493. declare module BABYLON {
  26494. class HighlightsPostProcess extends PostProcess {
  26495. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26496. }
  26497. }
  26498. declare module BABYLON {
  26499. class ImageProcessingPostProcess extends PostProcess {
  26500. /**
  26501. * Default configuration related to image processing available in the PBR Material.
  26502. */
  26503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26504. /**
  26505. * Gets the image processing configuration used either in this material.
  26506. */
  26507. /**
  26508. * Sets the Default image processing configuration used either in the this material.
  26509. *
  26510. * If sets to null, the scene one is in use.
  26511. */
  26512. imageProcessingConfiguration: ImageProcessingConfiguration;
  26513. /**
  26514. * Keep track of the image processing observer to allow dispose and replace.
  26515. */
  26516. private _imageProcessingObserver;
  26517. /**
  26518. * Attaches a new image processing configuration to the PBR Material.
  26519. * @param configuration
  26520. */
  26521. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  26522. /**
  26523. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26524. */
  26525. /**
  26526. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26527. */
  26528. colorCurves: Nullable<ColorCurves>;
  26529. /**
  26530. * Gets wether the color curves effect is enabled.
  26531. */
  26532. /**
  26533. * Sets wether the color curves effect is enabled.
  26534. */
  26535. colorCurvesEnabled: boolean;
  26536. /**
  26537. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26538. */
  26539. /**
  26540. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26541. */
  26542. colorGradingTexture: Nullable<BaseTexture>;
  26543. /**
  26544. * Gets wether the color grading effect is enabled.
  26545. */
  26546. /**
  26547. * Gets wether the color grading effect is enabled.
  26548. */
  26549. colorGradingEnabled: boolean;
  26550. /**
  26551. * Gets exposure used in the effect.
  26552. */
  26553. /**
  26554. * Sets exposure used in the effect.
  26555. */
  26556. exposure: number;
  26557. /**
  26558. * Gets wether tonemapping is enabled or not.
  26559. */
  26560. /**
  26561. * Sets wether tonemapping is enabled or not
  26562. */
  26563. toneMappingEnabled: boolean;
  26564. /**
  26565. * Gets contrast used in the effect.
  26566. */
  26567. /**
  26568. * Sets contrast used in the effect.
  26569. */
  26570. contrast: number;
  26571. /**
  26572. * Gets Vignette stretch size.
  26573. */
  26574. /**
  26575. * Sets Vignette stretch size.
  26576. */
  26577. vignetteStretch: number;
  26578. /**
  26579. * Gets Vignette centre X Offset.
  26580. */
  26581. /**
  26582. * Sets Vignette centre X Offset.
  26583. */
  26584. vignetteCentreX: number;
  26585. /**
  26586. * Gets Vignette centre Y Offset.
  26587. */
  26588. /**
  26589. * Sets Vignette centre Y Offset.
  26590. */
  26591. vignetteCentreY: number;
  26592. /**
  26593. * Gets Vignette weight or intensity of the vignette effect.
  26594. */
  26595. /**
  26596. * Sets Vignette weight or intensity of the vignette effect.
  26597. */
  26598. vignetteWeight: number;
  26599. /**
  26600. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26601. * if vignetteEnabled is set to true.
  26602. */
  26603. /**
  26604. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26605. * if vignetteEnabled is set to true.
  26606. */
  26607. vignetteColor: Color4;
  26608. /**
  26609. * Gets Camera field of view used by the Vignette effect.
  26610. */
  26611. /**
  26612. * Sets Camera field of view used by the Vignette effect.
  26613. */
  26614. vignetteCameraFov: number;
  26615. /**
  26616. * Gets the vignette blend mode allowing different kind of effect.
  26617. */
  26618. /**
  26619. * Sets the vignette blend mode allowing different kind of effect.
  26620. */
  26621. vignetteBlendMode: number;
  26622. /**
  26623. * Gets wether the vignette effect is enabled.
  26624. */
  26625. /**
  26626. * Sets wether the vignette effect is enabled.
  26627. */
  26628. vignetteEnabled: boolean;
  26629. private _fromLinearSpace;
  26630. /**
  26631. * Gets wether the input of the processing is in Gamma or Linear Space.
  26632. */
  26633. /**
  26634. * Sets wether the input of the processing is in Gamma or Linear Space.
  26635. */
  26636. fromLinearSpace: boolean;
  26637. /**
  26638. * Defines cache preventing GC.
  26639. */
  26640. private _defines;
  26641. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  26642. getClassName(): string;
  26643. protected _updateParameters(): void;
  26644. dispose(camera?: Camera): void;
  26645. }
  26646. }
  26647. declare module BABYLON {
  26648. class PassPostProcess extends PostProcess {
  26649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26650. }
  26651. }
  26652. declare module BABYLON {
  26653. type PostProcessOptions = {
  26654. width: number;
  26655. height: number;
  26656. };
  26657. /**
  26658. * PostProcess can be used to apply a shader to a texture after it has been rendered
  26659. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26660. */
  26661. class PostProcess {
  26662. /** Name of the PostProcess. */ name: string;
  26663. /**
  26664. * Width of the texture to apply the post process on
  26665. */
  26666. width: number;
  26667. /**
  26668. * Height of the texture to apply the post process on
  26669. */
  26670. height: number;
  26671. /**
  26672. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  26673. */
  26674. _outputTexture: Nullable<InternalTexture>;
  26675. /**
  26676. * Sampling mode used by the shader
  26677. * See https://doc.babylonjs.com/classes/3.1/texture
  26678. */
  26679. renderTargetSamplingMode: number;
  26680. /**
  26681. * Clear color to use when screen clearing
  26682. */
  26683. clearColor: Color4;
  26684. /**
  26685. * If the buffer needs to be cleared before applying the post process. (default: true)
  26686. * Should be set to false if shader will overwrite all previous pixels.
  26687. */
  26688. autoClear: boolean;
  26689. /**
  26690. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  26691. */
  26692. alphaMode: number;
  26693. /**
  26694. * Sets the setAlphaBlendConstants of the babylon engine
  26695. */
  26696. alphaConstants: Color4;
  26697. /**
  26698. * Animations to be used for the post processing
  26699. */
  26700. animations: Animation[];
  26701. /**
  26702. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26703. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26704. */
  26705. enablePixelPerfectMode: boolean;
  26706. /**
  26707. * Force the postprocess to be applied without taking in account viewport
  26708. */
  26709. forceFullscreenViewport: boolean;
  26710. /**
  26711. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26712. *
  26713. * | Value | Type | Description |
  26714. * | ----- | ----------------------------------- | ----------- |
  26715. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  26716. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  26717. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  26718. *
  26719. */
  26720. scaleMode: number;
  26721. /**
  26722. * Force textures to be a power of two (default: false)
  26723. */
  26724. alwaysForcePOT: boolean;
  26725. /**
  26726. * Number of sample textures (default: 1)
  26727. */
  26728. samples: number;
  26729. /**
  26730. * Modify the scale of the post process to be the same as the viewport (default: false)
  26731. */
  26732. adaptScaleToCurrentViewport: boolean;
  26733. private _camera;
  26734. private _scene;
  26735. private _engine;
  26736. private _options;
  26737. private _reusable;
  26738. private _textureType;
  26739. /**
  26740. * Smart array of input and output textures for the post process.
  26741. */
  26742. _textures: SmartArray<InternalTexture>;
  26743. /**
  26744. * The index in _textures that corresponds to the output texture.
  26745. */
  26746. _currentRenderTextureInd: number;
  26747. private _effect;
  26748. private _samplers;
  26749. private _fragmentUrl;
  26750. private _vertexUrl;
  26751. private _parameters;
  26752. private _scaleRatio;
  26753. protected _indexParameters: any;
  26754. private _shareOutputWithPostProcess;
  26755. private _texelSize;
  26756. private _forcedOutputTexture;
  26757. /**
  26758. * An event triggered when the postprocess is activated.
  26759. */
  26760. onActivateObservable: Observable<Camera>;
  26761. private _onActivateObserver;
  26762. /**
  26763. * A function that is added to the onActivateObservable
  26764. */
  26765. onActivate: Nullable<(camera: Camera) => void>;
  26766. /**
  26767. * An event triggered when the postprocess changes its size.
  26768. */
  26769. onSizeChangedObservable: Observable<PostProcess>;
  26770. private _onSizeChangedObserver;
  26771. /**
  26772. * A function that is added to the onSizeChangedObservable
  26773. */
  26774. onSizeChanged: (postProcess: PostProcess) => void;
  26775. /**
  26776. * An event triggered when the postprocess applies its effect.
  26777. */
  26778. onApplyObservable: Observable<Effect>;
  26779. private _onApplyObserver;
  26780. /**
  26781. * A function that is added to the onApplyObservable
  26782. */
  26783. onApply: (effect: Effect) => void;
  26784. /**
  26785. * An event triggered before rendering the postprocess
  26786. */
  26787. onBeforeRenderObservable: Observable<Effect>;
  26788. private _onBeforeRenderObserver;
  26789. /**
  26790. * A function that is added to the onBeforeRenderObservable
  26791. */
  26792. onBeforeRender: (effect: Effect) => void;
  26793. /**
  26794. * An event triggered after rendering the postprocess
  26795. */
  26796. onAfterRenderObservable: Observable<Effect>;
  26797. private _onAfterRenderObserver;
  26798. /**
  26799. * A function that is added to the onAfterRenderObservable
  26800. */
  26801. onAfterRender: (efect: Effect) => void;
  26802. /**
  26803. * 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
  26804. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26805. */
  26806. inputTexture: InternalTexture;
  26807. /**
  26808. * Gets the camera which post process is applied to.
  26809. * @returns The camera the post process is applied to.
  26810. */
  26811. getCamera(): Camera;
  26812. /**
  26813. * Gets the texel size of the postprocess.
  26814. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26815. */
  26816. readonly texelSize: Vector2;
  26817. /**
  26818. * Creates a new instance PostProcess
  26819. * @param name The name of the PostProcess.
  26820. * @param fragmentUrl The url of the fragment shader to be used.
  26821. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26822. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26823. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26824. * @param camera The camera to apply the render pass to.
  26825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26826. * @param engine The engine which the post process will be applied. (default: current engine)
  26827. * @param reusable If the post process can be reused on the same frame. (default: false)
  26828. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26829. * @param textureType Type of textures used when performing the post process. (default: 0)
  26830. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26831. * @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
  26832. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26833. */
  26834. 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);
  26835. /**
  26836. * Gets the engine which this post process belongs to.
  26837. * @returns The engine the post process was enabled with.
  26838. */
  26839. getEngine(): Engine;
  26840. /**
  26841. * The effect that is created when initializing the post process.
  26842. * @returns The created effect corrisponding the the postprocess.
  26843. */
  26844. getEffect(): Effect;
  26845. /**
  26846. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26847. * @param postProcess The post process to share the output with.
  26848. * @returns This post process.
  26849. */
  26850. shareOutputWith(postProcess: PostProcess): PostProcess;
  26851. /**
  26852. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26853. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26854. */
  26855. useOwnOutput(): void;
  26856. /**
  26857. * Updates the effect with the current post process compile time values and recompiles the shader.
  26858. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26859. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26860. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26861. * @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
  26862. * @param onCompiled Called when the shader has been compiled.
  26863. * @param onError Called if there is an error when compiling a shader.
  26864. */
  26865. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26866. /**
  26867. * The post process is reusable if it can be used multiple times within one frame.
  26868. * @returns If the post process is reusable
  26869. */
  26870. isReusable(): boolean;
  26871. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26872. markTextureDirty(): void;
  26873. /**
  26874. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26875. * 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.
  26876. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26877. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26878. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26879. * @returns The target texture that was bound to be written to.
  26880. */
  26881. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26882. /**
  26883. * If the post process is supported.
  26884. */
  26885. readonly isSupported: boolean;
  26886. /**
  26887. * The aspect ratio of the output texture.
  26888. */
  26889. readonly aspectRatio: number;
  26890. /**
  26891. * Get a value indicating if the post-process is ready to be used
  26892. * @returns true if the post-process is ready (shader is compiled)
  26893. */
  26894. isReady(): boolean;
  26895. /**
  26896. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26897. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26898. */
  26899. apply(): Nullable<Effect>;
  26900. private _disposeTextures();
  26901. /**
  26902. * Disposes the post process.
  26903. * @param camera The camera to dispose the post process on.
  26904. */
  26905. dispose(camera?: Camera): void;
  26906. }
  26907. }
  26908. declare module BABYLON {
  26909. /**
  26910. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26911. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26912. */
  26913. class PostProcessManager {
  26914. private _scene;
  26915. private _indexBuffer;
  26916. private _vertexBuffers;
  26917. /**
  26918. * Creates a new instance PostProcess
  26919. * @param scene The scene that the post process is associated with.
  26920. */
  26921. constructor(scene: Scene);
  26922. private _prepareBuffers();
  26923. private _buildIndexBuffer();
  26924. /**
  26925. * Rebuilds the vertex buffers of the manager.
  26926. */
  26927. _rebuild(): void;
  26928. /**
  26929. * Prepares a frame to be run through a post process.
  26930. * @param sourceTexture The input texture to the post procesess. (default: null)
  26931. * @param postProcesses An array of post processes to be run. (default: null)
  26932. * @returns True if the post processes were able to be run.
  26933. */
  26934. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26935. /**
  26936. * Manually render a set of post processes to a texture.
  26937. * @param postProcesses An array of post processes to be run.
  26938. * @param targetTexture The target texture to render to.
  26939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26940. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  26941. * @param lodLevel defines which lod of the texture to render to
  26942. */
  26943. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  26944. /**
  26945. * Finalize the result of the output of the postprocesses.
  26946. * @param doNotPresent If true the result will not be displayed to the screen.
  26947. * @param targetTexture The target texture to render to.
  26948. * @param faceIndex The index of the face to bind the target texture to.
  26949. * @param postProcesses The array of post processes to render.
  26950. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26951. */
  26952. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26953. /**
  26954. * Disposes of the post process manager.
  26955. */
  26956. dispose(): void;
  26957. }
  26958. }
  26959. declare module BABYLON {
  26960. class RefractionPostProcess extends PostProcess {
  26961. color: Color3;
  26962. depth: number;
  26963. colorLevel: number;
  26964. private _refTexture;
  26965. private _ownRefractionTexture;
  26966. /**
  26967. * Gets or sets the refraction texture
  26968. * Please note that you are responsible for disposing the texture if you set it manually
  26969. */
  26970. refractionTexture: Texture;
  26971. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26972. dispose(camera: Camera): void;
  26973. }
  26974. }
  26975. declare module BABYLON {
  26976. /**
  26977. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26978. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26979. */
  26980. class SharpenPostProcess extends PostProcess {
  26981. /**
  26982. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26983. */
  26984. colorAmount: number;
  26985. /**
  26986. * How much sharpness should be applied (default: 0.3)
  26987. */
  26988. edgeAmount: number;
  26989. /**
  26990. * Creates a new instance ConvolutionPostProcess
  26991. * @param name The name of the effect.
  26992. * @param options The required width/height ratio to downsize to before computing the render pass.
  26993. * @param camera The camera to apply the render pass to.
  26994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26995. * @param engine The engine which the post process will be applied. (default: current engine)
  26996. * @param reusable If the post process can be reused on the same frame. (default: false)
  26997. * @param textureType Type of textures used when performing the post process. (default: 0)
  26998. * @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)
  26999. */
  27000. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27001. }
  27002. }
  27003. declare module BABYLON {
  27004. class StereoscopicInterlacePostProcess extends PostProcess {
  27005. private _stepSize;
  27006. private _passedProcess;
  27007. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27008. }
  27009. }
  27010. declare module BABYLON {
  27011. /** Defines operator used for tonemapping */
  27012. enum TonemappingOperator {
  27013. /** Hable */
  27014. Hable = 0,
  27015. /** Reinhard */
  27016. Reinhard = 1,
  27017. /** HejiDawson */
  27018. HejiDawson = 2,
  27019. /** Photographic */
  27020. Photographic = 3,
  27021. }
  27022. /**
  27023. * Defines a post process to apply tone mapping
  27024. */
  27025. class TonemapPostProcess extends PostProcess {
  27026. private _operator;
  27027. /** Defines the required exposure adjustement */
  27028. exposureAdjustment: number;
  27029. /**
  27030. * Creates a new TonemapPostProcess
  27031. * @param name defines the name of the postprocess
  27032. * @param _operator defines the operator to use
  27033. * @param exposureAdjustment defines the required exposure adjustement
  27034. * @param camera defines the camera to use (can be null)
  27035. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  27036. * @param engine defines the hosting engine (can be ignore if camera is set)
  27037. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27038. */
  27039. constructor(name: string, _operator: TonemappingOperator,
  27040. /** Defines the required exposure adjustement */
  27041. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  27042. }
  27043. }
  27044. declare module BABYLON {
  27045. class VolumetricLightScatteringPostProcess extends PostProcess {
  27046. private _volumetricLightScatteringPass;
  27047. private _volumetricLightScatteringRTT;
  27048. private _viewPort;
  27049. private _screenCoordinates;
  27050. private _cachedDefines;
  27051. /**
  27052. * If not undefined, the mesh position is computed from the attached node position
  27053. */
  27054. attachedNode: {
  27055. position: Vector3;
  27056. };
  27057. /**
  27058. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  27059. */
  27060. customMeshPosition: Vector3;
  27061. /**
  27062. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  27063. */
  27064. useCustomMeshPosition: boolean;
  27065. /**
  27066. * If the post-process should inverse the light scattering direction
  27067. */
  27068. invert: boolean;
  27069. /**
  27070. * The internal mesh used by the post-process
  27071. */
  27072. mesh: Mesh;
  27073. useDiffuseColor: boolean;
  27074. /**
  27075. * Array containing the excluded meshes not rendered in the internal pass
  27076. */
  27077. excludedMeshes: AbstractMesh[];
  27078. /**
  27079. * Controls the overall intensity of the post-process
  27080. */
  27081. exposure: number;
  27082. /**
  27083. * Dissipates each sample's contribution in range [0, 1]
  27084. */
  27085. decay: number;
  27086. /**
  27087. * Controls the overall intensity of each sample
  27088. */
  27089. weight: number;
  27090. /**
  27091. * Controls the density of each sample
  27092. */
  27093. density: number;
  27094. /**
  27095. * @constructor
  27096. * @param {string} name - The post-process name
  27097. * @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)
  27098. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  27099. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  27100. * @param {number} samples - The post-process quality, default 100
  27101. * @param {number} samplingMode - The post-process filtering mode
  27102. * @param {BABYLON.Engine} engine - The babylon engine
  27103. * @param {boolean} reusable - If the post-process is reusable
  27104. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  27105. */
  27106. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  27107. getClassName(): string;
  27108. private _isReady(subMesh, useInstances);
  27109. /**
  27110. * Sets the new light position for light scattering effect
  27111. * @param {BABYLON.Vector3} The new custom light position
  27112. */
  27113. setCustomMeshPosition(position: Vector3): void;
  27114. /**
  27115. * Returns the light position for light scattering effect
  27116. * @return {BABYLON.Vector3} The custom light position
  27117. */
  27118. getCustomMeshPosition(): Vector3;
  27119. /**
  27120. * Disposes the internal assets and detaches the post-process from the camera
  27121. */
  27122. dispose(camera: Camera): void;
  27123. /**
  27124. * Returns the render target texture used by the post-process
  27125. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  27126. */
  27127. getPass(): RenderTargetTexture;
  27128. private _meshExcluded(mesh);
  27129. private _createPass(scene, ratio);
  27130. private _updateMeshScreenCoordinates(scene);
  27131. /**
  27132. * Creates a default mesh for the Volumeric Light Scattering post-process
  27133. * @param {string} The mesh name
  27134. * @param {BABYLON.Scene} The scene where to create the mesh
  27135. * @return {BABYLON.Mesh} the default mesh
  27136. */
  27137. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  27138. }
  27139. }
  27140. declare module BABYLON {
  27141. class VRDistortionCorrectionPostProcess extends PostProcess {
  27142. private _isRightEye;
  27143. private _distortionFactors;
  27144. private _postProcessScaleFactor;
  27145. private _lensCenterOffset;
  27146. private _scaleIn;
  27147. private _scaleFactor;
  27148. private _lensCenter;
  27149. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  27150. }
  27151. }
  27152. declare module BABYLON {
  27153. /**
  27154. * @hidden
  27155. **/
  27156. class _AlphaState {
  27157. private _isAlphaBlendDirty;
  27158. private _isBlendFunctionParametersDirty;
  27159. private _isBlendEquationParametersDirty;
  27160. private _isBlendConstantsDirty;
  27161. private _alphaBlend;
  27162. private _blendFunctionParameters;
  27163. private _blendEquationParameters;
  27164. private _blendConstants;
  27165. /**
  27166. * Initializes the state.
  27167. */
  27168. constructor();
  27169. readonly isDirty: boolean;
  27170. alphaBlend: boolean;
  27171. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  27172. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  27173. setAlphaEquationParameters(rgb: number, alpha: number): void;
  27174. reset(): void;
  27175. apply(gl: WebGLRenderingContext): void;
  27176. }
  27177. }
  27178. declare module BABYLON {
  27179. /**
  27180. * @hidden
  27181. **/
  27182. class _DepthCullingState {
  27183. private _isDepthTestDirty;
  27184. private _isDepthMaskDirty;
  27185. private _isDepthFuncDirty;
  27186. private _isCullFaceDirty;
  27187. private _isCullDirty;
  27188. private _isZOffsetDirty;
  27189. private _isFrontFaceDirty;
  27190. private _depthTest;
  27191. private _depthMask;
  27192. private _depthFunc;
  27193. private _cull;
  27194. private _cullFace;
  27195. private _zOffset;
  27196. private _frontFace;
  27197. /**
  27198. * Initializes the state.
  27199. */
  27200. constructor();
  27201. readonly isDirty: boolean;
  27202. zOffset: number;
  27203. cullFace: Nullable<number>;
  27204. cull: Nullable<boolean>;
  27205. depthFunc: Nullable<number>;
  27206. depthMask: boolean;
  27207. depthTest: boolean;
  27208. frontFace: Nullable<number>;
  27209. reset(): void;
  27210. apply(gl: WebGLRenderingContext): void;
  27211. }
  27212. }
  27213. declare module BABYLON {
  27214. /**
  27215. * @hidden
  27216. **/
  27217. class _StencilState {
  27218. private _isStencilTestDirty;
  27219. private _isStencilMaskDirty;
  27220. private _isStencilFuncDirty;
  27221. private _isStencilOpDirty;
  27222. private _stencilTest;
  27223. private _stencilMask;
  27224. private _stencilFunc;
  27225. private _stencilFuncRef;
  27226. private _stencilFuncMask;
  27227. private _stencilOpStencilFail;
  27228. private _stencilOpDepthFail;
  27229. private _stencilOpStencilDepthPass;
  27230. readonly isDirty: boolean;
  27231. stencilFunc: number;
  27232. stencilFuncRef: number;
  27233. stencilFuncMask: number;
  27234. stencilOpStencilFail: number;
  27235. stencilOpDepthFail: number;
  27236. stencilOpStencilDepthPass: number;
  27237. stencilMask: number;
  27238. stencilTest: boolean;
  27239. constructor();
  27240. reset(): void;
  27241. apply(gl: WebGLRenderingContext): void;
  27242. }
  27243. }
  27244. declare module BABYLON {
  27245. class Sprite {
  27246. name: string;
  27247. position: Vector3;
  27248. color: Color4;
  27249. width: number;
  27250. height: number;
  27251. angle: number;
  27252. cellIndex: number;
  27253. invertU: number;
  27254. invertV: number;
  27255. disposeWhenFinishedAnimating: boolean;
  27256. animations: Animation[];
  27257. isPickable: boolean;
  27258. actionManager: ActionManager;
  27259. private _animationStarted;
  27260. private _loopAnimation;
  27261. private _fromIndex;
  27262. private _toIndex;
  27263. private _delay;
  27264. private _direction;
  27265. private _manager;
  27266. private _time;
  27267. private _onAnimationEnd;
  27268. /**
  27269. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  27270. */
  27271. isVisible: boolean;
  27272. size: number;
  27273. constructor(name: string, manager: SpriteManager);
  27274. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  27275. stopAnimation(): void;
  27276. _animate(deltaTime: number): void;
  27277. dispose(): void;
  27278. }
  27279. }
  27280. declare module BABYLON {
  27281. class SpriteManager {
  27282. name: string;
  27283. sprites: Sprite[];
  27284. renderingGroupId: number;
  27285. layerMask: number;
  27286. fogEnabled: boolean;
  27287. isPickable: boolean;
  27288. cellWidth: number;
  27289. cellHeight: number;
  27290. /**
  27291. * An event triggered when the manager is disposed.
  27292. */
  27293. onDisposeObservable: Observable<SpriteManager>;
  27294. private _onDisposeObserver;
  27295. onDispose: () => void;
  27296. private _capacity;
  27297. private _spriteTexture;
  27298. private _epsilon;
  27299. private _scene;
  27300. private _vertexData;
  27301. private _buffer;
  27302. private _vertexBuffers;
  27303. private _indexBuffer;
  27304. private _effectBase;
  27305. private _effectFog;
  27306. texture: Texture;
  27307. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  27308. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  27309. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  27310. render(): void;
  27311. dispose(): void;
  27312. }
  27313. }
  27314. declare module BABYLON {
  27315. /**
  27316. * Class used to evalaute queries containing `and` and `or` operators
  27317. */
  27318. class AndOrNotEvaluator {
  27319. /**
  27320. * Evaluate a query
  27321. * @param query defines the query to evaluate
  27322. * @param evaluateCallback defines the callback used to filter result
  27323. * @returns true if the query matches
  27324. */
  27325. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  27326. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  27327. private static _SimplifyNegation(booleanString);
  27328. }
  27329. }
  27330. declare module BABYLON {
  27331. /**
  27332. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  27333. */
  27334. enum AssetTaskState {
  27335. /**
  27336. * Initialization
  27337. */
  27338. INIT = 0,
  27339. /**
  27340. * Running
  27341. */
  27342. RUNNING = 1,
  27343. /**
  27344. * Done
  27345. */
  27346. DONE = 2,
  27347. /**
  27348. * Error
  27349. */
  27350. ERROR = 3,
  27351. }
  27352. /**
  27353. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  27354. */
  27355. abstract class AbstractAssetTask {
  27356. /**
  27357. * Task name
  27358. */ name: string;
  27359. /**
  27360. * Callback called when the task is successful
  27361. */
  27362. onSuccess: (task: any) => void;
  27363. /**
  27364. * Callback called when the task is not successful
  27365. */
  27366. onError: (task: any, message?: string, exception?: any) => void;
  27367. /**
  27368. * Creates a new {BABYLON.AssetsManager}
  27369. * @param name defines the name of the task
  27370. */
  27371. constructor(
  27372. /**
  27373. * Task name
  27374. */ name: string);
  27375. private _isCompleted;
  27376. private _taskState;
  27377. private _errorObject;
  27378. /**
  27379. * Get if the task is completed
  27380. */
  27381. readonly isCompleted: boolean;
  27382. /**
  27383. * Gets the current state of the task
  27384. */
  27385. readonly taskState: AssetTaskState;
  27386. /**
  27387. * Gets the current error object (if task is in error)
  27388. */
  27389. readonly errorObject: {
  27390. message?: string;
  27391. exception?: any;
  27392. };
  27393. /**
  27394. * Internal only
  27395. * @hidden
  27396. */
  27397. _setErrorObject(message?: string, exception?: any): void;
  27398. /**
  27399. * Execute the current task
  27400. * @param scene defines the scene where you want your assets to be loaded
  27401. * @param onSuccess is a callback called when the task is successfully executed
  27402. * @param onError is a callback called if an error occurs
  27403. */
  27404. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27405. /**
  27406. * Execute the current task
  27407. * @param scene defines the scene where you want your assets to be loaded
  27408. * @param onSuccess is a callback called when the task is successfully executed
  27409. * @param onError is a callback called if an error occurs
  27410. */
  27411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27412. /**
  27413. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  27414. * This can be used with failed tasks that have the reason for failure fixed.
  27415. */
  27416. reset(): void;
  27417. private onErrorCallback(onError, message?, exception?);
  27418. private onDoneCallback(onSuccess, onError);
  27419. }
  27420. /**
  27421. * Define the interface used by progress events raised during assets loading
  27422. */
  27423. interface IAssetsProgressEvent {
  27424. /**
  27425. * Defines the number of remaining tasks to process
  27426. */
  27427. remainingCount: number;
  27428. /**
  27429. * Defines the total number of tasks
  27430. */
  27431. totalCount: number;
  27432. /**
  27433. * Defines the task that was just processed
  27434. */
  27435. task: AbstractAssetTask;
  27436. }
  27437. /**
  27438. * Class used to share progress information about assets loading
  27439. */
  27440. class AssetsProgressEvent implements IAssetsProgressEvent {
  27441. /**
  27442. * Defines the number of remaining tasks to process
  27443. */
  27444. remainingCount: number;
  27445. /**
  27446. * Defines the total number of tasks
  27447. */
  27448. totalCount: number;
  27449. /**
  27450. * Defines the task that was just processed
  27451. */
  27452. task: AbstractAssetTask;
  27453. /**
  27454. * Creates a {BABYLON.AssetsProgressEvent}
  27455. * @param remainingCount defines the number of remaining tasks to process
  27456. * @param totalCount defines the total number of tasks
  27457. * @param task defines the task that was just processed
  27458. */
  27459. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  27460. }
  27461. /**
  27462. * Define a task used by {BABYLON.AssetsManager} to load meshes
  27463. */
  27464. class MeshAssetTask extends AbstractAssetTask {
  27465. /**
  27466. * Defines the name of the task
  27467. */
  27468. name: string;
  27469. /**
  27470. * Defines the list of mesh's names you want to load
  27471. */
  27472. meshesNames: any;
  27473. /**
  27474. * Defines the root url to use as a base to load your meshes and associated resources
  27475. */
  27476. rootUrl: string;
  27477. /**
  27478. * Defines the filename of the scene to load from
  27479. */
  27480. sceneFilename: string;
  27481. /**
  27482. * Gets the list of loaded meshes
  27483. */
  27484. loadedMeshes: Array<AbstractMesh>;
  27485. /**
  27486. * Gets the list of loaded particle systems
  27487. */
  27488. loadedParticleSystems: Array<ParticleSystem>;
  27489. /**
  27490. * Gets the list of loaded skeletons
  27491. */
  27492. loadedSkeletons: Array<Skeleton>;
  27493. /**
  27494. * Callback called when the task is successful
  27495. */
  27496. onSuccess: (task: MeshAssetTask) => void;
  27497. /**
  27498. * Callback called when the task is successful
  27499. */
  27500. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  27501. /**
  27502. * Creates a new {BABYLON.MeshAssetTask}
  27503. * @param name defines the name of the task
  27504. * @param meshesNames defines the list of mesh's names you want to load
  27505. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  27506. * @param sceneFilename defines the filename of the scene to load from
  27507. */
  27508. constructor(
  27509. /**
  27510. * Defines the name of the task
  27511. */
  27512. name: string,
  27513. /**
  27514. * Defines the list of mesh's names you want to load
  27515. */
  27516. meshesNames: any,
  27517. /**
  27518. * Defines the root url to use as a base to load your meshes and associated resources
  27519. */
  27520. rootUrl: string,
  27521. /**
  27522. * Defines the filename of the scene to load from
  27523. */
  27524. sceneFilename: string);
  27525. /**
  27526. * Execute the current task
  27527. * @param scene defines the scene where you want your assets to be loaded
  27528. * @param onSuccess is a callback called when the task is successfully executed
  27529. * @param onError is a callback called if an error occurs
  27530. */
  27531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27532. }
  27533. /**
  27534. * Define a task used by {BABYLON.AssetsManager} to load text content
  27535. */
  27536. class TextFileAssetTask extends AbstractAssetTask {
  27537. /**
  27538. * Defines the name of the task
  27539. */
  27540. name: string;
  27541. /**
  27542. * Defines the location of the file to load
  27543. */
  27544. url: string;
  27545. /**
  27546. * Gets the loaded text string
  27547. */
  27548. text: string;
  27549. /**
  27550. * Callback called when the task is successful
  27551. */
  27552. onSuccess: (task: TextFileAssetTask) => void;
  27553. /**
  27554. * Callback called when the task is successful
  27555. */
  27556. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  27557. /**
  27558. * Creates a new TextFileAssetTask object
  27559. * @param name defines the name of the task
  27560. * @param url defines the location of the file to load
  27561. */
  27562. constructor(
  27563. /**
  27564. * Defines the name of the task
  27565. */
  27566. name: string,
  27567. /**
  27568. * Defines the location of the file to load
  27569. */
  27570. url: string);
  27571. /**
  27572. * Execute the current task
  27573. * @param scene defines the scene where you want your assets to be loaded
  27574. * @param onSuccess is a callback called when the task is successfully executed
  27575. * @param onError is a callback called if an error occurs
  27576. */
  27577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27578. }
  27579. /**
  27580. * Define a task used by {BABYLON.AssetsManager} to load binary data
  27581. */
  27582. class BinaryFileAssetTask extends AbstractAssetTask {
  27583. /**
  27584. * Defines the name of the task
  27585. */
  27586. name: string;
  27587. /**
  27588. * Defines the location of the file to load
  27589. */
  27590. url: string;
  27591. /**
  27592. * Gets the lodaded data (as an array buffer)
  27593. */
  27594. data: ArrayBuffer;
  27595. /**
  27596. * Callback called when the task is successful
  27597. */
  27598. onSuccess: (task: BinaryFileAssetTask) => void;
  27599. /**
  27600. * Callback called when the task is successful
  27601. */
  27602. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27603. /**
  27604. * Creates a new BinaryFileAssetTask object
  27605. * @param name defines the name of the new task
  27606. * @param url defines the location of the file to load
  27607. */
  27608. constructor(
  27609. /**
  27610. * Defines the name of the task
  27611. */
  27612. name: string,
  27613. /**
  27614. * Defines the location of the file to load
  27615. */
  27616. url: string);
  27617. /**
  27618. * Execute the current task
  27619. * @param scene defines the scene where you want your assets to be loaded
  27620. * @param onSuccess is a callback called when the task is successfully executed
  27621. * @param onError is a callback called if an error occurs
  27622. */
  27623. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27624. }
  27625. /**
  27626. * Define a task used by {BABYLON.AssetsManager} to load images
  27627. */
  27628. class ImageAssetTask extends AbstractAssetTask {
  27629. /**
  27630. * Defines the name of the task
  27631. */
  27632. name: string;
  27633. /**
  27634. * Defines the location of the image to load
  27635. */
  27636. url: string;
  27637. /**
  27638. * Gets the loaded images
  27639. */
  27640. image: HTMLImageElement;
  27641. /**
  27642. * Callback called when the task is successful
  27643. */
  27644. onSuccess: (task: ImageAssetTask) => void;
  27645. /**
  27646. * Callback called when the task is successful
  27647. */
  27648. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27649. /**
  27650. * Creates a new ImageAssetTask
  27651. * @param name defines the name of the task
  27652. * @param url defines the location of the image to load
  27653. */
  27654. constructor(
  27655. /**
  27656. * Defines the name of the task
  27657. */
  27658. name: string,
  27659. /**
  27660. * Defines the location of the image to load
  27661. */
  27662. url: string);
  27663. /**
  27664. * Execute the current task
  27665. * @param scene defines the scene where you want your assets to be loaded
  27666. * @param onSuccess is a callback called when the task is successfully executed
  27667. * @param onError is a callback called if an error occurs
  27668. */
  27669. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27670. }
  27671. /**
  27672. * Defines the interface used by texture loading tasks
  27673. */
  27674. interface ITextureAssetTask<TEX extends BaseTexture> {
  27675. /**
  27676. * Gets the loaded texture
  27677. */
  27678. texture: TEX;
  27679. }
  27680. /**
  27681. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27682. */
  27683. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27684. /**
  27685. * Defines the name of the task
  27686. */
  27687. name: string;
  27688. /**
  27689. * Defines the location of the file to load
  27690. */
  27691. url: string;
  27692. /**
  27693. * Defines if mipmap should not be generated (default is false)
  27694. */
  27695. noMipmap: boolean | undefined;
  27696. /**
  27697. * Defines if texture must be inverted on Y axis (default is false)
  27698. */
  27699. invertY: boolean | undefined;
  27700. /**
  27701. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27702. */
  27703. samplingMode: number;
  27704. /**
  27705. * Gets the loaded texture
  27706. */
  27707. texture: Texture;
  27708. /**
  27709. * Callback called when the task is successful
  27710. */
  27711. onSuccess: (task: TextureAssetTask) => void;
  27712. /**
  27713. * Callback called when the task is successful
  27714. */
  27715. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27716. /**
  27717. * Creates a new TextureAssetTask object
  27718. * @param name defines the name of the task
  27719. * @param url defines the location of the file to load
  27720. * @param noMipmap defines if mipmap should not be generated (default is false)
  27721. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27722. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27723. */
  27724. constructor(
  27725. /**
  27726. * Defines the name of the task
  27727. */
  27728. name: string,
  27729. /**
  27730. * Defines the location of the file to load
  27731. */
  27732. url: string,
  27733. /**
  27734. * Defines if mipmap should not be generated (default is false)
  27735. */
  27736. noMipmap?: boolean | undefined,
  27737. /**
  27738. * Defines if texture must be inverted on Y axis (default is false)
  27739. */
  27740. invertY?: boolean | undefined,
  27741. /**
  27742. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27743. */
  27744. samplingMode?: number);
  27745. /**
  27746. * Execute the current task
  27747. * @param scene defines the scene where you want your assets to be loaded
  27748. * @param onSuccess is a callback called when the task is successfully executed
  27749. * @param onError is a callback called if an error occurs
  27750. */
  27751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27752. }
  27753. /**
  27754. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27755. */
  27756. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27757. /**
  27758. * Defines the name of the task
  27759. */
  27760. name: string;
  27761. /**
  27762. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27763. */
  27764. url: string;
  27765. /**
  27766. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27767. */
  27768. extensions: string[] | undefined;
  27769. /**
  27770. * Defines if mipmaps should not be generated (default is false)
  27771. */
  27772. noMipmap: boolean | undefined;
  27773. /**
  27774. * Defines the explicit list of files (undefined by default)
  27775. */
  27776. files: string[] | undefined;
  27777. /**
  27778. * Gets the loaded texture
  27779. */
  27780. texture: CubeTexture;
  27781. /**
  27782. * Callback called when the task is successful
  27783. */
  27784. onSuccess: (task: CubeTextureAssetTask) => void;
  27785. /**
  27786. * Callback called when the task is successful
  27787. */
  27788. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27789. /**
  27790. * Creates a new CubeTextureAssetTask
  27791. * @param name defines the name of the task
  27792. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27793. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27794. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27795. * @param files defines the explicit list of files (undefined by default)
  27796. */
  27797. constructor(
  27798. /**
  27799. * Defines the name of the task
  27800. */
  27801. name: string,
  27802. /**
  27803. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27804. */
  27805. url: string,
  27806. /**
  27807. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27808. */
  27809. extensions?: string[] | undefined,
  27810. /**
  27811. * Defines if mipmaps should not be generated (default is false)
  27812. */
  27813. noMipmap?: boolean | undefined,
  27814. /**
  27815. * Defines the explicit list of files (undefined by default)
  27816. */
  27817. files?: string[] | undefined);
  27818. /**
  27819. * Execute the current task
  27820. * @param scene defines the scene where you want your assets to be loaded
  27821. * @param onSuccess is a callback called when the task is successfully executed
  27822. * @param onError is a callback called if an error occurs
  27823. */
  27824. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27825. }
  27826. /**
  27827. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27828. */
  27829. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27830. /**
  27831. * Defines the name of the task
  27832. */
  27833. name: string;
  27834. /**
  27835. * Defines the location of the file to load
  27836. */
  27837. url: string;
  27838. /**
  27839. * Defines the desired size (the more it increases the longer the generation will be)
  27840. */
  27841. size: number;
  27842. /**
  27843. * Defines if mipmaps should not be generated (default is false)
  27844. */
  27845. noMipmap: boolean;
  27846. /**
  27847. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27848. */
  27849. generateHarmonics: boolean;
  27850. /**
  27851. * 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)
  27852. */
  27853. gammaSpace: boolean;
  27854. /**
  27855. * Internal Use Only
  27856. */
  27857. reserved: boolean;
  27858. /**
  27859. * Gets the loaded texture
  27860. */
  27861. texture: HDRCubeTexture;
  27862. /**
  27863. * Callback called when the task is successful
  27864. */
  27865. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27866. /**
  27867. * Callback called when the task is successful
  27868. */
  27869. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27870. /**
  27871. * Creates a new HDRCubeTextureAssetTask object
  27872. * @param name defines the name of the task
  27873. * @param url defines the location of the file to load
  27874. * @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.
  27875. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27876. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27877. * @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)
  27878. * @param reserved Internal use only
  27879. */
  27880. constructor(
  27881. /**
  27882. * Defines the name of the task
  27883. */
  27884. name: string,
  27885. /**
  27886. * Defines the location of the file to load
  27887. */
  27888. url: string,
  27889. /**
  27890. * Defines the desired size (the more it increases the longer the generation will be)
  27891. */
  27892. size: number,
  27893. /**
  27894. * Defines if mipmaps should not be generated (default is false)
  27895. */
  27896. noMipmap?: boolean,
  27897. /**
  27898. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27899. */
  27900. generateHarmonics?: boolean,
  27901. /**
  27902. * 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)
  27903. */
  27904. gammaSpace?: boolean,
  27905. /**
  27906. * Internal Use Only
  27907. */
  27908. reserved?: boolean);
  27909. /**
  27910. * Execute the current task
  27911. * @param scene defines the scene where you want your assets to be loaded
  27912. * @param onSuccess is a callback called when the task is successfully executed
  27913. * @param onError is a callback called if an error occurs
  27914. */
  27915. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27916. }
  27917. /**
  27918. * This class can be used to easily import assets into a scene
  27919. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27920. */
  27921. class AssetsManager {
  27922. private _scene;
  27923. private _isLoading;
  27924. protected _tasks: AbstractAssetTask[];
  27925. protected _waitingTasksCount: number;
  27926. protected _totalTasksCount: number;
  27927. /**
  27928. * Callback called when all tasks are processed
  27929. */
  27930. onFinish: (tasks: AbstractAssetTask[]) => void;
  27931. /**
  27932. * Callback called when a task is successful
  27933. */
  27934. onTaskSuccess: (task: AbstractAssetTask) => void;
  27935. /**
  27936. * Callback called when a task had an error
  27937. */
  27938. onTaskError: (task: AbstractAssetTask) => void;
  27939. /**
  27940. * Callback called when a task is done (whatever the result is)
  27941. */
  27942. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27943. /**
  27944. * Observable called when all tasks are processed
  27945. */
  27946. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27947. /**
  27948. * Observable called when a task had an error
  27949. */
  27950. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27951. /**
  27952. * Observable called when a task is successful
  27953. */
  27954. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27955. /**
  27956. * Observable called when a task is done (whatever the result is)
  27957. */
  27958. onProgressObservable: Observable<IAssetsProgressEvent>;
  27959. /**
  27960. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27961. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27962. */
  27963. useDefaultLoadingScreen: boolean;
  27964. /**
  27965. * Creates a new AssetsManager
  27966. * @param scene defines the scene to work on
  27967. */
  27968. constructor(scene: Scene);
  27969. /**
  27970. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27971. * @param taskName defines the name of the new task
  27972. * @param meshesNames defines the name of meshes to load
  27973. * @param rootUrl defines the root url to use to locate files
  27974. * @param sceneFilename defines the filename of the scene file
  27975. * @returns a new {BABYLON.MeshAssetTask} object
  27976. */
  27977. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27978. /**
  27979. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27980. * @param taskName defines the name of the new task
  27981. * @param url defines the url of the file to load
  27982. * @returns a new {BABYLON.TextFileAssetTask} object
  27983. */
  27984. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27985. /**
  27986. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27987. * @param taskName defines the name of the new task
  27988. * @param url defines the url of the file to load
  27989. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27990. */
  27991. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27992. /**
  27993. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27994. * @param taskName defines the name of the new task
  27995. * @param url defines the url of the file to load
  27996. * @returns a new {BABYLON.ImageAssetTask} object
  27997. */
  27998. addImageTask(taskName: string, url: string): ImageAssetTask;
  27999. /**
  28000. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  28001. * @param taskName defines the name of the new task
  28002. * @param url defines the url of the file to load
  28003. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28004. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  28005. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  28006. * @returns a new {BABYLON.TextureAssetTask} object
  28007. */
  28008. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  28009. /**
  28010. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  28011. * @param taskName defines the name of the new task
  28012. * @param url defines the url of the file to load
  28013. * @param extensions defines the extension to use to load the cube map (can be null)
  28014. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28015. * @param files defines the list of files to load (can be null)
  28016. * @returns a new {BABYLON.CubeTextureAssetTask} object
  28017. */
  28018. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  28019. /**
  28020. *
  28021. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  28022. * @param taskName defines the name of the new task
  28023. * @param url defines the url of the file to load
  28024. * @param size defines the size you want for the cubemap (can be null)
  28025. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28026. * @param generateHarmonics defines if you want to automatically generate (true by default)
  28027. * @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)
  28028. * @param reserved Internal use only
  28029. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  28030. */
  28031. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  28032. /**
  28033. * Remove a task from the assets manager.
  28034. * @param task the task to remove
  28035. */
  28036. removeTask(task: AbstractAssetTask): void;
  28037. private _decreaseWaitingTasksCount(task);
  28038. private _runTask(task);
  28039. /**
  28040. * Reset the {BABYLON.AssetsManager} and remove all tasks
  28041. * @return the current instance of the {BABYLON.AssetsManager}
  28042. */
  28043. reset(): AssetsManager;
  28044. /**
  28045. * Start the loading process
  28046. * @return the current instance of the {BABYLON.AssetsManager}
  28047. */
  28048. load(): AssetsManager;
  28049. }
  28050. }
  28051. declare module BABYLON {
  28052. /**
  28053. * Class used to enable access to IndexedDB
  28054. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  28055. */
  28056. class Database {
  28057. private callbackManifestChecked;
  28058. private currentSceneUrl;
  28059. private db;
  28060. private _enableSceneOffline;
  28061. private _enableTexturesOffline;
  28062. private manifestVersionFound;
  28063. private mustUpdateRessources;
  28064. private hasReachedQuota;
  28065. private isSupported;
  28066. private idbFactory;
  28067. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  28068. static IsUASupportingBlobStorage: boolean;
  28069. /** Gets a boolean indicating if Database storate is enabled */
  28070. static IDBStorageEnabled: boolean;
  28071. /**
  28072. * Gets a boolean indicating if scene must be saved in the database
  28073. */
  28074. readonly enableSceneOffline: boolean;
  28075. /**
  28076. * Gets a boolean indicating if textures must be saved in the database
  28077. */
  28078. readonly enableTexturesOffline: boolean;
  28079. /**
  28080. * Creates a new Database
  28081. * @param urlToScene defines the url to load the scene
  28082. * @param callbackManifestChecked defines the callback to use when manifest is checked
  28083. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  28084. */
  28085. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  28086. private static _ParseURL;
  28087. private static _ReturnFullUrlLocation;
  28088. private _checkManifestFile();
  28089. /**
  28090. * Open the database and make it available
  28091. * @param successCallback defines the callback to call on success
  28092. * @param errorCallback defines the callback to call on error
  28093. */
  28094. openAsync(successCallback: () => void, errorCallback: () => void): void;
  28095. /**
  28096. * Loads an image from the database
  28097. * @param url defines the url to load from
  28098. * @param image defines the target DOM image
  28099. */
  28100. loadImageFromDB(url: string, image: HTMLImageElement): void;
  28101. private _loadImageFromDBAsync(url, image, notInDBCallback);
  28102. private _saveImageIntoDBAsync(url, image);
  28103. private _checkVersionFromDB(url, versionLoaded);
  28104. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  28105. private _saveVersionIntoDBAsync(url, callback);
  28106. /**
  28107. * Loads a file from database
  28108. * @param url defines the URL to load from
  28109. * @param sceneLoaded defines a callback to call on success
  28110. * @param progressCallBack defines a callback to call when progress changed
  28111. * @param errorCallback defines a callback to call on error
  28112. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  28113. */
  28114. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  28115. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  28116. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  28117. }
  28118. }
  28119. declare module BABYLON {
  28120. interface DDSInfo {
  28121. width: number;
  28122. height: number;
  28123. mipmapCount: number;
  28124. isFourCC: boolean;
  28125. isRGB: boolean;
  28126. isLuminance: boolean;
  28127. isCube: boolean;
  28128. isCompressed: boolean;
  28129. dxgiFormat: number;
  28130. textureType: number;
  28131. /** Sphericle polynomial created for the dds texture */
  28132. sphericalPolynomial?: SphericalPolynomial;
  28133. }
  28134. class DDSTools {
  28135. static StoreLODInAlphaChannel: boolean;
  28136. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  28137. private static _FloatView;
  28138. private static _Int32View;
  28139. private static _ToHalfFloat(value);
  28140. private static _FromHalfFloat(value);
  28141. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28142. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28143. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28144. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28145. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28146. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  28147. private static _ExtractLongWordOrder(value);
  28148. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  28149. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  28150. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  28151. }
  28152. }
  28153. declare module BABYLON {
  28154. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28155. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28156. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28157. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28158. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28159. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28160. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28161. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28162. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28163. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28164. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28165. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28166. /**
  28167. * Decorator used to define property that can be serialized as reference to a camera
  28168. * @param sourceName defines the name of the property to decorate
  28169. */
  28170. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28171. class SerializationHelper {
  28172. static Serialize<T>(entity: T, serializationObject?: any): any;
  28173. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28174. static Clone<T>(creationFunction: () => T, source: T): T;
  28175. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28176. }
  28177. }
  28178. declare module BABYLON {
  28179. /**
  28180. * Wrapper class for promise with external resolve and reject.
  28181. */
  28182. class Deferred<T> {
  28183. /**
  28184. * The promise associated with this deferred object.
  28185. */
  28186. readonly promise: Promise<T>;
  28187. private _resolve;
  28188. private _reject;
  28189. /**
  28190. * The resolve method of the promise associated with this deferred object.
  28191. */
  28192. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  28193. /**
  28194. * The reject method of the promise associated with this deferred object.
  28195. */
  28196. readonly reject: (reason?: any) => void;
  28197. /**
  28198. * Constructor for this deferred object.
  28199. */
  28200. constructor();
  28201. }
  28202. }
  28203. declare module BABYLON {
  28204. /**
  28205. * Raw texture data and descriptor sufficient for WebGL texture upload
  28206. */
  28207. interface EnvironmentTextureInfo {
  28208. /**
  28209. * Version of the environment map
  28210. */
  28211. version: number;
  28212. /**
  28213. * Width of image
  28214. */
  28215. width: number;
  28216. /**
  28217. * Irradiance information stored in the file.
  28218. */
  28219. irradiance: any;
  28220. /**
  28221. * Specular information stored in the file.
  28222. */
  28223. specular: any;
  28224. }
  28225. /**
  28226. * Sets of helpers addressing the serialization and deserialization of environment texture
  28227. * stored in a BabylonJS env file.
  28228. * Those files are usually stored as .env files.
  28229. */
  28230. class EnvironmentTextureTools {
  28231. /**
  28232. * Magic number identifying the env file.
  28233. */
  28234. private static _MagicBytes;
  28235. /**
  28236. * Gets the environment info from an env file.
  28237. * @param data The array buffer containing the .env bytes.
  28238. * @returns the environment file info (the json header) if successfully parsed.
  28239. */
  28240. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  28241. /**
  28242. * Creates an environment texture from a loaded cube texture.
  28243. * @param texture defines the cube texture to convert in env file
  28244. * @return a promise containing the environment data if succesfull.
  28245. */
  28246. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  28247. /**
  28248. * Creates a JSON representation of the spherical data.
  28249. * @param texture defines the texture containing the polynomials
  28250. * @return the JSON representation of the spherical info
  28251. */
  28252. private static _CreateEnvTextureIrradiance(texture);
  28253. /**
  28254. * Uploads the texture info contained in the env file to te GPU.
  28255. * @param texture defines the internal texture to upload to
  28256. * @param arrayBuffer defines the buffer cotaining the data to load
  28257. * @param info defines the texture info retrieved through the GetEnvInfo method
  28258. * @returns a promise
  28259. */
  28260. static UploadLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  28261. /**
  28262. * Uploads spherical polynomials information to the texture.
  28263. * @param texture defines the texture we are trying to upload the information to
  28264. * @param arrayBuffer defines the array buffer holding the data
  28265. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  28266. */
  28267. static UploadPolynomials(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): void;
  28268. /**
  28269. * Upload spherical polynomial coefficients to the texture
  28270. * @param polynmials Spherical polynmial coefficients (9)
  28271. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28272. */
  28273. private static _UploadSP(polynmials, outPolynomialCoefficents);
  28274. /**
  28275. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  28276. * L = (1/pi) * E * rho
  28277. *
  28278. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  28279. * @param harmonics Spherical harmonic coefficients (9)
  28280. */
  28281. private static _ConvertSHIrradianceToLambertianRadiance(harmonics);
  28282. /**
  28283. * Convert spherical harmonics to spherical polynomial coefficients
  28284. * @param harmonics Spherical harmonic coefficients (9)
  28285. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28286. */
  28287. private static _ConvertSHToSP(harmonics, outPolynomialCoefficents);
  28288. }
  28289. }
  28290. declare module BABYLON {
  28291. class FilesInput {
  28292. static FilesToLoad: {
  28293. [key: string]: File;
  28294. };
  28295. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  28296. private _engine;
  28297. private _currentScene;
  28298. private _sceneLoadedCallback;
  28299. private _progressCallback;
  28300. private _additionalRenderLoopLogicCallback;
  28301. private _textureLoadingCallback;
  28302. private _startingProcessingFilesCallback;
  28303. private _onReloadCallback;
  28304. private _errorCallback;
  28305. private _elementToMonitor;
  28306. private _sceneFileToLoad;
  28307. private _filesToLoad;
  28308. 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);
  28309. private _dragEnterHandler;
  28310. private _dragOverHandler;
  28311. private _dropHandler;
  28312. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  28313. dispose(): void;
  28314. private renderFunction();
  28315. private drag(e);
  28316. private drop(eventDrop);
  28317. private _traverseFolder(folder, files, remaining, callback);
  28318. private _processFiles(files);
  28319. loadFiles(event: any): void;
  28320. private _processReload();
  28321. reload(): void;
  28322. }
  28323. }
  28324. declare module BABYLON {
  28325. /**
  28326. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28327. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28328. */
  28329. class KhronosTextureContainer {
  28330. arrayBuffer: any;
  28331. static HEADER_LEN: number;
  28332. static COMPRESSED_2D: number;
  28333. static COMPRESSED_3D: number;
  28334. static TEX_2D: number;
  28335. static TEX_3D: number;
  28336. glType: number;
  28337. glTypeSize: number;
  28338. glFormat: number;
  28339. glInternalFormat: number;
  28340. glBaseInternalFormat: number;
  28341. pixelWidth: number;
  28342. pixelHeight: number;
  28343. pixelDepth: number;
  28344. numberOfArrayElements: number;
  28345. numberOfFaces: number;
  28346. numberOfMipmapLevels: number;
  28347. bytesOfKeyValueData: number;
  28348. loadType: number;
  28349. /**
  28350. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  28351. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  28352. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  28353. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  28354. */
  28355. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  28356. switchEndainness(val: number): number;
  28357. /**
  28358. * It is assumed that the texture has already been created & is currently bound
  28359. */
  28360. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  28361. private _upload2DCompressedLevels(gl, loadMipmaps);
  28362. }
  28363. }
  28364. declare module BABYLON {
  28365. /**
  28366. * A class serves as a medium between the observable and its observers
  28367. */
  28368. class EventState {
  28369. /**
  28370. * Create a new EventState
  28371. * @param mask defines the mask associated with this state
  28372. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28373. * @param target defines the original target of the state
  28374. * @param currentTarget defines the current target of the state
  28375. */
  28376. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  28377. /**
  28378. * Initialize the current event state
  28379. * @param mask defines the mask associated with this state
  28380. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28381. * @param target defines the original target of the state
  28382. * @param currentTarget defines the current target of the state
  28383. * @returns the current event state
  28384. */
  28385. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  28386. /**
  28387. * An Observer can set this property to true to prevent subsequent observers of being notified
  28388. */
  28389. skipNextObservers: boolean;
  28390. /**
  28391. * Get the mask value that were used to trigger the event corresponding to this EventState object
  28392. */
  28393. mask: number;
  28394. /**
  28395. * The object that originally notified the event
  28396. */
  28397. target?: any;
  28398. /**
  28399. * The current object in the bubbling phase
  28400. */
  28401. currentTarget?: any;
  28402. /**
  28403. * This will be populated with the return value of the last function that was executed.
  28404. * If it is the first function in the callback chain it will be the event data.
  28405. */
  28406. lastReturnValue?: any;
  28407. }
  28408. /**
  28409. * Represent an Observer registered to a given Observable object.
  28410. */
  28411. class Observer<T> {
  28412. /**
  28413. * Defines the callback to call when the observer is notified
  28414. */
  28415. callback: (eventData: T, eventState: EventState) => void;
  28416. /**
  28417. * Defines the mask of the observer (used to filter notifications)
  28418. */
  28419. mask: number;
  28420. /**
  28421. * Defines the current scope used to restore the JS context
  28422. */
  28423. scope: any;
  28424. /** @hidden */
  28425. _willBeUnregistered: boolean;
  28426. /**
  28427. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  28428. */
  28429. unregisterOnNextCall: boolean;
  28430. /**
  28431. * Creates a new observer
  28432. * @param callback defines the callback to call when the observer is notified
  28433. * @param mask defines the mask of the observer (used to filter notifications)
  28434. * @param scope defines the current scope used to restore the JS context
  28435. */
  28436. constructor(
  28437. /**
  28438. * Defines the callback to call when the observer is notified
  28439. */
  28440. callback: (eventData: T, eventState: EventState) => void,
  28441. /**
  28442. * Defines the mask of the observer (used to filter notifications)
  28443. */
  28444. mask: number,
  28445. /**
  28446. * Defines the current scope used to restore the JS context
  28447. */
  28448. scope?: any);
  28449. }
  28450. /**
  28451. * Represent a list of observers registered to multiple Observables object.
  28452. */
  28453. class MultiObserver<T> {
  28454. private _observers;
  28455. private _observables;
  28456. /**
  28457. * Release associated resources
  28458. */
  28459. dispose(): void;
  28460. /**
  28461. * Raise a callback when one of the observable will notify
  28462. * @param observables defines a list of observables to watch
  28463. * @param callback defines the callback to call on notification
  28464. * @param mask defines the mask used to filter notifications
  28465. * @param scope defines the current scope used to restore the JS context
  28466. * @returns the new MultiObserver
  28467. */
  28468. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  28469. }
  28470. /**
  28471. * The Observable class is a simple implementation of the Observable pattern.
  28472. *
  28473. * 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.
  28474. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  28475. * 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).
  28476. * 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.
  28477. */
  28478. class Observable<T> {
  28479. private _observers;
  28480. private _eventState;
  28481. private _onObserverAdded;
  28482. /**
  28483. * Creates a new observable
  28484. * @param onObserverAdded defines a callback to call when a new observer is added
  28485. */
  28486. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  28487. /**
  28488. * Create a new Observer with the specified callback
  28489. * @param callback the callback that will be executed for that Observer
  28490. * @param mask the mask used to filter observers
  28491. * @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.
  28492. * @param scope optional scope for the callback to be called from
  28493. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  28494. * @returns the new observer created for the callback
  28495. */
  28496. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  28497. /**
  28498. * Create a new Observer with the specified callback and unregisters after the next notification
  28499. * @param callback the callback that will be executed for that Observer
  28500. * @returns the new observer created for the callback
  28501. */
  28502. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  28503. /**
  28504. * Remove an Observer from the Observable object
  28505. * @param observer the instance of the Observer to remove
  28506. * @returns false if it doesn't belong to this Observable
  28507. */
  28508. remove(observer: Nullable<Observer<T>>): boolean;
  28509. /**
  28510. * Remove a callback from the Observable object
  28511. * @param callback the callback to remove
  28512. * @param scope optional scope. If used only the callbacks with this scope will be removed
  28513. * @returns false if it doesn't belong to this Observable
  28514. */
  28515. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  28516. private _deferUnregister(observer);
  28517. /**
  28518. * Notify all Observers by calling their respective callback with the given data
  28519. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  28520. * @param eventData defines the data to send to all observers
  28521. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  28522. * @param target defines the original target of the state
  28523. * @param currentTarget defines the current target of the state
  28524. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  28525. */
  28526. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  28527. /**
  28528. * Calling this will execute each callback, expecting it to be a promise or return a value.
  28529. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  28530. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  28531. * and it is crucial that all callbacks will be executed.
  28532. * The order of the callbacks is kept, callbacks are not executed parallel.
  28533. *
  28534. * @param eventData The data to be sent to each callback
  28535. * @param mask is used to filter observers defaults to -1
  28536. * @param target defines the callback target (see EventState)
  28537. * @param currentTarget defines he current object in the bubbling phase
  28538. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  28539. */
  28540. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  28541. /**
  28542. * Notify a specific observer
  28543. * @param observer defines the observer to notify
  28544. * @param eventData defines the data to be sent to each callback
  28545. * @param mask is used to filter observers defaults to -1
  28546. */
  28547. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  28548. /**
  28549. * Gets a boolean indicating if the observable has at least one observer
  28550. * @returns true is the Observable has at least one Observer registered
  28551. */
  28552. hasObservers(): boolean;
  28553. /**
  28554. * Clear the list of observers
  28555. */
  28556. clear(): void;
  28557. /**
  28558. * Clone the current observable
  28559. * @returns a new observable
  28560. */
  28561. clone(): Observable<T>;
  28562. /**
  28563. * Does this observable handles observer registered with a given mask
  28564. * @param mask defines the mask to be tested
  28565. * @return whether or not one observer registered with the given mask is handeled
  28566. **/
  28567. hasSpecificMask(mask?: number): boolean;
  28568. }
  28569. }
  28570. declare module BABYLON {
  28571. /**
  28572. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  28573. */
  28574. class PerformanceMonitor {
  28575. private _enabled;
  28576. private _rollingFrameTime;
  28577. private _lastFrameTimeMs;
  28578. /**
  28579. * constructor
  28580. * @param frameSampleSize The number of samples required to saturate the sliding window
  28581. */
  28582. constructor(frameSampleSize?: number);
  28583. /**
  28584. * Samples current frame
  28585. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  28586. */
  28587. sampleFrame(timeMs?: number): void;
  28588. /**
  28589. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28590. * @return Average frame time in milliseconds
  28591. */
  28592. readonly averageFrameTime: number;
  28593. /**
  28594. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28595. * @return Frame time variance in milliseconds squared
  28596. */
  28597. readonly averageFrameTimeVariance: number;
  28598. /**
  28599. * Returns the frame time of the most recent frame
  28600. * @return Frame time in milliseconds
  28601. */
  28602. readonly instantaneousFrameTime: number;
  28603. /**
  28604. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  28605. * @return Framerate in frames per second
  28606. */
  28607. readonly averageFPS: number;
  28608. /**
  28609. * Returns the average framerate in frames per second using the most recent frame time
  28610. * @return Framerate in frames per second
  28611. */
  28612. readonly instantaneousFPS: number;
  28613. /**
  28614. * Returns true if enough samples have been taken to completely fill the sliding window
  28615. * @return true if saturated
  28616. */
  28617. readonly isSaturated: boolean;
  28618. /**
  28619. * Enables contributions to the sliding window sample set
  28620. */
  28621. enable(): void;
  28622. /**
  28623. * Disables contributions to the sliding window sample set
  28624. * Samples will not be interpolated over the disabled period
  28625. */
  28626. disable(): void;
  28627. /**
  28628. * Returns true if sampling is enabled
  28629. * @return true if enabled
  28630. */
  28631. readonly isEnabled: boolean;
  28632. /**
  28633. * Resets performance monitor
  28634. */
  28635. reset(): void;
  28636. }
  28637. /**
  28638. * RollingAverage
  28639. *
  28640. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  28641. */
  28642. class RollingAverage {
  28643. /**
  28644. * Current average
  28645. */
  28646. average: number;
  28647. /**
  28648. * Current variance
  28649. */
  28650. variance: number;
  28651. protected _samples: Array<number>;
  28652. protected _sampleCount: number;
  28653. protected _pos: number;
  28654. protected _m2: number;
  28655. /**
  28656. * constructor
  28657. * @param length The number of samples required to saturate the sliding window
  28658. */
  28659. constructor(length: number);
  28660. /**
  28661. * Adds a sample to the sample set
  28662. * @param v The sample value
  28663. */
  28664. add(v: number): void;
  28665. /**
  28666. * Returns previously added values or null if outside of history or outside the sliding window domain
  28667. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  28668. * @return Value previously recorded with add() or null if outside of range
  28669. */
  28670. history(i: number): number;
  28671. /**
  28672. * Returns true if enough samples have been taken to completely fill the sliding window
  28673. * @return true if sample-set saturated
  28674. */
  28675. isSaturated(): boolean;
  28676. /**
  28677. * Resets the rolling average (equivalent to 0 samples taken so far)
  28678. */
  28679. reset(): void;
  28680. /**
  28681. * Wraps a value around the sample range boundaries
  28682. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  28683. * @return Wrapped position in sample range
  28684. */
  28685. protected _wrapPosition(i: number): number;
  28686. }
  28687. }
  28688. declare module BABYLON {
  28689. /**
  28690. * Helper class that provides a small promise polyfill
  28691. */
  28692. class PromisePolyfill {
  28693. /**
  28694. * Static function used to check if the polyfill is required
  28695. * If this is the case then the function will inject the polyfill to window.Promise
  28696. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28697. */
  28698. static Apply(force?: boolean): void;
  28699. }
  28700. }
  28701. declare module BABYLON {
  28702. /**
  28703. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28704. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28705. */
  28706. class SceneOptimization {
  28707. /**
  28708. * Defines the priority of this optimization (0 by default which means first in the list)
  28709. */
  28710. priority: number;
  28711. /**
  28712. * Gets a string describing the action executed by the current optimization
  28713. * @returns description string
  28714. */
  28715. getDescription(): string;
  28716. /**
  28717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28718. * @param scene defines the current scene where to apply this optimization
  28719. * @param optimizer defines the current optimizer
  28720. * @returns true if everything that can be done was applied
  28721. */
  28722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28723. /**
  28724. * Creates the SceneOptimization object
  28725. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28726. * @param desc defines the description associated with the optimization
  28727. */
  28728. constructor(
  28729. /**
  28730. * Defines the priority of this optimization (0 by default which means first in the list)
  28731. */
  28732. priority?: number);
  28733. }
  28734. /**
  28735. * Defines an optimization used to reduce the size of render target textures
  28736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28737. */
  28738. class TextureOptimization extends SceneOptimization {
  28739. /**
  28740. * Defines the priority of this optimization (0 by default which means first in the list)
  28741. */
  28742. priority: number;
  28743. /**
  28744. * 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
  28745. */
  28746. maximumSize: number;
  28747. /**
  28748. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28749. */
  28750. step: number;
  28751. /**
  28752. * Gets a string describing the action executed by the current optimization
  28753. * @returns description string
  28754. */
  28755. getDescription(): string;
  28756. /**
  28757. * Creates the TextureOptimization object
  28758. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28759. * @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
  28760. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28761. */
  28762. constructor(
  28763. /**
  28764. * Defines the priority of this optimization (0 by default which means first in the list)
  28765. */
  28766. priority?: number,
  28767. /**
  28768. * 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
  28769. */
  28770. maximumSize?: number,
  28771. /**
  28772. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28773. */
  28774. step?: number);
  28775. /**
  28776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28777. * @param scene defines the current scene where to apply this optimization
  28778. * @param optimizer defines the current optimizer
  28779. * @returns true if everything that can be done was applied
  28780. */
  28781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28782. }
  28783. /**
  28784. * Defines an optimization used to increase or decrease the rendering resolution
  28785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28786. */
  28787. class HardwareScalingOptimization extends SceneOptimization {
  28788. /**
  28789. * Defines the priority of this optimization (0 by default which means first in the list)
  28790. */
  28791. priority: number;
  28792. /**
  28793. * Defines the maximum scale to use (2 by default)
  28794. */
  28795. maximumScale: number;
  28796. /**
  28797. * Defines the step to use between two passes (0.5 by default)
  28798. */
  28799. step: number;
  28800. private _currentScale;
  28801. private _directionOffset;
  28802. /**
  28803. * Gets a string describing the action executed by the current optimization
  28804. * @return description string
  28805. */
  28806. getDescription(): string;
  28807. /**
  28808. * Creates the HardwareScalingOptimization object
  28809. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28810. * @param maximumScale defines the maximum scale to use (2 by default)
  28811. * @param step defines the step to use between two passes (0.5 by default)
  28812. */
  28813. constructor(
  28814. /**
  28815. * Defines the priority of this optimization (0 by default which means first in the list)
  28816. */
  28817. priority?: number,
  28818. /**
  28819. * Defines the maximum scale to use (2 by default)
  28820. */
  28821. maximumScale?: number,
  28822. /**
  28823. * Defines the step to use between two passes (0.5 by default)
  28824. */
  28825. step?: number);
  28826. /**
  28827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28828. * @param scene defines the current scene where to apply this optimization
  28829. * @param optimizer defines the current optimizer
  28830. * @returns true if everything that can be done was applied
  28831. */
  28832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28833. }
  28834. /**
  28835. * Defines an optimization used to remove shadows
  28836. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28837. */
  28838. class ShadowsOptimization extends SceneOptimization {
  28839. /**
  28840. * Gets a string describing the action executed by the current optimization
  28841. * @return description string
  28842. */
  28843. getDescription(): string;
  28844. /**
  28845. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28846. * @param scene defines the current scene where to apply this optimization
  28847. * @param optimizer defines the current optimizer
  28848. * @returns true if everything that can be done was applied
  28849. */
  28850. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28851. }
  28852. /**
  28853. * Defines an optimization used to turn post-processes off
  28854. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28855. */
  28856. class PostProcessesOptimization extends SceneOptimization {
  28857. /**
  28858. * Gets a string describing the action executed by the current optimization
  28859. * @return description string
  28860. */
  28861. getDescription(): string;
  28862. /**
  28863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28864. * @param scene defines the current scene where to apply this optimization
  28865. * @param optimizer defines the current optimizer
  28866. * @returns true if everything that can be done was applied
  28867. */
  28868. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28869. }
  28870. /**
  28871. * Defines an optimization used to turn lens flares off
  28872. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28873. */
  28874. class LensFlaresOptimization extends SceneOptimization {
  28875. /**
  28876. * Gets a string describing the action executed by the current optimization
  28877. * @return description string
  28878. */
  28879. getDescription(): string;
  28880. /**
  28881. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28882. * @param scene defines the current scene where to apply this optimization
  28883. * @param optimizer defines the current optimizer
  28884. * @returns true if everything that can be done was applied
  28885. */
  28886. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28887. }
  28888. /**
  28889. * Defines an optimization based on user defined callback.
  28890. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28891. */
  28892. class CustomOptimization extends SceneOptimization {
  28893. /**
  28894. * Callback called to apply the custom optimization.
  28895. */
  28896. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28897. /**
  28898. * Callback called to get custom description
  28899. */
  28900. onGetDescription: () => string;
  28901. /**
  28902. * Gets a string describing the action executed by the current optimization
  28903. * @returns description string
  28904. */
  28905. getDescription(): string;
  28906. /**
  28907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28908. * @param scene defines the current scene where to apply this optimization
  28909. * @param optimizer defines the current optimizer
  28910. * @returns true if everything that can be done was applied
  28911. */
  28912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28913. }
  28914. /**
  28915. * Defines an optimization used to turn particles off
  28916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28917. */
  28918. class ParticlesOptimization extends SceneOptimization {
  28919. /**
  28920. * Gets a string describing the action executed by the current optimization
  28921. * @return description string
  28922. */
  28923. getDescription(): string;
  28924. /**
  28925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28926. * @param scene defines the current scene where to apply this optimization
  28927. * @param optimizer defines the current optimizer
  28928. * @returns true if everything that can be done was applied
  28929. */
  28930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28931. }
  28932. /**
  28933. * Defines an optimization used to turn render targets off
  28934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28935. */
  28936. class RenderTargetsOptimization extends SceneOptimization {
  28937. /**
  28938. * Gets a string describing the action executed by the current optimization
  28939. * @return description string
  28940. */
  28941. getDescription(): string;
  28942. /**
  28943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28944. * @param scene defines the current scene where to apply this optimization
  28945. * @param optimizer defines the current optimizer
  28946. * @returns true if everything that can be done was applied
  28947. */
  28948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28949. }
  28950. /**
  28951. * Defines an optimization used to merge meshes with compatible materials
  28952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28953. */
  28954. class MergeMeshesOptimization extends SceneOptimization {
  28955. private static _UpdateSelectionTree;
  28956. /**
  28957. * Gets or sets a boolean which defines if optimization octree has to be updated
  28958. */
  28959. /**
  28960. * Gets or sets a boolean which defines if optimization octree has to be updated
  28961. */
  28962. static UpdateSelectionTree: boolean;
  28963. /**
  28964. * Gets a string describing the action executed by the current optimization
  28965. * @return description string
  28966. */
  28967. getDescription(): string;
  28968. private _canBeMerged;
  28969. /**
  28970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28971. * @param scene defines the current scene where to apply this optimization
  28972. * @param optimizer defines the current optimizer
  28973. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28974. * @returns true if everything that can be done was applied
  28975. */
  28976. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28977. }
  28978. /**
  28979. * Defines a list of options used by SceneOptimizer
  28980. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28981. */
  28982. class SceneOptimizerOptions {
  28983. /**
  28984. * Defines the target frame rate to reach (60 by default)
  28985. */
  28986. targetFrameRate: number;
  28987. /**
  28988. * Defines the interval between two checkes (2000ms by default)
  28989. */
  28990. trackerDuration: number;
  28991. /**
  28992. * Gets the list of optimizations to apply
  28993. */
  28994. optimizations: SceneOptimization[];
  28995. /**
  28996. * Creates a new list of options used by SceneOptimizer
  28997. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28998. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28999. */
  29000. constructor(
  29001. /**
  29002. * Defines the target frame rate to reach (60 by default)
  29003. */
  29004. targetFrameRate?: number,
  29005. /**
  29006. * Defines the interval between two checkes (2000ms by default)
  29007. */
  29008. trackerDuration?: number);
  29009. /**
  29010. * Add a new optimization
  29011. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  29012. * @returns the current SceneOptimizerOptions
  29013. */
  29014. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  29015. /**
  29016. * Add a new custom optimization
  29017. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  29018. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  29019. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29020. * @returns the current SceneOptimizerOptions
  29021. */
  29022. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  29023. /**
  29024. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  29025. * @param targetFrameRate defines the target frame rate (60 by default)
  29026. * @returns a SceneOptimizerOptions object
  29027. */
  29028. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29029. /**
  29030. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  29031. * @param targetFrameRate defines the target frame rate (60 by default)
  29032. * @returns a SceneOptimizerOptions object
  29033. */
  29034. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29035. /**
  29036. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  29037. * @param targetFrameRate defines the target frame rate (60 by default)
  29038. * @returns a SceneOptimizerOptions object
  29039. */
  29040. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29041. }
  29042. /**
  29043. * Class used to run optimizations in order to reach a target frame rate
  29044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29045. */
  29046. class SceneOptimizer implements IDisposable {
  29047. private _isRunning;
  29048. private _options;
  29049. private _scene;
  29050. private _currentPriorityLevel;
  29051. private _targetFrameRate;
  29052. private _trackerDuration;
  29053. private _currentFrameRate;
  29054. private _sceneDisposeObserver;
  29055. private _improvementMode;
  29056. /**
  29057. * Defines an observable called when the optimizer reaches the target frame rate
  29058. */
  29059. onSuccessObservable: Observable<SceneOptimizer>;
  29060. /**
  29061. * Defines an observable called when the optimizer enables an optimization
  29062. */
  29063. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  29064. /**
  29065. * Defines an observable called when the optimizer is not able to reach the target frame rate
  29066. */
  29067. onFailureObservable: Observable<SceneOptimizer>;
  29068. /**
  29069. * Gets a boolean indicating if the optimizer is in improvement mode
  29070. */
  29071. readonly isInImprovementMode: boolean;
  29072. /**
  29073. * Gets the current priority level (0 at start)
  29074. */
  29075. readonly currentPriorityLevel: number;
  29076. /**
  29077. * Gets the current frame rate checked by the SceneOptimizer
  29078. */
  29079. readonly currentFrameRate: number;
  29080. /**
  29081. * Gets or sets the current target frame rate (60 by default)
  29082. */
  29083. /**
  29084. * Gets or sets the current target frame rate (60 by default)
  29085. */
  29086. targetFrameRate: number;
  29087. /**
  29088. * Gets or sets the current interval between two checks (every 2000ms by default)
  29089. */
  29090. /**
  29091. * Gets or sets the current interval between two checks (every 2000ms by default)
  29092. */
  29093. trackerDuration: number;
  29094. /**
  29095. * Gets the list of active optimizations
  29096. */
  29097. readonly optimizations: SceneOptimization[];
  29098. /**
  29099. * Creates a new SceneOptimizer
  29100. * @param scene defines the scene to work on
  29101. * @param options defines the options to use with the SceneOptimizer
  29102. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  29103. * @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)
  29104. */
  29105. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  29106. /**
  29107. * Stops the current optimizer
  29108. */
  29109. stop(): void;
  29110. /**
  29111. * Reset the optimizer to initial step (current priority level = 0)
  29112. */
  29113. reset(): void;
  29114. /**
  29115. * Start the optimizer. By default it will try to reach a specific framerate
  29116. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  29117. */
  29118. start(): void;
  29119. private _checkCurrentState();
  29120. /**
  29121. * Release all resources
  29122. */
  29123. dispose(): void;
  29124. /**
  29125. * Helper function to create a SceneOptimizer with one single line of code
  29126. * @param scene defines the scene to work on
  29127. * @param options defines the options to use with the SceneOptimizer
  29128. * @param onSuccess defines a callback to call on success
  29129. * @param onFailure defines a callback to call on failure
  29130. * @returns the new SceneOptimizer object
  29131. */
  29132. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  29133. }
  29134. }
  29135. declare module BABYLON {
  29136. class SceneSerializer {
  29137. static ClearCache(): void;
  29138. static Serialize(scene: Scene): any;
  29139. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  29140. }
  29141. }
  29142. declare module BABYLON {
  29143. class SmartArray<T> {
  29144. data: Array<T>;
  29145. length: number;
  29146. protected _id: number;
  29147. [index: number]: T;
  29148. constructor(capacity: number);
  29149. push(value: T): void;
  29150. forEach(func: (content: T) => void): void;
  29151. sort(compareFn: (a: T, b: T) => number): void;
  29152. reset(): void;
  29153. dispose(): void;
  29154. concat(array: any): void;
  29155. indexOf(value: T): number;
  29156. contains(value: T): boolean;
  29157. private static _GlobalId;
  29158. }
  29159. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  29160. private _duplicateId;
  29161. [index: number]: T;
  29162. push(value: T): void;
  29163. pushNoDuplicate(value: T): boolean;
  29164. reset(): void;
  29165. concatWithNoDuplicate(array: any): void;
  29166. }
  29167. }
  29168. declare module BABYLON {
  29169. /**
  29170. * This class implement a typical dictionary using a string as key and the generic type T as value.
  29171. * The underlying implementation relies on an associative array to ensure the best performances.
  29172. * The value can be anything including 'null' but except 'undefined'
  29173. */
  29174. class StringDictionary<T> {
  29175. /**
  29176. * This will clear this dictionary and copy the content from the 'source' one.
  29177. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  29178. * @param source the dictionary to take the content from and copy to this dictionary
  29179. */
  29180. copyFrom(source: StringDictionary<T>): void;
  29181. /**
  29182. * Get a value based from its key
  29183. * @param key the given key to get the matching value from
  29184. * @return the value if found, otherwise undefined is returned
  29185. */
  29186. get(key: string): T | undefined;
  29187. /**
  29188. * Get a value from its key or add it if it doesn't exist.
  29189. * This method will ensure you that a given key/data will be present in the dictionary.
  29190. * @param key the given key to get the matching value from
  29191. * @param factory the factory that will create the value if the key is not present in the dictionary.
  29192. * The factory will only be invoked if there's no data for the given key.
  29193. * @return the value corresponding to the key.
  29194. */
  29195. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  29196. /**
  29197. * Get a value from its key if present in the dictionary otherwise add it
  29198. * @param key the key to get the value from
  29199. * @param val if there's no such key/value pair in the dictionary add it with this value
  29200. * @return the value corresponding to the key
  29201. */
  29202. getOrAdd(key: string, val: T): T;
  29203. /**
  29204. * Check if there's a given key in the dictionary
  29205. * @param key the key to check for
  29206. * @return true if the key is present, false otherwise
  29207. */
  29208. contains(key: string): boolean;
  29209. /**
  29210. * Add a new key and its corresponding value
  29211. * @param key the key to add
  29212. * @param value the value corresponding to the key
  29213. * @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
  29214. */
  29215. add(key: string, value: T): boolean;
  29216. set(key: string, value: T): boolean;
  29217. /**
  29218. * Get the element of the given key and remove it from the dictionary
  29219. * @param key
  29220. */
  29221. getAndRemove(key: string): Nullable<T>;
  29222. /**
  29223. * Remove a key/value from the dictionary.
  29224. * @param key the key to remove
  29225. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  29226. */
  29227. remove(key: string): boolean;
  29228. /**
  29229. * Clear the whole content of the dictionary
  29230. */
  29231. clear(): void;
  29232. readonly count: number;
  29233. /**
  29234. * Execute a callback on each key/val of the dictionary.
  29235. * Note that you can remove any element in this dictionary in the callback implementation
  29236. * @param callback the callback to execute on a given key/value pair
  29237. */
  29238. forEach(callback: (key: string, val: T) => void): void;
  29239. /**
  29240. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  29241. * If the callback returns null or undefined the method will iterate to the next key/value pair
  29242. * Note that you can remove any element in this dictionary in the callback implementation
  29243. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  29244. */
  29245. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  29246. private _count;
  29247. private _data;
  29248. }
  29249. }
  29250. declare module BABYLON {
  29251. class Tags {
  29252. static EnableFor(obj: any): void;
  29253. static DisableFor(obj: any): void;
  29254. static HasTags(obj: any): boolean;
  29255. static GetTags(obj: any, asString?: boolean): any;
  29256. static AddTagsTo(obj: any, tagsString: string): void;
  29257. static _AddTagTo(obj: any, tag: string): void;
  29258. static RemoveTagsFrom(obj: any, tagsString: string): void;
  29259. static _RemoveTagFrom(obj: any, tag: string): void;
  29260. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  29261. }
  29262. }
  29263. declare module BABYLON {
  29264. class TextureTools {
  29265. /**
  29266. * Uses the GPU to create a copy texture rescaled at a given size
  29267. * @param texture Texture to copy from
  29268. * @param width Desired width
  29269. * @param height Desired height
  29270. * @return Generated texture
  29271. */
  29272. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  29273. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  29274. private static _environmentBRDFBase64Texture;
  29275. }
  29276. }
  29277. declare module BABYLON {
  29278. class TGATools {
  29279. private static _TYPE_INDEXED;
  29280. private static _TYPE_RGB;
  29281. private static _TYPE_GREY;
  29282. private static _TYPE_RLE_INDEXED;
  29283. private static _TYPE_RLE_RGB;
  29284. private static _TYPE_RLE_GREY;
  29285. private static _ORIGIN_MASK;
  29286. private static _ORIGIN_SHIFT;
  29287. private static _ORIGIN_BL;
  29288. private static _ORIGIN_BR;
  29289. private static _ORIGIN_UL;
  29290. private static _ORIGIN_UR;
  29291. static GetTGAHeader(data: Uint8Array): any;
  29292. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  29293. 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;
  29294. 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;
  29295. 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;
  29296. 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;
  29297. 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;
  29298. 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;
  29299. }
  29300. }
  29301. declare module BABYLON {
  29302. interface IAnimatable {
  29303. animations: Array<Animation>;
  29304. }
  29305. class LoadFileError extends Error {
  29306. request: XMLHttpRequest | undefined;
  29307. private static _setPrototypeOf;
  29308. constructor(message: string, request?: XMLHttpRequest | undefined);
  29309. }
  29310. class RetryStrategy {
  29311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29312. }
  29313. interface IFileRequest {
  29314. /**
  29315. * Raised when the request is complete (success or error).
  29316. */
  29317. onCompleteObservable: Observable<IFileRequest>;
  29318. /**
  29319. * Aborts the request for a file.
  29320. */
  29321. abort: () => void;
  29322. }
  29323. class Tools {
  29324. static BaseUrl: string;
  29325. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29326. /**
  29327. * Default behaviour for cors in the application.
  29328. * It can be a string if the expected behavior is identical in the entire app.
  29329. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29330. */
  29331. static CorsBehavior: string | ((url: string | string[]) => string);
  29332. static UseFallbackTexture: boolean;
  29333. /**
  29334. * Use this object to register external classes like custom textures or material
  29335. * to allow the laoders to instantiate them
  29336. */
  29337. static RegisteredExternalClasses: {
  29338. [key: string]: Object;
  29339. };
  29340. static fallbackTexture: string;
  29341. /**
  29342. * Interpolates between a and b via alpha
  29343. * @param a The lower value (returned when alpha = 0)
  29344. * @param b The upper value (returned when alpha = 1)
  29345. * @param alpha The interpolation-factor
  29346. * @return The mixed value
  29347. */
  29348. static Mix(a: number, b: number, alpha: number): number;
  29349. static Instantiate(className: string): any;
  29350. /**
  29351. * Provides a slice function that will work even on IE
  29352. * @param data defines the array to slice
  29353. * @param start defines the start of the data (optional)
  29354. * @param end defines the end of the data (optional)
  29355. * @returns the new sliced array
  29356. */
  29357. static Slice<T>(data: T, start?: number, end?: number): T;
  29358. static SetImmediate(action: () => void): void;
  29359. static IsExponentOfTwo(value: number): boolean;
  29360. private static _tmpFloatArray;
  29361. /**
  29362. * Returns the nearest 32-bit single precision float representation of a Number
  29363. * @param value A Number. If the parameter is of a different type, it will get converted
  29364. * to a number or to NaN if it cannot be converted
  29365. * @returns number
  29366. */
  29367. static FloatRound(value: number): number;
  29368. /**
  29369. * Find the next highest power of two.
  29370. * @param x Number to start search from.
  29371. * @return Next highest power of two.
  29372. */
  29373. static CeilingPOT(x: number): number;
  29374. /**
  29375. * Find the next lowest power of two.
  29376. * @param x Number to start search from.
  29377. * @return Next lowest power of two.
  29378. */
  29379. static FloorPOT(x: number): number;
  29380. /**
  29381. * Find the nearest power of two.
  29382. * @param x Number to start search from.
  29383. * @return Next nearest power of two.
  29384. */
  29385. static NearestPOT(x: number): number;
  29386. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29387. static GetFilename(path: string): string;
  29388. /**
  29389. * Extracts the "folder" part of a path (everything before the filename).
  29390. * @param uri The URI to extract the info from
  29391. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29392. * @returns The "folder" part of the path
  29393. */
  29394. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29395. static GetDOMTextContent(element: HTMLElement): string;
  29396. static ToDegrees(angle: number): number;
  29397. static ToRadians(angle: number): number;
  29398. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29399. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29400. minimum: Vector3;
  29401. maximum: Vector3;
  29402. };
  29403. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29404. minimum: Vector3;
  29405. maximum: Vector3;
  29406. };
  29407. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  29408. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  29409. minimum: Vector2;
  29410. maximum: Vector2;
  29411. };
  29412. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29413. static GetPointerPrefix(): string;
  29414. /**
  29415. * @param func - the function to be called
  29416. * @param requester - the object that will request the next frame. Falls back to window.
  29417. */
  29418. static QueueNewFrame(func: () => void, requester?: any): number;
  29419. static RequestFullscreen(element: HTMLElement): void;
  29420. static ExitFullscreen(): void;
  29421. static SetCorsBehavior(url: string | string[], element: {
  29422. crossOrigin: string | null;
  29423. }): void;
  29424. static CleanUrl(url: string): string;
  29425. static PreprocessUrl: (url: string) => string;
  29426. /**
  29427. * Loads an image as an HTMLImageElement.
  29428. * @param input url string, ArrayBuffer, or Blob to load
  29429. * @param onLoad callback called when the image successfully loads
  29430. * @param onError callback called when the image fails to load
  29431. * @param database database for caching
  29432. * @returns the HTMLImageElement of the loaded image
  29433. */
  29434. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  29435. 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;
  29436. /**
  29437. * Load a script (identified by an url). When the url returns, the
  29438. * content of this file is added into a new script element, attached to the DOM (body element)
  29439. */
  29440. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29441. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29442. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29443. static FileAsURL(content: string): string;
  29444. static Format(value: number, decimals?: number): string;
  29445. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29447. static IsEmpty(obj: any): boolean;
  29448. static RegisterTopRootEvents(events: {
  29449. name: string;
  29450. handler: Nullable<(e: FocusEvent) => any>;
  29451. }[]): void;
  29452. static UnregisterTopRootEvents(events: {
  29453. name: string;
  29454. handler: Nullable<(e: FocusEvent) => any>;
  29455. }[]): void;
  29456. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29457. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29458. /**
  29459. * Downloads a blob in the browser
  29460. * @param blob defines the blob to download
  29461. * @param fileName defines the name of the downloaded file
  29462. */
  29463. static Download(blob: Blob, fileName: string): void;
  29464. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29465. /**
  29466. * Generates an image screenshot from the specified camera.
  29467. *
  29468. * @param engine The engine to use for rendering
  29469. * @param camera The camera to use for rendering
  29470. * @param size This parameter can be set to a single number or to an object with the
  29471. * following (optional) properties: precision, width, height. If a single number is passed,
  29472. * it will be used for both width and height. If an object is passed, the screenshot size
  29473. * will be derived from the parameters. The precision property is a multiplier allowing
  29474. * rendering at a higher or lower resolution.
  29475. * @param successCallback The callback receives a single parameter which contains the
  29476. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29477. * src parameter of an <img> to display it.
  29478. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29479. * Check your browser for supported MIME types.
  29480. * @param samples Texture samples (default: 1)
  29481. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29482. * @param fileName A name for for the downloaded file.
  29483. * @constructor
  29484. */
  29485. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29486. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  29487. /**
  29488. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29489. * Be aware Math.random() could cause collisions, but:
  29490. * "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"
  29491. */
  29492. static RandomId(): string;
  29493. /**
  29494. * Test if the given uri is a base64 string.
  29495. * @param uri The uri to test
  29496. * @return True if the uri is a base64 string or false otherwise.
  29497. */
  29498. static IsBase64(uri: string): boolean;
  29499. /**
  29500. * Decode the given base64 uri.
  29501. * @param uri The uri to decode
  29502. * @return The decoded base64 data.
  29503. */
  29504. static DecodeBase64(uri: string): ArrayBuffer;
  29505. private static _NoneLogLevel;
  29506. private static _MessageLogLevel;
  29507. private static _WarningLogLevel;
  29508. private static _ErrorLogLevel;
  29509. private static _LogCache;
  29510. static errorsCount: number;
  29511. static OnNewCacheEntry: (entry: string) => void;
  29512. static readonly NoneLogLevel: number;
  29513. static readonly MessageLogLevel: number;
  29514. static readonly WarningLogLevel: number;
  29515. static readonly ErrorLogLevel: number;
  29516. static readonly AllLogLevel: number;
  29517. private static _AddLogEntry(entry);
  29518. private static _FormatMessage(message);
  29519. private static _LogDisabled(message);
  29520. private static _LogEnabled(message);
  29521. private static _WarnDisabled(message);
  29522. private static _WarnEnabled(message);
  29523. private static _ErrorDisabled(message);
  29524. private static _ErrorEnabled(message);
  29525. static Log: (message: string) => void;
  29526. static Warn: (message: string) => void;
  29527. static Error: (message: string) => void;
  29528. static readonly LogCache: string;
  29529. static ClearLogCache(): void;
  29530. static LogLevels: number;
  29531. static IsWindowObjectExist(): boolean;
  29532. private static _PerformanceNoneLogLevel;
  29533. private static _PerformanceUserMarkLogLevel;
  29534. private static _PerformanceConsoleLogLevel;
  29535. private static _performance;
  29536. static readonly PerformanceNoneLogLevel: number;
  29537. static readonly PerformanceUserMarkLogLevel: number;
  29538. static readonly PerformanceConsoleLogLevel: number;
  29539. static PerformanceLogLevel: number;
  29540. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29541. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29542. static _StartUserMark(counterName: string, condition?: boolean): void;
  29543. static _EndUserMark(counterName: string, condition?: boolean): void;
  29544. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  29545. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  29546. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29547. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29548. static readonly Now: number;
  29549. /**
  29550. * This method will return the name of the class used to create the instance of the given object.
  29551. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29552. * @param object the object to get the class name from
  29553. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  29554. */
  29555. static GetClassName(object: any, isType?: boolean): string;
  29556. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29557. /**
  29558. * This method will return the name of the full name of the class, including its owning module (if any).
  29559. * 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).
  29560. * @param object the object to get the class name from
  29561. * @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.
  29562. */
  29563. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29564. /**
  29565. * 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.
  29566. * @param array
  29567. */
  29568. static arrayOrStringFeeder(array: any): (i: number) => number;
  29569. /**
  29570. * Compute the hashCode of a stream of number
  29571. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  29572. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  29573. * @return the hash code computed
  29574. */
  29575. static hashCodeFromStream(feeder: (index: number) => number): number;
  29576. /**
  29577. * Returns a promise that resolves after the given amount of time.
  29578. * @param delay Number of milliseconds to delay
  29579. * @returns Promise that resolves after the given amount of time
  29580. */
  29581. static DelayAsync(delay: number): Promise<void>;
  29582. }
  29583. /**
  29584. * This class is used to track a performance counter which is number based.
  29585. * The user has access to many properties which give statistics of different nature
  29586. *
  29587. * The implementer can track two kinds of Performance Counter: time and count
  29588. * 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.
  29589. * 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.
  29590. */
  29591. class PerfCounter {
  29592. static Enabled: boolean;
  29593. /**
  29594. * Returns the smallest value ever
  29595. */
  29596. readonly min: number;
  29597. /**
  29598. * Returns the biggest value ever
  29599. */
  29600. readonly max: number;
  29601. /**
  29602. * Returns the average value since the performance counter is running
  29603. */
  29604. readonly average: number;
  29605. /**
  29606. * Returns the average value of the last second the counter was monitored
  29607. */
  29608. readonly lastSecAverage: number;
  29609. /**
  29610. * Returns the current value
  29611. */
  29612. readonly current: number;
  29613. readonly total: number;
  29614. readonly count: number;
  29615. constructor();
  29616. /**
  29617. * Call this method to start monitoring a new frame.
  29618. * 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.
  29619. */
  29620. fetchNewFrame(): void;
  29621. /**
  29622. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29623. * @param newCount the count value to add to the monitored count
  29624. * @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.
  29625. */
  29626. addCount(newCount: number, fetchResult: boolean): void;
  29627. /**
  29628. * Start monitoring this performance counter
  29629. */
  29630. beginMonitoring(): void;
  29631. /**
  29632. * Compute the time lapsed since the previous beginMonitoring() call.
  29633. * @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
  29634. */
  29635. endMonitoring(newFrame?: boolean): void;
  29636. private _fetchResult();
  29637. private _startMonitoringTime;
  29638. private _min;
  29639. private _max;
  29640. private _average;
  29641. private _current;
  29642. private _totalValueCount;
  29643. private _totalAccumulated;
  29644. private _lastSecAverage;
  29645. private _lastSecAccumulated;
  29646. private _lastSecTime;
  29647. private _lastSecValueCount;
  29648. }
  29649. /**
  29650. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29651. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29652. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29653. * @param name The name of the class, case should be preserved
  29654. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29655. */
  29656. function className(name: string, module?: string): (target: Object) => void;
  29657. /**
  29658. * An implementation of a loop for asynchronous functions.
  29659. */
  29660. class AsyncLoop {
  29661. iterations: number;
  29662. private _fn;
  29663. private _successCallback;
  29664. index: number;
  29665. private _done;
  29666. /**
  29667. * Constroctor.
  29668. * @param iterations the number of iterations.
  29669. * @param _fn the function to run each iteration
  29670. * @param _successCallback the callback that will be called upon succesful execution
  29671. * @param offset starting offset.
  29672. */
  29673. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  29674. /**
  29675. * Execute the next iteration. Must be called after the last iteration was finished.
  29676. */
  29677. executeNext(): void;
  29678. /**
  29679. * Break the loop and run the success callback.
  29680. */
  29681. breakLoop(): void;
  29682. /**
  29683. * Helper function
  29684. */
  29685. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  29686. /**
  29687. * A for-loop that will run a given number of iterations synchronous and the rest async.
  29688. * @param iterations total number of iterations
  29689. * @param syncedIterations number of synchronous iterations in each async iteration.
  29690. * @param fn the function to call each iteration.
  29691. * @param callback a success call back that will be called when iterating stops.
  29692. * @param breakFunction a break condition (optional)
  29693. * @param timeout timeout settings for the setTimeout function. default - 0.
  29694. * @constructor
  29695. */
  29696. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  29697. }
  29698. }
  29699. declare module BABYLON {
  29700. /**
  29701. * Defines the potential axis of a Joystick
  29702. */
  29703. enum JoystickAxis {
  29704. /** X axis */
  29705. X = 0,
  29706. /** Y axis */
  29707. Y = 1,
  29708. /** Z axis */
  29709. Z = 2,
  29710. }
  29711. /**
  29712. * Class used to define virtual joystick (used in touch mode)
  29713. */
  29714. class VirtualJoystick {
  29715. /**
  29716. * Gets or sets a boolean indicating that left and right values must be inverted
  29717. */
  29718. reverseLeftRight: boolean;
  29719. /**
  29720. * Gets or sets a boolean indicating that up and down values must be inverted
  29721. */
  29722. reverseUpDown: boolean;
  29723. /**
  29724. * Gets the offset value for the position (ie. the change of the position value)
  29725. */
  29726. deltaPosition: Vector3;
  29727. /**
  29728. * Gets a boolean indicating if the virtual joystick was pressed
  29729. */
  29730. pressed: boolean;
  29731. private static _globalJoystickIndex;
  29732. private static vjCanvas;
  29733. private static vjCanvasContext;
  29734. private static vjCanvasWidth;
  29735. private static vjCanvasHeight;
  29736. private static halfWidth;
  29737. private _action;
  29738. private _axisTargetedByLeftAndRight;
  29739. private _axisTargetedByUpAndDown;
  29740. private _joystickSensibility;
  29741. private _inversedSensibility;
  29742. private _joystickPointerID;
  29743. private _joystickColor;
  29744. private _joystickPointerPos;
  29745. private _joystickPreviousPointerPos;
  29746. private _joystickPointerStartPos;
  29747. private _deltaJoystickVector;
  29748. private _leftJoystick;
  29749. private _touches;
  29750. private _onPointerDownHandlerRef;
  29751. private _onPointerMoveHandlerRef;
  29752. private _onPointerUpHandlerRef;
  29753. private _onResize;
  29754. /**
  29755. * Creates a new virtual joystick
  29756. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29757. */
  29758. constructor(leftJoystick?: boolean);
  29759. /**
  29760. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29761. * @param newJoystickSensibility defines the new sensibility
  29762. */
  29763. setJoystickSensibility(newJoystickSensibility: number): void;
  29764. private _onPointerDown(e);
  29765. private _onPointerMove(e);
  29766. private _onPointerUp(e);
  29767. /**
  29768. * Change the color of the virtual joystick
  29769. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29770. */
  29771. setJoystickColor(newColor: string): void;
  29772. /**
  29773. * Defines a callback to call when the joystick is touched
  29774. * @param action defines the callback
  29775. */
  29776. setActionOnTouch(action: () => any): void;
  29777. /**
  29778. * Defines which axis you'd like to control for left & right
  29779. * @param axis defines the axis to use
  29780. */
  29781. setAxisForLeftRight(axis: JoystickAxis): void;
  29782. /**
  29783. * Defines which axis you'd like to control for up & down
  29784. * @param axis defines the axis to use
  29785. */
  29786. setAxisForUpDown(axis: JoystickAxis): void;
  29787. private _drawVirtualJoystick();
  29788. /**
  29789. * Release internal HTML canvas
  29790. */
  29791. releaseCanvas(): void;
  29792. }
  29793. }
  29794. declare module BABYLON {
  29795. /**
  29796. * Helper class to push actions to a pool of workers.
  29797. */
  29798. class WorkerPool implements IDisposable {
  29799. private _workerInfos;
  29800. private _pendingActions;
  29801. /**
  29802. * Constructor
  29803. * @param workers Array of workers to use for actions
  29804. */
  29805. constructor(workers: Array<Worker>);
  29806. /**
  29807. * Terminates all workers and clears any pending actions.
  29808. */
  29809. dispose(): void;
  29810. /**
  29811. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29812. * pended until a worker has completed its action.
  29813. * @param action The action to perform. Call onComplete when the action is complete.
  29814. */
  29815. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29816. private _execute(workerInfo, action);
  29817. }
  29818. }
  29819. declare module BABYLON {
  29820. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29821. readonly name: string;
  29822. private _zoomStopsAnimation;
  29823. private _idleRotationSpeed;
  29824. private _idleRotationWaitTime;
  29825. private _idleRotationSpinupTime;
  29826. /**
  29827. * Gets the flag that indicates if user zooming should stop animation.
  29828. */
  29829. /**
  29830. * Sets the flag that indicates if user zooming should stop animation.
  29831. */
  29832. zoomStopsAnimation: boolean;
  29833. /**
  29834. * Gets the default speed at which the camera rotates around the model.
  29835. */
  29836. /**
  29837. * Sets the default speed at which the camera rotates around the model.
  29838. */
  29839. idleRotationSpeed: number;
  29840. /**
  29841. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29842. */
  29843. /**
  29844. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29845. */
  29846. idleRotationWaitTime: number;
  29847. /**
  29848. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29849. */
  29850. /**
  29851. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29852. */
  29853. idleRotationSpinupTime: number;
  29854. /**
  29855. * Gets a value indicating if the camera is currently rotating because of this behavior
  29856. */
  29857. readonly rotationInProgress: boolean;
  29858. private _onPrePointerObservableObserver;
  29859. private _onAfterCheckInputsObserver;
  29860. private _attachedCamera;
  29861. private _isPointerDown;
  29862. private _lastFrameTime;
  29863. private _lastInteractionTime;
  29864. private _cameraRotationSpeed;
  29865. init(): void;
  29866. attach(camera: ArcRotateCamera): void;
  29867. detach(): void;
  29868. /**
  29869. * Returns true if user is scrolling.
  29870. * @return true if user is scrolling.
  29871. */
  29872. private _userIsZooming();
  29873. private _lastFrameRadius;
  29874. private _shouldAnimationStopForInteraction();
  29875. /**
  29876. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29877. */
  29878. private _applyUserInteraction();
  29879. private _userIsMoving();
  29880. }
  29881. }
  29882. declare module BABYLON {
  29883. /**
  29884. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29885. */
  29886. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29887. readonly name: string;
  29888. /**
  29889. * The easing function used by animations
  29890. */
  29891. static EasingFunction: BackEase;
  29892. /**
  29893. * The easing mode used by animations
  29894. */
  29895. static EasingMode: number;
  29896. /**
  29897. * The duration of the animation, in milliseconds
  29898. */
  29899. transitionDuration: number;
  29900. /**
  29901. * Length of the distance animated by the transition when lower radius is reached
  29902. */
  29903. lowerRadiusTransitionRange: number;
  29904. /**
  29905. * Length of the distance animated by the transition when upper radius is reached
  29906. */
  29907. upperRadiusTransitionRange: number;
  29908. private _autoTransitionRange;
  29909. /**
  29910. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29911. */
  29912. /**
  29913. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29914. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29915. */
  29916. autoTransitionRange: boolean;
  29917. private _attachedCamera;
  29918. private _onAfterCheckInputsObserver;
  29919. private _onMeshTargetChangedObserver;
  29920. init(): void;
  29921. attach(camera: ArcRotateCamera): void;
  29922. detach(): void;
  29923. private _radiusIsAnimating;
  29924. private _radiusBounceTransition;
  29925. private _animatables;
  29926. private _cachedWheelPrecision;
  29927. /**
  29928. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29929. * @param radiusLimit The limit to check against.
  29930. * @return Bool to indicate if at limit.
  29931. */
  29932. private _isRadiusAtLimit(radiusLimit);
  29933. /**
  29934. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29935. * @param radiusDelta The delta by which to animate to. Can be negative.
  29936. */
  29937. private _applyBoundRadiusAnimation(radiusDelta);
  29938. /**
  29939. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29940. */
  29941. protected _clearAnimationLocks(): void;
  29942. /**
  29943. * Stops and removes all animations that have been applied to the camera
  29944. */
  29945. stopAllAnimations(): void;
  29946. }
  29947. }
  29948. declare module BABYLON {
  29949. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29950. readonly name: string;
  29951. private _mode;
  29952. private _radiusScale;
  29953. private _positionScale;
  29954. private _defaultElevation;
  29955. private _elevationReturnTime;
  29956. private _elevationReturnWaitTime;
  29957. private _zoomStopsAnimation;
  29958. private _framingTime;
  29959. /**
  29960. * The easing function used by animations
  29961. */
  29962. static EasingFunction: ExponentialEase;
  29963. /**
  29964. * The easing mode used by animations
  29965. */
  29966. static EasingMode: number;
  29967. /**
  29968. * Gets current mode used by the behavior.
  29969. */
  29970. /**
  29971. * Sets the current mode used by the behavior
  29972. */
  29973. mode: number;
  29974. /**
  29975. * Gets the scale applied to the radius
  29976. */
  29977. /**
  29978. * Sets the scale applied to the radius (1 by default)
  29979. */
  29980. radiusScale: number;
  29981. /**
  29982. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29983. */
  29984. /**
  29985. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29986. */
  29987. positionScale: number;
  29988. /**
  29989. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29990. * behaviour is triggered, in radians.
  29991. */
  29992. /**
  29993. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29994. * behaviour is triggered, in radians.
  29995. */
  29996. defaultElevation: number;
  29997. /**
  29998. * Gets the time (in milliseconds) taken to return to the default beta position.
  29999. * Negative value indicates camera should not return to default.
  30000. */
  30001. /**
  30002. * Sets the time (in milliseconds) taken to return to the default beta position.
  30003. * Negative value indicates camera should not return to default.
  30004. */
  30005. elevationReturnTime: number;
  30006. /**
  30007. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30008. */
  30009. /**
  30010. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30011. */
  30012. elevationReturnWaitTime: number;
  30013. /**
  30014. * Gets the flag that indicates if user zooming should stop animation.
  30015. */
  30016. /**
  30017. * Sets the flag that indicates if user zooming should stop animation.
  30018. */
  30019. zoomStopsAnimation: boolean;
  30020. /**
  30021. * Gets the transition time when framing the mesh, in milliseconds
  30022. */
  30023. /**
  30024. * Sets the transition time when framing the mesh, in milliseconds
  30025. */
  30026. framingTime: number;
  30027. private _onPrePointerObservableObserver;
  30028. private _onAfterCheckInputsObserver;
  30029. private _onMeshTargetChangedObserver;
  30030. private _attachedCamera;
  30031. private _isPointerDown;
  30032. private _lastInteractionTime;
  30033. init(): void;
  30034. attach(camera: ArcRotateCamera): void;
  30035. detach(): void;
  30036. private _animatables;
  30037. private _betaIsAnimating;
  30038. private _betaTransition;
  30039. private _radiusTransition;
  30040. private _vectorTransition;
  30041. /**
  30042. * Targets the given mesh and updates zoom level accordingly.
  30043. * @param mesh The mesh to target.
  30044. * @param radius Optional. If a cached radius position already exists, overrides default.
  30045. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30048. */
  30049. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30050. /**
  30051. * Targets the given mesh with its children and updates zoom level accordingly.
  30052. * @param mesh The mesh to target.
  30053. * @param radius Optional. If a cached radius position already exists, overrides default.
  30054. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30055. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30056. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30057. */
  30058. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30059. /**
  30060. * Targets the given meshes with their children and updates zoom level accordingly.
  30061. * @param meshes The mesh to target.
  30062. * @param radius Optional. If a cached radius position already exists, overrides default.
  30063. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30064. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30065. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30066. */
  30067. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30068. /**
  30069. * Targets the given mesh and updates zoom level accordingly.
  30070. * @param mesh The mesh to target.
  30071. * @param radius Optional. If a cached radius position already exists, overrides default.
  30072. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30073. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30074. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30075. */
  30076. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30077. /**
  30078. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  30079. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  30080. * frustum width.
  30081. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  30082. * to fully enclose the mesh in the viewing frustum.
  30083. */
  30084. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  30085. /**
  30086. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  30087. * is automatically returned to its default position (expected to be above ground plane).
  30088. */
  30089. private _maintainCameraAboveGround();
  30090. /**
  30091. * Returns the frustum slope based on the canvas ratio and camera FOV
  30092. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  30093. */
  30094. private _getFrustumSlope();
  30095. /**
  30096. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  30097. */
  30098. private _clearAnimationLocks();
  30099. /**
  30100. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30101. */
  30102. private _applyUserInteraction();
  30103. /**
  30104. * Stops and removes all animations that have been applied to the camera
  30105. */
  30106. stopAllAnimations(): void;
  30107. /**
  30108. * Gets a value indicating if the user is moving the camera
  30109. */
  30110. readonly isUserIsMoving: boolean;
  30111. /**
  30112. * The camera can move all the way towards the mesh.
  30113. */
  30114. static IgnoreBoundsSizeMode: number;
  30115. /**
  30116. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  30117. */
  30118. static FitFrustumSidesMode: number;
  30119. }
  30120. }
  30121. declare module BABYLON {
  30122. /**
  30123. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  30124. */
  30125. class PointerDragBehavior implements Behavior<Mesh> {
  30126. private options;
  30127. private _attachedNode;
  30128. private _dragPlane;
  30129. private _scene;
  30130. private _pointerObserver;
  30131. private static _planeScene;
  30132. private _draggingID;
  30133. /**
  30134. * Fires each time the attached mesh is dragged with the pointer
  30135. */
  30136. onDragObservable: Observable<{
  30137. delta: Vector3;
  30138. dragPlanePoint: Vector3;
  30139. }>;
  30140. /**
  30141. * Fires each time a drag begins (eg. mouse down on mesh)
  30142. */
  30143. onDragStartObservable: Observable<{
  30144. dragPlanePoint: Vector3;
  30145. }>;
  30146. /**
  30147. * Fires each time a drag ends (eg. mouse release after drag)
  30148. */
  30149. onDragEndObservable: Observable<{
  30150. dragPlanePoint: Vector3;
  30151. }>;
  30152. /**
  30153. * If the attached mesh should be moved when dragged
  30154. */
  30155. moveAttached: boolean;
  30156. /**
  30157. * Mesh with the position where the drag plane should be placed
  30158. */
  30159. _dragPlaneParent: Nullable<Mesh>;
  30160. /**
  30161. * If the drag behavior will react to drag events
  30162. */
  30163. enabled: boolean;
  30164. /**
  30165. * Creates a pointer drag behavior that can be attached to a mesh
  30166. * @param options The drag axis or normal of the plane that will be dragged across.
  30167. */
  30168. constructor(options: {
  30169. dragAxis?: Vector3;
  30170. dragPlaneNormal?: Vector3;
  30171. });
  30172. /**
  30173. * The name of the behavior
  30174. */
  30175. readonly name: string;
  30176. /**
  30177. * Initializes the behavior
  30178. */
  30179. init(): void;
  30180. /**
  30181. * Attaches the drag behavior the passed in mesh
  30182. * @param ownerNode The mesh that will be dragged around once attached
  30183. */
  30184. attach(ownerNode: Mesh): void;
  30185. private _pickWithRayOnDragPlane(ray);
  30186. private _updateDragPlanePosition(ray);
  30187. /**
  30188. * Detaches the behavior from the mesh
  30189. */
  30190. detach(): void;
  30191. }
  30192. }
  30193. declare module BABYLON {
  30194. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  30195. camera: ArcRotateCamera;
  30196. gamepad: Nullable<Gamepad>;
  30197. private _onGamepadConnectedObserver;
  30198. private _onGamepadDisconnectedObserver;
  30199. gamepadRotationSensibility: number;
  30200. gamepadMoveSensibility: number;
  30201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30202. detachControl(element: Nullable<HTMLElement>): void;
  30203. checkInputs(): void;
  30204. getClassName(): string;
  30205. getSimpleName(): string;
  30206. }
  30207. }
  30208. declare module BABYLON {
  30209. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  30210. camera: ArcRotateCamera;
  30211. private _keys;
  30212. keysUp: number[];
  30213. keysDown: number[];
  30214. keysLeft: number[];
  30215. keysRight: number[];
  30216. keysReset: number[];
  30217. panningSensibility: number;
  30218. zoomingSensibility: number;
  30219. useAltToZoom: boolean;
  30220. private _ctrlPressed;
  30221. private _altPressed;
  30222. private _onCanvasBlurObserver;
  30223. private _onKeyboardObserver;
  30224. private _engine;
  30225. private _scene;
  30226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30227. detachControl(element: Nullable<HTMLElement>): void;
  30228. checkInputs(): void;
  30229. getClassName(): string;
  30230. getSimpleName(): string;
  30231. }
  30232. }
  30233. declare module BABYLON {
  30234. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  30235. camera: ArcRotateCamera;
  30236. private _wheel;
  30237. private _observer;
  30238. wheelPrecision: number;
  30239. /**
  30240. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  30241. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  30242. */
  30243. wheelDeltaPercentage: number;
  30244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30245. detachControl(element: Nullable<HTMLElement>): void;
  30246. getClassName(): string;
  30247. getSimpleName(): string;
  30248. }
  30249. }
  30250. declare module BABYLON {
  30251. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  30252. camera: ArcRotateCamera;
  30253. buttons: number[];
  30254. angularSensibilityX: number;
  30255. angularSensibilityY: number;
  30256. pinchPrecision: number;
  30257. /**
  30258. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  30259. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  30260. */
  30261. pinchDeltaPercentage: number;
  30262. panningSensibility: number;
  30263. multiTouchPanning: boolean;
  30264. multiTouchPanAndZoom: boolean;
  30265. private _isPanClick;
  30266. pinchInwards: boolean;
  30267. private _pointerInput;
  30268. private _observer;
  30269. private _onMouseMove;
  30270. private _onGestureStart;
  30271. private _onGesture;
  30272. private _MSGestureHandler;
  30273. private _onLostFocus;
  30274. private _onContextMenu;
  30275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30276. detachControl(element: Nullable<HTMLElement>): void;
  30277. getClassName(): string;
  30278. getSimpleName(): string;
  30279. }
  30280. }
  30281. declare module BABYLON {
  30282. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  30283. camera: ArcRotateCamera;
  30284. alphaCorrection: number;
  30285. betaCorrection: number;
  30286. gammaCorrection: number;
  30287. private _alpha;
  30288. private _gamma;
  30289. private _dirty;
  30290. private _deviceOrientationHandler;
  30291. constructor();
  30292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30293. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  30294. checkInputs(): void;
  30295. detachControl(element: Nullable<HTMLElement>): void;
  30296. getClassName(): string;
  30297. getSimpleName(): string;
  30298. }
  30299. }
  30300. declare module BABYLON {
  30301. /**
  30302. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  30303. * Screen rotation is taken into account.
  30304. */
  30305. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  30306. private _camera;
  30307. private _screenOrientationAngle;
  30308. private _constantTranform;
  30309. private _screenQuaternion;
  30310. private _alpha;
  30311. private _beta;
  30312. private _gamma;
  30313. constructor();
  30314. camera: FreeCamera;
  30315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30316. private _orientationChanged;
  30317. private _deviceOrientation;
  30318. detachControl(element: Nullable<HTMLElement>): void;
  30319. checkInputs(): void;
  30320. getClassName(): string;
  30321. getSimpleName(): string;
  30322. }
  30323. }
  30324. declare module BABYLON {
  30325. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  30326. camera: FreeCamera;
  30327. gamepad: Nullable<Gamepad>;
  30328. private _onGamepadConnectedObserver;
  30329. private _onGamepadDisconnectedObserver;
  30330. gamepadAngularSensibility: number;
  30331. gamepadMoveSensibility: number;
  30332. private _cameraTransform;
  30333. private _deltaTransform;
  30334. private _vector3;
  30335. private _vector2;
  30336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30337. detachControl(element: Nullable<HTMLElement>): void;
  30338. checkInputs(): void;
  30339. getClassName(): string;
  30340. getSimpleName(): string;
  30341. }
  30342. }
  30343. declare module BABYLON {
  30344. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  30345. camera: FreeCamera;
  30346. private _keys;
  30347. private _onCanvasBlurObserver;
  30348. private _onKeyboardObserver;
  30349. private _engine;
  30350. private _scene;
  30351. keysUp: number[];
  30352. keysDown: number[];
  30353. keysLeft: number[];
  30354. keysRight: number[];
  30355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30356. detachControl(element: Nullable<HTMLElement>): void;
  30357. checkInputs(): void;
  30358. getClassName(): string;
  30359. _onLostFocus(e: FocusEvent): void;
  30360. getSimpleName(): string;
  30361. }
  30362. }
  30363. declare module BABYLON {
  30364. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  30365. touchEnabled: boolean;
  30366. camera: FreeCamera;
  30367. buttons: number[];
  30368. angularSensibility: number;
  30369. private _pointerInput;
  30370. private _onMouseMove;
  30371. private _observer;
  30372. private previousPosition;
  30373. constructor(touchEnabled?: boolean);
  30374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30375. detachControl(element: Nullable<HTMLElement>): void;
  30376. getClassName(): string;
  30377. getSimpleName(): string;
  30378. }
  30379. }
  30380. declare module BABYLON {
  30381. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  30382. camera: FreeCamera;
  30383. private _offsetX;
  30384. private _offsetY;
  30385. private _pointerPressed;
  30386. private _pointerInput;
  30387. private _observer;
  30388. private _onLostFocus;
  30389. touchAngularSensibility: number;
  30390. touchMoveSensibility: number;
  30391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30392. detachControl(element: Nullable<HTMLElement>): void;
  30393. checkInputs(): void;
  30394. getClassName(): string;
  30395. getSimpleName(): string;
  30396. }
  30397. }
  30398. declare module BABYLON {
  30399. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  30400. camera: FreeCamera;
  30401. private _leftjoystick;
  30402. private _rightjoystick;
  30403. getLeftJoystick(): VirtualJoystick;
  30404. getRightJoystick(): VirtualJoystick;
  30405. checkInputs(): void;
  30406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30407. detachControl(element: Nullable<HTMLElement>): void;
  30408. getClassName(): string;
  30409. getSimpleName(): string;
  30410. }
  30411. }
  30412. declare module BABYLON {
  30413. class VRCameraMetrics {
  30414. hResolution: number;
  30415. vResolution: number;
  30416. hScreenSize: number;
  30417. vScreenSize: number;
  30418. vScreenCenter: number;
  30419. eyeToScreenDistance: number;
  30420. lensSeparationDistance: number;
  30421. interpupillaryDistance: number;
  30422. distortionK: number[];
  30423. chromaAbCorrection: number[];
  30424. postProcessScaleFactor: number;
  30425. lensCenterOffset: number;
  30426. compensateDistortion: boolean;
  30427. readonly aspectRatio: number;
  30428. readonly aspectRatioFov: number;
  30429. readonly leftHMatrix: Matrix;
  30430. readonly rightHMatrix: Matrix;
  30431. readonly leftPreViewMatrix: Matrix;
  30432. readonly rightPreViewMatrix: Matrix;
  30433. static GetDefault(): VRCameraMetrics;
  30434. }
  30435. }
  30436. declare module BABYLON {
  30437. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  30438. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30439. getClassName(): string;
  30440. }
  30441. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  30442. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30443. getClassName(): string;
  30444. }
  30445. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  30446. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30447. getClassName(): string;
  30448. }
  30449. }
  30450. declare module BABYLON {
  30451. /**
  30452. * Options to modify the vr teleportation behavior.
  30453. */
  30454. interface VRTeleportationOptions {
  30455. /**
  30456. * The name of the mesh which should be used as the teleportation floor. (default: null)
  30457. */
  30458. floorMeshName?: string;
  30459. /**
  30460. * A list of meshes to be used as the teleportation floor. (default: empty)
  30461. */
  30462. floorMeshes?: Mesh[];
  30463. }
  30464. /**
  30465. * Options to modify the vr experience helper's behavior.
  30466. */
  30467. interface VRExperienceHelperOptions extends WebVROptions {
  30468. /**
  30469. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  30470. */
  30471. createDeviceOrientationCamera?: boolean;
  30472. /**
  30473. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  30474. */
  30475. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  30476. /**
  30477. * Uses the main button on the controller to toggle the laser casted. (default: true)
  30478. */
  30479. laserToggle?: boolean;
  30480. /**
  30481. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  30482. */
  30483. floorMeshes?: Mesh[];
  30484. }
  30485. /**
  30486. * Helps to quickly add VR support to an existing scene.
  30487. * See http://doc.babylonjs.com/how_to/webvr_helper
  30488. */
  30489. class VRExperienceHelper {
  30490. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  30491. private _scene;
  30492. private _position;
  30493. private _btnVR;
  30494. private _btnVRDisplayed;
  30495. private _webVRsupported;
  30496. private _webVRready;
  30497. private _webVRrequesting;
  30498. private _webVRpresenting;
  30499. private _fullscreenVRpresenting;
  30500. private _canvas;
  30501. private _webVRCamera;
  30502. private _vrDeviceOrientationCamera;
  30503. private _deviceOrientationCamera;
  30504. private _existingCamera;
  30505. private _onKeyDown;
  30506. private _onVrDisplayPresentChange;
  30507. private _onVRDisplayChanged;
  30508. private _onVRRequestPresentStart;
  30509. private _onVRRequestPresentComplete;
  30510. /**
  30511. * Observable raised when entering VR.
  30512. */
  30513. onEnteringVRObservable: Observable<VRExperienceHelper>;
  30514. /**
  30515. * Observable raised when exiting VR.
  30516. */
  30517. onExitingVRObservable: Observable<VRExperienceHelper>;
  30518. /**
  30519. * Observable raised when controller mesh is loaded.
  30520. */
  30521. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30522. /** Return this.onEnteringVRObservable
  30523. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  30524. */
  30525. readonly onEnteringVR: Observable<VRExperienceHelper>;
  30526. /** Return this.onExitingVRObservable
  30527. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  30528. */
  30529. readonly onExitingVR: Observable<VRExperienceHelper>;
  30530. /** Return this.onControllerMeshLoadedObservable
  30531. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  30532. */
  30533. readonly onControllerMeshLoaded: Observable<WebVRController>;
  30534. private _rayLength;
  30535. private _useCustomVRButton;
  30536. private _teleportationRequested;
  30537. private _teleportActive;
  30538. private _floorMeshName;
  30539. private _floorMeshesCollection;
  30540. private _rotationAllowed;
  30541. private _teleportBackwardsVector;
  30542. private _teleportationTarget;
  30543. private _isDefaultTeleportationTarget;
  30544. private _postProcessMove;
  30545. private _teleportationFillColor;
  30546. private _teleportationBorderColor;
  30547. private _rotationAngle;
  30548. private _haloCenter;
  30549. private _cameraGazer;
  30550. private _padSensibilityUp;
  30551. private _padSensibilityDown;
  30552. private leftController;
  30553. private rightController;
  30554. /**
  30555. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  30556. */
  30557. onNewMeshSelected: Observable<AbstractMesh>;
  30558. /**
  30559. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  30560. */
  30561. onNewMeshPicked: Observable<PickingInfo>;
  30562. private _circleEase;
  30563. /**
  30564. * Observable raised before camera teleportation
  30565. */
  30566. onBeforeCameraTeleport: Observable<Vector3>;
  30567. /**
  30568. * Observable raised after camera teleportation
  30569. */
  30570. onAfterCameraTeleport: Observable<Vector3>;
  30571. /**
  30572. * Observable raised when current selected mesh gets unselected
  30573. */
  30574. onSelectedMeshUnselected: Observable<AbstractMesh>;
  30575. private _raySelectionPredicate;
  30576. /**
  30577. * To be optionaly changed by user to define custom ray selection
  30578. */
  30579. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  30580. /**
  30581. * To be optionaly changed by user to define custom selection logic (after ray selection)
  30582. */
  30583. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  30584. /**
  30585. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  30586. */
  30587. teleportationEnabled: boolean;
  30588. private _defaultHeight;
  30589. private _teleportationInitialized;
  30590. private _interactionsEnabled;
  30591. private _interactionsRequested;
  30592. private _displayGaze;
  30593. private _displayLaserPointer;
  30594. /**
  30595. * The mesh used to display where the user is going to teleport.
  30596. */
  30597. /**
  30598. * Sets the mesh to be used to display where the user is going to teleport.
  30599. */
  30600. teleportationTarget: Mesh;
  30601. /**
  30602. * The mesh used to display where the user is selecting,
  30603. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  30604. * See http://doc.babylonjs.com/resources/baking_transformations
  30605. */
  30606. gazeTrackerMesh: Mesh;
  30607. /**
  30608. * If the ray of the gaze should be displayed.
  30609. */
  30610. /**
  30611. * Sets if the ray of the gaze should be displayed.
  30612. */
  30613. displayGaze: boolean;
  30614. /**
  30615. * If the ray of the LaserPointer should be displayed.
  30616. */
  30617. /**
  30618. * Sets if the ray of the LaserPointer should be displayed.
  30619. */
  30620. displayLaserPointer: boolean;
  30621. /**
  30622. * The deviceOrientationCamera used as the camera when not in VR.
  30623. */
  30624. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  30625. /**
  30626. * Based on the current WebVR support, returns the current VR camera used.
  30627. */
  30628. readonly currentVRCamera: Nullable<Camera>;
  30629. /**
  30630. * The webVRCamera which is used when in VR.
  30631. */
  30632. readonly webVRCamera: WebVRFreeCamera;
  30633. /**
  30634. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  30635. */
  30636. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  30637. private readonly _teleportationRequestInitiated;
  30638. /**
  30639. * Instantiates a VRExperienceHelper.
  30640. * Helps to quickly add VR support to an existing scene.
  30641. * @param scene The scene the VRExperienceHelper belongs to.
  30642. * @param webVROptions Options to modify the vr experience helper's behavior.
  30643. */
  30644. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  30645. private _onDefaultMeshLoaded(webVRController);
  30646. private _onResize;
  30647. private _onFullscreenChange;
  30648. /**
  30649. * Gets a value indicating if we are currently in VR mode.
  30650. */
  30651. readonly isInVRMode: boolean;
  30652. private onVrDisplayPresentChange();
  30653. private onVRDisplayChanged(eventArgs);
  30654. private moveButtonToBottomRight();
  30655. private displayVRButton();
  30656. private updateButtonVisibility();
  30657. /**
  30658. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  30659. * Otherwise, will use the fullscreen API.
  30660. */
  30661. enterVR(): void;
  30662. /**
  30663. * Attempt to exit VR, or fullscreen.
  30664. */
  30665. exitVR(): void;
  30666. /**
  30667. * The position of the vr experience helper.
  30668. */
  30669. /**
  30670. * Sets the position of the vr experience helper.
  30671. */
  30672. position: Vector3;
  30673. /**
  30674. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  30675. */
  30676. enableInteractions(): void;
  30677. private beforeRender;
  30678. private _isTeleportationFloor(mesh);
  30679. /**
  30680. * Adds a floor mesh to be used for teleportation.
  30681. * @param floorMesh the mesh to be used for teleportation.
  30682. */
  30683. addFloorMesh(floorMesh: Mesh): void;
  30684. /**
  30685. * Removes a floor mesh from being used for teleportation.
  30686. * @param floorMesh the mesh to be removed.
  30687. */
  30688. removeFloorMesh(floorMesh: Mesh): void;
  30689. /**
  30690. * Enables interactions and teleportation using the VR controllers and gaze.
  30691. * @param vrTeleportationOptions options to modify teleportation behavior.
  30692. */
  30693. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  30694. private _onNewGamepadConnected;
  30695. private _tryEnableInteractionOnController;
  30696. private _onNewGamepadDisconnected;
  30697. private _enableInteractionOnController(controller);
  30698. private _checkTeleportWithRay(stateObject, gazer);
  30699. private _checkRotate(stateObject, gazer);
  30700. private _checkTeleportBackwards(stateObject, gazer);
  30701. private _enableTeleportationOnController(controller);
  30702. private _createTeleportationCircles();
  30703. private _displayTeleportationTarget();
  30704. private _hideTeleportationTarget();
  30705. private _rotateCamera(right);
  30706. private _moveTeleportationSelectorTo(hit, gazer, ray);
  30707. private _workingVector;
  30708. private _workingQuaternion;
  30709. private _workingMatrix;
  30710. private _teleportCamera(location);
  30711. private _convertNormalToDirectionOfRay(normal, ray);
  30712. private _castRayAndSelectObject(gazer);
  30713. private _notifySelectedMeshUnselected(mesh);
  30714. /**
  30715. * Sets the color of the laser ray from the vr controllers.
  30716. * @param color new color for the ray.
  30717. */
  30718. changeLaserColor(color: Color3): void;
  30719. /**
  30720. * Sets the color of the ray from the vr headsets gaze.
  30721. * @param color new color for the ray.
  30722. */
  30723. changeGazeColor(color: Color3): void;
  30724. /**
  30725. * Exits VR and disposes of the vr experience helper
  30726. */
  30727. dispose(): void;
  30728. /**
  30729. * Gets the name of the VRExperienceHelper class
  30730. * @returns "VRExperienceHelper"
  30731. */
  30732. getClassName(): string;
  30733. }
  30734. }
  30735. declare module BABYLON {
  30736. /**
  30737. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  30738. * IMPORTANT!! The data is right-hand data.
  30739. * @export
  30740. * @interface DevicePose
  30741. */
  30742. interface DevicePose {
  30743. /**
  30744. * The position of the device, values in array are [x,y,z].
  30745. */
  30746. readonly position: Nullable<Float32Array>;
  30747. /**
  30748. * The linearVelocity of the device, values in array are [x,y,z].
  30749. */
  30750. readonly linearVelocity: Nullable<Float32Array>;
  30751. /**
  30752. * The linearAcceleration of the device, values in array are [x,y,z].
  30753. */
  30754. readonly linearAcceleration: Nullable<Float32Array>;
  30755. /**
  30756. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  30757. */
  30758. readonly orientation: Nullable<Float32Array>;
  30759. /**
  30760. * The angularVelocity of the device, values in array are [x,y,z].
  30761. */
  30762. readonly angularVelocity: Nullable<Float32Array>;
  30763. /**
  30764. * The angularAcceleration of the device, values in array are [x,y,z].
  30765. */
  30766. readonly angularAcceleration: Nullable<Float32Array>;
  30767. }
  30768. /**
  30769. * Interface representing a pose controlled object in Babylon.
  30770. * A pose controlled object has both regular pose values as well as pose values
  30771. * from an external device such as a VR head mounted display
  30772. */
  30773. interface PoseControlled {
  30774. /**
  30775. * The position of the object in babylon space.
  30776. */
  30777. position: Vector3;
  30778. /**
  30779. * The rotation quaternion of the object in babylon space.
  30780. */
  30781. rotationQuaternion: Quaternion;
  30782. /**
  30783. * The position of the device in babylon space.
  30784. */
  30785. devicePosition?: Vector3;
  30786. /**
  30787. * The rotation quaternion of the device in babylon space.
  30788. */
  30789. deviceRotationQuaternion: Quaternion;
  30790. /**
  30791. * The raw pose coming from the device.
  30792. */
  30793. rawPose: Nullable<DevicePose>;
  30794. /**
  30795. * The scale of the device to be used when translating from device space to babylon space.
  30796. */
  30797. deviceScaleFactor: number;
  30798. /**
  30799. * Updates the poseControlled values based on the input device pose.
  30800. * @param poseData the pose data to update the object with
  30801. */
  30802. updateFromDevice(poseData: DevicePose): void;
  30803. }
  30804. /**
  30805. * Set of options to customize the webVRCamera
  30806. */
  30807. interface WebVROptions {
  30808. /**
  30809. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  30810. */
  30811. trackPosition?: boolean;
  30812. /**
  30813. * Sets the scale of the vrDevice in babylon space. (default: 1)
  30814. */
  30815. positionScale?: number;
  30816. /**
  30817. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  30818. */
  30819. displayName?: string;
  30820. /**
  30821. * Should the native controller meshes be initialized. (default: true)
  30822. */
  30823. controllerMeshes?: boolean;
  30824. /**
  30825. * Creating a default HemiLight only on controllers. (default: true)
  30826. */
  30827. defaultLightingOnControllers?: boolean;
  30828. /**
  30829. * If you don't want to use the default VR button of the helper. (default: false)
  30830. */
  30831. useCustomVRButton?: boolean;
  30832. /**
  30833. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  30834. */
  30835. customVRButton?: HTMLButtonElement;
  30836. /**
  30837. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  30838. */
  30839. rayLength?: number;
  30840. /**
  30841. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  30842. */
  30843. defaultHeight?: number;
  30844. }
  30845. /**
  30846. * This represents a WebVR camera.
  30847. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  30848. * @example http://doc.babylonjs.com/how_to/webvr_camera
  30849. */
  30850. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  30851. private webVROptions;
  30852. /**
  30853. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  30854. */
  30855. _vrDevice: any;
  30856. /**
  30857. * The rawPose of the vrDevice.
  30858. */
  30859. rawPose: Nullable<DevicePose>;
  30860. private _onVREnabled;
  30861. private _specsVersion;
  30862. private _attached;
  30863. private _frameData;
  30864. protected _descendants: Array<Node>;
  30865. private _deviceRoomPosition;
  30866. private _deviceRoomRotationQuaternion;
  30867. private _standingMatrix;
  30868. /**
  30869. * Represents device position in babylon space.
  30870. */
  30871. devicePosition: Vector3;
  30872. /**
  30873. * Represents device rotation in babylon space.
  30874. */
  30875. deviceRotationQuaternion: Quaternion;
  30876. /**
  30877. * The scale of the device to be used when translating from device space to babylon space.
  30878. */
  30879. deviceScaleFactor: number;
  30880. private _deviceToWorld;
  30881. private _worldToDevice;
  30882. /**
  30883. * References to the webVR controllers for the vrDevice.
  30884. */
  30885. controllers: Array<WebVRController>;
  30886. /**
  30887. * Emits an event when a controller is attached.
  30888. */
  30889. onControllersAttachedObservable: Observable<WebVRController[]>;
  30890. /**
  30891. * Emits an event when a controller's mesh has been loaded;
  30892. */
  30893. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30894. /**
  30895. * If the rig cameras be used as parent instead of this camera.
  30896. */
  30897. rigParenting: boolean;
  30898. private _lightOnControllers;
  30899. private _defaultHeight?;
  30900. /**
  30901. * Instantiates a WebVRFreeCamera.
  30902. * @param name The name of the WebVRFreeCamera
  30903. * @param position The starting anchor position for the camera
  30904. * @param scene The scene the camera belongs to
  30905. * @param webVROptions a set of customizable options for the webVRCamera
  30906. */
  30907. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  30908. /**
  30909. * Gets the device distance from the ground in meters.
  30910. * @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.
  30911. */
  30912. deviceDistanceToRoomGround(): number;
  30913. /**
  30914. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30915. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  30916. */
  30917. useStandingMatrix(callback?: (bool: boolean) => void): void;
  30918. /**
  30919. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30920. * @returns A promise with a boolean set to if the standing matrix is supported.
  30921. */
  30922. useStandingMatrixAsync(): Promise<boolean>;
  30923. /**
  30924. * Disposes the camera
  30925. */
  30926. dispose(): void;
  30927. /**
  30928. * Gets a vrController by name.
  30929. * @param name The name of the controller to retreive
  30930. * @returns the controller matching the name specified or null if not found
  30931. */
  30932. getControllerByName(name: string): Nullable<WebVRController>;
  30933. private _leftController;
  30934. /**
  30935. * The controller corrisponding to the users left hand.
  30936. */
  30937. readonly leftController: Nullable<WebVRController>;
  30938. private _rightController;
  30939. /**
  30940. * The controller corrisponding to the users right hand.
  30941. */
  30942. readonly rightController: Nullable<WebVRController>;
  30943. /**
  30944. * Casts a ray forward from the vrCamera's gaze.
  30945. * @param length Length of the ray (default: 100)
  30946. * @returns the ray corrisponding to the gaze
  30947. */
  30948. getForwardRay(length?: number): Ray;
  30949. /**
  30950. * Updates the camera based on device's frame data
  30951. */
  30952. _checkInputs(): void;
  30953. /**
  30954. * Updates the poseControlled values based on the input device pose.
  30955. * @param poseData Pose coming from the device
  30956. */
  30957. updateFromDevice(poseData: DevicePose): void;
  30958. /**
  30959. * WebVR's attach control will start broadcasting frames to the device.
  30960. * Note that in certain browsers (chrome for example) this function must be called
  30961. * within a user-interaction callback. Example:
  30962. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  30963. *
  30964. * @param element html element to attach the vrDevice to
  30965. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  30966. */
  30967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30968. /**
  30969. * Detaches the camera from the html element and disables VR
  30970. *
  30971. * @param element html element to detach from
  30972. */
  30973. detachControl(element: HTMLElement): void;
  30974. /**
  30975. * @returns the name of this class
  30976. */
  30977. getClassName(): string;
  30978. /**
  30979. * Calls resetPose on the vrDisplay
  30980. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  30981. */
  30982. resetToCurrentRotation(): void;
  30983. /**
  30984. * Updates the rig cameras (left and right eye)
  30985. */
  30986. _updateRigCameras(): void;
  30987. private _workingVector;
  30988. private _oneVector;
  30989. private _workingMatrix;
  30990. private updateCacheCalled;
  30991. /**
  30992. * Updates the cached values of the camera
  30993. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  30994. */
  30995. _updateCache(ignoreParentClass?: boolean): void;
  30996. /**
  30997. * Updates the current device position and rotation in the babylon world
  30998. */
  30999. update(): void;
  31000. /**
  31001. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  31002. * @returns an identity matrix
  31003. */
  31004. _getViewMatrix(): Matrix;
  31005. /**
  31006. * This function is called by the two RIG cameras.
  31007. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  31008. */
  31009. protected _getWebVRViewMatrix(): Matrix;
  31010. protected _getWebVRProjectionMatrix(): Matrix;
  31011. private _onGamepadConnectedObserver;
  31012. private _onGamepadDisconnectedObserver;
  31013. /**
  31014. * Initializes the controllers and their meshes
  31015. */
  31016. initControllers(): void;
  31017. }
  31018. }
  31019. declare module BABYLON {
  31020. interface IOctreeContainer<T> {
  31021. blocks: Array<OctreeBlock<T>>;
  31022. }
  31023. class Octree<T> {
  31024. maxDepth: number;
  31025. blocks: Array<OctreeBlock<T>>;
  31026. dynamicContent: T[];
  31027. private _maxBlockCapacity;
  31028. private _selectionContent;
  31029. private _creationFunc;
  31030. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  31031. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  31032. addMesh(entry: T): void;
  31033. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  31034. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  31035. intersectsRay(ray: Ray): SmartArray<T>;
  31036. 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;
  31037. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  31038. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  31039. }
  31040. }
  31041. declare module BABYLON {
  31042. class OctreeBlock<T> {
  31043. entries: T[];
  31044. blocks: Array<OctreeBlock<T>>;
  31045. private _depth;
  31046. private _maxDepth;
  31047. private _capacity;
  31048. private _minPoint;
  31049. private _maxPoint;
  31050. private _boundingVectors;
  31051. private _creationFunc;
  31052. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  31053. readonly capacity: number;
  31054. readonly minPoint: Vector3;
  31055. readonly maxPoint: Vector3;
  31056. addEntry(entry: T): void;
  31057. addEntries(entries: T[]): void;
  31058. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31059. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31060. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  31061. createInnerBlocks(): void;
  31062. }
  31063. }
  31064. declare module BABYLON {
  31065. /**
  31066. * Google Daydream controller
  31067. */
  31068. class DaydreamController extends WebVRController {
  31069. /**
  31070. * Base Url for the controller model.
  31071. */
  31072. static MODEL_BASE_URL: string;
  31073. /**
  31074. * File name for the controller model.
  31075. */
  31076. static MODEL_FILENAME: string;
  31077. /**
  31078. * Gamepad Id prefix used to identify Daydream Controller.
  31079. */
  31080. static readonly GAMEPAD_ID_PREFIX: string;
  31081. /**
  31082. * Creates a new DaydreamController from a gamepad
  31083. * @param vrGamepad the gamepad that the controller should be created from
  31084. */
  31085. constructor(vrGamepad: any);
  31086. /**
  31087. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31088. * @param scene scene in which to add meshes
  31089. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31090. */
  31091. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31092. /**
  31093. * Called once for each button that changed state since the last frame
  31094. * @param buttonIdx Which button index changed
  31095. * @param state New state of the button
  31096. * @param changes Which properties on the state changed since last frame
  31097. */
  31098. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31099. }
  31100. }
  31101. declare module BABYLON {
  31102. /**
  31103. * Gear VR Controller
  31104. */
  31105. class GearVRController extends WebVRController {
  31106. /**
  31107. * Base Url for the controller model.
  31108. */
  31109. static MODEL_BASE_URL: string;
  31110. /**
  31111. * File name for the controller model.
  31112. */
  31113. static MODEL_FILENAME: string;
  31114. /**
  31115. * Gamepad Id prefix used to identify this controller.
  31116. */
  31117. static readonly GAMEPAD_ID_PREFIX: string;
  31118. private readonly _buttonIndexToObservableNameMap;
  31119. /**
  31120. * Creates a new GearVRController from a gamepad
  31121. * @param vrGamepad the gamepad that the controller should be created from
  31122. */
  31123. constructor(vrGamepad: any);
  31124. /**
  31125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31126. * @param scene scene in which to add meshes
  31127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31128. */
  31129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31130. /**
  31131. * Called once for each button that changed state since the last frame
  31132. * @param buttonIdx Which button index changed
  31133. * @param state New state of the button
  31134. * @param changes Which properties on the state changed since last frame
  31135. */
  31136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31137. }
  31138. }
  31139. declare module BABYLON {
  31140. /**
  31141. * Generic Controller
  31142. */
  31143. class GenericController extends WebVRController {
  31144. /**
  31145. * Base Url for the controller model.
  31146. */
  31147. static readonly MODEL_BASE_URL: string;
  31148. /**
  31149. * File name for the controller model.
  31150. */
  31151. static readonly MODEL_FILENAME: string;
  31152. /**
  31153. * Creates a new GenericController from a gamepad
  31154. * @param vrGamepad the gamepad that the controller should be created from
  31155. */
  31156. constructor(vrGamepad: any);
  31157. /**
  31158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31159. * @param scene scene in which to add meshes
  31160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31161. */
  31162. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31163. /**
  31164. * Called once for each button that changed state since the last frame
  31165. * @param buttonIdx Which button index changed
  31166. * @param state New state of the button
  31167. * @param changes Which properties on the state changed since last frame
  31168. */
  31169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31170. }
  31171. }
  31172. declare module BABYLON {
  31173. /**
  31174. * Oculus Touch Controller
  31175. */
  31176. class OculusTouchController extends WebVRController {
  31177. /**
  31178. * Base Url for the controller model.
  31179. */
  31180. static MODEL_BASE_URL: string;
  31181. /**
  31182. * File name for the left controller model.
  31183. */
  31184. static MODEL_LEFT_FILENAME: string;
  31185. /**
  31186. * File name for the right controller model.
  31187. */
  31188. static MODEL_RIGHT_FILENAME: string;
  31189. /**
  31190. * Fired when the secondary trigger on this controller is modified
  31191. */
  31192. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31193. /**
  31194. * Fired when the thumb rest on this controller is modified
  31195. */
  31196. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  31197. /**
  31198. * Creates a new OculusTouchController from a gamepad
  31199. * @param vrGamepad the gamepad that the controller should be created from
  31200. */
  31201. constructor(vrGamepad: any);
  31202. /**
  31203. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31204. * @param scene scene in which to add meshes
  31205. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31206. */
  31207. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31208. /**
  31209. * Fired when the A button on this controller is modified
  31210. */
  31211. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31212. /**
  31213. * Fired when the B button on this controller is modified
  31214. */
  31215. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31216. /**
  31217. * Fired when the X button on this controller is modified
  31218. */
  31219. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31220. /**
  31221. * Fired when the Y button on this controller is modified
  31222. */
  31223. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31224. /**
  31225. * Called once for each button that changed state since the last frame
  31226. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  31227. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  31228. * 2) secondary trigger (same)
  31229. * 3) A (right) X (left), touch, pressed = value
  31230. * 4) B / Y
  31231. * 5) thumb rest
  31232. * @param buttonIdx Which button index changed
  31233. * @param state New state of the button
  31234. * @param changes Which properties on the state changed since last frame
  31235. */
  31236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31237. }
  31238. }
  31239. declare module BABYLON {
  31240. /**
  31241. * Defines the types of pose enabled controllers that are supported
  31242. */
  31243. enum PoseEnabledControllerType {
  31244. /**
  31245. * HTC Vive
  31246. */
  31247. VIVE = 0,
  31248. /**
  31249. * Oculus Rift
  31250. */
  31251. OCULUS = 1,
  31252. /**
  31253. * Windows mixed reality
  31254. */
  31255. WINDOWS = 2,
  31256. /**
  31257. * Samsung gear VR
  31258. */
  31259. GEAR_VR = 3,
  31260. /**
  31261. * Google Daydream
  31262. */
  31263. DAYDREAM = 4,
  31264. /**
  31265. * Generic
  31266. */
  31267. GENERIC = 5,
  31268. }
  31269. /**
  31270. * Defines the MutableGamepadButton interface for the state of a gamepad button
  31271. */
  31272. interface MutableGamepadButton {
  31273. /**
  31274. * Value of the button/trigger
  31275. */
  31276. value: number;
  31277. /**
  31278. * If the button/trigger is currently touched
  31279. */
  31280. touched: boolean;
  31281. /**
  31282. * If the button/trigger is currently pressed
  31283. */
  31284. pressed: boolean;
  31285. }
  31286. /**
  31287. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  31288. * @hidden
  31289. */
  31290. interface ExtendedGamepadButton extends GamepadButton {
  31291. /**
  31292. * If the button/trigger is currently pressed
  31293. */
  31294. readonly pressed: boolean;
  31295. /**
  31296. * If the button/trigger is currently touched
  31297. */
  31298. readonly touched: boolean;
  31299. /**
  31300. * Value of the button/trigger
  31301. */
  31302. readonly value: number;
  31303. }
  31304. /**
  31305. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31306. */
  31307. class PoseEnabledControllerHelper {
  31308. /**
  31309. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31310. * @param vrGamepad the gamepad to initialized
  31311. * @returns a vr controller of the type the gamepad identified as
  31312. */
  31313. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  31314. }
  31315. /**
  31316. * Defines the PoseEnabledController object that contains state of a vr capable controller
  31317. */
  31318. class PoseEnabledController extends Gamepad implements PoseControlled {
  31319. private _deviceRoomPosition;
  31320. private _deviceRoomRotationQuaternion;
  31321. /**
  31322. * The device position in babylon space
  31323. */
  31324. devicePosition: Vector3;
  31325. /**
  31326. * The device rotation in babylon space
  31327. */
  31328. deviceRotationQuaternion: Quaternion;
  31329. /**
  31330. * The scale factor of the device in babylon space
  31331. */
  31332. deviceScaleFactor: number;
  31333. /**
  31334. * (Likely devicePosition should be used instead) The device position in its room space
  31335. */
  31336. position: Vector3;
  31337. /**
  31338. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  31339. */
  31340. rotationQuaternion: Quaternion;
  31341. /**
  31342. * The type of controller (Eg. Windows mixed reality)
  31343. */
  31344. controllerType: PoseEnabledControllerType;
  31345. protected _calculatedPosition: Vector3;
  31346. private _calculatedRotation;
  31347. /**
  31348. * The raw pose from the device
  31349. */
  31350. rawPose: DevicePose;
  31351. /**
  31352. * Internal, the mesh attached to the controller
  31353. */
  31354. _mesh: Nullable<AbstractMesh>;
  31355. private _poseControlledCamera;
  31356. private _leftHandSystemQuaternion;
  31357. /**
  31358. * Internal, matrix used to convert room space to babylon space
  31359. */
  31360. _deviceToWorld: Matrix;
  31361. /**
  31362. * Node to be used when casting a ray from the controller
  31363. */
  31364. _pointingPoseNode: Nullable<AbstractMesh>;
  31365. /**
  31366. * Name of the child mesh that can be used to cast a ray from the controller
  31367. */
  31368. static readonly POINTING_POSE: string;
  31369. /**
  31370. * Creates a new PoseEnabledController from a gamepad
  31371. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  31372. */
  31373. constructor(browserGamepad: any);
  31374. private _workingMatrix;
  31375. /**
  31376. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  31377. */
  31378. update(): void;
  31379. /**
  31380. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  31381. * @param poseData raw pose fromthe device
  31382. */
  31383. updateFromDevice(poseData: DevicePose): void;
  31384. /**
  31385. * @hidden
  31386. */
  31387. _meshAttachedObservable: Observable<AbstractMesh>;
  31388. /**
  31389. * Attaches a mesh to the controller
  31390. * @param mesh the mesh to be attached
  31391. */
  31392. attachToMesh(mesh: AbstractMesh): void;
  31393. /**
  31394. * Attaches the controllers mesh to a camera
  31395. * @param camera the camera the mesh should be attached to
  31396. */
  31397. attachToPoseControlledCamera(camera: TargetCamera): void;
  31398. /**
  31399. * Disposes of the controller
  31400. */
  31401. dispose(): void;
  31402. /**
  31403. * The mesh that is attached to the controller
  31404. */
  31405. readonly mesh: Nullable<AbstractMesh>;
  31406. /**
  31407. * Gets the ray of the controller in the direction the controller is pointing
  31408. * @param length the length the resulting ray should be
  31409. * @returns a ray in the direction the controller is pointing
  31410. */
  31411. getForwardRay(length?: number): Ray;
  31412. }
  31413. }
  31414. declare module BABYLON {
  31415. /**
  31416. * Vive Controller
  31417. */
  31418. class ViveController extends WebVRController {
  31419. /**
  31420. * Base Url for the controller model.
  31421. */
  31422. static MODEL_BASE_URL: string;
  31423. /**
  31424. * File name for the controller model.
  31425. */
  31426. static MODEL_FILENAME: string;
  31427. /**
  31428. * Creates a new ViveController from a gamepad
  31429. * @param vrGamepad the gamepad that the controller should be created from
  31430. */
  31431. constructor(vrGamepad: any);
  31432. /**
  31433. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31434. * @param scene scene in which to add meshes
  31435. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31436. */
  31437. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31438. /**
  31439. * Fired when the left button on this controller is modified
  31440. */
  31441. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31442. /**
  31443. * Fired when the right button on this controller is modified
  31444. */
  31445. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31446. /**
  31447. * Fired when the menu button on this controller is modified
  31448. */
  31449. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31450. /**
  31451. * Called once for each button that changed state since the last frame
  31452. * Vive mapping:
  31453. * 0: touchpad
  31454. * 1: trigger
  31455. * 2: left AND right buttons
  31456. * 3: menu button
  31457. * @param buttonIdx Which button index changed
  31458. * @param state New state of the button
  31459. * @param changes Which properties on the state changed since last frame
  31460. */
  31461. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31462. }
  31463. }
  31464. declare module BABYLON {
  31465. /**
  31466. * Defines the WebVRController object that represents controllers tracked in 3D space
  31467. */
  31468. abstract class WebVRController extends PoseEnabledController {
  31469. /**
  31470. * Internal, the default controller model for the controller
  31471. */
  31472. protected _defaultModel: AbstractMesh;
  31473. /**
  31474. * Fired when the trigger state has changed
  31475. */
  31476. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31477. /**
  31478. * Fired when the main button state has changed
  31479. */
  31480. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31481. /**
  31482. * Fired when the secondary button state has changed
  31483. */
  31484. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31485. /**
  31486. * Fired when the pad state has changed
  31487. */
  31488. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  31489. /**
  31490. * Fired when controllers stick values have changed
  31491. */
  31492. onPadValuesChangedObservable: Observable<StickValues>;
  31493. /**
  31494. * Array of button availible on the controller
  31495. */
  31496. protected _buttons: Array<MutableGamepadButton>;
  31497. private _onButtonStateChange;
  31498. /**
  31499. * Fired when a controller button's state has changed
  31500. * @param callback the callback containing the button that was modified
  31501. */
  31502. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  31503. /**
  31504. * X and Y axis corrisponding to the controllers joystick
  31505. */
  31506. pad: StickValues;
  31507. /**
  31508. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  31509. */
  31510. hand: string;
  31511. /**
  31512. * The default controller model for the controller
  31513. */
  31514. readonly defaultModel: AbstractMesh;
  31515. /**
  31516. * Creates a new WebVRController from a gamepad
  31517. * @param vrGamepad the gamepad that the WebVRController should be created from
  31518. */
  31519. constructor(vrGamepad: any);
  31520. /**
  31521. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  31522. */
  31523. update(): void;
  31524. /**
  31525. * Function to be called when a button is modified
  31526. */
  31527. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31528. /**
  31529. * Loads a mesh and attaches it to the controller
  31530. * @param scene the scene the mesh should be added to
  31531. * @param meshLoaded callback for when the mesh has been loaded
  31532. */
  31533. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31534. private _setButtonValue(newState, currentState, buttonIndex);
  31535. private _changes;
  31536. private _checkChanges(newState, currentState);
  31537. /**
  31538. * Disposes of th webVRCOntroller
  31539. */
  31540. dispose(): void;
  31541. }
  31542. }
  31543. declare module BABYLON {
  31544. /**
  31545. * Defines the WindowsMotionController object that the state of the windows motion controller
  31546. */
  31547. class WindowsMotionController extends WebVRController {
  31548. /**
  31549. * The base url used to load the left and right controller models
  31550. */
  31551. static MODEL_BASE_URL: string;
  31552. /**
  31553. * The name of the left controller model file
  31554. */
  31555. static MODEL_LEFT_FILENAME: string;
  31556. /**
  31557. * The name of the right controller model file
  31558. */
  31559. static MODEL_RIGHT_FILENAME: string;
  31560. /**
  31561. * The controller name prefix for this controller type
  31562. */
  31563. static readonly GAMEPAD_ID_PREFIX: string;
  31564. /**
  31565. * The controller id pattern for this controller type
  31566. */
  31567. private static readonly GAMEPAD_ID_PATTERN;
  31568. private _loadedMeshInfo;
  31569. private readonly _mapping;
  31570. /**
  31571. * Fired when the trackpad on this controller is clicked
  31572. */
  31573. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  31574. /**
  31575. * Fired when the trackpad on this controller is modified
  31576. */
  31577. onTrackpadValuesChangedObservable: Observable<StickValues>;
  31578. /**
  31579. * The current x and y values of this controller's trackpad
  31580. */
  31581. trackpad: StickValues;
  31582. /**
  31583. * Creates a new WindowsMotionController from a gamepad
  31584. * @param vrGamepad the gamepad that the controller should be created from
  31585. */
  31586. constructor(vrGamepad: any);
  31587. /**
  31588. * Fired when the trigger on this controller is modified
  31589. */
  31590. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31591. /**
  31592. * Fired when the menu button on this controller is modified
  31593. */
  31594. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31595. /**
  31596. * Fired when the grip button on this controller is modified
  31597. */
  31598. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31599. /**
  31600. * Fired when the thumbstick button on this controller is modified
  31601. */
  31602. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31603. /**
  31604. * Fired when the touchpad button on this controller is modified
  31605. */
  31606. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31607. /**
  31608. * Fired when the touchpad values on this controller are modified
  31609. */
  31610. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  31611. private _updateTrackpad();
  31612. /**
  31613. * Called once per frame by the engine.
  31614. */
  31615. update(): void;
  31616. /**
  31617. * Called once for each button that changed state since the last frame
  31618. * @param buttonIdx Which button index changed
  31619. * @param state New state of the button
  31620. * @param changes Which properties on the state changed since last frame
  31621. */
  31622. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31623. /**
  31624. * Moves the buttons on the controller mesh based on their current state
  31625. * @param buttonName the name of the button to move
  31626. * @param buttonValue the value of the button which determines the buttons new position
  31627. */
  31628. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  31629. /**
  31630. * Moves the axis on the controller mesh based on its current state
  31631. * @param axis the index of the axis
  31632. * @param axisValue the value of the axis which determines the meshes new position
  31633. * @hidden
  31634. */
  31635. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  31636. /**
  31637. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31638. * @param scene scene in which to add meshes
  31639. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31640. */
  31641. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  31642. /**
  31643. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  31644. * can be transformed by button presses and axes values, based on this._mapping.
  31645. *
  31646. * @param scene scene in which the meshes exist
  31647. * @param meshes list of meshes that make up the controller model to process
  31648. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  31649. */
  31650. private processModel(scene, meshes);
  31651. private createMeshInfo(rootNode);
  31652. /**
  31653. * Gets the ray of the controller in the direction the controller is pointing
  31654. * @param length the length the resulting ray should be
  31655. * @returns a ray in the direction the controller is pointing
  31656. */
  31657. getForwardRay(length?: number): Ray;
  31658. /**
  31659. * Disposes of the controller
  31660. */
  31661. dispose(): void;
  31662. }
  31663. }
  31664. declare module BABYLON {
  31665. }
  31666. declare module BABYLON {
  31667. /**
  31668. * Interface to implement to create a shadow generator compatible with BJS.
  31669. */
  31670. interface IShadowGenerator {
  31671. /**
  31672. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31673. * @returns The render target texture if present otherwise, null
  31674. */
  31675. getShadowMap(): Nullable<RenderTargetTexture>;
  31676. /**
  31677. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31678. * @returns The render target texture if the shadow map is present otherwise, null
  31679. */
  31680. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31681. /**
  31682. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31683. * @param subMesh The submesh we want to render in the shadow map
  31684. * @param useInstances Defines wether will draw in the map using instances
  31685. * @returns true if ready otherwise, false
  31686. */
  31687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31688. /**
  31689. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31690. * @param defines Defines of the material we want to update
  31691. * @param lightIndex Index of the light in the enabled light list of the material
  31692. */
  31693. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  31694. /**
  31695. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31696. * defined in the generator but impacting the effect).
  31697. * It implies the unifroms available on the materials are the standard BJS ones.
  31698. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31699. * @param effect The effect we are binfing the information for
  31700. */
  31701. bindShadowLight(lightIndex: string, effect: Effect): void;
  31702. /**
  31703. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31704. * (eq to shadow prjection matrix * light transform matrix)
  31705. * @returns The transform matrix used to create the shadow map
  31706. */
  31707. getTransformMatrix(): Matrix;
  31708. /**
  31709. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31710. * Cube and 2D textures for instance.
  31711. */
  31712. recreateShadowMap(): void;
  31713. /**
  31714. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31715. * @param onCompiled Callback triggered at the and of the effects compilation
  31716. * @param options Sets of optional options forcing the compilation with different modes
  31717. */
  31718. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31719. useInstances: boolean;
  31720. }>): void;
  31721. /**
  31722. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31723. * @param options Sets of optional options forcing the compilation with different modes
  31724. * @returns A promise that resolves when the compilation completes
  31725. */
  31726. forceCompilationAsync(options?: Partial<{
  31727. useInstances: boolean;
  31728. }>): Promise<void>;
  31729. /**
  31730. * Serializes the shadow generator setup to a json object.
  31731. * @returns The serialized JSON object
  31732. */
  31733. serialize(): any;
  31734. /**
  31735. * Disposes the Shadow map and related Textures and effects.
  31736. */
  31737. dispose(): void;
  31738. }
  31739. /**
  31740. * Default implementation IShadowGenerator.
  31741. * This is the main object responsible of generating shadows in the framework.
  31742. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  31743. */
  31744. class ShadowGenerator implements IShadowGenerator {
  31745. /**
  31746. * Shadow generator mode None: no filtering applied.
  31747. */
  31748. static readonly FILTER_NONE: number;
  31749. /**
  31750. * Shadow generator mode ESM: Exponential Shadow Mapping.
  31751. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31752. */
  31753. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  31754. /**
  31755. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  31756. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  31757. */
  31758. static readonly FILTER_POISSONSAMPLING: number;
  31759. /**
  31760. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  31761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31762. */
  31763. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  31764. /**
  31765. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  31766. * edge artifacts on steep falloff.
  31767. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31768. */
  31769. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31770. /**
  31771. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  31772. * edge artifacts on steep falloff.
  31773. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31774. */
  31775. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  31776. /**
  31777. * Shadow generator mode PCF: Percentage Closer Filtering
  31778. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31779. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  31780. */
  31781. static readonly FILTER_PCF: number;
  31782. /**
  31783. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  31784. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31785. * Contact Hardening
  31786. */
  31787. static readonly FILTER_PCSS: number;
  31788. /**
  31789. * Reserved for PCF and PCSS
  31790. * Highest Quality.
  31791. *
  31792. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  31793. *
  31794. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  31795. */
  31796. static readonly QUALITY_HIGH: number;
  31797. /**
  31798. * Reserved for PCF and PCSS
  31799. * Good tradeoff for quality/perf cross devices
  31800. *
  31801. * Execute PCF on a 3*3 kernel.
  31802. *
  31803. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  31804. */
  31805. static readonly QUALITY_MEDIUM: number;
  31806. /**
  31807. * Reserved for PCF and PCSS
  31808. * The lowest quality but the fastest.
  31809. *
  31810. * Execute PCF on a 1*1 kernel.
  31811. *
  31812. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31813. */
  31814. static readonly QUALITY_LOW: number;
  31815. private _bias;
  31816. /**
  31817. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31818. */
  31819. /**
  31820. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31821. */
  31822. bias: number;
  31823. private _normalBias;
  31824. /**
  31825. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31826. */
  31827. /**
  31828. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31829. */
  31830. normalBias: number;
  31831. private _blurBoxOffset;
  31832. /**
  31833. * Gets the blur box offset: offset applied during the blur pass.
  31834. * Only usefull if useKernelBlur = false
  31835. */
  31836. /**
  31837. * Sets the blur box offset: offset applied during the blur pass.
  31838. * Only usefull if useKernelBlur = false
  31839. */
  31840. blurBoxOffset: number;
  31841. private _blurScale;
  31842. /**
  31843. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31844. * 2 means half of the size.
  31845. */
  31846. /**
  31847. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31848. * 2 means half of the size.
  31849. */
  31850. blurScale: number;
  31851. private _blurKernel;
  31852. /**
  31853. * Gets the blur kernel: kernel size of the blur pass.
  31854. * Only usefull if useKernelBlur = true
  31855. */
  31856. /**
  31857. * Sets the blur kernel: kernel size of the blur pass.
  31858. * Only usefull if useKernelBlur = true
  31859. */
  31860. blurKernel: number;
  31861. private _useKernelBlur;
  31862. /**
  31863. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31864. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31865. */
  31866. /**
  31867. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31868. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31869. */
  31870. useKernelBlur: boolean;
  31871. private _depthScale;
  31872. /**
  31873. * Gets the depth scale used in ESM mode.
  31874. */
  31875. /**
  31876. * Sets the depth scale used in ESM mode.
  31877. * This can override the scale stored on the light.
  31878. */
  31879. depthScale: number;
  31880. private _filter;
  31881. /**
  31882. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31883. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31884. */
  31885. /**
  31886. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31887. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31888. */
  31889. filter: number;
  31890. /**
  31891. * Gets if the current filter is set to Poisson Sampling.
  31892. */
  31893. /**
  31894. * Sets the current filter to Poisson Sampling.
  31895. */
  31896. usePoissonSampling: boolean;
  31897. /**
  31898. * Gets if the current filter is set to VSM.
  31899. * DEPRECATED. Should use useExponentialShadowMap instead.
  31900. */
  31901. /**
  31902. * Sets the current filter is to VSM.
  31903. * DEPRECATED. Should use useExponentialShadowMap instead.
  31904. */
  31905. useVarianceShadowMap: boolean;
  31906. /**
  31907. * Gets if the current filter is set to blurred VSM.
  31908. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31909. */
  31910. /**
  31911. * Sets the current filter is to blurred VSM.
  31912. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31913. */
  31914. useBlurVarianceShadowMap: boolean;
  31915. /**
  31916. * Gets if the current filter is set to ESM.
  31917. */
  31918. /**
  31919. * Sets the current filter is to ESM.
  31920. */
  31921. useExponentialShadowMap: boolean;
  31922. /**
  31923. * Gets if the current filter is set to filtered ESM.
  31924. */
  31925. /**
  31926. * Gets if the current filter is set to filtered ESM.
  31927. */
  31928. useBlurExponentialShadowMap: boolean;
  31929. /**
  31930. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31931. * exponential to prevent steep falloff artifacts).
  31932. */
  31933. /**
  31934. * Sets the current filter to "close ESM" (using the inverse of the
  31935. * exponential to prevent steep falloff artifacts).
  31936. */
  31937. useCloseExponentialShadowMap: boolean;
  31938. /**
  31939. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31940. * exponential to prevent steep falloff artifacts).
  31941. */
  31942. /**
  31943. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31944. * exponential to prevent steep falloff artifacts).
  31945. */
  31946. useBlurCloseExponentialShadowMap: boolean;
  31947. /**
  31948. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31949. */
  31950. /**
  31951. * Sets the current filter to "PCF" (percentage closer filtering).
  31952. */
  31953. usePercentageCloserFiltering: boolean;
  31954. private _filteringQuality;
  31955. /**
  31956. * Gets the PCF or PCSS Quality.
  31957. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31958. */
  31959. /**
  31960. * Sets the PCF or PCSS Quality.
  31961. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31962. */
  31963. filteringQuality: number;
  31964. /**
  31965. * Gets if the current filter is set to "PCSS" (contact hardening).
  31966. */
  31967. /**
  31968. * Sets the current filter to "PCSS" (contact hardening).
  31969. */
  31970. useContactHardeningShadow: boolean;
  31971. private _contactHardeningLightSizeUVRatio;
  31972. /**
  31973. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31974. * Using a ratio helps keeping shape stability independently of the map size.
  31975. *
  31976. * It does not account for the light projection as it was having too much
  31977. * instability during the light setup or during light position changes.
  31978. *
  31979. * Only valid if useContactHardeningShadow is true.
  31980. */
  31981. /**
  31982. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31983. * Using a ratio helps keeping shape stability independently of the map size.
  31984. *
  31985. * It does not account for the light projection as it was having too much
  31986. * instability during the light setup or during light position changes.
  31987. *
  31988. * Only valid if useContactHardeningShadow is true.
  31989. */
  31990. contactHardeningLightSizeUVRatio: number;
  31991. private _darkness;
  31992. /**
  31993. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31994. * 0 means strongest and 1 would means no shadow.
  31995. * @returns the darkness.
  31996. */
  31997. getDarkness(): number;
  31998. /**
  31999. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  32000. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  32001. * @returns the shadow generator allowing fluent coding.
  32002. */
  32003. setDarkness(darkness: number): ShadowGenerator;
  32004. private _transparencyShadow;
  32005. /**
  32006. * Sets the ability to have transparent shadow (boolean).
  32007. * @param transparent True if transparent else False
  32008. * @returns the shadow generator allowing fluent coding
  32009. */
  32010. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  32011. private _shadowMap;
  32012. private _shadowMap2;
  32013. /**
  32014. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  32015. * @returns The render target texture if present otherwise, null
  32016. */
  32017. getShadowMap(): Nullable<RenderTargetTexture>;
  32018. /**
  32019. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  32020. * @returns The render target texture if the shadow map is present otherwise, null
  32021. */
  32022. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  32023. /**
  32024. * Helper function to add a mesh and its descendants to the list of shadow casters.
  32025. * @param mesh Mesh to add
  32026. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  32027. * @returns the Shadow Generator itself
  32028. */
  32029. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32030. /**
  32031. * Helper function to remove a mesh and its descendants from the list of shadow casters
  32032. * @param mesh Mesh to remove
  32033. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  32034. * @returns the Shadow Generator itself
  32035. */
  32036. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32037. /**
  32038. * Controls the extent to which the shadows fade out at the edge of the frustum
  32039. * Used only by directionals and spots
  32040. */
  32041. frustumEdgeFalloff: number;
  32042. private _light;
  32043. /**
  32044. * Returns the associated light object.
  32045. * @returns the light generating the shadow
  32046. */
  32047. getLight(): IShadowLight;
  32048. /**
  32049. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  32050. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  32051. * It might on the other hand introduce peter panning.
  32052. */
  32053. forceBackFacesOnly: boolean;
  32054. private _scene;
  32055. private _lightDirection;
  32056. private _effect;
  32057. private _viewMatrix;
  32058. private _projectionMatrix;
  32059. private _transformMatrix;
  32060. private _cachedPosition;
  32061. private _cachedDirection;
  32062. private _cachedDefines;
  32063. private _currentRenderID;
  32064. private _boxBlurPostprocess;
  32065. private _kernelBlurXPostprocess;
  32066. private _kernelBlurYPostprocess;
  32067. private _blurPostProcesses;
  32068. private _mapSize;
  32069. private _currentFaceIndex;
  32070. private _currentFaceIndexCache;
  32071. private _textureType;
  32072. private _defaultTextureMatrix;
  32073. /**
  32074. * Creates a ShadowGenerator object.
  32075. * A ShadowGenerator is the required tool to use the shadows.
  32076. * Each light casting shadows needs to use its own ShadowGenerator.
  32077. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  32078. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  32079. * @param light The light object generating the shadows.
  32080. * @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.
  32081. */
  32082. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  32083. private _initializeGenerator();
  32084. private _initializeShadowMap();
  32085. private _initializeBlurRTTAndPostProcesses();
  32086. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  32087. private _renderSubMeshForShadowMap(subMesh);
  32088. private _applyFilterValues();
  32089. /**
  32090. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32091. * @param onCompiled Callback triggered at the and of the effects compilation
  32092. * @param options Sets of optional options forcing the compilation with different modes
  32093. */
  32094. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  32095. useInstances: boolean;
  32096. }>): void;
  32097. /**
  32098. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32099. * @param options Sets of optional options forcing the compilation with different modes
  32100. * @returns A promise that resolves when the compilation completes
  32101. */
  32102. forceCompilationAsync(options?: Partial<{
  32103. useInstances: boolean;
  32104. }>): Promise<void>;
  32105. /**
  32106. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  32107. * @param subMesh The submesh we want to render in the shadow map
  32108. * @param useInstances Defines wether will draw in the map using instances
  32109. * @returns true if ready otherwise, false
  32110. */
  32111. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32112. /**
  32113. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  32114. * @param defines Defines of the material we want to update
  32115. * @param lightIndex Index of the light in the enabled light list of the material
  32116. */
  32117. prepareDefines(defines: any, lightIndex: number): void;
  32118. /**
  32119. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  32120. * defined in the generator but impacting the effect).
  32121. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  32122. * @param effect The effect we are binfing the information for
  32123. */
  32124. bindShadowLight(lightIndex: string, effect: Effect): void;
  32125. /**
  32126. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  32127. * (eq to shadow prjection matrix * light transform matrix)
  32128. * @returns The transform matrix used to create the shadow map
  32129. */
  32130. getTransformMatrix(): Matrix;
  32131. /**
  32132. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  32133. * Cube and 2D textures for instance.
  32134. */
  32135. recreateShadowMap(): void;
  32136. private _disposeBlurPostProcesses();
  32137. private _disposeRTTandPostProcesses();
  32138. /**
  32139. * Disposes the ShadowGenerator.
  32140. * Returns nothing.
  32141. */
  32142. dispose(): void;
  32143. /**
  32144. * Serializes the shadow generator setup to a json object.
  32145. * @returns The serialized JSON object
  32146. */
  32147. serialize(): any;
  32148. /**
  32149. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  32150. * @param parsedShadowGenerator The JSON object to parse
  32151. * @param scene The scene to create the shadow map for
  32152. * @returns The parsed shadow generator
  32153. */
  32154. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  32155. }
  32156. }
  32157. declare module BABYLON {
  32158. /**
  32159. * Background material used to create an efficient environement around your scene.
  32160. */
  32161. class BackgroundMaterial extends PushMaterial {
  32162. /**
  32163. * Standard reflectance value at parallel view angle.
  32164. */
  32165. static StandardReflectance0: number;
  32166. /**
  32167. * Standard reflectance value at grazing angle.
  32168. */
  32169. static StandardReflectance90: number;
  32170. protected _primaryColor: Color3;
  32171. /**
  32172. * Key light Color (multiply against the environement texture)
  32173. */
  32174. primaryColor: Color3;
  32175. protected __perceptualColor: Nullable<Color3>;
  32176. /**
  32177. * Experimental Internal Use Only.
  32178. *
  32179. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  32180. * This acts as a helper to set the primary color to a more "human friendly" value.
  32181. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  32182. * output color as close as possible from the chosen value.
  32183. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  32184. * part of lighting setup.)
  32185. */
  32186. _perceptualColor: Nullable<Color3>;
  32187. protected _primaryColorShadowLevel: float;
  32188. /**
  32189. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  32190. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  32191. */
  32192. primaryColorShadowLevel: float;
  32193. protected _primaryColorHighlightLevel: float;
  32194. /**
  32195. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  32196. * The primary color is used at the level chosen to define what the white area would look.
  32197. */
  32198. primaryColorHighlightLevel: float;
  32199. protected _reflectionTexture: Nullable<BaseTexture>;
  32200. /**
  32201. * Reflection Texture used in the material.
  32202. * Should be author in a specific way for the best result (refer to the documentation).
  32203. */
  32204. reflectionTexture: Nullable<BaseTexture>;
  32205. protected _reflectionBlur: float;
  32206. /**
  32207. * Reflection Texture level of blur.
  32208. *
  32209. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  32210. * texture twice.
  32211. */
  32212. reflectionBlur: float;
  32213. protected _diffuseTexture: Nullable<BaseTexture>;
  32214. /**
  32215. * Diffuse Texture used in the material.
  32216. * Should be author in a specific way for the best result (refer to the documentation).
  32217. */
  32218. diffuseTexture: Nullable<BaseTexture>;
  32219. protected _shadowLights: Nullable<IShadowLight[]>;
  32220. /**
  32221. * Specify the list of lights casting shadow on the material.
  32222. * All scene shadow lights will be included if null.
  32223. */
  32224. shadowLights: Nullable<IShadowLight[]>;
  32225. protected _shadowLevel: float;
  32226. /**
  32227. * Helps adjusting the shadow to a softer level if required.
  32228. * 0 means black shadows and 1 means no shadows.
  32229. */
  32230. shadowLevel: float;
  32231. protected _sceneCenter: Vector3;
  32232. /**
  32233. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  32234. * It is usually zero but might be interesting to modify according to your setup.
  32235. */
  32236. sceneCenter: Vector3;
  32237. protected _opacityFresnel: boolean;
  32238. /**
  32239. * This helps specifying that the material is falling off to the sky box at grazing angle.
  32240. * This helps ensuring a nice transition when the camera goes under the ground.
  32241. */
  32242. opacityFresnel: boolean;
  32243. protected _reflectionFresnel: boolean;
  32244. /**
  32245. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  32246. * This helps adding a mirror texture on the ground.
  32247. */
  32248. reflectionFresnel: boolean;
  32249. protected _reflectionFalloffDistance: number;
  32250. /**
  32251. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  32252. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  32253. */
  32254. reflectionFalloffDistance: number;
  32255. protected _reflectionAmount: number;
  32256. /**
  32257. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  32258. */
  32259. reflectionAmount: number;
  32260. protected _reflectionReflectance0: number;
  32261. /**
  32262. * This specifies the weight of the reflection at grazing angle.
  32263. */
  32264. reflectionReflectance0: number;
  32265. protected _reflectionReflectance90: number;
  32266. /**
  32267. * This specifies the weight of the reflection at a perpendicular point of view.
  32268. */
  32269. reflectionReflectance90: number;
  32270. /**
  32271. * Sets the reflection reflectance fresnel values according to the default standard
  32272. * empirically know to work well :-)
  32273. */
  32274. reflectionStandardFresnelWeight: number;
  32275. protected _useRGBColor: boolean;
  32276. /**
  32277. * Helps to directly use the maps channels instead of their level.
  32278. */
  32279. useRGBColor: boolean;
  32280. protected _enableNoise: boolean;
  32281. /**
  32282. * This helps reducing the banding effect that could occur on the background.
  32283. */
  32284. enableNoise: boolean;
  32285. /**
  32286. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  32287. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  32288. * Recommended to be keep at 1.0 except for special cases.
  32289. */
  32290. fovMultiplier: number;
  32291. private _fovMultiplier;
  32292. /**
  32293. * Enable the FOV adjustment feature controlled by fovMultiplier.
  32294. */
  32295. useEquirectangularFOV: boolean;
  32296. private _maxSimultaneousLights;
  32297. /**
  32298. * Number of Simultaneous lights allowed on the material.
  32299. */
  32300. maxSimultaneousLights: int;
  32301. /**
  32302. * Default configuration related to image processing available in the Background Material.
  32303. */
  32304. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32305. /**
  32306. * Keep track of the image processing observer to allow dispose and replace.
  32307. */
  32308. private _imageProcessingObserver;
  32309. /**
  32310. * Attaches a new image processing configuration to the PBR Material.
  32311. * @param configuration (if null the scene configuration will be use)
  32312. */
  32313. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32314. /**
  32315. * Gets the image processing configuration used either in this material.
  32316. */
  32317. /**
  32318. * Sets the Default image processing configuration used either in the this material.
  32319. *
  32320. * If sets to null, the scene one is in use.
  32321. */
  32322. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  32323. /**
  32324. * Gets wether the color curves effect is enabled.
  32325. */
  32326. /**
  32327. * Sets wether the color curves effect is enabled.
  32328. */
  32329. cameraColorCurvesEnabled: boolean;
  32330. /**
  32331. * Gets wether the color grading effect is enabled.
  32332. */
  32333. /**
  32334. * Gets wether the color grading effect is enabled.
  32335. */
  32336. cameraColorGradingEnabled: boolean;
  32337. /**
  32338. * Gets wether tonemapping is enabled or not.
  32339. */
  32340. /**
  32341. * Sets wether tonemapping is enabled or not
  32342. */
  32343. cameraToneMappingEnabled: boolean;
  32344. /**
  32345. * The camera exposure used on this material.
  32346. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32347. * This corresponds to a photographic exposure.
  32348. */
  32349. /**
  32350. * The camera exposure used on this material.
  32351. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32352. * This corresponds to a photographic exposure.
  32353. */
  32354. cameraExposure: float;
  32355. /**
  32356. * Gets The camera contrast used on this material.
  32357. */
  32358. /**
  32359. * Sets The camera contrast used on this material.
  32360. */
  32361. cameraContrast: float;
  32362. /**
  32363. * Gets the Color Grading 2D Lookup Texture.
  32364. */
  32365. /**
  32366. * Sets the Color Grading 2D Lookup Texture.
  32367. */
  32368. cameraColorGradingTexture: Nullable<BaseTexture>;
  32369. /**
  32370. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32371. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32372. * 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;
  32373. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32374. */
  32375. /**
  32376. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32377. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32378. * 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;
  32379. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32380. */
  32381. cameraColorCurves: Nullable<ColorCurves>;
  32382. /**
  32383. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  32384. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  32385. */
  32386. switchToBGR: boolean;
  32387. private _renderTargets;
  32388. private _reflectionControls;
  32389. private _white;
  32390. private _primaryShadowColor;
  32391. private _primaryHighlightColor;
  32392. /**
  32393. * Instantiates a Background Material in the given scene
  32394. * @param name The friendly name of the material
  32395. * @param scene The scene to add the material to
  32396. */
  32397. constructor(name: string, scene: Scene);
  32398. /**
  32399. * The entire material has been created in order to prevent overdraw.
  32400. * @returns false
  32401. */
  32402. needAlphaTesting(): boolean;
  32403. /**
  32404. * The entire material has been created in order to prevent overdraw.
  32405. * @returns true if blending is enable
  32406. */
  32407. needAlphaBlending(): boolean;
  32408. /**
  32409. * Checks wether the material is ready to be rendered for a given mesh.
  32410. * @param mesh The mesh to render
  32411. * @param subMesh The submesh to check against
  32412. * @param useInstances Specify wether or not the material is used with instances
  32413. * @returns true if all the dependencies are ready (Textures, Effects...)
  32414. */
  32415. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32416. /**
  32417. * Compute the primary color according to the chosen perceptual color.
  32418. */
  32419. private _computePrimaryColorFromPerceptualColor();
  32420. /**
  32421. * Compute the highlights and shadow colors according to their chosen levels.
  32422. */
  32423. private _computePrimaryColors();
  32424. /**
  32425. * Build the uniform buffer used in the material.
  32426. */
  32427. buildUniformLayout(): void;
  32428. /**
  32429. * Unbind the material.
  32430. */
  32431. unbind(): void;
  32432. /**
  32433. * Bind only the world matrix to the material.
  32434. * @param world The world matrix to bind.
  32435. */
  32436. bindOnlyWorldMatrix(world: Matrix): void;
  32437. /**
  32438. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  32439. * @param world The world matrix to bind.
  32440. * @param subMesh The submesh to bind for.
  32441. */
  32442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32443. /**
  32444. * Dispose the material.
  32445. * @param forceDisposeEffect Force disposal of the associated effect.
  32446. * @param forceDisposeTextures Force disposal of the associated textures.
  32447. */
  32448. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32449. /**
  32450. * Clones the material.
  32451. * @param name The cloned name.
  32452. * @returns The cloned material.
  32453. */
  32454. clone(name: string): BackgroundMaterial;
  32455. /**
  32456. * Serializes the current material to its JSON representation.
  32457. * @returns The JSON representation.
  32458. */
  32459. serialize(): any;
  32460. /**
  32461. * Gets the class name of the material
  32462. * @returns "BackgroundMaterial"
  32463. */
  32464. getClassName(): string;
  32465. /**
  32466. * Parse a JSON input to create back a background material.
  32467. * @param source The JSON data to parse
  32468. * @param scene The scene to create the parsed material in
  32469. * @param rootUrl The root url of the assets the material depends upon
  32470. * @returns the instantiated BackgroundMaterial.
  32471. */
  32472. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  32473. }
  32474. }
  32475. declare module BABYLON {
  32476. /**
  32477. * The Physically based material base class of BJS.
  32478. *
  32479. * This offers the main features of a standard PBR material.
  32480. * For more information, please refer to the documentation :
  32481. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32482. */
  32483. abstract class PBRBaseMaterial extends PushMaterial {
  32484. /**
  32485. * Intensity of the direct lights e.g. the four lights available in your scene.
  32486. * This impacts both the direct diffuse and specular highlights.
  32487. */
  32488. protected _directIntensity: number;
  32489. /**
  32490. * Intensity of the emissive part of the material.
  32491. * This helps controlling the emissive effect without modifying the emissive color.
  32492. */
  32493. protected _emissiveIntensity: number;
  32494. /**
  32495. * Intensity of the environment e.g. how much the environment will light the object
  32496. * either through harmonics for rough material or through the refelction for shiny ones.
  32497. */
  32498. protected _environmentIntensity: number;
  32499. /**
  32500. * This is a special control allowing the reduction of the specular highlights coming from the
  32501. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32502. */
  32503. protected _specularIntensity: number;
  32504. /**
  32505. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  32506. */
  32507. private _lightingInfos;
  32508. /**
  32509. * Debug Control allowing disabling the bump map on this material.
  32510. */
  32511. protected _disableBumpMap: boolean;
  32512. /**
  32513. * AKA Diffuse Texture in standard nomenclature.
  32514. */
  32515. protected _albedoTexture: BaseTexture;
  32516. /**
  32517. * AKA Occlusion Texture in other nomenclature.
  32518. */
  32519. protected _ambientTexture: BaseTexture;
  32520. /**
  32521. * AKA Occlusion Texture Intensity in other nomenclature.
  32522. */
  32523. protected _ambientTextureStrength: number;
  32524. /**
  32525. * Stores the alpha values in a texture.
  32526. */
  32527. protected _opacityTexture: BaseTexture;
  32528. /**
  32529. * Stores the reflection values in a texture.
  32530. */
  32531. protected _reflectionTexture: BaseTexture;
  32532. /**
  32533. * Stores the refraction values in a texture.
  32534. */
  32535. protected _refractionTexture: BaseTexture;
  32536. /**
  32537. * Stores the emissive values in a texture.
  32538. */
  32539. protected _emissiveTexture: BaseTexture;
  32540. /**
  32541. * AKA Specular texture in other nomenclature.
  32542. */
  32543. protected _reflectivityTexture: BaseTexture;
  32544. /**
  32545. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32546. */
  32547. protected _metallicTexture: BaseTexture;
  32548. /**
  32549. * Specifies the metallic scalar of the metallic/roughness workflow.
  32550. * Can also be used to scale the metalness values of the metallic texture.
  32551. */
  32552. protected _metallic: number;
  32553. /**
  32554. * Specifies the roughness scalar of the metallic/roughness workflow.
  32555. * Can also be used to scale the roughness values of the metallic texture.
  32556. */
  32557. protected _roughness: number;
  32558. /**
  32559. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32560. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32561. */
  32562. protected _microSurfaceTexture: BaseTexture;
  32563. /**
  32564. * Stores surface normal data used to displace a mesh in a texture.
  32565. */
  32566. protected _bumpTexture: BaseTexture;
  32567. /**
  32568. * Stores the pre-calculated light information of a mesh in a texture.
  32569. */
  32570. protected _lightmapTexture: BaseTexture;
  32571. /**
  32572. * The color of a material in ambient lighting.
  32573. */
  32574. protected _ambientColor: Color3;
  32575. /**
  32576. * AKA Diffuse Color in other nomenclature.
  32577. */
  32578. protected _albedoColor: Color3;
  32579. /**
  32580. * AKA Specular Color in other nomenclature.
  32581. */
  32582. protected _reflectivityColor: Color3;
  32583. /**
  32584. * The color applied when light is reflected from a material.
  32585. */
  32586. protected _reflectionColor: Color3;
  32587. /**
  32588. * The color applied when light is emitted from a material.
  32589. */
  32590. protected _emissiveColor: Color3;
  32591. /**
  32592. * AKA Glossiness in other nomenclature.
  32593. */
  32594. protected _microSurface: number;
  32595. /**
  32596. * source material index of refraction (IOR)' / 'destination material IOR.
  32597. */
  32598. protected _indexOfRefraction: number;
  32599. /**
  32600. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32601. */
  32602. protected _invertRefractionY: boolean;
  32603. /**
  32604. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32605. * Materials half opaque for instance using refraction could benefit from this control.
  32606. */
  32607. protected _linkRefractionWithTransparency: boolean;
  32608. /**
  32609. * Specifies that the material will use the light map as a show map.
  32610. */
  32611. protected _useLightmapAsShadowmap: boolean;
  32612. /**
  32613. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32614. * makes the reflect vector face the model (under horizon).
  32615. */
  32616. protected _useHorizonOcclusion: boolean;
  32617. /**
  32618. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32619. * too much the area relying on ambient texture to define their ambient occlusion.
  32620. */
  32621. protected _useRadianceOcclusion: boolean;
  32622. /**
  32623. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32624. */
  32625. protected _useAlphaFromAlbedoTexture: boolean;
  32626. /**
  32627. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32628. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32629. */
  32630. protected _useSpecularOverAlpha: boolean;
  32631. /**
  32632. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32633. */
  32634. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32635. /**
  32636. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32637. */
  32638. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  32639. /**
  32640. * Specifies if the metallic texture contains the roughness information in its green channel.
  32641. */
  32642. protected _useRoughnessFromMetallicTextureGreen: boolean;
  32643. /**
  32644. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32645. */
  32646. protected _useMetallnessFromMetallicTextureBlue: boolean;
  32647. /**
  32648. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32649. */
  32650. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  32651. /**
  32652. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32653. */
  32654. protected _useAmbientInGrayScale: boolean;
  32655. /**
  32656. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32657. * The material will try to infer what glossiness each pixel should be.
  32658. */
  32659. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  32660. /**
  32661. * BJS is using an harcoded light falloff based on a manually sets up range.
  32662. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32663. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32664. */
  32665. protected _usePhysicalLightFalloff: boolean;
  32666. /**
  32667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32669. */
  32670. protected _useRadianceOverAlpha: boolean;
  32671. /**
  32672. * Allows using an object space normal map (instead of tangent space).
  32673. */
  32674. protected _useObjectSpaceNormalMap: boolean;
  32675. /**
  32676. * Allows using the bump map in parallax mode.
  32677. */
  32678. protected _useParallax: boolean;
  32679. /**
  32680. * Allows using the bump map in parallax occlusion mode.
  32681. */
  32682. protected _useParallaxOcclusion: boolean;
  32683. /**
  32684. * Controls the scale bias of the parallax mode.
  32685. */
  32686. protected _parallaxScaleBias: number;
  32687. /**
  32688. * If sets to true, disables all the lights affecting the material.
  32689. */
  32690. protected _disableLighting: boolean;
  32691. /**
  32692. * Number of Simultaneous lights allowed on the material.
  32693. */
  32694. protected _maxSimultaneousLights: number;
  32695. /**
  32696. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  32697. */
  32698. protected _invertNormalMapX: boolean;
  32699. /**
  32700. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  32701. */
  32702. protected _invertNormalMapY: boolean;
  32703. /**
  32704. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32705. */
  32706. protected _twoSidedLighting: boolean;
  32707. /**
  32708. * Defines the alpha limits in alpha test mode.
  32709. */
  32710. protected _alphaCutOff: number;
  32711. /**
  32712. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32713. */
  32714. protected _forceAlphaTest: boolean;
  32715. /**
  32716. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32717. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32718. */
  32719. protected _useAlphaFresnel: boolean;
  32720. /**
  32721. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32722. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32723. */
  32724. protected _useLinearAlphaFresnel: boolean;
  32725. /**
  32726. * The transparency mode of the material.
  32727. */
  32728. protected _transparencyMode: Nullable<number>;
  32729. /**
  32730. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32731. * from cos thetav and roughness:
  32732. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32733. */
  32734. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32735. /**
  32736. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32737. */
  32738. protected _forceIrradianceInFragment: boolean;
  32739. /**
  32740. * Force normal to face away from face.
  32741. */
  32742. protected _forceNormalForward: boolean;
  32743. /**
  32744. * Enables specular anti aliasing in the PBR shader.
  32745. * It will both interacts on the Geometry for analytical and IBL lighting.
  32746. * It also prefilter the roughness map based on the bump values.
  32747. */
  32748. protected _enableSpecularAntiAliasing: boolean;
  32749. /**
  32750. * Default configuration related to image processing available in the PBR Material.
  32751. */
  32752. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32753. /**
  32754. * Keep track of the image processing observer to allow dispose and replace.
  32755. */
  32756. private _imageProcessingObserver;
  32757. /**
  32758. * Attaches a new image processing configuration to the PBR Material.
  32759. * @param configuration
  32760. */
  32761. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32762. /**
  32763. * Stores the available render targets.
  32764. */
  32765. private _renderTargets;
  32766. /**
  32767. * Sets the global ambient color for the material used in lighting calculations.
  32768. */
  32769. private _globalAmbientColor;
  32770. /**
  32771. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32772. */
  32773. private _useLogarithmicDepth;
  32774. /**
  32775. * If set to true, no lighting calculations will be applied.
  32776. */
  32777. private _unlit;
  32778. /**
  32779. * Instantiates a new PBRMaterial instance.
  32780. *
  32781. * @param name The material name
  32782. * @param scene The scene the material will be use in.
  32783. */
  32784. constructor(name: string, scene: Scene);
  32785. /**
  32786. * Gets the name of the material class.
  32787. */
  32788. getClassName(): string;
  32789. /**
  32790. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32791. */
  32792. /**
  32793. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32794. */
  32795. useLogarithmicDepth: boolean;
  32796. /**
  32797. * Gets the current transparency mode.
  32798. */
  32799. /**
  32800. * Sets the transparency mode of the material.
  32801. *
  32802. * | Value | Type | Description |
  32803. * | ----- | ----------------------------------- | ----------- |
  32804. * | 0 | OPAQUE | |
  32805. * | 1 | ALPHATEST | |
  32806. * | 2 | ALPHABLEND | |
  32807. * | 3 | ALPHATESTANDBLEND | |
  32808. *
  32809. */
  32810. transparencyMode: Nullable<number>;
  32811. /**
  32812. * Returns true if alpha blending should be disabled.
  32813. */
  32814. private readonly _disableAlphaBlending;
  32815. /**
  32816. * Specifies whether or not this material should be rendered in alpha blend mode.
  32817. */
  32818. needAlphaBlending(): boolean;
  32819. /**
  32820. * Specifies if the mesh will require alpha blending.
  32821. * @param mesh - BJS mesh.
  32822. */
  32823. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32824. /**
  32825. * Specifies whether or not this material should be rendered in alpha test mode.
  32826. */
  32827. needAlphaTesting(): boolean;
  32828. /**
  32829. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32830. */
  32831. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32832. /**
  32833. * Gets the texture used for the alpha test.
  32834. */
  32835. getAlphaTestTexture(): BaseTexture;
  32836. /**
  32837. * Stores the reflectivity values based on metallic roughness workflow.
  32838. */
  32839. private static _scaledReflectivity;
  32840. /**
  32841. * Specifies that the submesh is ready to be used.
  32842. * @param mesh - BJS mesh.
  32843. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32844. * @param useInstances - Specifies that instances should be used.
  32845. * @returns - boolean indicating that the submesh is ready or not.
  32846. */
  32847. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32848. /**
  32849. * Specifies if the material uses metallic roughness workflow.
  32850. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32851. */
  32852. isMetallicWorkflow(): boolean;
  32853. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32854. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32855. /**
  32856. * Force shader compilation
  32857. */
  32858. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32859. clipPlane: boolean;
  32860. }>): void;
  32861. /**
  32862. * Initializes the uniform buffer layout for the shader.
  32863. */
  32864. buildUniformLayout(): void;
  32865. /**
  32866. * Unbinds the textures.
  32867. */
  32868. unbind(): void;
  32869. /**
  32870. * Binds the submesh data.
  32871. * @param world - The world matrix.
  32872. * @param mesh - The BJS mesh.
  32873. * @param subMesh - A submesh of the BJS mesh.
  32874. */
  32875. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32876. /**
  32877. * Returns the animatable textures.
  32878. * @returns - Array of animatable textures.
  32879. */
  32880. getAnimatables(): IAnimatable[];
  32881. /**
  32882. * Returns the texture used for reflections.
  32883. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32884. */
  32885. private _getReflectionTexture();
  32886. /**
  32887. * Returns the texture used for refraction or null if none is used.
  32888. * @returns - Refection texture if present. If no refraction texture and refraction
  32889. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32890. */
  32891. private _getRefractionTexture();
  32892. /**
  32893. * Disposes the resources of the material.
  32894. * @param forceDisposeEffect - Forces the disposal of effects.
  32895. * @param forceDisposeTextures - Forces the disposal of all textures.
  32896. */
  32897. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32898. }
  32899. }
  32900. declare module BABYLON {
  32901. /**
  32902. * The Physically based simple base material of BJS.
  32903. *
  32904. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32905. * It is used as the base class for both the specGloss and metalRough conventions.
  32906. */
  32907. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32908. /**
  32909. * Number of Simultaneous lights allowed on the material.
  32910. */
  32911. maxSimultaneousLights: number;
  32912. /**
  32913. * If sets to true, disables all the lights affecting the material.
  32914. */
  32915. disableLighting: boolean;
  32916. /**
  32917. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32918. */
  32919. environmentTexture: BaseTexture;
  32920. /**
  32921. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32922. */
  32923. invertNormalMapX: boolean;
  32924. /**
  32925. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32926. */
  32927. invertNormalMapY: boolean;
  32928. /**
  32929. * Normal map used in the model.
  32930. */
  32931. normalTexture: BaseTexture;
  32932. /**
  32933. * Emissivie color used to self-illuminate the model.
  32934. */
  32935. emissiveColor: Color3;
  32936. /**
  32937. * Emissivie texture used to self-illuminate the model.
  32938. */
  32939. emissiveTexture: BaseTexture;
  32940. /**
  32941. * Occlusion Channel Strenght.
  32942. */
  32943. occlusionStrength: number;
  32944. /**
  32945. * Occlusion Texture of the material (adding extra occlusion effects).
  32946. */
  32947. occlusionTexture: BaseTexture;
  32948. /**
  32949. * Defines the alpha limits in alpha test mode.
  32950. */
  32951. alphaCutOff: number;
  32952. /**
  32953. * Gets the current double sided mode.
  32954. */
  32955. /**
  32956. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32957. */
  32958. doubleSided: boolean;
  32959. lightmapTexture: BaseTexture;
  32960. useLightmapAsShadowmap: boolean;
  32961. /**
  32962. * Return the active textures of the material.
  32963. */
  32964. getActiveTextures(): BaseTexture[];
  32965. hasTexture(texture: BaseTexture): boolean;
  32966. /**
  32967. * Instantiates a new PBRMaterial instance.
  32968. *
  32969. * @param name The material name
  32970. * @param scene The scene the material will be use in.
  32971. */
  32972. constructor(name: string, scene: Scene);
  32973. getClassName(): string;
  32974. }
  32975. }
  32976. declare module BABYLON {
  32977. /**
  32978. * The Physically based material of BJS.
  32979. *
  32980. * This offers the main features of a standard PBR material.
  32981. * For more information, please refer to the documentation :
  32982. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32983. */
  32984. class PBRMaterial extends PBRBaseMaterial {
  32985. private static _PBRMATERIAL_OPAQUE;
  32986. /**
  32987. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32988. */
  32989. static readonly PBRMATERIAL_OPAQUE: number;
  32990. /**
  32991. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32992. */
  32993. private static _PBRMATERIAL_ALPHATEST;
  32994. /**
  32995. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32996. */
  32997. static readonly PBRMATERIAL_ALPHATEST: number;
  32998. /**
  32999. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33000. */
  33001. private static _PBRMATERIAL_ALPHABLEND;
  33002. /**
  33003. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33004. */
  33005. static readonly PBRMATERIAL_ALPHABLEND: number;
  33006. /**
  33007. * 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.
  33008. * They are also discarded below the alpha cutoff threshold to improve performances.
  33009. */
  33010. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  33011. /**
  33012. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33013. * They are also discarded below the alpha cutoff threshold to improve performances.
  33014. */
  33015. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  33016. /**
  33017. * Intensity of the direct lights e.g. the four lights available in your scene.
  33018. * This impacts both the direct diffuse and specular highlights.
  33019. */
  33020. directIntensity: number;
  33021. /**
  33022. * Intensity of the emissive part of the material.
  33023. * This helps controlling the emissive effect without modifying the emissive color.
  33024. */
  33025. emissiveIntensity: number;
  33026. /**
  33027. * Intensity of the environment e.g. how much the environment will light the object
  33028. * either through harmonics for rough material or through the refelction for shiny ones.
  33029. */
  33030. environmentIntensity: number;
  33031. /**
  33032. * This is a special control allowing the reduction of the specular highlights coming from the
  33033. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33034. */
  33035. specularIntensity: number;
  33036. /**
  33037. * Debug Control allowing disabling the bump map on this material.
  33038. */
  33039. disableBumpMap: boolean;
  33040. /**
  33041. * AKA Diffuse Texture in standard nomenclature.
  33042. */
  33043. albedoTexture: BaseTexture;
  33044. /**
  33045. * AKA Occlusion Texture in other nomenclature.
  33046. */
  33047. ambientTexture: BaseTexture;
  33048. /**
  33049. * AKA Occlusion Texture Intensity in other nomenclature.
  33050. */
  33051. ambientTextureStrength: number;
  33052. /**
  33053. * Stores the alpha values in a texture.
  33054. */
  33055. opacityTexture: BaseTexture;
  33056. /**
  33057. * Stores the reflection values in a texture.
  33058. */
  33059. reflectionTexture: Nullable<BaseTexture>;
  33060. /**
  33061. * Stores the emissive values in a texture.
  33062. */
  33063. emissiveTexture: BaseTexture;
  33064. /**
  33065. * AKA Specular texture in other nomenclature.
  33066. */
  33067. reflectivityTexture: BaseTexture;
  33068. /**
  33069. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33070. */
  33071. metallicTexture: BaseTexture;
  33072. /**
  33073. * Specifies the metallic scalar of the metallic/roughness workflow.
  33074. * Can also be used to scale the metalness values of the metallic texture.
  33075. */
  33076. metallic: number;
  33077. /**
  33078. * Specifies the roughness scalar of the metallic/roughness workflow.
  33079. * Can also be used to scale the roughness values of the metallic texture.
  33080. */
  33081. roughness: number;
  33082. /**
  33083. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33084. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33085. */
  33086. microSurfaceTexture: BaseTexture;
  33087. /**
  33088. * Stores surface normal data used to displace a mesh in a texture.
  33089. */
  33090. bumpTexture: BaseTexture;
  33091. /**
  33092. * Stores the pre-calculated light information of a mesh in a texture.
  33093. */
  33094. lightmapTexture: BaseTexture;
  33095. /**
  33096. * Stores the refracted light information in a texture.
  33097. */
  33098. refractionTexture: BaseTexture;
  33099. /**
  33100. * The color of a material in ambient lighting.
  33101. */
  33102. ambientColor: Color3;
  33103. /**
  33104. * AKA Diffuse Color in other nomenclature.
  33105. */
  33106. albedoColor: Color3;
  33107. /**
  33108. * AKA Specular Color in other nomenclature.
  33109. */
  33110. reflectivityColor: Color3;
  33111. /**
  33112. * The color reflected from the material.
  33113. */
  33114. reflectionColor: Color3;
  33115. /**
  33116. * The color emitted from the material.
  33117. */
  33118. emissiveColor: Color3;
  33119. /**
  33120. * AKA Glossiness in other nomenclature.
  33121. */
  33122. microSurface: number;
  33123. /**
  33124. * source material index of refraction (IOR)' / 'destination material IOR.
  33125. */
  33126. indexOfRefraction: number;
  33127. /**
  33128. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33129. */
  33130. invertRefractionY: boolean;
  33131. /**
  33132. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33133. * Materials half opaque for instance using refraction could benefit from this control.
  33134. */
  33135. linkRefractionWithTransparency: boolean;
  33136. useLightmapAsShadowmap: boolean;
  33137. /**
  33138. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  33139. */
  33140. useAlphaFromAlbedoTexture: boolean;
  33141. /**
  33142. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  33143. */
  33144. forceAlphaTest: boolean;
  33145. /**
  33146. * Defines the alpha limits in alpha test mode.
  33147. */
  33148. alphaCutOff: number;
  33149. /**
  33150. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  33151. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33152. */
  33153. useSpecularOverAlpha: boolean;
  33154. /**
  33155. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  33156. */
  33157. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  33158. /**
  33159. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  33160. */
  33161. useRoughnessFromMetallicTextureAlpha: boolean;
  33162. /**
  33163. * Specifies if the metallic texture contains the roughness information in its green channel.
  33164. */
  33165. useRoughnessFromMetallicTextureGreen: boolean;
  33166. /**
  33167. * Specifies if the metallic texture contains the metallness information in its blue channel.
  33168. */
  33169. useMetallnessFromMetallicTextureBlue: boolean;
  33170. /**
  33171. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  33172. */
  33173. useAmbientOcclusionFromMetallicTextureRed: boolean;
  33174. /**
  33175. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  33176. */
  33177. useAmbientInGrayScale: boolean;
  33178. /**
  33179. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  33180. * The material will try to infer what glossiness each pixel should be.
  33181. */
  33182. useAutoMicroSurfaceFromReflectivityMap: boolean;
  33183. /**
  33184. * BJS is using an harcoded light falloff based on a manually sets up range.
  33185. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  33186. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  33187. */
  33188. usePhysicalLightFalloff: boolean;
  33189. /**
  33190. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33191. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33192. */
  33193. useRadianceOverAlpha: boolean;
  33194. /**
  33195. * Allows using an object space normal map (instead of tangent space).
  33196. */
  33197. useObjectSpaceNormalMap: boolean;
  33198. /**
  33199. * Allows using the bump map in parallax mode.
  33200. */
  33201. useParallax: boolean;
  33202. /**
  33203. * Allows using the bump map in parallax occlusion mode.
  33204. */
  33205. useParallaxOcclusion: boolean;
  33206. /**
  33207. * Controls the scale bias of the parallax mode.
  33208. */
  33209. parallaxScaleBias: number;
  33210. /**
  33211. * If sets to true, disables all the lights affecting the material.
  33212. */
  33213. disableLighting: boolean;
  33214. /**
  33215. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  33216. */
  33217. forceIrradianceInFragment: boolean;
  33218. /**
  33219. * Number of Simultaneous lights allowed on the material.
  33220. */
  33221. maxSimultaneousLights: number;
  33222. /**
  33223. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  33224. */
  33225. invertNormalMapX: boolean;
  33226. /**
  33227. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  33228. */
  33229. invertNormalMapY: boolean;
  33230. /**
  33231. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33232. */
  33233. twoSidedLighting: boolean;
  33234. /**
  33235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33236. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  33237. */
  33238. useAlphaFresnel: boolean;
  33239. /**
  33240. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33241. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  33242. */
  33243. useLinearAlphaFresnel: boolean;
  33244. /**
  33245. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33246. * And/Or occlude the blended part.
  33247. */
  33248. environmentBRDFTexture: Nullable<BaseTexture>;
  33249. /**
  33250. * Force normal to face away from face.
  33251. */
  33252. forceNormalForward: boolean;
  33253. /**
  33254. * Enables specular anti aliasing in the PBR shader.
  33255. * It will both interacts on the Geometry for analytical and IBL lighting.
  33256. * It also prefilter the roughness map based on the bump values.
  33257. */
  33258. enableSpecularAntiAliasing: boolean;
  33259. /**
  33260. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  33261. * makes the reflect vector face the model (under horizon).
  33262. */
  33263. useHorizonOcclusion: boolean;
  33264. /**
  33265. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  33266. * too much the area relying on ambient texture to define their ambient occlusion.
  33267. */
  33268. useRadianceOcclusion: boolean;
  33269. /**
  33270. * If set to true, no lighting calculations will be applied.
  33271. */
  33272. unlit: boolean;
  33273. /**
  33274. * Gets the image processing configuration used either in this material.
  33275. */
  33276. /**
  33277. * Sets the Default image processing configuration used either in the this material.
  33278. *
  33279. * If sets to null, the scene one is in use.
  33280. */
  33281. imageProcessingConfiguration: ImageProcessingConfiguration;
  33282. /**
  33283. * Gets wether the color curves effect is enabled.
  33284. */
  33285. /**
  33286. * Sets wether the color curves effect is enabled.
  33287. */
  33288. cameraColorCurvesEnabled: boolean;
  33289. /**
  33290. * Gets wether the color grading effect is enabled.
  33291. */
  33292. /**
  33293. * Gets wether the color grading effect is enabled.
  33294. */
  33295. cameraColorGradingEnabled: boolean;
  33296. /**
  33297. * Gets wether tonemapping is enabled or not.
  33298. */
  33299. /**
  33300. * Sets wether tonemapping is enabled or not
  33301. */
  33302. cameraToneMappingEnabled: boolean;
  33303. /**
  33304. * The camera exposure used on this material.
  33305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33306. * This corresponds to a photographic exposure.
  33307. */
  33308. /**
  33309. * The camera exposure used on this material.
  33310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33311. * This corresponds to a photographic exposure.
  33312. */
  33313. cameraExposure: number;
  33314. /**
  33315. * Gets The camera contrast used on this material.
  33316. */
  33317. /**
  33318. * Sets The camera contrast used on this material.
  33319. */
  33320. cameraContrast: number;
  33321. /**
  33322. * Gets the Color Grading 2D Lookup Texture.
  33323. */
  33324. /**
  33325. * Sets the Color Grading 2D Lookup Texture.
  33326. */
  33327. cameraColorGradingTexture: Nullable<BaseTexture>;
  33328. /**
  33329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33331. * 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;
  33332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33333. */
  33334. /**
  33335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33337. * 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;
  33338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33339. */
  33340. cameraColorCurves: Nullable<ColorCurves>;
  33341. /**
  33342. * Instantiates a new PBRMaterial instance.
  33343. *
  33344. * @param name The material name
  33345. * @param scene The scene the material will be use in.
  33346. */
  33347. constructor(name: string, scene: Scene);
  33348. /**
  33349. * Returns the name of this material class.
  33350. */
  33351. getClassName(): string;
  33352. /**
  33353. * Returns an array of the actively used textures.
  33354. * @returns - Array of BaseTextures
  33355. */
  33356. getActiveTextures(): BaseTexture[];
  33357. /**
  33358. * Checks to see if a texture is used in the material.
  33359. * @param texture - Base texture to use.
  33360. * @returns - Boolean specifying if a texture is used in the material.
  33361. */
  33362. hasTexture(texture: BaseTexture): boolean;
  33363. /**
  33364. * Makes a duplicate of the current material.
  33365. * @param name - name to use for the new material.
  33366. */
  33367. clone(name: string): PBRMaterial;
  33368. /**
  33369. * Serializes this PBR Material.
  33370. * @returns - An object with the serialized material.
  33371. */
  33372. serialize(): any;
  33373. /**
  33374. * Parses a PBR Material from a serialized object.
  33375. * @param source - Serialized object.
  33376. * @param scene - BJS scene instance.
  33377. * @param rootUrl - url for the scene object
  33378. * @returns - PBRMaterial
  33379. */
  33380. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  33381. }
  33382. }
  33383. declare module BABYLON {
  33384. /**
  33385. * The PBR material of BJS following the metal roughness convention.
  33386. *
  33387. * This fits to the PBR convention in the GLTF definition:
  33388. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  33389. */
  33390. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  33391. /**
  33392. * The base color has two different interpretations depending on the value of metalness.
  33393. * When the material is a metal, the base color is the specific measured reflectance value
  33394. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  33395. * of the material.
  33396. */
  33397. baseColor: Color3;
  33398. /**
  33399. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  33400. * well as opacity information in the alpha channel.
  33401. */
  33402. baseTexture: BaseTexture;
  33403. /**
  33404. * Specifies the metallic scalar value of the material.
  33405. * Can also be used to scale the metalness values of the metallic texture.
  33406. */
  33407. metallic: number;
  33408. /**
  33409. * Specifies the roughness scalar value of the material.
  33410. * Can also be used to scale the roughness values of the metallic texture.
  33411. */
  33412. roughness: number;
  33413. /**
  33414. * Texture containing both the metallic value in the B channel and the
  33415. * roughness value in the G channel to keep better precision.
  33416. */
  33417. metallicRoughnessTexture: BaseTexture;
  33418. /**
  33419. * Instantiates a new PBRMetalRoughnessMaterial instance.
  33420. *
  33421. * @param name The material name
  33422. * @param scene The scene the material will be use in.
  33423. */
  33424. constructor(name: string, scene: Scene);
  33425. /**
  33426. * Return the currrent class name of the material.
  33427. */
  33428. getClassName(): string;
  33429. /**
  33430. * Return the active textures of the material.
  33431. */
  33432. getActiveTextures(): BaseTexture[];
  33433. /**
  33434. * Checks to see if a texture is used in the material.
  33435. * @param texture - Base texture to use.
  33436. * @returns - Boolean specifying if a texture is used in the material.
  33437. */
  33438. hasTexture(texture: BaseTexture): boolean;
  33439. /**
  33440. * Makes a duplicate of the current material.
  33441. * @param name - name to use for the new material.
  33442. */
  33443. clone(name: string): PBRMetallicRoughnessMaterial;
  33444. /**
  33445. * Serialize the material to a parsable JSON object.
  33446. */
  33447. serialize(): any;
  33448. /**
  33449. * Parses a JSON object correponding to the serialize function.
  33450. */
  33451. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  33452. }
  33453. }
  33454. declare module BABYLON {
  33455. /**
  33456. * The PBR material of BJS following the specular glossiness convention.
  33457. *
  33458. * This fits to the PBR convention in the GLTF definition:
  33459. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  33460. */
  33461. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  33462. /**
  33463. * Specifies the diffuse color of the material.
  33464. */
  33465. diffuseColor: Color3;
  33466. /**
  33467. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  33468. * channel.
  33469. */
  33470. diffuseTexture: BaseTexture;
  33471. /**
  33472. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  33473. */
  33474. specularColor: Color3;
  33475. /**
  33476. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  33477. */
  33478. glossiness: number;
  33479. /**
  33480. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  33481. */
  33482. specularGlossinessTexture: BaseTexture;
  33483. /**
  33484. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  33485. *
  33486. * @param name The material name
  33487. * @param scene The scene the material will be use in.
  33488. */
  33489. constructor(name: string, scene: Scene);
  33490. /**
  33491. * Return the currrent class name of the material.
  33492. */
  33493. getClassName(): string;
  33494. /**
  33495. * Return the active textures of the material.
  33496. */
  33497. getActiveTextures(): BaseTexture[];
  33498. /**
  33499. * Checks to see if a texture is used in the material.
  33500. * @param texture - Base texture to use.
  33501. * @returns - Boolean specifying if a texture is used in the material.
  33502. */
  33503. hasTexture(texture: BaseTexture): boolean;
  33504. /**
  33505. * Makes a duplicate of the current material.
  33506. * @param name - name to use for the new material.
  33507. */
  33508. clone(name: string): PBRSpecularGlossinessMaterial;
  33509. /**
  33510. * Serialize the material to a parsable JSON object.
  33511. */
  33512. serialize(): any;
  33513. /**
  33514. * Parses a JSON object correponding to the serialize function.
  33515. */
  33516. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  33517. }
  33518. }
  33519. declare module BABYLON {
  33520. class BaseTexture {
  33521. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33522. name: string;
  33523. private _hasAlpha;
  33524. hasAlpha: boolean;
  33525. getAlphaFromRGB: boolean;
  33526. level: number;
  33527. coordinatesIndex: number;
  33528. private _coordinatesMode;
  33529. /**
  33530. * How a texture is mapped.
  33531. *
  33532. * | Value | Type | Description |
  33533. * | ----- | ----------------------------------- | ----------- |
  33534. * | 0 | EXPLICIT_MODE | |
  33535. * | 1 | SPHERICAL_MODE | |
  33536. * | 2 | PLANAR_MODE | |
  33537. * | 3 | CUBIC_MODE | |
  33538. * | 4 | PROJECTION_MODE | |
  33539. * | 5 | SKYBOX_MODE | |
  33540. * | 6 | INVCUBIC_MODE | |
  33541. * | 7 | EQUIRECTANGULAR_MODE | |
  33542. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33543. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33544. */
  33545. coordinatesMode: number;
  33546. /**
  33547. * | Value | Type | Description |
  33548. * | ----- | ------------------ | ----------- |
  33549. * | 0 | CLAMP_ADDRESSMODE | |
  33550. * | 1 | WRAP_ADDRESSMODE | |
  33551. * | 2 | MIRROR_ADDRESSMODE | |
  33552. */
  33553. wrapU: number;
  33554. /**
  33555. * | Value | Type | Description |
  33556. * | ----- | ------------------ | ----------- |
  33557. * | 0 | CLAMP_ADDRESSMODE | |
  33558. * | 1 | WRAP_ADDRESSMODE | |
  33559. * | 2 | MIRROR_ADDRESSMODE | |
  33560. */
  33561. wrapV: number;
  33562. /**
  33563. * | Value | Type | Description |
  33564. * | ----- | ------------------ | ----------- |
  33565. * | 0 | CLAMP_ADDRESSMODE | |
  33566. * | 1 | WRAP_ADDRESSMODE | |
  33567. * | 2 | MIRROR_ADDRESSMODE | |
  33568. */
  33569. wrapR: number;
  33570. anisotropicFilteringLevel: number;
  33571. isCube: boolean;
  33572. is3D: boolean;
  33573. gammaSpace: boolean;
  33574. /**
  33575. * Gets whether or not the texture contains RGBD data.
  33576. */
  33577. readonly isRGBD: boolean;
  33578. invertZ: boolean;
  33579. lodLevelInAlpha: boolean;
  33580. lodGenerationOffset: number;
  33581. lodGenerationScale: number;
  33582. isRenderTarget: boolean;
  33583. readonly uid: string;
  33584. toString(): string;
  33585. getClassName(): string;
  33586. animations: Animation[];
  33587. /**
  33588. * An event triggered when the texture is disposed.
  33589. */
  33590. onDisposeObservable: Observable<BaseTexture>;
  33591. private _onDisposeObserver;
  33592. onDispose: () => void;
  33593. delayLoadState: number;
  33594. private _scene;
  33595. _texture: Nullable<InternalTexture>;
  33596. private _uid;
  33597. readonly isBlocking: boolean;
  33598. constructor(scene: Nullable<Scene>);
  33599. getScene(): Nullable<Scene>;
  33600. getTextureMatrix(): Matrix;
  33601. getReflectionTextureMatrix(): Matrix;
  33602. getInternalTexture(): Nullable<InternalTexture>;
  33603. isReadyOrNotBlocking(): boolean;
  33604. isReady(): boolean;
  33605. getSize(): ISize;
  33606. getBaseSize(): ISize;
  33607. scale(ratio: number): void;
  33608. readonly canRescale: boolean;
  33609. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  33610. _rebuild(): void;
  33611. delayLoad(): void;
  33612. clone(): Nullable<BaseTexture>;
  33613. readonly textureType: number;
  33614. readonly textureFormat: number;
  33615. /**
  33616. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33617. * This will returns an RGBA array buffer containing either in values (0-255) or
  33618. * float values (0-1) depending of the underlying buffer type.
  33619. * @param faceIndex The face of the texture to read (in case of cube texture)
  33620. * @param level The LOD level of the texture to read (in case of Mip Maps)
  33621. * @returns The Array buffer containing the pixels data.
  33622. */
  33623. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  33624. releaseInternalTexture(): void;
  33625. sphericalPolynomial: Nullable<SphericalPolynomial>;
  33626. readonly _lodTextureHigh: Nullable<BaseTexture>;
  33627. readonly _lodTextureMid: Nullable<BaseTexture>;
  33628. readonly _lodTextureLow: Nullable<BaseTexture>;
  33629. dispose(): void;
  33630. serialize(): any;
  33631. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33632. }
  33633. }
  33634. declare module BABYLON {
  33635. /**
  33636. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  33637. * It can help converting any input color in a desired output one. This can then be used to create effects
  33638. * from sepia, black and white to sixties or futuristic rendering...
  33639. *
  33640. * The only supported format is currently 3dl.
  33641. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  33642. */
  33643. class ColorGradingTexture extends BaseTexture {
  33644. /**
  33645. * The current texture matrix. (will always be identity in color grading texture)
  33646. */
  33647. private _textureMatrix;
  33648. /**
  33649. * The texture URL.
  33650. */
  33651. url: string;
  33652. /**
  33653. * Empty line regex stored for GC.
  33654. */
  33655. private static _noneEmptyLineRegex;
  33656. private _engine;
  33657. /**
  33658. * Instantiates a ColorGradingTexture from the following parameters.
  33659. *
  33660. * @param url The location of the color gradind data (currently only supporting 3dl)
  33661. * @param scene The scene the texture will be used in
  33662. */
  33663. constructor(url: string, scene: Scene);
  33664. /**
  33665. * Returns the texture matrix used in most of the material.
  33666. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  33667. */
  33668. getTextureMatrix(): Matrix;
  33669. /**
  33670. * Occurs when the file being loaded is a .3dl LUT file.
  33671. */
  33672. private load3dlTexture();
  33673. /**
  33674. * Starts the loading process of the texture.
  33675. */
  33676. private loadTexture();
  33677. /**
  33678. * Clones the color gradind texture.
  33679. */
  33680. clone(): ColorGradingTexture;
  33681. /**
  33682. * Called during delayed load for textures.
  33683. */
  33684. delayLoad(): void;
  33685. /**
  33686. * Parses a color grading texture serialized by Babylon.
  33687. * @param parsedTexture The texture information being parsedTexture
  33688. * @param scene The scene to load the texture in
  33689. * @param rootUrl The root url of the data assets to load
  33690. * @return A color gradind texture
  33691. */
  33692. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  33693. /**
  33694. * Serializes the LUT texture to json format.
  33695. */
  33696. serialize(): any;
  33697. }
  33698. }
  33699. declare module BABYLON {
  33700. class CubeTexture extends BaseTexture {
  33701. url: string;
  33702. coordinatesMode: number;
  33703. /**
  33704. * Gets or sets the center of the bounding box associated with the cube texture
  33705. * It must define where the camera used to render the texture was set
  33706. */
  33707. boundingBoxPosition: Vector3;
  33708. private _boundingBoxSize;
  33709. /**
  33710. * Gets or sets the size of the bounding box associated with the cube texture
  33711. * When defined, the cubemap will switch to local mode
  33712. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33713. * @example https://www.babylonjs-playground.com/#RNASML
  33714. */
  33715. boundingBoxSize: Vector3;
  33716. protected _rotationY: number;
  33717. /**
  33718. * Gets texture matrix rotation angle around Y axis radians.
  33719. */
  33720. /**
  33721. * Sets texture matrix rotation angle around Y axis in radians.
  33722. */
  33723. rotationY: number;
  33724. private _noMipmap;
  33725. private _files;
  33726. private _extensions;
  33727. private _textureMatrix;
  33728. private _format;
  33729. private _createPolynomials;
  33730. /** @hidden */
  33731. readonly _prefiltered: boolean;
  33732. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  33733. /**
  33734. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  33735. * @param url defines the url of the prefiltered texture
  33736. * @param scene defines the scene the texture is attached to
  33737. * @param forcedExtension defines the extension of the file if different from the url
  33738. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33739. * @return the prefiltered texture
  33740. */
  33741. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  33742. /**
  33743. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  33744. * as prefiltered data.
  33745. * @param rootUrl defines the url of the texture or the root name of the six images
  33746. * @param scene defines the scene the texture is attached to
  33747. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  33748. * @param noMipmap defines if mipmaps should be created or not
  33749. * @param files defines the six files to load for the different faces
  33750. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  33751. * @param onError defines a callback triggered in case of error during load
  33752. * @param format defines the internal format to use for the texture once loaded
  33753. * @param prefiltered defines whether or not the texture is created from prefiltered data
  33754. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  33755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  33757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  33758. * @return the cube texture
  33759. */
  33760. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  33761. delayLoad(): void;
  33762. getReflectionTextureMatrix(): Matrix;
  33763. setReflectionTextureMatrix(value: Matrix): void;
  33764. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  33765. clone(): CubeTexture;
  33766. }
  33767. }
  33768. declare module BABYLON {
  33769. /**
  33770. * A class extending {BABYLON.Texture} allowing drawing on a texture
  33771. * @see http://doc.babylonjs.com/how_to/dynamictexture
  33772. */
  33773. class DynamicTexture extends Texture {
  33774. private _generateMipMaps;
  33775. private _canvas;
  33776. private _context;
  33777. private _engine;
  33778. /**
  33779. * Creates a {BABYLON.DynamicTexture}
  33780. * @param name defines the name of the texture
  33781. * @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
  33782. * @param scene defines the scene where you want the texture
  33783. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  33784. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33785. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  33786. */
  33787. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  33788. /**
  33789. * Gets the current state of canRescale
  33790. */
  33791. readonly canRescale: boolean;
  33792. private _recreate(textureSize);
  33793. /**
  33794. * Scales the texture
  33795. * @param ratio the scale factor to apply to both width and height
  33796. */
  33797. scale(ratio: number): void;
  33798. /**
  33799. * Resizes the texture
  33800. * @param width the new width
  33801. * @param height the new height
  33802. */
  33803. scaleTo(width: number, height: number): void;
  33804. /**
  33805. * Gets the context of the canvas used by the texture
  33806. * @returns the canvas context of the dynamic texture
  33807. */
  33808. getContext(): CanvasRenderingContext2D;
  33809. /**
  33810. * Clears the texture
  33811. */
  33812. clear(): void;
  33813. /**
  33814. * Updates the texture
  33815. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33816. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  33817. */
  33818. update(invertY?: boolean, premulAlpha?: boolean): void;
  33819. /**
  33820. * Draws text onto the texture
  33821. * @param text defines the text to be drawn
  33822. * @param x defines the placement of the text from the left
  33823. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  33824. * @param font defines the font to be used with font-style, font-size, font-name
  33825. * @param color defines the color used for the text
  33826. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  33827. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33828. * @param update defines whether texture is immediately update (default is true)
  33829. */
  33830. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33831. /**
  33832. * Clones the texture
  33833. * @returns the clone of the texture.
  33834. */
  33835. clone(): DynamicTexture;
  33836. /** @hidden */
  33837. _rebuild(): void;
  33838. }
  33839. }
  33840. declare module BABYLON {
  33841. /**
  33842. * This represents a texture coming from an HDR input.
  33843. *
  33844. * The only supported format is currently panorama picture stored in RGBE format.
  33845. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33846. */
  33847. class HDRCubeTexture extends BaseTexture {
  33848. private static _facesMapping;
  33849. private _generateHarmonics;
  33850. private _noMipmap;
  33851. private _textureMatrix;
  33852. private _size;
  33853. private _onLoad;
  33854. private _onError;
  33855. /**
  33856. * The texture URL.
  33857. */
  33858. url: string;
  33859. /**
  33860. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33861. */
  33862. coordinatesMode: number;
  33863. protected _isBlocking: boolean;
  33864. /**
  33865. * Gets wether or not the texture is blocking during loading.
  33866. */
  33867. /**
  33868. * Sets wether or not the texture is blocking during loading.
  33869. */
  33870. isBlocking: boolean;
  33871. protected _rotationY: number;
  33872. /**
  33873. * Gets texture matrix rotation angle around Y axis radians.
  33874. */
  33875. /**
  33876. * Sets texture matrix rotation angle around Y axis in radians.
  33877. */
  33878. rotationY: number;
  33879. /**
  33880. * Gets or sets the center of the bounding box associated with the cube texture
  33881. * It must define where the camera used to render the texture was set
  33882. */
  33883. boundingBoxPosition: Vector3;
  33884. private _boundingBoxSize;
  33885. /**
  33886. * Gets or sets the size of the bounding box associated with the cube texture
  33887. * When defined, the cubemap will switch to local mode
  33888. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33889. * @example https://www.babylonjs-playground.com/#RNASML
  33890. */
  33891. boundingBoxSize: Vector3;
  33892. /**
  33893. * Instantiates an HDRTexture from the following parameters.
  33894. *
  33895. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33896. * @param scene The scene the texture will be used in
  33897. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33898. * @param noMipmap Forces to not generate the mipmap if true
  33899. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33900. * @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)
  33901. * @param reserved Reserved flag for internal use.
  33902. */
  33903. 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>);
  33904. /**
  33905. * Occurs when the file is raw .hdr file.
  33906. */
  33907. private loadTexture();
  33908. clone(): HDRCubeTexture;
  33909. delayLoad(): void;
  33910. getReflectionTextureMatrix(): Matrix;
  33911. setReflectionTextureMatrix(value: Matrix): void;
  33912. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33913. serialize(): any;
  33914. }
  33915. }
  33916. declare module BABYLON {
  33917. /**
  33918. * Class used to store data associated with WebGL texture data for the engine
  33919. * This class should not be used directly
  33920. */
  33921. class InternalTexture implements IInternalTextureTracker {
  33922. /**
  33923. * The source of the texture data is unknown
  33924. */
  33925. static DATASOURCE_UNKNOWN: number;
  33926. /**
  33927. * Texture data comes from an URL
  33928. */
  33929. static DATASOURCE_URL: number;
  33930. /**
  33931. * Texture data is only used for temporary storage
  33932. */
  33933. static DATASOURCE_TEMP: number;
  33934. /**
  33935. * Texture data comes from raw data (ArrayBuffer)
  33936. */
  33937. static DATASOURCE_RAW: number;
  33938. /**
  33939. * Texture content is dynamic (video or dynamic texture)
  33940. */
  33941. static DATASOURCE_DYNAMIC: number;
  33942. /**
  33943. * Texture content is generated by rendering to it
  33944. */
  33945. static DATASOURCE_RENDERTARGET: number;
  33946. /**
  33947. * Texture content is part of a multi render target process
  33948. */
  33949. static DATASOURCE_MULTIRENDERTARGET: number;
  33950. /**
  33951. * Texture data comes from a cube data file
  33952. */
  33953. static DATASOURCE_CUBE: number;
  33954. /**
  33955. * Texture data comes from a raw cube data
  33956. */
  33957. static DATASOURCE_CUBERAW: number;
  33958. /**
  33959. * Texture data come from a prefiltered cube data file
  33960. */
  33961. static DATASOURCE_CUBEPREFILTERED: number;
  33962. /**
  33963. * Texture content is raw 3D data
  33964. */
  33965. static DATASOURCE_RAW3D: number;
  33966. /**
  33967. * Texture content is a depth texture
  33968. */
  33969. static DATASOURCE_DEPTHTEXTURE: number;
  33970. /**
  33971. * Defines if the texture is ready
  33972. */
  33973. isReady: boolean;
  33974. /**
  33975. * Defines if the texture is a cube texture
  33976. */
  33977. isCube: boolean;
  33978. /**
  33979. * Defines if the texture contains 3D data
  33980. */
  33981. is3D: boolean;
  33982. /**
  33983. * Gets the URL used to load this texture
  33984. */
  33985. url: string;
  33986. /**
  33987. * Gets the sampling mode of the texture
  33988. */
  33989. samplingMode: number;
  33990. /**
  33991. * Gets a boolean indicating if the texture needs mipmaps generation
  33992. */
  33993. generateMipMaps: boolean;
  33994. /**
  33995. * Gets the number of samples used by the texture (WebGL2+ only)
  33996. */
  33997. samples: number;
  33998. /**
  33999. * Gets the type of the texture
  34000. */
  34001. type: number;
  34002. /**
  34003. * Gets the format of the texture
  34004. */
  34005. format: number;
  34006. /**
  34007. * Observable called when the texture is loaded
  34008. */
  34009. onLoadedObservable: Observable<InternalTexture>;
  34010. /**
  34011. * Gets the width of the texture
  34012. */
  34013. width: number;
  34014. /**
  34015. * Gets the height of the texture
  34016. */
  34017. height: number;
  34018. /**
  34019. * Gets the depth of the texture
  34020. */
  34021. depth: number;
  34022. /**
  34023. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  34024. */
  34025. baseWidth: number;
  34026. /**
  34027. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  34028. */
  34029. baseHeight: number;
  34030. /**
  34031. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  34032. */
  34033. baseDepth: number;
  34034. /**
  34035. * Gets a boolean indicating if the texture is inverted on Y axis
  34036. */
  34037. invertY: boolean;
  34038. /**
  34039. * Gets or set the previous tracker in the list
  34040. */
  34041. previous: Nullable<IInternalTextureTracker>;
  34042. /**
  34043. * Gets or set the next tracker in the list
  34044. */
  34045. next: Nullable<IInternalTextureTracker>;
  34046. /** @hidden */
  34047. _initialSlot: number;
  34048. /** @hidden */
  34049. _designatedSlot: number;
  34050. /** @hidden */
  34051. _dataSource: number;
  34052. /** @hidden */
  34053. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34054. /** @hidden */
  34055. _bufferView: Nullable<ArrayBufferView>;
  34056. /** @hidden */
  34057. _bufferViewArray: Nullable<ArrayBufferView[]>;
  34058. /** @hidden */
  34059. _size: number;
  34060. /** @hidden */
  34061. _extension: string;
  34062. /** @hidden */
  34063. _files: Nullable<string[]>;
  34064. /** @hidden */
  34065. _workingCanvas: HTMLCanvasElement;
  34066. /** @hidden */
  34067. _workingContext: CanvasRenderingContext2D;
  34068. /** @hidden */
  34069. _framebuffer: Nullable<WebGLFramebuffer>;
  34070. /** @hidden */
  34071. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  34072. /** @hidden */
  34073. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  34074. /** @hidden */
  34075. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  34076. /** @hidden */
  34077. _attachments: Nullable<number[]>;
  34078. /** @hidden */
  34079. _cachedCoordinatesMode: Nullable<number>;
  34080. /** @hidden */
  34081. _cachedWrapU: Nullable<number>;
  34082. /** @hidden */
  34083. _cachedWrapV: Nullable<number>;
  34084. /** @hidden */
  34085. _cachedWrapR: Nullable<number>;
  34086. /** @hidden */
  34087. _cachedAnisotropicFilteringLevel: Nullable<number>;
  34088. /** @hidden */
  34089. _isDisabled: boolean;
  34090. /** @hidden */
  34091. _compression: Nullable<string>;
  34092. /** @hidden */
  34093. _generateStencilBuffer: boolean;
  34094. /** @hidden */
  34095. _generateDepthBuffer: boolean;
  34096. /** @hidden */
  34097. _comparisonFunction: number;
  34098. /** @hidden */
  34099. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  34100. /** @hidden */
  34101. _lodGenerationScale: number;
  34102. /** @hidden */
  34103. _lodGenerationOffset: number;
  34104. /** @hidden */
  34105. _lodTextureHigh: BaseTexture;
  34106. /** @hidden */
  34107. _lodTextureMid: BaseTexture;
  34108. /** @hidden */
  34109. _lodTextureLow: BaseTexture;
  34110. /** @hidden */
  34111. _isRGBD: boolean;
  34112. /** @hidden */
  34113. _webGLTexture: Nullable<WebGLTexture>;
  34114. /** @hidden */
  34115. _references: number;
  34116. private _engine;
  34117. /**
  34118. * Gets the Engine the texture belongs to.
  34119. * @returns The babylon engine
  34120. */
  34121. getEngine(): Engine;
  34122. /**
  34123. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  34124. */
  34125. readonly dataSource: number;
  34126. /**
  34127. * Creates a new InternalTexture
  34128. * @param engine defines the engine to use
  34129. * @param dataSource defines the type of data that will be used
  34130. */
  34131. constructor(engine: Engine, dataSource: number);
  34132. /**
  34133. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  34134. */
  34135. incrementReferences(): void;
  34136. /**
  34137. * Change the size of the texture (not the size of the content)
  34138. * @param width defines the new width
  34139. * @param height defines the new height
  34140. * @param depth defines the new depth (1 by default)
  34141. */
  34142. updateSize(width: int, height: int, depth?: int): void;
  34143. /** @hidden */
  34144. _rebuild(): void;
  34145. _swapAndDie(target: InternalTexture): void;
  34146. /**
  34147. * Dispose the current allocated resources
  34148. */
  34149. dispose(): void;
  34150. }
  34151. }
  34152. declare module BABYLON {
  34153. /**
  34154. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  34155. */
  34156. interface IInternalTextureTracker {
  34157. /**
  34158. * Gets or set the previous tracker in the list
  34159. */
  34160. previous: Nullable<IInternalTextureTracker>;
  34161. /**
  34162. * Gets or set the next tracker in the list
  34163. */
  34164. next: Nullable<IInternalTextureTracker>;
  34165. }
  34166. /**
  34167. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  34168. */
  34169. class DummyInternalTextureTracker {
  34170. /**
  34171. * Gets or set the previous tracker in the list
  34172. */
  34173. previous: Nullable<IInternalTextureTracker>;
  34174. /**
  34175. * Gets or set the next tracker in the list
  34176. */
  34177. next: Nullable<IInternalTextureTracker>;
  34178. }
  34179. }
  34180. declare module BABYLON {
  34181. class MirrorTexture extends RenderTargetTexture {
  34182. private scene;
  34183. mirrorPlane: Plane;
  34184. private _transformMatrix;
  34185. private _mirrorMatrix;
  34186. private _savedViewMatrix;
  34187. private _blurX;
  34188. private _blurY;
  34189. private _adaptiveBlurKernel;
  34190. private _blurKernelX;
  34191. private _blurKernelY;
  34192. private _blurRatio;
  34193. blurRatio: number;
  34194. adaptiveBlurKernel: number;
  34195. blurKernel: number;
  34196. blurKernelX: number;
  34197. blurKernelY: number;
  34198. private _autoComputeBlurKernel();
  34199. protected _onRatioRescale(): void;
  34200. private _updateGammaSpace();
  34201. private _imageProcessingConfigChangeObserver;
  34202. constructor(name: string, size: number | {
  34203. width: number;
  34204. height: number;
  34205. } | {
  34206. ratio: number;
  34207. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  34208. private _preparePostProcesses();
  34209. clone(): MirrorTexture;
  34210. serialize(): any;
  34211. dispose(): void;
  34212. }
  34213. }
  34214. declare module BABYLON {
  34215. interface IMultiRenderTargetOptions {
  34216. generateMipMaps?: boolean;
  34217. types?: number[];
  34218. samplingModes?: number[];
  34219. generateDepthBuffer?: boolean;
  34220. generateStencilBuffer?: boolean;
  34221. generateDepthTexture?: boolean;
  34222. textureCount?: number;
  34223. doNotChangeAspectRatio?: boolean;
  34224. defaultType?: number;
  34225. }
  34226. class MultiRenderTarget extends RenderTargetTexture {
  34227. private _internalTextures;
  34228. private _textures;
  34229. readonly isSupported: boolean;
  34230. private _multiRenderTargetOptions;
  34231. readonly textures: Texture[];
  34232. readonly depthTexture: Texture;
  34233. wrapU: number;
  34234. wrapV: number;
  34235. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  34236. _rebuild(): void;
  34237. private _createInternalTextures();
  34238. private _createTextures();
  34239. samples: number;
  34240. resize(size: any): void;
  34241. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34242. dispose(): void;
  34243. releaseInternalTextures(): void;
  34244. }
  34245. }
  34246. declare module BABYLON {
  34247. class RawTexture extends Texture {
  34248. format: number;
  34249. private _engine;
  34250. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  34251. update(data: ArrayBufferView): void;
  34252. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34253. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34254. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34255. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34256. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34257. }
  34258. }
  34259. declare module BABYLON {
  34260. /**
  34261. * Class used to store 3D textures containing user data
  34262. */
  34263. class RawTexture3D extends Texture {
  34264. /** Gets or sets the texture format to use */
  34265. format: number;
  34266. private _engine;
  34267. /**
  34268. * Create a new RawTexture3D
  34269. * @param data defines the data of the texture
  34270. * @param width defines the width of the texture
  34271. * @param height defines the height of the texture
  34272. * @param depth defines the depth of the texture
  34273. * @param format defines the texture format to use
  34274. * @param scene defines the hosting scene
  34275. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  34276. * @param invertY defines if texture must be stored with Y axis inverted
  34277. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  34278. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  34279. */
  34280. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  34281. /** Gets or sets the texture format to use */
  34282. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  34283. /**
  34284. * Update the texture with new data
  34285. * @param data defines the data to store in the texture
  34286. */
  34287. update(data: ArrayBufferView): void;
  34288. }
  34289. }
  34290. declare module BABYLON {
  34291. /**
  34292. * Creates a refraction texture used by refraction channel of the standard material.
  34293. * @param name the texture name
  34294. * @param size size of the underlying texture
  34295. * @param scene root scene
  34296. */
  34297. class RefractionTexture extends RenderTargetTexture {
  34298. refractionPlane: Plane;
  34299. depth: number;
  34300. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  34301. clone(): RefractionTexture;
  34302. serialize(): any;
  34303. }
  34304. }
  34305. declare module BABYLON {
  34306. class RenderTargetTexture extends Texture {
  34307. isCube: boolean;
  34308. static _REFRESHRATE_RENDER_ONCE: number;
  34309. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34310. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34311. static readonly REFRESHRATE_RENDER_ONCE: number;
  34312. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34313. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34314. /**
  34315. * Use this predicate to dynamically define the list of mesh you want to render.
  34316. * If set, the renderList property will be overwritten.
  34317. */
  34318. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  34319. /**
  34320. * Use this list to define the list of mesh you want to render.
  34321. */
  34322. renderList: Nullable<Array<AbstractMesh>>;
  34323. renderParticles: boolean;
  34324. renderSprites: boolean;
  34325. coordinatesMode: number;
  34326. activeCamera: Nullable<Camera>;
  34327. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  34328. useCameraPostProcesses: boolean;
  34329. ignoreCameraViewport: boolean;
  34330. private _postProcessManager;
  34331. private _postProcesses;
  34332. private _resizeObserver;
  34333. /**
  34334. * An event triggered when the texture is unbind.
  34335. */
  34336. onBeforeBindObservable: Observable<RenderTargetTexture>;
  34337. /**
  34338. * An event triggered when the texture is unbind.
  34339. */
  34340. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  34341. private _onAfterUnbindObserver;
  34342. onAfterUnbind: () => void;
  34343. /**
  34344. * An event triggered before rendering the texture
  34345. */
  34346. onBeforeRenderObservable: Observable<number>;
  34347. private _onBeforeRenderObserver;
  34348. onBeforeRender: (faceIndex: number) => void;
  34349. /**
  34350. * An event triggered after rendering the texture
  34351. */
  34352. onAfterRenderObservable: Observable<number>;
  34353. private _onAfterRenderObserver;
  34354. onAfterRender: (faceIndex: number) => void;
  34355. /**
  34356. * An event triggered after the texture clear
  34357. */
  34358. onClearObservable: Observable<Engine>;
  34359. private _onClearObserver;
  34360. onClear: (Engine: Engine) => void;
  34361. clearColor: Color4;
  34362. protected _size: number | {
  34363. width: number;
  34364. height: number;
  34365. };
  34366. protected _initialSizeParameter: number | {
  34367. width: number;
  34368. height: number;
  34369. } | {
  34370. ratio: number;
  34371. };
  34372. protected _sizeRatio: Nullable<number>;
  34373. _generateMipMaps: boolean;
  34374. protected _renderingManager: RenderingManager;
  34375. _waitingRenderList: string[];
  34376. protected _doNotChangeAspectRatio: boolean;
  34377. protected _currentRefreshId: number;
  34378. protected _refreshRate: number;
  34379. protected _textureMatrix: Matrix;
  34380. protected _samples: number;
  34381. protected _renderTargetOptions: RenderTargetCreationOptions;
  34382. readonly renderTargetOptions: RenderTargetCreationOptions;
  34383. protected _engine: Engine;
  34384. protected _onRatioRescale(): void;
  34385. /**
  34386. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  34387. * It must define where the camera used to render the texture is set
  34388. */
  34389. boundingBoxPosition: Vector3;
  34390. private _boundingBoxSize;
  34391. /**
  34392. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  34393. * When defined, the cubemap will switch to local mode
  34394. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34395. * @example https://www.babylonjs-playground.com/#RNASML
  34396. */
  34397. boundingBoxSize: Vector3;
  34398. /**
  34399. * In case the RTT has been created with a depth texture, get the associated
  34400. * depth texture.
  34401. * Otherwise, return null.
  34402. */
  34403. depthStencilTexture: Nullable<InternalTexture>;
  34404. /**
  34405. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  34406. * or used a shadow, depth texture...
  34407. * @param name The friendly name of the texture
  34408. * @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)
  34409. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  34410. * @param generateMipMaps True if mip maps need to be generated after render.
  34411. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  34412. * @param type The type of the buffer in the RTT (int, half float, float...)
  34413. * @param isCube True if a cube texture needs to be created
  34414. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  34415. * @param generateDepthBuffer True to generate a depth buffer
  34416. * @param generateStencilBuffer True to generate a stencil buffer
  34417. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  34418. */
  34419. constructor(name: string, size: number | {
  34420. width: number;
  34421. height: number;
  34422. } | {
  34423. ratio: number;
  34424. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  34425. /**
  34426. * Creates a depth stencil texture.
  34427. * This is only available in WebGL 2 or with the depth texture extension available.
  34428. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  34429. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  34430. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  34431. */
  34432. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  34433. private _processSizeParameter(size);
  34434. samples: number;
  34435. resetRefreshCounter(): void;
  34436. refreshRate: number;
  34437. addPostProcess(postProcess: PostProcess): void;
  34438. clearPostProcesses(dispose?: boolean): void;
  34439. removePostProcess(postProcess: PostProcess): void;
  34440. _shouldRender(): boolean;
  34441. getRenderSize(): number;
  34442. getRenderWidth(): number;
  34443. getRenderHeight(): number;
  34444. readonly canRescale: boolean;
  34445. scale(ratio: number): void;
  34446. getReflectionTextureMatrix(): Matrix;
  34447. resize(size: number | {
  34448. width: number;
  34449. height: number;
  34450. } | {
  34451. ratio: number;
  34452. }): void;
  34453. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  34454. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  34455. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34456. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  34457. /**
  34458. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34459. * This allowed control for front to back rendering or reversly depending of the special needs.
  34460. *
  34461. * @param renderingGroupId The rendering group id corresponding to its index
  34462. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34463. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34464. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34465. */
  34466. 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;
  34467. /**
  34468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34469. *
  34470. * @param renderingGroupId The rendering group id corresponding to its index
  34471. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34472. */
  34473. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34474. clone(): RenderTargetTexture;
  34475. serialize(): any;
  34476. disposeFramebufferObjects(): void;
  34477. dispose(): void;
  34478. _rebuild(): void;
  34479. /**
  34480. * Clear the info related to rendering groups preventing retention point in material dispose.
  34481. */
  34482. freeRenderingGroups(): void;
  34483. }
  34484. }
  34485. declare module BABYLON {
  34486. class Texture extends BaseTexture {
  34487. static NEAREST_SAMPLINGMODE: number;
  34488. static NEAREST_NEAREST_MIPLINEAR: number;
  34489. static BILINEAR_SAMPLINGMODE: number;
  34490. static LINEAR_LINEAR_MIPNEAREST: number;
  34491. static TRILINEAR_SAMPLINGMODE: number;
  34492. static LINEAR_LINEAR_MIPLINEAR: number;
  34493. static NEAREST_NEAREST_MIPNEAREST: number;
  34494. static NEAREST_LINEAR_MIPNEAREST: number;
  34495. static NEAREST_LINEAR_MIPLINEAR: number;
  34496. static NEAREST_LINEAR: number;
  34497. static NEAREST_NEAREST: number;
  34498. static LINEAR_NEAREST_MIPNEAREST: number;
  34499. static LINEAR_NEAREST_MIPLINEAR: number;
  34500. static LINEAR_LINEAR: number;
  34501. static LINEAR_NEAREST: number;
  34502. static EXPLICIT_MODE: number;
  34503. static SPHERICAL_MODE: number;
  34504. static PLANAR_MODE: number;
  34505. static CUBIC_MODE: number;
  34506. static PROJECTION_MODE: number;
  34507. static SKYBOX_MODE: number;
  34508. static INVCUBIC_MODE: number;
  34509. static EQUIRECTANGULAR_MODE: number;
  34510. static FIXED_EQUIRECTANGULAR_MODE: number;
  34511. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34512. static CLAMP_ADDRESSMODE: number;
  34513. static WRAP_ADDRESSMODE: number;
  34514. static MIRROR_ADDRESSMODE: number;
  34515. /**
  34516. * 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
  34517. */
  34518. static UseSerializedUrlIfAny: boolean;
  34519. url: Nullable<string>;
  34520. uOffset: number;
  34521. vOffset: number;
  34522. uScale: number;
  34523. vScale: number;
  34524. uAng: number;
  34525. vAng: number;
  34526. wAng: number;
  34527. /**
  34528. * Defines the center of rotation (U)
  34529. */
  34530. uRotationCenter: number;
  34531. /**
  34532. * Defines the center of rotation (V)
  34533. */
  34534. vRotationCenter: number;
  34535. /**
  34536. * Defines the center of rotation (W)
  34537. */
  34538. wRotationCenter: number;
  34539. readonly noMipmap: boolean;
  34540. private _noMipmap;
  34541. _invertY: boolean;
  34542. private _rowGenerationMatrix;
  34543. private _cachedTextureMatrix;
  34544. private _projectionModeMatrix;
  34545. private _t0;
  34546. private _t1;
  34547. private _t2;
  34548. private _cachedUOffset;
  34549. private _cachedVOffset;
  34550. private _cachedUScale;
  34551. private _cachedVScale;
  34552. private _cachedUAng;
  34553. private _cachedVAng;
  34554. private _cachedWAng;
  34555. private _cachedProjectionMatrixId;
  34556. private _cachedCoordinatesMode;
  34557. _samplingMode: number;
  34558. /** @hidden */
  34559. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34560. private _deleteBuffer;
  34561. protected _format: Nullable<number>;
  34562. private _delayedOnLoad;
  34563. private _delayedOnError;
  34564. protected _onLoadObservable: Nullable<Observable<Texture>>;
  34565. protected _isBlocking: boolean;
  34566. isBlocking: boolean;
  34567. readonly samplingMode: number;
  34568. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  34569. /**
  34570. * Update the url (and optional buffer) of this texture if url was null during construction.
  34571. * @param url the url of the texture
  34572. * @param buffer the buffer of the texture (defaults to null)
  34573. */
  34574. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  34575. delayLoad(): void;
  34576. updateSamplingMode(samplingMode: number): void;
  34577. private _prepareRowForTextureGeneration(x, y, z, t);
  34578. getTextureMatrix(): Matrix;
  34579. getReflectionTextureMatrix(): Matrix;
  34580. clone(): Texture;
  34581. readonly onLoadObservable: Observable<Texture>;
  34582. serialize(): any;
  34583. getClassName(): string;
  34584. dispose(): void;
  34585. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  34586. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  34587. 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;
  34588. }
  34589. }
  34590. declare module BABYLON {
  34591. /**
  34592. * Settings for finer control over video usage
  34593. */
  34594. interface VideoTextureSettings {
  34595. /**
  34596. * Applies `autoplay` to video, if specified
  34597. */
  34598. autoPlay?: boolean;
  34599. /**
  34600. * Applies `loop` to video, if specified
  34601. */
  34602. loop?: boolean;
  34603. /**
  34604. * Automatically updates internal texture from video at every frame in the render loop
  34605. */
  34606. autoUpdateTexture: boolean;
  34607. }
  34608. class VideoTexture extends Texture {
  34609. /**
  34610. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34611. */
  34612. readonly autoUpdateTexture: boolean;
  34613. /**
  34614. * The video instance used by the texture internally
  34615. */
  34616. readonly video: HTMLVideoElement;
  34617. private _generateMipMaps;
  34618. private _engine;
  34619. private _stillImageCaptured;
  34620. /**
  34621. * Creates a video texture.
  34622. * Sample : https://doc.babylonjs.com/how_to/video_texture
  34623. * @param {string | null} name optional name, will detect from video source, if not defined
  34624. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  34625. * @param {BABYLON.Scene} scene is obviously the current scene.
  34626. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34627. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  34628. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34629. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  34630. */
  34631. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34632. private _getName(src);
  34633. private _getVideo(src);
  34634. private _createInternalTexture;
  34635. private reset;
  34636. /**
  34637. * Internal method to initiate `update`.
  34638. */
  34639. _rebuild(): void;
  34640. /**
  34641. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34642. */
  34643. update(): void;
  34644. /**
  34645. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34646. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34647. */
  34648. updateTexture(isVisible: boolean): void;
  34649. protected _updateInternalTexture: (e?: Event | undefined) => void;
  34650. /**
  34651. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34652. * @param url New url.
  34653. */
  34654. updateURL(url: string): void;
  34655. dispose(): void;
  34656. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34657. minWidth: number;
  34658. maxWidth: number;
  34659. minHeight: number;
  34660. maxHeight: number;
  34661. deviceId: string;
  34662. }): void;
  34663. }
  34664. }
  34665. declare module BABYLON {
  34666. /**
  34667. * Particle emitter emitting particles from the inside of a box.
  34668. * It emits the particles randomly between 2 given directions.
  34669. */
  34670. class BoxParticleEmitter implements IParticleEmitterType {
  34671. /**
  34672. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34673. */
  34674. direction1: Vector3;
  34675. /**
  34676. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34677. */
  34678. direction2: Vector3;
  34679. /**
  34680. * 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.
  34681. */
  34682. minEmitBox: Vector3;
  34683. /**
  34684. * 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.
  34685. */
  34686. maxEmitBox: Vector3;
  34687. /**
  34688. * Creates a new instance BoxParticleEmitter
  34689. */
  34690. constructor();
  34691. /**
  34692. * Called by the particle System when the direction is computed for the created particle.
  34693. * @param emitPower is the power of the particle (speed)
  34694. * @param worldMatrix is the world matrix of the particle system
  34695. * @param directionToUpdate is the direction vector to update with the result
  34696. * @param particle is the particle we are computed the direction for
  34697. */
  34698. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34699. /**
  34700. * Called by the particle System when the position is computed for the created particle.
  34701. * @param worldMatrix is the world matrix of the particle system
  34702. * @param positionToUpdate is the position vector to update with the result
  34703. * @param particle is the particle we are computed the position for
  34704. */
  34705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34706. /**
  34707. * Clones the current emitter and returns a copy of it
  34708. * @returns the new emitter
  34709. */
  34710. clone(): BoxParticleEmitter;
  34711. /**
  34712. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34713. * @param effect defines the update shader
  34714. */
  34715. applyToShader(effect: Effect): void;
  34716. /**
  34717. * Returns a string to use to update the GPU particles update shader
  34718. * @returns a string containng the defines string
  34719. */
  34720. getEffectDefines(): string;
  34721. /**
  34722. * Returns the string "BoxEmitter"
  34723. * @returns a string containing the class name
  34724. */
  34725. getClassName(): string;
  34726. /**
  34727. * Serializes the particle system to a JSON object.
  34728. * @returns the JSON object
  34729. */
  34730. serialize(): any;
  34731. /**
  34732. * Parse properties from a JSON object
  34733. * @param serializationObject defines the JSON object
  34734. */
  34735. parse(serializationObject: any): void;
  34736. }
  34737. }
  34738. declare module BABYLON {
  34739. /**
  34740. * Particle emitter emitting particles from the inside of a cone.
  34741. * It emits the particles alongside the cone volume from the base to the particle.
  34742. * The emission direction might be randomized.
  34743. */
  34744. class ConeParticleEmitter implements IParticleEmitterType {
  34745. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  34746. directionRandomizer: number;
  34747. private _radius;
  34748. private _angle;
  34749. private _height;
  34750. /**
  34751. * Gets or sets the radius of the emission cone
  34752. */
  34753. radius: number;
  34754. /**
  34755. * Gets or sets the angle of the emission cone
  34756. */
  34757. angle: number;
  34758. private _buildHeight();
  34759. /**
  34760. * Creates a new instance ConeParticleEmitter
  34761. * @param radius the radius of the emission cone (1 by default)
  34762. * @param angles the cone base angle (PI by default)
  34763. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  34764. */
  34765. constructor(radius?: number, angle?: number,
  34766. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  34767. directionRandomizer?: number);
  34768. /**
  34769. * Called by the particle System when the direction is computed for the created particle.
  34770. * @param emitPower is the power of the particle (speed)
  34771. * @param worldMatrix is the world matrix of the particle system
  34772. * @param directionToUpdate is the direction vector to update with the result
  34773. * @param particle is the particle we are computed the direction for
  34774. */
  34775. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34776. /**
  34777. * Called by the particle System when the position is computed for the created particle.
  34778. * @param worldMatrix is the world matrix of the particle system
  34779. * @param positionToUpdate is the position vector to update with the result
  34780. * @param particle is the particle we are computed the position for
  34781. */
  34782. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34783. /**
  34784. * Clones the current emitter and returns a copy of it
  34785. * @returns the new emitter
  34786. */
  34787. clone(): ConeParticleEmitter;
  34788. /**
  34789. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34790. * @param effect defines the update shader
  34791. */
  34792. applyToShader(effect: Effect): void;
  34793. /**
  34794. * Returns a string to use to update the GPU particles update shader
  34795. * @returns a string containng the defines string
  34796. */
  34797. getEffectDefines(): string;
  34798. /**
  34799. * Returns the string "BoxEmitter"
  34800. * @returns a string containing the class name
  34801. */
  34802. getClassName(): string;
  34803. /**
  34804. * Serializes the particle system to a JSON object.
  34805. * @returns the JSON object
  34806. */
  34807. serialize(): any;
  34808. /**
  34809. * Parse properties from a JSON object
  34810. * @param serializationObject defines the JSON object
  34811. */
  34812. parse(serializationObject: any): void;
  34813. }
  34814. }
  34815. declare module BABYLON {
  34816. /**
  34817. * Particle emitter represents a volume emitting particles.
  34818. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  34819. */
  34820. interface IParticleEmitterType {
  34821. /**
  34822. * Called by the particle System when the direction is computed for the created particle.
  34823. * @param emitPower is the power of the particle (speed)
  34824. * @param worldMatrix is the world matrix of the particle system
  34825. * @param directionToUpdate is the direction vector to update with the result
  34826. * @param particle is the particle we are computed the direction for
  34827. */
  34828. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34829. /**
  34830. * Called by the particle System when the position is computed for the created particle.
  34831. * @param worldMatrix is the world matrix of the particle system
  34832. * @param positionToUpdate is the position vector to update with the result
  34833. * @param particle is the particle we are computed the position for
  34834. */
  34835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34836. /**
  34837. * Clones the current emitter and returns a copy of it
  34838. * @returns the new emitter
  34839. */
  34840. clone(): IParticleEmitterType;
  34841. /**
  34842. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34843. * @param effect defines the update shader
  34844. */
  34845. applyToShader(effect: Effect): void;
  34846. /**
  34847. * Returns a string to use to update the GPU particles update shader
  34848. * @returns the effect defines string
  34849. */
  34850. getEffectDefines(): string;
  34851. /**
  34852. * Returns a string representing the class name
  34853. * @returns a string containing the class name
  34854. */
  34855. getClassName(): string;
  34856. /**
  34857. * Serializes the particle system to a JSON object.
  34858. * @returns the JSON object
  34859. */
  34860. serialize(): any;
  34861. /**
  34862. * Parse properties from a JSON object
  34863. * @param serializationObject defines the JSON object
  34864. */
  34865. parse(serializationObject: any): void;
  34866. }
  34867. }
  34868. declare module BABYLON {
  34869. /**
  34870. * Particle emitter emitting particles from the inside of a sphere.
  34871. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  34872. */
  34873. class SphereParticleEmitter implements IParticleEmitterType {
  34874. /**
  34875. * The radius of the emission sphere.
  34876. */
  34877. radius: number;
  34878. /**
  34879. * How much to randomize the particle direction [0-1].
  34880. */
  34881. directionRandomizer: number;
  34882. /**
  34883. * Creates a new instance SphereParticleEmitter
  34884. * @param radius the radius of the emission sphere (1 by default)
  34885. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34886. */
  34887. constructor(
  34888. /**
  34889. * The radius of the emission sphere.
  34890. */
  34891. radius?: number,
  34892. /**
  34893. * How much to randomize the particle direction [0-1].
  34894. */
  34895. directionRandomizer?: number);
  34896. /**
  34897. * Called by the particle System when the direction is computed for the created particle.
  34898. * @param emitPower is the power of the particle (speed)
  34899. * @param worldMatrix is the world matrix of the particle system
  34900. * @param directionToUpdate is the direction vector to update with the result
  34901. * @param particle is the particle we are computed the direction for
  34902. */
  34903. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34904. /**
  34905. * Called by the particle System when the position is computed for the created particle.
  34906. * @param worldMatrix is the world matrix of the particle system
  34907. * @param positionToUpdate is the position vector to update with the result
  34908. * @param particle is the particle we are computed the position for
  34909. */
  34910. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34911. /**
  34912. * Clones the current emitter and returns a copy of it
  34913. * @returns the new emitter
  34914. */
  34915. clone(): SphereParticleEmitter;
  34916. /**
  34917. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34918. * @param effect defines the update shader
  34919. */
  34920. applyToShader(effect: Effect): void;
  34921. /**
  34922. * Returns a string to use to update the GPU particles update shader
  34923. * @returns a string containng the defines string
  34924. */
  34925. getEffectDefines(): string;
  34926. /**
  34927. * Returns the string "SphereParticleEmitter"
  34928. * @returns a string containing the class name
  34929. */
  34930. getClassName(): string;
  34931. /**
  34932. * Serializes the particle system to a JSON object.
  34933. * @returns the JSON object
  34934. */
  34935. serialize(): any;
  34936. /**
  34937. * Parse properties from a JSON object
  34938. * @param serializationObject defines the JSON object
  34939. */
  34940. parse(serializationObject: any): void;
  34941. }
  34942. /**
  34943. * Particle emitter emitting particles from the inside of a sphere.
  34944. * It emits the particles randomly between two vectors.
  34945. */
  34946. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34947. /**
  34948. * The min limit of the emission direction.
  34949. */
  34950. direction1: Vector3;
  34951. /**
  34952. * The max limit of the emission direction.
  34953. */
  34954. direction2: Vector3;
  34955. /**
  34956. * Creates a new instance SphereDirectedParticleEmitter
  34957. * @param radius the radius of the emission sphere (1 by default)
  34958. * @param direction1 the min limit of the emission direction (up vector by default)
  34959. * @param direction2 the max limit of the emission direction (up vector by default)
  34960. */
  34961. constructor(radius?: number,
  34962. /**
  34963. * The min limit of the emission direction.
  34964. */
  34965. direction1?: Vector3,
  34966. /**
  34967. * The max limit of the emission direction.
  34968. */
  34969. direction2?: Vector3);
  34970. /**
  34971. * Called by the particle System when the direction is computed for the created particle.
  34972. * @param emitPower is the power of the particle (speed)
  34973. * @param worldMatrix is the world matrix of the particle system
  34974. * @param directionToUpdate is the direction vector to update with the result
  34975. * @param particle is the particle we are computed the direction for
  34976. */
  34977. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34978. /**
  34979. * Clones the current emitter and returns a copy of it
  34980. * @returns the new emitter
  34981. */
  34982. clone(): SphereDirectedParticleEmitter;
  34983. /**
  34984. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34985. * @param effect defines the update shader
  34986. */
  34987. applyToShader(effect: Effect): void;
  34988. /**
  34989. * Returns a string to use to update the GPU particles update shader
  34990. * @returns a string containng the defines string
  34991. */
  34992. getEffectDefines(): string;
  34993. /**
  34994. * Returns the string "SphereDirectedParticleEmitter"
  34995. * @returns a string containing the class name
  34996. */
  34997. getClassName(): string;
  34998. /**
  34999. * Serializes the particle system to a JSON object.
  35000. * @returns the JSON object
  35001. */
  35002. serialize(): any;
  35003. /**
  35004. * Parse properties from a JSON object
  35005. * @param serializationObject defines the JSON object
  35006. */
  35007. parse(serializationObject: any): void;
  35008. }
  35009. }
  35010. declare var DracoDecoderModule: any;
  35011. declare var WebAssembly: any;
  35012. declare module BABYLON {
  35013. /**
  35014. * Configuration for Draco compression
  35015. */
  35016. interface IDracoCompressionConfiguration {
  35017. /**
  35018. * Configuration for the decoder.
  35019. */
  35020. decoder?: {
  35021. /**
  35022. * The url to the WebAssembly module.
  35023. */
  35024. wasmUrl?: string;
  35025. /**
  35026. * The url to the WebAssembly binary.
  35027. */
  35028. wasmBinaryUrl?: string;
  35029. /**
  35030. * The url to the fallback JavaScript module.
  35031. */
  35032. fallbackUrl?: string;
  35033. };
  35034. }
  35035. /**
  35036. * Draco compression (https://google.github.io/draco/)
  35037. *
  35038. * This class wraps the Draco module.
  35039. *
  35040. * **Encoder**
  35041. *
  35042. * The encoder is not currently implemented.
  35043. *
  35044. * **Decoder**
  35045. *
  35046. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  35047. *
  35048. * To update the configuration, use the following code:
  35049. * ```javascript
  35050. * BABYLON.DracoCompression.Configuration = {
  35051. * decoder: {
  35052. * wasmUrl: "<url to the WebAssembly library>",
  35053. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  35054. * fallbackUrl: "<url to the fallback JavaScript library>",
  35055. * }
  35056. * };
  35057. * ```
  35058. *
  35059. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  35060. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  35061. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  35062. *
  35063. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  35064. * ```javascript
  35065. * var dracoCompression = new BABYLON.DracoCompression();
  35066. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  35067. * [BABYLON.VertexBuffer.PositionKind]: 0
  35068. * });
  35069. * ```
  35070. *
  35071. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  35072. */
  35073. class DracoCompression implements IDisposable {
  35074. private static _DecoderModulePromise;
  35075. /**
  35076. * The configuration. Defaults to the following urls:
  35077. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  35078. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  35079. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  35080. */
  35081. static Configuration: IDracoCompressionConfiguration;
  35082. /**
  35083. * Returns true if the decoder is available.
  35084. */
  35085. static readonly DecoderAvailable: boolean;
  35086. /**
  35087. * Constructor
  35088. */
  35089. constructor();
  35090. /**
  35091. * Stop all async operations and release resources.
  35092. */
  35093. dispose(): void;
  35094. /**
  35095. * Decode Draco compressed mesh data to vertex data.
  35096. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  35097. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  35098. * @returns A promise that resolves with the decoded vertex data
  35099. */
  35100. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  35101. [kind: string]: number;
  35102. }): Promise<VertexData>;
  35103. private static _GetDecoderModule();
  35104. private static _LoadScriptAsync(url);
  35105. private static _LoadFileAsync(url);
  35106. }
  35107. }
  35108. declare module BABYLON {
  35109. class CannonJSPlugin implements IPhysicsEnginePlugin {
  35110. private _useDeltaForWorldStep;
  35111. world: any;
  35112. name: string;
  35113. private _physicsMaterials;
  35114. private _fixedTimeStep;
  35115. BJSCANNON: any;
  35116. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  35117. setGravity(gravity: Vector3): void;
  35118. setTimeStep(timeStep: number): void;
  35119. getTimeStep(): number;
  35120. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35121. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35122. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35123. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35124. private _processChildMeshes(mainImpostor);
  35125. removePhysicsBody(impostor: PhysicsImpostor): void;
  35126. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35127. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35128. private _addMaterial(name, friction, restitution);
  35129. private _checkWithEpsilon(value);
  35130. private _createShape(impostor);
  35131. private _createHeightmap(object, pointDepth?);
  35132. private _minus90X;
  35133. private _plus90X;
  35134. private _tmpPosition;
  35135. private _tmpDeltaPosition;
  35136. private _tmpUnityRotation;
  35137. private _updatePhysicsBodyTransformation(impostor);
  35138. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35139. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35140. isSupported(): boolean;
  35141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35146. getBodyMass(impostor: PhysicsImpostor): number;
  35147. getBodyFriction(impostor: PhysicsImpostor): number;
  35148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35149. getBodyRestitution(impostor: PhysicsImpostor): number;
  35150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35151. sleepBody(impostor: PhysicsImpostor): void;
  35152. wakeUpBody(impostor: PhysicsImpostor): void;
  35153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35154. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  35155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  35156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35157. getRadius(impostor: PhysicsImpostor): number;
  35158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35159. dispose(): void;
  35160. private _extendNamespace();
  35161. }
  35162. }
  35163. declare module BABYLON {
  35164. class OimoJSPlugin implements IPhysicsEnginePlugin {
  35165. world: any;
  35166. name: string;
  35167. BJSOIMO: any;
  35168. constructor(iterations?: number);
  35169. setGravity(gravity: Vector3): void;
  35170. setTimeStep(timeStep: number): void;
  35171. getTimeStep(): number;
  35172. private _tmpImpostorsArray;
  35173. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35174. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35175. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35176. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35177. private _tmpPositionVector;
  35178. removePhysicsBody(impostor: PhysicsImpostor): void;
  35179. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35180. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35181. isSupported(): boolean;
  35182. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35183. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35184. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35185. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35186. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35187. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35188. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35189. getBodyMass(impostor: PhysicsImpostor): number;
  35190. getBodyFriction(impostor: PhysicsImpostor): number;
  35191. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35192. getBodyRestitution(impostor: PhysicsImpostor): number;
  35193. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35194. sleepBody(impostor: PhysicsImpostor): void;
  35195. wakeUpBody(impostor: PhysicsImpostor): void;
  35196. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35197. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  35198. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  35199. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35200. getRadius(impostor: PhysicsImpostor): number;
  35201. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35202. dispose(): void;
  35203. }
  35204. }
  35205. declare module BABYLON {
  35206. /**
  35207. * This represents a set of one or more post processes in Babylon.
  35208. * A post process can be used to apply a shader to a texture after it is rendered.
  35209. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  35210. */
  35211. class PostProcessRenderEffect {
  35212. private _postProcesses;
  35213. private _getPostProcesses;
  35214. private _singleInstance;
  35215. private _cameras;
  35216. private _indicesForCamera;
  35217. /**
  35218. * Name of the effect
  35219. */
  35220. _name: string;
  35221. /**
  35222. * Instantiates a post process render effect.
  35223. * A post process can be used to apply a shader to a texture after it is rendered.
  35224. * @param engine The engine the effect is tied to
  35225. * @param name The name of the effect
  35226. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  35227. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  35228. */
  35229. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  35230. /**
  35231. * Checks if all the post processes in the effect are supported.
  35232. */
  35233. readonly isSupported: boolean;
  35234. /**
  35235. * Updates the current state of the effect
  35236. */
  35237. _update(): void;
  35238. /**
  35239. * Attaches the effect on cameras
  35240. * @param cameras The camera to attach to.
  35241. */
  35242. _attachCameras(cameras: Camera): void;
  35243. /**
  35244. * Attaches the effect on cameras
  35245. * @param cameras The camera to attach to.
  35246. */
  35247. _attachCameras(cameras: Camera[]): void;
  35248. /**
  35249. * Detatches the effect on cameras
  35250. * @param cameras The camera to detatch from.
  35251. */
  35252. _detachCameras(cameras: Camera): void;
  35253. /**
  35254. * Detatches the effect on cameras
  35255. * @param cameras The camera to detatch from.
  35256. */
  35257. _detachCameras(cameras: Camera[]): void;
  35258. /**
  35259. * Enables the effect on given cameras
  35260. * @param cameras The camera to enable.
  35261. */
  35262. _enable(cameras: Camera): void;
  35263. /**
  35264. * Enables the effect on given cameras
  35265. * @param cameras The camera to enable.
  35266. */
  35267. _enable(cameras: Nullable<Camera[]>): void;
  35268. /**
  35269. * Disables the effect on the given cameras
  35270. * @param cameras The camera to disable.
  35271. */
  35272. _disable(cameras: Camera): void;
  35273. /**
  35274. * Disables the effect on the given cameras
  35275. * @param cameras The camera to disable.
  35276. */
  35277. _disable(cameras: Nullable<Camera[]>): void;
  35278. /**
  35279. * Gets a list of the post processes contained in the effect.
  35280. * @param camera The camera to get the post processes on.
  35281. * @returns The list of the post processes in the effect.
  35282. */
  35283. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  35284. }
  35285. }
  35286. declare module BABYLON {
  35287. class PostProcessRenderPipeline {
  35288. private engine;
  35289. private _renderEffects;
  35290. private _renderEffectsForIsolatedPass;
  35291. protected _cameras: Camera[];
  35292. _name: string;
  35293. constructor(engine: Engine, name: string);
  35294. getClassName(): string;
  35295. readonly isSupported: boolean;
  35296. addEffect(renderEffect: PostProcessRenderEffect): void;
  35297. _rebuild(): void;
  35298. _enableEffect(renderEffectName: string, cameras: Camera): void;
  35299. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  35300. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  35301. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  35302. _attachCameras(cameras: Camera, unique: boolean): void;
  35303. _attachCameras(cameras: Camera[], unique: boolean): void;
  35304. _detachCameras(cameras: Camera): void;
  35305. _detachCameras(cameras: Nullable<Camera[]>): void;
  35306. _update(): void;
  35307. _reset(): void;
  35308. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  35309. dispose(): void;
  35310. }
  35311. }
  35312. declare module BABYLON {
  35313. class PostProcessRenderPipelineManager {
  35314. private _renderPipelines;
  35315. constructor();
  35316. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  35317. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  35318. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  35319. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  35320. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  35321. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35322. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35323. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35324. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35325. update(): void;
  35326. _rebuild(): void;
  35327. dispose(): void;
  35328. }
  35329. }
  35330. declare module BABYLON {
  35331. /**
  35332. * Helper class dealing with the extraction of spherical polynomial dataArray
  35333. * from a cube map.
  35334. */
  35335. class CubeMapToSphericalPolynomialTools {
  35336. private static FileFaces;
  35337. /**
  35338. * Converts a texture to the according Spherical Polynomial data.
  35339. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35340. *
  35341. * @param texture The texture to extract the information from.
  35342. * @return The Spherical Polynomial data.
  35343. */
  35344. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  35345. /**
  35346. * Converts a cubemap to the according Spherical Polynomial data.
  35347. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35348. *
  35349. * @param cubeInfo The Cube map to extract the information from.
  35350. * @return The Spherical Polynomial data.
  35351. */
  35352. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  35353. }
  35354. }
  35355. declare module BABYLON {
  35356. /**
  35357. * Header information of HDR texture files.
  35358. */
  35359. interface HDRInfo {
  35360. /**
  35361. * The height of the texture in pixels.
  35362. */
  35363. height: number;
  35364. /**
  35365. * The width of the texture in pixels.
  35366. */
  35367. width: number;
  35368. /**
  35369. * The index of the beginning of the data in the binary file.
  35370. */
  35371. dataPosition: number;
  35372. }
  35373. /**
  35374. * This groups tools to convert HDR texture to native colors array.
  35375. */
  35376. class HDRTools {
  35377. private static Ldexp(mantissa, exponent);
  35378. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  35379. private static readStringLine(uint8array, startIndex);
  35380. /**
  35381. * Reads header information from an RGBE texture stored in a native array.
  35382. * More information on this format are available here:
  35383. * https://en.wikipedia.org/wiki/RGBE_image_format
  35384. *
  35385. * @param uint8array The binary file stored in native array.
  35386. * @return The header information.
  35387. */
  35388. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  35389. /**
  35390. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  35391. * This RGBE texture needs to store the information as a panorama.
  35392. *
  35393. * More information on this format are available here:
  35394. * https://en.wikipedia.org/wiki/RGBE_image_format
  35395. *
  35396. * @param buffer The binary file stored in an array buffer.
  35397. * @param size The expected size of the extracted cubemap.
  35398. * @return The Cube Map information.
  35399. */
  35400. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  35401. /**
  35402. * Returns the pixels data extracted from an RGBE texture.
  35403. * This pixels will be stored left to right up to down in the R G B order in one array.
  35404. *
  35405. * More information on this format are available here:
  35406. * https://en.wikipedia.org/wiki/RGBE_image_format
  35407. *
  35408. * @param uint8array The binary file stored in an array buffer.
  35409. * @param hdrInfo The header information of the file.
  35410. * @return The pixels data in RGB right to left up to down order.
  35411. */
  35412. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  35413. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  35414. }
  35415. }
  35416. declare module BABYLON {
  35417. /**
  35418. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  35419. */
  35420. interface CubeMapInfo {
  35421. /**
  35422. * The pixel array for the front face.
  35423. * This is stored in format, left to right, up to down format.
  35424. */
  35425. front: Nullable<ArrayBufferView>;
  35426. /**
  35427. * The pixel array for the back face.
  35428. * This is stored in format, left to right, up to down format.
  35429. */
  35430. back: Nullable<ArrayBufferView>;
  35431. /**
  35432. * The pixel array for the left face.
  35433. * This is stored in format, left to right, up to down format.
  35434. */
  35435. left: Nullable<ArrayBufferView>;
  35436. /**
  35437. * The pixel array for the right face.
  35438. * This is stored in format, left to right, up to down format.
  35439. */
  35440. right: Nullable<ArrayBufferView>;
  35441. /**
  35442. * The pixel array for the up face.
  35443. * This is stored in format, left to right, up to down format.
  35444. */
  35445. up: Nullable<ArrayBufferView>;
  35446. /**
  35447. * The pixel array for the down face.
  35448. * This is stored in format, left to right, up to down format.
  35449. */
  35450. down: Nullable<ArrayBufferView>;
  35451. /**
  35452. * The size of the cubemap stored.
  35453. *
  35454. * Each faces will be size * size pixels.
  35455. */
  35456. size: number;
  35457. /**
  35458. * The format of the texture.
  35459. *
  35460. * RGBA, RGB.
  35461. */
  35462. format: number;
  35463. /**
  35464. * The type of the texture data.
  35465. *
  35466. * UNSIGNED_INT, FLOAT.
  35467. */
  35468. type: number;
  35469. /**
  35470. * Specifies whether the texture is in gamma space.
  35471. */
  35472. gammaSpace: boolean;
  35473. }
  35474. /**
  35475. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  35476. */
  35477. class PanoramaToCubeMapTools {
  35478. private static FACE_FRONT;
  35479. private static FACE_BACK;
  35480. private static FACE_RIGHT;
  35481. private static FACE_LEFT;
  35482. private static FACE_DOWN;
  35483. private static FACE_UP;
  35484. /**
  35485. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  35486. *
  35487. * @param float32Array The source data.
  35488. * @param inputWidth The width of the input panorama.
  35489. * @param inputhHeight The height of the input panorama.
  35490. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  35491. * @return The cubemap data
  35492. */
  35493. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  35494. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  35495. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  35496. }
  35497. }
  35498. declare module BABYLON {
  35499. class CustomProceduralTexture extends ProceduralTexture {
  35500. private _animate;
  35501. private _time;
  35502. private _config;
  35503. private _texturePath;
  35504. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  35505. private loadJson(jsonUrl);
  35506. isReady(): boolean;
  35507. render(useCameraPostProcess?: boolean): void;
  35508. updateTextures(): void;
  35509. updateShaderUniforms(): void;
  35510. animate: boolean;
  35511. }
  35512. }
  35513. declare module BABYLON {
  35514. class ProceduralTexture extends Texture {
  35515. isCube: boolean;
  35516. private _size;
  35517. _generateMipMaps: boolean;
  35518. isEnabled: boolean;
  35519. private _currentRefreshId;
  35520. private _refreshRate;
  35521. onGenerated: () => void;
  35522. private _vertexBuffers;
  35523. private _indexBuffer;
  35524. private _effect;
  35525. private _uniforms;
  35526. private _samplers;
  35527. private _fragment;
  35528. _textures: {
  35529. [key: string]: Texture;
  35530. };
  35531. private _floats;
  35532. private _floatsArrays;
  35533. private _colors3;
  35534. private _colors4;
  35535. private _vectors2;
  35536. private _vectors3;
  35537. private _matrices;
  35538. private _fallbackTexture;
  35539. private _fallbackTextureUsed;
  35540. private _engine;
  35541. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  35542. private _createIndexBuffer();
  35543. _rebuild(): void;
  35544. reset(): void;
  35545. isReady(): boolean;
  35546. resetRefreshCounter(): void;
  35547. setFragment(fragment: any): void;
  35548. refreshRate: number;
  35549. _shouldRender(): boolean;
  35550. getRenderSize(): number;
  35551. resize(size: number, generateMipMaps: boolean): void;
  35552. private _checkUniform(uniformName);
  35553. setTexture(name: string, texture: Texture): ProceduralTexture;
  35554. setFloat(name: string, value: number): ProceduralTexture;
  35555. setFloats(name: string, value: number[]): ProceduralTexture;
  35556. setColor3(name: string, value: Color3): ProceduralTexture;
  35557. setColor4(name: string, value: Color4): ProceduralTexture;
  35558. setVector2(name: string, value: Vector2): ProceduralTexture;
  35559. setVector3(name: string, value: Vector3): ProceduralTexture;
  35560. setMatrix(name: string, value: Matrix): ProceduralTexture;
  35561. render(useCameraPostProcess?: boolean): void;
  35562. clone(): ProceduralTexture;
  35563. dispose(): void;
  35564. }
  35565. }
  35566. declare module BABYLON {
  35567. /**
  35568. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  35569. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  35570. */
  35571. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35572. private _scene;
  35573. private _originalCameras;
  35574. /**
  35575. * ID of the sharpen post process,
  35576. */
  35577. private readonly SharpenPostProcessId;
  35578. /**
  35579. * ID of the image processing post process;
  35580. */
  35581. readonly ImageProcessingPostProcessId: string;
  35582. /**
  35583. * ID of the Fast Approximate Anti-Aliasing post process;
  35584. */
  35585. readonly FxaaPostProcessId: string;
  35586. /**
  35587. * ID of the chromatic aberration post process,
  35588. */
  35589. private readonly ChromaticAberrationPostProcessId;
  35590. /**
  35591. * ID of the grain post process
  35592. */
  35593. private readonly GrainPostProcessId;
  35594. /**
  35595. * Sharpen post process which will apply a sharpen convolution to enhance edges
  35596. */
  35597. sharpen: SharpenPostProcess;
  35598. private _sharpenEffect;
  35599. private bloom;
  35600. /**
  35601. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  35602. */
  35603. depthOfField: DepthOfFieldEffect;
  35604. /**
  35605. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  35606. */
  35607. fxaa: FxaaPostProcess;
  35608. /**
  35609. * Image post processing pass used to perform operations such as tone mapping or color grading.
  35610. */
  35611. imageProcessing: ImageProcessingPostProcess;
  35612. /**
  35613. * Chromatic aberration post process which will shift rgb colors in the image
  35614. */
  35615. chromaticAberration: ChromaticAberrationPostProcess;
  35616. private _chromaticAberrationEffect;
  35617. /**
  35618. * Grain post process which add noise to the image
  35619. */
  35620. grain: GrainPostProcess;
  35621. private _grainEffect;
  35622. /**
  35623. * Glow post process which adds a glow to emmisive areas of the image
  35624. */
  35625. private _glowLayer;
  35626. /**
  35627. * Animations which can be used to tweak settings over a period of time
  35628. */
  35629. animations: Animation[];
  35630. private _imageProcessingConfigurationObserver;
  35631. private _sharpenEnabled;
  35632. private _bloomEnabled;
  35633. private _depthOfFieldEnabled;
  35634. private _depthOfFieldBlurLevel;
  35635. private _fxaaEnabled;
  35636. private _imageProcessingEnabled;
  35637. private _defaultPipelineTextureType;
  35638. private _bloomScale;
  35639. private _chromaticAberrationEnabled;
  35640. private _grainEnabled;
  35641. private _buildAllowed;
  35642. /**
  35643. * Enable or disable the sharpen process from the pipeline
  35644. */
  35645. sharpenEnabled: boolean;
  35646. private _resizeObserver;
  35647. private _hardwareScaleLevel;
  35648. private _bloomKernel;
  35649. /**
  35650. * Specifies the size of the bloom blur kernel, relative to the final output size
  35651. */
  35652. bloomKernel: number;
  35653. /**
  35654. * Specifies the weight of the bloom in the final rendering
  35655. */
  35656. private _bloomWeight;
  35657. /**
  35658. * Specifies the luma threshold for the area that will be blurred by the bloom
  35659. */
  35660. private _bloomThreshold;
  35661. private _hdr;
  35662. /**
  35663. * The strength of the bloom.
  35664. */
  35665. bloomWeight: number;
  35666. /**
  35667. * The strength of the bloom.
  35668. */
  35669. bloomThreshold: number;
  35670. /**
  35671. * The scale of the bloom, lower value will provide better performance.
  35672. */
  35673. bloomScale: number;
  35674. /**
  35675. * Enable or disable the bloom from the pipeline
  35676. */
  35677. bloomEnabled: boolean;
  35678. private _rebuildBloom();
  35679. /**
  35680. * If the depth of field is enabled.
  35681. */
  35682. depthOfFieldEnabled: boolean;
  35683. /**
  35684. * Blur level of the depth of field effect. (Higher blur will effect performance)
  35685. */
  35686. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  35687. /**
  35688. * If the anti aliasing is enabled.
  35689. */
  35690. fxaaEnabled: boolean;
  35691. private _samples;
  35692. /**
  35693. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  35694. */
  35695. samples: number;
  35696. /**
  35697. * If image processing is enabled.
  35698. */
  35699. imageProcessingEnabled: boolean;
  35700. /**
  35701. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  35702. */
  35703. glowLayerEnabled: boolean;
  35704. /**
  35705. * Enable or disable the chromaticAberration process from the pipeline
  35706. */
  35707. chromaticAberrationEnabled: boolean;
  35708. /**
  35709. * Enable or disable the grain process from the pipeline
  35710. */
  35711. grainEnabled: boolean;
  35712. /**
  35713. * @constructor
  35714. * @param {string} name - The rendering pipeline name (default: "")
  35715. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  35716. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  35717. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  35718. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  35719. */
  35720. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  35721. /**
  35722. * Force the compilation of the entire pipeline.
  35723. */
  35724. prepare(): void;
  35725. private _hasCleared;
  35726. private _prevPostProcess;
  35727. private _prevPrevPostProcess;
  35728. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  35729. private _buildPipeline();
  35730. private _disposePostProcesses(disposeNonRecreated?);
  35731. /**
  35732. * Dispose of the pipeline and stop all post processes
  35733. */
  35734. dispose(): void;
  35735. /**
  35736. * Serialize the rendering pipeline (Used when exporting)
  35737. * @returns the serialized object
  35738. */
  35739. serialize(): any;
  35740. /**
  35741. * Parse the serialized pipeline
  35742. * @param source Source pipeline.
  35743. * @param scene The scene to load the pipeline to.
  35744. * @param rootUrl The URL of the serialized pipeline.
  35745. * @returns An instantiated pipeline from the serialized object.
  35746. */
  35747. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  35748. }
  35749. }
  35750. declare module BABYLON {
  35751. class LensRenderingPipeline extends PostProcessRenderPipeline {
  35752. /**
  35753. * The chromatic aberration PostProcess id in the pipeline
  35754. */
  35755. LensChromaticAberrationEffect: string;
  35756. /**
  35757. * The highlights enhancing PostProcess id in the pipeline
  35758. */
  35759. HighlightsEnhancingEffect: string;
  35760. /**
  35761. * The depth-of-field PostProcess id in the pipeline
  35762. */
  35763. LensDepthOfFieldEffect: string;
  35764. private _scene;
  35765. private _depthTexture;
  35766. private _grainTexture;
  35767. private _chromaticAberrationPostProcess;
  35768. private _highlightsPostProcess;
  35769. private _depthOfFieldPostProcess;
  35770. private _edgeBlur;
  35771. private _grainAmount;
  35772. private _chromaticAberration;
  35773. private _distortion;
  35774. private _highlightsGain;
  35775. private _highlightsThreshold;
  35776. private _dofDistance;
  35777. private _dofAperture;
  35778. private _dofDarken;
  35779. private _dofPentagon;
  35780. private _blurNoise;
  35781. /**
  35782. * @constructor
  35783. *
  35784. * Effect parameters are as follow:
  35785. * {
  35786. * chromatic_aberration: number; // from 0 to x (1 for realism)
  35787. * edge_blur: number; // from 0 to x (1 for realism)
  35788. * distortion: number; // from 0 to x (1 for realism)
  35789. * grain_amount: number; // from 0 to 1
  35790. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  35791. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  35792. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  35793. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  35794. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  35795. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  35796. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  35797. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  35798. * }
  35799. * Note: if an effect parameter is unset, effect is disabled
  35800. *
  35801. * @param {string} name - The rendering pipeline name
  35802. * @param {object} parameters - An object containing all parameters (see above)
  35803. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35804. * @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)
  35805. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35806. */
  35807. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  35808. setEdgeBlur(amount: number): void;
  35809. disableEdgeBlur(): void;
  35810. setGrainAmount(amount: number): void;
  35811. disableGrain(): void;
  35812. setChromaticAberration(amount: number): void;
  35813. disableChromaticAberration(): void;
  35814. setEdgeDistortion(amount: number): void;
  35815. disableEdgeDistortion(): void;
  35816. setFocusDistance(amount: number): void;
  35817. disableDepthOfField(): void;
  35818. setAperture(amount: number): void;
  35819. setDarkenOutOfFocus(amount: number): void;
  35820. enablePentagonBokeh(): void;
  35821. disablePentagonBokeh(): void;
  35822. enableNoiseBlur(): void;
  35823. disableNoiseBlur(): void;
  35824. setHighlightsGain(amount: number): void;
  35825. setHighlightsThreshold(amount: number): void;
  35826. disableHighlights(): void;
  35827. /**
  35828. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  35829. */
  35830. dispose(disableDepthRender?: boolean): void;
  35831. private _createChromaticAberrationPostProcess(ratio);
  35832. private _createHighlightsPostProcess(ratio);
  35833. private _createDepthOfFieldPostProcess(ratio);
  35834. private _createGrainTexture();
  35835. }
  35836. }
  35837. declare module BABYLON {
  35838. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  35839. /**
  35840. * The PassPostProcess id in the pipeline that contains the original scene color
  35841. */
  35842. SSAOOriginalSceneColorEffect: string;
  35843. /**
  35844. * The SSAO PostProcess id in the pipeline
  35845. */
  35846. SSAORenderEffect: string;
  35847. /**
  35848. * The horizontal blur PostProcess id in the pipeline
  35849. */
  35850. SSAOBlurHRenderEffect: string;
  35851. /**
  35852. * The vertical blur PostProcess id in the pipeline
  35853. */
  35854. SSAOBlurVRenderEffect: string;
  35855. /**
  35856. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35857. */
  35858. SSAOCombineRenderEffect: string;
  35859. /**
  35860. * The output strength of the SSAO post-process. Default value is 1.0.
  35861. */
  35862. totalStrength: number;
  35863. /**
  35864. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  35865. */
  35866. maxZ: number;
  35867. /**
  35868. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  35869. */
  35870. minZAspect: number;
  35871. /**
  35872. * Number of samples used for the SSAO calculations. Default value is 8
  35873. */
  35874. private _samples;
  35875. /**
  35876. * Ratio object used for SSAO ratio and blur ratio
  35877. */
  35878. private _ratio;
  35879. /**
  35880. * Dynamically generated sphere sampler.
  35881. */
  35882. private _sampleSphere;
  35883. /**
  35884. * Blur filter offsets
  35885. */
  35886. private _samplerOffsets;
  35887. samples: number;
  35888. /**
  35889. * Are we using bilateral blur ?
  35890. */
  35891. private _expensiveBlur;
  35892. expensiveBlur: boolean;
  35893. /**
  35894. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  35895. */
  35896. radius: number;
  35897. /**
  35898. * The base color of the SSAO post-process
  35899. * The final result is "base + ssao" between [0, 1]
  35900. */
  35901. base: number;
  35902. /**
  35903. * Support test.
  35904. */
  35905. static readonly IsSupported: boolean;
  35906. private _scene;
  35907. private _depthTexture;
  35908. private _normalTexture;
  35909. private _randomTexture;
  35910. private _originalColorPostProcess;
  35911. private _ssaoPostProcess;
  35912. private _blurHPostProcess;
  35913. private _blurVPostProcess;
  35914. private _ssaoCombinePostProcess;
  35915. private _firstUpdate;
  35916. /**
  35917. * @constructor
  35918. * @param {string} name - The rendering pipeline name
  35919. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35920. * @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 }
  35921. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35922. */
  35923. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35924. /**
  35925. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35926. */
  35927. dispose(disableGeometryBufferRenderer?: boolean): void;
  35928. private _createBlurPostProcess(ssaoRatio, blurRatio);
  35929. _rebuild(): void;
  35930. private _generateHemisphere();
  35931. private _createSSAOPostProcess(ratio);
  35932. private _createSSAOCombinePostProcess(ratio);
  35933. private _createRandomTexture();
  35934. /**
  35935. * Serialize the rendering pipeline (Used when exporting)
  35936. * @returns the serialized object
  35937. */
  35938. serialize(): any;
  35939. /**
  35940. * Parse the serialized pipeline
  35941. * @param source Source pipeline.
  35942. * @param scene The scene to load the pipeline to.
  35943. * @param rootUrl The URL of the serialized pipeline.
  35944. * @returns An instantiated pipeline from the serialized object.
  35945. */
  35946. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  35947. }
  35948. }
  35949. declare module BABYLON {
  35950. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  35951. /**
  35952. * The PassPostProcess id in the pipeline that contains the original scene color
  35953. */
  35954. SSAOOriginalSceneColorEffect: string;
  35955. /**
  35956. * The SSAO PostProcess id in the pipeline
  35957. */
  35958. SSAORenderEffect: string;
  35959. /**
  35960. * The horizontal blur PostProcess id in the pipeline
  35961. */
  35962. SSAOBlurHRenderEffect: string;
  35963. /**
  35964. * The vertical blur PostProcess id in the pipeline
  35965. */
  35966. SSAOBlurVRenderEffect: string;
  35967. /**
  35968. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35969. */
  35970. SSAOCombineRenderEffect: string;
  35971. /**
  35972. * The output strength of the SSAO post-process. Default value is 1.0.
  35973. */
  35974. totalStrength: number;
  35975. /**
  35976. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  35977. */
  35978. radius: number;
  35979. /**
  35980. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  35981. * Must not be equal to fallOff and superior to fallOff.
  35982. * Default value is 0.975
  35983. */
  35984. area: number;
  35985. /**
  35986. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  35987. * Must not be equal to area and inferior to area.
  35988. * Default value is 0.0
  35989. */
  35990. fallOff: number;
  35991. /**
  35992. * The base color of the SSAO post-process
  35993. * The final result is "base + ssao" between [0, 1]
  35994. */
  35995. base: number;
  35996. private _scene;
  35997. private _depthTexture;
  35998. private _randomTexture;
  35999. private _originalColorPostProcess;
  36000. private _ssaoPostProcess;
  36001. private _blurHPostProcess;
  36002. private _blurVPostProcess;
  36003. private _ssaoCombinePostProcess;
  36004. private _firstUpdate;
  36005. /**
  36006. * @constructor
  36007. * @param {string} name - The rendering pipeline name
  36008. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36009. * @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 }
  36010. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36011. */
  36012. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  36013. /**
  36014. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  36015. */
  36016. dispose(disableDepthRender?: boolean): void;
  36017. private _createBlurPostProcess(ratio);
  36018. _rebuild(): void;
  36019. private _createSSAOPostProcess(ratio);
  36020. private _createSSAOCombinePostProcess(ratio);
  36021. private _createRandomTexture();
  36022. }
  36023. }
  36024. declare module BABYLON {
  36025. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  36026. /**
  36027. * Public members
  36028. */
  36029. originalPostProcess: Nullable<PostProcess>;
  36030. downSampleX4PostProcess: Nullable<PostProcess>;
  36031. brightPassPostProcess: Nullable<PostProcess>;
  36032. blurHPostProcesses: PostProcess[];
  36033. blurVPostProcesses: PostProcess[];
  36034. textureAdderPostProcess: Nullable<PostProcess>;
  36035. volumetricLightPostProcess: Nullable<PostProcess>;
  36036. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  36037. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  36038. volumetricLightMergePostProces: Nullable<PostProcess>;
  36039. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  36040. luminancePostProcess: Nullable<PostProcess>;
  36041. luminanceDownSamplePostProcesses: PostProcess[];
  36042. hdrPostProcess: Nullable<PostProcess>;
  36043. textureAdderFinalPostProcess: Nullable<PostProcess>;
  36044. lensFlareFinalPostProcess: Nullable<PostProcess>;
  36045. hdrFinalPostProcess: Nullable<PostProcess>;
  36046. lensFlarePostProcess: Nullable<PostProcess>;
  36047. lensFlareComposePostProcess: Nullable<PostProcess>;
  36048. motionBlurPostProcess: Nullable<PostProcess>;
  36049. depthOfFieldPostProcess: Nullable<PostProcess>;
  36050. brightThreshold: number;
  36051. blurWidth: number;
  36052. horizontalBlur: boolean;
  36053. exposure: number;
  36054. lensTexture: Nullable<Texture>;
  36055. volumetricLightCoefficient: number;
  36056. volumetricLightPower: number;
  36057. volumetricLightBlurScale: number;
  36058. sourceLight: Nullable<SpotLight | DirectionalLight>;
  36059. hdrMinimumLuminance: number;
  36060. hdrDecreaseRate: number;
  36061. hdrIncreaseRate: number;
  36062. lensColorTexture: Nullable<Texture>;
  36063. lensFlareStrength: number;
  36064. lensFlareGhostDispersal: number;
  36065. lensFlareHaloWidth: number;
  36066. lensFlareDistortionStrength: number;
  36067. lensStarTexture: Nullable<Texture>;
  36068. lensFlareDirtTexture: Nullable<Texture>;
  36069. depthOfFieldDistance: number;
  36070. depthOfFieldBlurWidth: number;
  36071. motionStrength: number;
  36072. animations: Animation[];
  36073. /**
  36074. * Private members
  36075. */
  36076. private _scene;
  36077. private _currentDepthOfFieldSource;
  36078. private _basePostProcess;
  36079. private _hdrCurrentLuminance;
  36080. private _floatTextureType;
  36081. private _ratio;
  36082. private _bloomEnabled;
  36083. private _depthOfFieldEnabled;
  36084. private _vlsEnabled;
  36085. private _lensFlareEnabled;
  36086. private _hdrEnabled;
  36087. private _motionBlurEnabled;
  36088. private _motionBlurSamples;
  36089. private _volumetricLightStepsCount;
  36090. BloomEnabled: boolean;
  36091. DepthOfFieldEnabled: boolean;
  36092. LensFlareEnabled: boolean;
  36093. HDREnabled: boolean;
  36094. VLSEnabled: boolean;
  36095. MotionBlurEnabled: boolean;
  36096. volumetricLightStepsCount: number;
  36097. motionBlurSamples: number;
  36098. /**
  36099. * @constructor
  36100. * @param {string} name - The rendering pipeline name
  36101. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36102. * @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)
  36103. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  36104. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36105. */
  36106. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  36107. private _buildPipeline();
  36108. private _createDownSampleX4PostProcess(scene, ratio);
  36109. private _createBrightPassPostProcess(scene, ratio);
  36110. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  36111. private _createTextureAdderPostProcess(scene, ratio);
  36112. private _createVolumetricLightPostProcess(scene, ratio);
  36113. private _createLuminancePostProcesses(scene, textureType);
  36114. private _createHdrPostProcess(scene, ratio);
  36115. private _createLensFlarePostProcess(scene, ratio);
  36116. private _createDepthOfFieldPostProcess(scene, ratio);
  36117. private _createMotionBlurPostProcess(scene, ratio);
  36118. private _getDepthTexture();
  36119. private _disposePostProcesses();
  36120. /**
  36121. * Dispose of the pipeline and stop all post processes
  36122. */
  36123. dispose(): void;
  36124. /**
  36125. * Serialize the rendering pipeline (Used when exporting)
  36126. * @returns the serialized object
  36127. */
  36128. serialize(): any;
  36129. /**
  36130. * Parse the serialized pipeline
  36131. * @param source Source pipeline.
  36132. * @param scene The scene to load the pipeline to.
  36133. * @param rootUrl The URL of the serialized pipeline.
  36134. * @returns An instantiated pipeline from the serialized object.
  36135. */
  36136. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  36137. static LuminanceSteps: number;
  36138. }
  36139. }