babylon.d.ts 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. protected _ranges: {
  369. [name: string]: Nullable<AnimationRange>;
  370. };
  371. /**
  372. * Callback raised when the node is ready to be used
  373. */
  374. onReady: (node: Node) => void;
  375. private _isEnabled;
  376. private _isReady;
  377. /** @hidden */
  378. _currentRenderId: number;
  379. private _parentRenderId;
  380. protected _childRenderId: number;
  381. /** @hidden */
  382. _waitingParentId: Nullable<string>;
  383. /** @hidden */
  384. _scene: Scene;
  385. /** @hidden */
  386. _cache: any;
  387. private _parentNode;
  388. private _children;
  389. /**
  390. * Gets a boolean indicating if the node has been disposed
  391. * @returns true if the node was disposed
  392. */
  393. isDisposed(): boolean;
  394. /**
  395. * Gets or sets the parent of the node
  396. */
  397. parent: Nullable<Node>;
  398. private _animationPropertiesOverride;
  399. /**
  400. * Gets or sets the animation properties override
  401. */
  402. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  403. /**
  404. * Gets a string idenfifying the name of the class
  405. * @returns "Node" string
  406. */
  407. getClassName(): string;
  408. /**
  409. * An event triggered when the mesh is disposed
  410. */
  411. onDisposeObservable: Observable<Node>;
  412. private _onDisposeObserver;
  413. /**
  414. * Sets a callback that will be raised when the node will be disposed
  415. */
  416. onDispose: () => void;
  417. /**
  418. * Creates a new Node
  419. * @param {string} name - the name and id to be given to this node
  420. * @param {BABYLON.Scene} the scene this node will be added to
  421. */
  422. constructor(name: string, scene?: Nullable<Scene>);
  423. /**
  424. * Gets the scene of the node
  425. * @returns a {BABYLON.Scene}
  426. */
  427. getScene(): Scene;
  428. /**
  429. * Gets the engine of the node
  430. * @returns a {BABYLON.Engine}
  431. */
  432. getEngine(): Engine;
  433. private _behaviors;
  434. /**
  435. * Attach a behavior to the node
  436. * @see http://doc.babylonjs.com/features/behaviour
  437. * @param behavior defines the behavior to attach
  438. * @returns the current Node
  439. */
  440. addBehavior(behavior: Behavior<Node>): Node;
  441. /**
  442. * Remove an attached behavior
  443. * @see http://doc.babylonjs.com/features/behaviour
  444. * @param behavior defines the behavior to attach
  445. * @returns the current Node
  446. */
  447. removeBehavior(behavior: Behavior<Node>): Node;
  448. /**
  449. * Gets the list of attached behaviors
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. */
  452. readonly behaviors: Behavior<Node>[];
  453. /**
  454. * Gets an attached behavior by name
  455. * @param name defines the name of the behavior to look for
  456. * @see http://doc.babylonjs.com/features/behaviour
  457. * @returns null if behavior was not found else the requested behavior
  458. */
  459. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  460. /**
  461. * Returns the world matrix of the node
  462. * @returns a matrix containing the node's world matrix
  463. */
  464. getWorldMatrix(): Matrix;
  465. /** @hidden */
  466. _getWorldMatrixDeterminant(): number;
  467. /** @hidden */
  468. _initCache(): void;
  469. /** @hidden */
  470. updateCache(force?: boolean): void;
  471. /** @hidden */
  472. _updateCache(ignoreParentClass?: boolean): void;
  473. /** @hidden */
  474. _isSynchronized(): boolean;
  475. /** @hidden */
  476. _markSyncedWithParent(): void;
  477. /** @hidden */
  478. isSynchronizedWithParent(): boolean;
  479. /** @hidden */
  480. isSynchronized(updateCache?: boolean): boolean;
  481. /** @hidden */
  482. hasNewParent(update?: boolean): boolean;
  483. /**
  484. * Is this node ready to be used/rendered
  485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  486. * @return true if the node is ready
  487. */
  488. isReady(completeCheck?: boolean): boolean;
  489. /**
  490. * Is this node enabled?
  491. * 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
  492. * @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
  493. * @return whether this node (and its parent) is enabled
  494. */
  495. isEnabled(checkAncestors?: boolean): boolean;
  496. /**
  497. * Set the enabled state of this node
  498. * @param value defines the new enabled state
  499. */
  500. setEnabled(value: boolean): void;
  501. /**
  502. * Is this node a descendant of the given node?
  503. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  504. * @param ancestor defines the parent node to inspect
  505. * @returns a boolean indicating if this node is a descendant of the given node
  506. */
  507. isDescendantOf(ancestor: Node): boolean;
  508. /** @hidden */
  509. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  510. /**
  511. * Will return all nodes that have this node as ascendant
  512. * @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
  513. * @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
  514. * @return all children nodes of all types
  515. */
  516. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  517. /**
  518. * Get all child-meshes of this node
  519. * @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
  520. * @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
  521. * @returns an array of {BABYLON.AbstractMesh}
  522. */
  523. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  524. /**
  525. * Get all child-transformNodes of this node
  526. * @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
  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.TransformNode}
  529. */
  530. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  531. /**
  532. * Get all direct children of this node
  533. * @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
  534. * @returns an array of {BABYLON.Node}
  535. */
  536. getChildren(predicate?: (node: Node) => boolean): Node[];
  537. /** @hidden */
  538. _setReady(state: boolean): void;
  539. /**
  540. * Get an animation by name
  541. * @param name defines the name of the animation to look for
  542. * @returns null if not found else the requested animation
  543. */
  544. getAnimationByName(name: string): Nullable<Animation>;
  545. /**
  546. * Creates an animation range for this node
  547. * @param name defines the name of the range
  548. * @param from defines the starting key
  549. * @param to defines the end key
  550. */
  551. createAnimationRange(name: string, from: number, to: number): void;
  552. /**
  553. * Delete a specific animation range
  554. * @param name defines the name of the range to delete
  555. * @param deleteFrames defines if animation frames from the range must be deleted as well
  556. */
  557. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  558. /**
  559. * Get an animation range by name
  560. * @param name defines the name of the animation range to look for
  561. * @returns null if not found else the requested animation range
  562. */
  563. getAnimationRange(name: string): Nullable<AnimationRange>;
  564. /**
  565. * Will start the animation sequence
  566. * @param name defines the range frames for animation sequence
  567. * @param loop defines if the animation should loop (false by default)
  568. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  569. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  570. * @returns the object created for this animation. If range does not exist, it will return null
  571. */
  572. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  573. /**
  574. * Serialize animation ranges into a JSON compatible object
  575. * @returns serialization object
  576. */
  577. serializeAnimationRanges(): any;
  578. /**
  579. * Computes the world matrix of the node
  580. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  581. * @returns the world matrix
  582. */
  583. computeWorldMatrix(force?: boolean): Matrix;
  584. /**
  585. * Releases resources associated with this node.
  586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  588. */
  589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  590. /**
  591. * Parse animation range data from a serialization object and store them into a given node
  592. * @param node defines where to store the animation ranges
  593. * @param parsedNode defines the serialization object to read data from
  594. * @param scene defines the hosting scene
  595. */
  596. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * Define an interface for all classes that will hold resources
  602. */
  603. interface IDisposable {
  604. /**
  605. * Releases all held resources
  606. */
  607. dispose(): void;
  608. }
  609. /**
  610. * Interface used to let developers provide their own mesh selection mechanism
  611. */
  612. interface IActiveMeshCandidateProvider {
  613. /**
  614. * Return the list of active meshes
  615. * @param scene defines the current scene
  616. * @returns the list of active meshes
  617. */
  618. getMeshes(scene: Scene): AbstractMesh[];
  619. /**
  620. * Indicates if the meshes have been checked to make sure they are isEnabled()
  621. */
  622. readonly checksIsEnabled: boolean;
  623. }
  624. /**
  625. * This class is used by the onRenderingGroupObservable
  626. */
  627. class RenderingGroupInfo {
  628. /**
  629. * The Scene that being rendered
  630. */
  631. scene: Scene;
  632. /**
  633. * The camera currently used for the rendering pass
  634. */
  635. camera: Nullable<Camera>;
  636. /**
  637. * The ID of the renderingGroup being processed
  638. */
  639. renderingGroupId: number;
  640. }
  641. /**
  642. * Represents a scene to be rendered by the engine.
  643. * @see http://doc.babylonjs.com/features/scene
  644. */
  645. class Scene extends AbstractScene implements IAnimatable {
  646. private static _uniqueIdCounter;
  647. /** The fog is deactivated */
  648. static readonly FOGMODE_NONE: number;
  649. /** The fog density is following an exponential function */
  650. static readonly FOGMODE_EXP: number;
  651. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  652. static readonly FOGMODE_EXP2: number;
  653. /** The fog density is following a linear function. */
  654. static readonly FOGMODE_LINEAR: number;
  655. /**
  656. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  658. */
  659. static MinDeltaTime: number;
  660. /**
  661. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  663. */
  664. static MaxDeltaTime: number;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  667. */
  668. autoClear: boolean;
  669. /**
  670. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  671. */
  672. autoClearDepthAndStencil: boolean;
  673. /**
  674. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  675. */
  676. clearColor: Color4;
  677. /**
  678. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  679. */
  680. ambientColor: Color3;
  681. /** @hidden */
  682. _environmentBRDFTexture: BaseTexture;
  683. /** @hidden */
  684. protected _environmentTexture: BaseTexture;
  685. /**
  686. * Texture used in all pbr material as the reflection texture.
  687. * As in the majority of the scene they are the same (exception for multi room and so on),
  688. * this is easier to reference from here than from all the materials.
  689. */
  690. /**
  691. * Texture used in all pbr material as the reflection texture.
  692. * As in the majority of the scene they are the same (exception for multi room and so on),
  693. * this is easier to set here than in all the materials.
  694. */
  695. environmentTexture: BaseTexture;
  696. /** @hidden */
  697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  698. /**
  699. * Default image processing configuration used either in the rendering
  700. * Forward main pass or through the imageProcessingPostProcess if present.
  701. * As in the majority of the scene they are the same (exception for multi camera),
  702. * this is easier to reference from here than from all the materials and post process.
  703. *
  704. * No setter as we it is a shared configuration, you can set the values instead.
  705. */
  706. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  707. private _forceWireframe;
  708. /**
  709. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  710. */
  711. forceWireframe: boolean;
  712. private _forcePointsCloud;
  713. /**
  714. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  715. */
  716. forcePointsCloud: boolean;
  717. /**
  718. * Gets or sets the active clipplane 1
  719. */
  720. clipPlane: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 2
  723. */
  724. clipPlane2: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 3
  727. */
  728. clipPlane3: Nullable<Plane>;
  729. /**
  730. * Gets or sets the active clipplane 4
  731. */
  732. clipPlane4: Nullable<Plane>;
  733. /**
  734. * Gets or sets a boolean indicating if animations are enabled
  735. */
  736. animationsEnabled: boolean;
  737. private _animationPropertiesOverride;
  738. /**
  739. * Gets or sets the animation properties override
  740. */
  741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  742. /**
  743. * Gets or sets a boolean indicating if a constant deltatime has to be used
  744. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  745. */
  746. useConstantAnimationDeltaTime: boolean;
  747. /**
  748. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  749. * Please note that it requires to run a ray cast through the scene on every frame
  750. */
  751. constantlyUpdateMeshUnderPointer: boolean;
  752. /**
  753. * Defines the HTML cursor to use when hovering over interactive elements
  754. */
  755. hoverCursor: string;
  756. /**
  757. * Defines the HTML default cursor to use (empty by default)
  758. */
  759. defaultCursor: string;
  760. /**
  761. * This is used to call preventDefault() on pointer down
  762. * in order to block unwanted artifacts like system double clicks
  763. */
  764. preventDefaultOnPointerDown: boolean;
  765. /**
  766. * Gets or sets user defined metadata
  767. */
  768. metadata: any;
  769. /**
  770. * Gets the name of the plugin used to load this scene (null by default)
  771. */
  772. loadingPluginName: string;
  773. /**
  774. * Use this array to add regular expressions used to disable offline support for specific urls
  775. */
  776. disableOfflineSupportExceptionRules: RegExp[];
  777. /**
  778. * An event triggered when the scene is disposed.
  779. */
  780. onDisposeObservable: Observable<Scene>;
  781. private _onDisposeObserver;
  782. /** Sets a function to be executed when this scene is disposed. */
  783. onDispose: () => void;
  784. /**
  785. * An event triggered before rendering the scene (right after animations and physics)
  786. */
  787. onBeforeRenderObservable: Observable<Scene>;
  788. private _onBeforeRenderObserver;
  789. /** Sets a function to be executed before rendering this scene */
  790. beforeRender: Nullable<() => void>;
  791. /**
  792. * An event triggered after rendering the scene
  793. */
  794. onAfterRenderObservable: Observable<Scene>;
  795. private _onAfterRenderObserver;
  796. /** Sets a function to be executed after rendering this scene */
  797. afterRender: Nullable<() => void>;
  798. /**
  799. * An event triggered before animating the scene
  800. */
  801. onBeforeAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered after animations processing
  804. */
  805. onAfterAnimationsObservable: Observable<Scene>;
  806. /**
  807. * An event triggered before draw calls are ready to be sent
  808. */
  809. onBeforeDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered after draw calls have been sent
  812. */
  813. onAfterDrawPhaseObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when physic simulation is about to be run
  816. */
  817. onBeforePhysicsObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when physic simulation has been done
  820. */
  821. onAfterPhysicsObservable: Observable<Scene>;
  822. /**
  823. * An event triggered when the scene is ready
  824. */
  825. onReadyObservable: Observable<Scene>;
  826. /**
  827. * An event triggered before rendering a camera
  828. */
  829. onBeforeCameraRenderObservable: Observable<Camera>;
  830. private _onBeforeCameraRenderObserver;
  831. /** Sets a function to be executed before rendering a camera*/
  832. beforeCameraRender: () => void;
  833. /**
  834. * An event triggered after rendering a camera
  835. */
  836. onAfterCameraRenderObservable: Observable<Camera>;
  837. private _onAfterCameraRenderObserver;
  838. /** Sets a function to be executed after rendering a camera*/
  839. afterCameraRender: () => void;
  840. /**
  841. * An event triggered when active meshes evaluation is about to start
  842. */
  843. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when active meshes evaluation is done
  846. */
  847. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  848. /**
  849. * An event triggered when particles rendering is about to start
  850. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  851. */
  852. onBeforeParticlesRenderingObservable: Observable<Scene>;
  853. /**
  854. * An event triggered when particles rendering is done
  855. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  856. */
  857. onAfterParticlesRenderingObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  860. */
  861. onDataLoadedObservable: Observable<Scene>;
  862. /**
  863. * An event triggered when a camera is created
  864. */
  865. onNewCameraAddedObservable: Observable<Camera>;
  866. /**
  867. * An event triggered when a camera is removed
  868. */
  869. onCameraRemovedObservable: Observable<Camera>;
  870. /**
  871. * An event triggered when a light is created
  872. */
  873. onNewLightAddedObservable: Observable<Light>;
  874. /**
  875. * An event triggered when a light is removed
  876. */
  877. onLightRemovedObservable: Observable<Light>;
  878. /**
  879. * An event triggered when a geometry is created
  880. */
  881. onNewGeometryAddedObservable: Observable<Geometry>;
  882. /**
  883. * An event triggered when a geometry is removed
  884. */
  885. onGeometryRemovedObservable: Observable<Geometry>;
  886. /**
  887. * An event triggered when a transform node is created
  888. */
  889. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  890. /**
  891. * An event triggered when a transform node is removed
  892. */
  893. onTransformNodeRemovedObservable: Observable<TransformNode>;
  894. /**
  895. * An event triggered when a mesh is created
  896. */
  897. onNewMeshAddedObservable: Observable<AbstractMesh>;
  898. /**
  899. * An event triggered when a mesh is removed
  900. */
  901. onMeshRemovedObservable: Observable<AbstractMesh>;
  902. /**
  903. * An event triggered when render targets are about to be rendered
  904. * Can happen multiple times per frame.
  905. */
  906. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when render targets were rendered.
  909. * Can happen multiple times per frame.
  910. */
  911. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  912. /**
  913. * An event triggered before calculating deterministic simulation step
  914. */
  915. onBeforeStepObservable: Observable<Scene>;
  916. /**
  917. * An event triggered after calculating deterministic simulation step
  918. */
  919. onAfterStepObservable: Observable<Scene>;
  920. /**
  921. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  922. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  923. * 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)
  924. */
  925. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  926. /**
  927. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  928. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  929. * 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)
  930. */
  931. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  932. private _registeredForLateAnimationBindings;
  933. /**
  934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  935. */
  936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  937. /**
  938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  939. */
  940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  941. /**
  942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  943. */
  944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  945. private _onPointerMove;
  946. private _onPointerDown;
  947. private _onPointerUp;
  948. /** Deprecated. Use onPointerObservable instead */
  949. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  950. /** Deprecated. Use onPointerObservable instead */
  951. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  952. /** Deprecated. Use onPointerObservable instead */
  953. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  954. /** Deprecated. Use onPointerObservable instead */
  955. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  956. /**
  957. * 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).
  958. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  959. */
  960. onPrePointerObservable: Observable<PointerInfoPre>;
  961. /**
  962. * Observable event triggered each time an input event is received from the rendering canvas
  963. */
  964. onPointerObservable: Observable<PointerInfo>;
  965. /**
  966. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  967. */
  968. readonly unTranslatedPointer: Vector2;
  969. /** The distance in pixel that you have to move to prevent some events */
  970. static DragMovementThreshold: number;
  971. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  972. static LongPressDelay: number;
  973. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  974. static DoubleClickDelay: number;
  975. /** If you need to check double click without raising a single click at first click, enable this flag */
  976. static ExclusiveDoubleClickMode: boolean;
  977. private _initClickEvent;
  978. private _initActionManager;
  979. private _delayedSimpleClick;
  980. private _delayedSimpleClickTimeout;
  981. private _previousDelayedSimpleClickTimeout;
  982. private _meshPickProceed;
  983. private _previousButtonPressed;
  984. private _currentPickResult;
  985. private _previousPickResult;
  986. private _totalPointersPressed;
  987. private _doubleClickOccured;
  988. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  989. cameraToUseForPointers: Nullable<Camera>;
  990. private _pointerX;
  991. private _pointerY;
  992. private _unTranslatedPointerX;
  993. private _unTranslatedPointerY;
  994. private _startingPointerPosition;
  995. private _previousStartingPointerPosition;
  996. private _startingPointerTime;
  997. private _previousStartingPointerTime;
  998. private _pointerCaptures;
  999. private _timeAccumulator;
  1000. private _currentStepId;
  1001. private _currentInternalStep;
  1002. /** @hidden */
  1003. _mirroredCameraPosition: Nullable<Vector3>;
  1004. /**
  1005. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1006. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1007. */
  1008. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1009. /**
  1010. * Observable event triggered each time an keyboard event is received from the hosting window
  1011. */
  1012. onKeyboardObservable: Observable<KeyboardInfo>;
  1013. private _onKeyDown;
  1014. private _onKeyUp;
  1015. private _onCanvasFocusObserver;
  1016. private _onCanvasBlurObserver;
  1017. private _useRightHandedSystem;
  1018. /**
  1019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1020. */
  1021. useRightHandedSystem: boolean;
  1022. /**
  1023. * Sets the step Id used by deterministic lock step
  1024. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1025. * @param newStepId defines the step Id
  1026. */
  1027. setStepId(newStepId: number): void;
  1028. /**
  1029. * Gets the step Id used by deterministic lock step
  1030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1031. * @returns the step Id
  1032. */
  1033. getStepId(): number;
  1034. /**
  1035. * Gets the internal step used by deterministic lock step
  1036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1037. * @returns the internal step
  1038. */
  1039. getInternalStep(): number;
  1040. private _fogEnabled;
  1041. /**
  1042. * Gets or sets a boolean indicating if fog is enabled on this scene
  1043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1044. */
  1045. fogEnabled: boolean;
  1046. private _fogMode;
  1047. /**
  1048. * Gets or sets the fog mode to use
  1049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1050. */
  1051. fogMode: number;
  1052. /**
  1053. * Gets or sets the fog color to use
  1054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1055. */
  1056. fogColor: Color3;
  1057. /**
  1058. * Gets or sets the fog density to use
  1059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1060. */
  1061. fogDensity: number;
  1062. /**
  1063. * Gets or sets the fog start distance to use
  1064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1065. */
  1066. fogStart: number;
  1067. /**
  1068. * Gets or sets the fog end distance to use
  1069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1070. */
  1071. fogEnd: number;
  1072. private _shadowsEnabled;
  1073. /**
  1074. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1075. */
  1076. shadowsEnabled: boolean;
  1077. private _lightsEnabled;
  1078. /**
  1079. * Gets or sets a boolean indicating if lights are enabled on this scene
  1080. */
  1081. lightsEnabled: boolean;
  1082. /** All of the active cameras added to this scene. */
  1083. activeCameras: Camera[];
  1084. /** The current active camera */
  1085. activeCamera: Nullable<Camera>;
  1086. private _defaultMaterial;
  1087. /** The default material used on meshes when no material is affected */
  1088. /** The default material used on meshes when no material is affected */
  1089. defaultMaterial: Material;
  1090. private _texturesEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if textures are enabled on this scene
  1093. */
  1094. texturesEnabled: boolean;
  1095. /**
  1096. * Gets or sets a boolean indicating if particles are enabled on this scene
  1097. */
  1098. particlesEnabled: boolean;
  1099. /**
  1100. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1101. */
  1102. spritesEnabled: boolean;
  1103. private _skeletonsEnabled;
  1104. /**
  1105. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1106. */
  1107. skeletonsEnabled: boolean;
  1108. /**
  1109. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1110. */
  1111. lensFlaresEnabled: boolean;
  1112. /**
  1113. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1114. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1115. */
  1116. collisionsEnabled: boolean;
  1117. private _workerCollisions;
  1118. /** @hidden */
  1119. collisionCoordinator: ICollisionCoordinator;
  1120. /**
  1121. * Defines the gravity applied to this scene (used only for collisions)
  1122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1123. */
  1124. gravity: Vector3;
  1125. /**
  1126. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1127. */
  1128. postProcessesEnabled: boolean;
  1129. /**
  1130. * The list of postprocesses added to the scene
  1131. */
  1132. postProcesses: PostProcess[];
  1133. /**
  1134. * Gets the current postprocess manager
  1135. */
  1136. postProcessManager: PostProcessManager;
  1137. /**
  1138. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1139. */
  1140. renderTargetsEnabled: boolean;
  1141. /**
  1142. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1143. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1144. */
  1145. dumpNextRenderTargets: boolean;
  1146. /**
  1147. * The list of user defined render targets added to the scene
  1148. */
  1149. customRenderTargets: RenderTargetTexture[];
  1150. /**
  1151. * Defines if texture loading must be delayed
  1152. * If true, textures will only be loaded when they need to be rendered
  1153. */
  1154. useDelayedTextureLoading: boolean;
  1155. /**
  1156. * Gets the list of meshes imported to the scene through SceneLoader
  1157. */
  1158. importedMeshesFiles: String[];
  1159. /**
  1160. * Gets or sets a boolean indicating if probes are enabled on this scene
  1161. */
  1162. probesEnabled: boolean;
  1163. /**
  1164. * The list of reflection probes added to the scene
  1165. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1166. */
  1167. reflectionProbes: ReflectionProbe[];
  1168. /**
  1169. * @hidden
  1170. */
  1171. database: Database;
  1172. /**
  1173. * Gets or sets the action manager associated with the scene
  1174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1175. */
  1176. actionManager: ActionManager;
  1177. private _meshesForIntersections;
  1178. /**
  1179. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1180. */
  1181. proceduralTexturesEnabled: boolean;
  1182. /**
  1183. * The list of procedural textures added to the scene
  1184. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1185. */
  1186. proceduralTextures: ProceduralTexture[];
  1187. private _mainSoundTrack;
  1188. /**
  1189. * The list of sound tracks added to the scene
  1190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1191. */
  1192. soundTracks: SoundTrack[];
  1193. private _audioEnabled;
  1194. private _headphone;
  1195. /**
  1196. * Gets the main soundtrack associated with the scene
  1197. */
  1198. readonly mainSoundTrack: SoundTrack;
  1199. /**
  1200. * Gets or sets the VRExperienceHelper attached to the scene
  1201. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1202. * @ignorenaming
  1203. */
  1204. VRHelper: VRExperienceHelper;
  1205. private _engine;
  1206. private _totalVertices;
  1207. /** @hidden */
  1208. _activeIndices: PerfCounter;
  1209. /** @hidden */
  1210. _activeParticles: PerfCounter;
  1211. /** @hidden */
  1212. _activeBones: PerfCounter;
  1213. private _animationRatio;
  1214. private _animationTimeLast;
  1215. private _animationTime;
  1216. /**
  1217. * Gets or sets a general scale for animation speed
  1218. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1219. */
  1220. animationTimeScale: number;
  1221. /** @hidden */
  1222. _cachedMaterial: Nullable<Material>;
  1223. /** @hidden */
  1224. _cachedEffect: Nullable<Effect>;
  1225. /** @hidden */
  1226. _cachedVisibility: Nullable<number>;
  1227. private _renderId;
  1228. private _executeWhenReadyTimeoutId;
  1229. private _intermediateRendering;
  1230. private _viewUpdateFlag;
  1231. private _projectionUpdateFlag;
  1232. private _alternateViewUpdateFlag;
  1233. private _alternateProjectionUpdateFlag;
  1234. /** @hidden */
  1235. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1236. private _activeRequests;
  1237. private _pendingData;
  1238. private _isDisposed;
  1239. /**
  1240. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1241. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1242. */
  1243. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1244. private _activeMeshes;
  1245. private _processedMaterials;
  1246. private _renderTargets;
  1247. /** @hidden */
  1248. _activeParticleSystems: SmartArray<IParticleSystem>;
  1249. private _activeSkeletons;
  1250. private _softwareSkinnedMeshes;
  1251. private _renderingManager;
  1252. private _physicsEngine;
  1253. /** @hidden */
  1254. _activeAnimatables: Animatable[];
  1255. private _transformMatrix;
  1256. private _sceneUbo;
  1257. private _alternateSceneUbo;
  1258. private _pickWithRayInverseMatrix;
  1259. private _viewMatrix;
  1260. private _projectionMatrix;
  1261. private _alternateViewMatrix;
  1262. private _alternateProjectionMatrix;
  1263. private _alternateTransformMatrix;
  1264. private _useAlternateCameraConfiguration;
  1265. private _alternateRendering;
  1266. /** @hidden */
  1267. _forcedViewPosition: Nullable<Vector3>;
  1268. /** @hidden */
  1269. readonly _isAlternateRenderingEnabled: boolean;
  1270. private _frustumPlanes;
  1271. /**
  1272. * Gets the list of frustum planes (built from the active camera)
  1273. */
  1274. readonly frustumPlanes: Plane[];
  1275. /**
  1276. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1277. * This is useful if there are more lights that the maximum simulteanous authorized
  1278. */
  1279. requireLightSorting: boolean;
  1280. private _selectionOctree;
  1281. private _pointerOverMesh;
  1282. private _debugLayer;
  1283. private _pickedDownMesh;
  1284. private _pickedUpMesh;
  1285. private _externalData;
  1286. private _uid;
  1287. /**
  1288. * @hidden
  1289. * Backing store of defined scene components.
  1290. */
  1291. _components: ISceneComponent[];
  1292. /**
  1293. * @hidden
  1294. * Backing store of defined scene components.
  1295. */
  1296. _serializableComponents: ISceneSerializableComponent[];
  1297. /**
  1298. * List of components to register on the next registration step.
  1299. */
  1300. private _transientComponents;
  1301. /**
  1302. * Registers the transient components if needed.
  1303. */
  1304. private _registerTransientComponents;
  1305. /**
  1306. * @hidden
  1307. * Add a component to the scene.
  1308. * Note that the ccomponent could be registered on th next frame if this is called after
  1309. * the register component stage.
  1310. * @param component Defines the component to add to the scene
  1311. */
  1312. _addComponent(component: ISceneComponent): void;
  1313. /**
  1314. * @hidden
  1315. * Gets a component from the scene.
  1316. * @param name defines the name of the component to retrieve
  1317. * @returns the component or null if not present
  1318. */
  1319. _getComponent(name: string): Nullable<ISceneComponent>;
  1320. /**
  1321. * @hidden
  1322. * Defines the actions happening before camera updates.
  1323. */
  1324. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1325. /**
  1326. * @hidden
  1327. * Defines the actions happening before camera updates.
  1328. */
  1329. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1330. /**
  1331. * @hidden
  1332. * Defines the actions happening during the per mesh ready checks.
  1333. */
  1334. _isReadyForMeshStage: Stage<MeshStageAction>;
  1335. /**
  1336. * @hidden
  1337. * Defines the actions happening before evaluate active mesh checks.
  1338. */
  1339. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1340. /**
  1341. * @hidden
  1342. * Defines the actions happening during the evaluate sub mesh checks.
  1343. */
  1344. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1345. /**
  1346. * @hidden
  1347. * Defines the actions happening during the active mesh stage.
  1348. */
  1349. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1350. /**
  1351. * @hidden
  1352. * Defines the actions happening during the per camera render target step.
  1353. */
  1354. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1355. /**
  1356. * @hidden
  1357. * Defines the actions happening just before the active camera is drawing.
  1358. */
  1359. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1360. /**
  1361. * @hidden
  1362. * Defines the actions happening just before a rendering group is drawing.
  1363. */
  1364. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1365. /**
  1366. * @hidden
  1367. * Defines the actions happening just before a mesh is drawing.
  1368. */
  1369. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1370. /**
  1371. * @hidden
  1372. * Defines the actions happening just after a mesh has been drawn.
  1373. */
  1374. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1375. /**
  1376. * @hidden
  1377. * Defines the actions happening just after a rendering group has been drawn.
  1378. */
  1379. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1380. /**
  1381. * @hidden
  1382. * Defines the actions happening just after the active camera has been drawn.
  1383. */
  1384. _afterCameraDrawStage: Stage<CameraStageAction>;
  1385. /**
  1386. * @hidden
  1387. * Defines the actions happening when Geometries are rebuilding.
  1388. */
  1389. _rebuildGeometryStage: Stage<SimpleStageAction>;
  1390. /**
  1391. * @hidden
  1392. * Defines the actions happening when a pointer move event happens.
  1393. */
  1394. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1395. /**
  1396. * @hidden
  1397. * Defines the actions happening when a pointer down event happens.
  1398. */
  1399. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1400. /**
  1401. * @hidden
  1402. * Defines the actions happening when a pointer up event happens.
  1403. */
  1404. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1405. /**
  1406. * Creates a new Scene
  1407. * @param engine defines the engine to use to render this scene
  1408. */
  1409. constructor(engine: Engine);
  1410. /**
  1411. * Gets the debug layer (aka Inspector) associated with the scene
  1412. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1413. */
  1414. readonly debugLayer: DebugLayer;
  1415. /**
  1416. * Gets a boolean indicating if collisions are processed on a web worker
  1417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1418. */
  1419. workerCollisions: boolean;
  1420. /**
  1421. * Gets the octree used to boost mesh selection (picking)
  1422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1423. */
  1424. readonly selectionOctree: Octree<AbstractMesh>;
  1425. /**
  1426. * Gets the mesh that is currently under the pointer
  1427. */
  1428. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1429. /**
  1430. * Gets the current on-screen X position of the pointer
  1431. */
  1432. readonly pointerX: number;
  1433. /**
  1434. * Gets the current on-screen Y position of the pointer
  1435. */
  1436. readonly pointerY: number;
  1437. /**
  1438. * Gets the cached material (ie. the latest rendered one)
  1439. * @returns the cached material
  1440. */
  1441. getCachedMaterial(): Nullable<Material>;
  1442. /**
  1443. * Gets the cached effect (ie. the latest rendered one)
  1444. * @returns the cached effect
  1445. */
  1446. getCachedEffect(): Nullable<Effect>;
  1447. /**
  1448. * Gets the cached visibility state (ie. the latest rendered one)
  1449. * @returns the cached visibility state
  1450. */
  1451. getCachedVisibility(): Nullable<number>;
  1452. /**
  1453. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1454. * @param material defines the current material
  1455. * @param effect defines the current effect
  1456. * @param visibility defines the current visibility state
  1457. * @returns true if one parameter is not cached
  1458. */
  1459. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1460. /**
  1461. * Gets the engine associated with the scene
  1462. * @returns an Engine
  1463. */
  1464. getEngine(): Engine;
  1465. /**
  1466. * Gets the total number of vertices rendered per frame
  1467. * @returns the total number of vertices rendered per frame
  1468. */
  1469. getTotalVertices(): number;
  1470. /**
  1471. * Gets the performance counter for total vertices
  1472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1473. */
  1474. readonly totalVerticesPerfCounter: PerfCounter;
  1475. /**
  1476. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1477. * @returns the total number of active indices rendered per frame
  1478. */
  1479. getActiveIndices(): number;
  1480. /**
  1481. * Gets the performance counter for active indices
  1482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1483. */
  1484. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1485. /**
  1486. * Gets the total number of active particles rendered per frame
  1487. * @returns the total number of active particles rendered per frame
  1488. */
  1489. getActiveParticles(): number;
  1490. /**
  1491. * Gets the performance counter for active particles
  1492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1493. */
  1494. readonly activeParticlesPerfCounter: PerfCounter;
  1495. /**
  1496. * Gets the total number of active bones rendered per frame
  1497. * @returns the total number of active bones rendered per frame
  1498. */
  1499. getActiveBones(): number;
  1500. /**
  1501. * Gets the performance counter for active bones
  1502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1503. */
  1504. readonly activeBonesPerfCounter: PerfCounter;
  1505. /** @hidden */
  1506. getInterFramePerfCounter(): number;
  1507. /** @hidden */
  1508. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1509. /** @hidden */
  1510. getLastFrameDuration(): number;
  1511. /** @hidden */
  1512. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1513. /** @hidden */
  1514. getEvaluateActiveMeshesDuration(): number;
  1515. /** @hidden */
  1516. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1517. /**
  1518. * Gets the array of active meshes
  1519. * @returns an array of AbstractMesh
  1520. */
  1521. getActiveMeshes(): SmartArray<AbstractMesh>;
  1522. /** @hidden */
  1523. getRenderTargetsDuration(): number;
  1524. /** @hidden */
  1525. getRenderDuration(): number;
  1526. /** @hidden */
  1527. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1528. /** @hidden */
  1529. getParticlesDuration(): number;
  1530. /** @hidden */
  1531. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1532. /** @hidden */
  1533. getSpritesDuration(): number;
  1534. /** @hidden */
  1535. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1536. /**
  1537. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1538. * @returns a number
  1539. */
  1540. getAnimationRatio(): number;
  1541. /**
  1542. * Gets an unique Id for the current frame
  1543. * @returns a number
  1544. */
  1545. getRenderId(): number;
  1546. /** Call this function if you want to manually increment the render Id*/
  1547. incrementRenderId(): void;
  1548. private _updatePointerPosition;
  1549. private _createUbo;
  1550. private _createAlternateUbo;
  1551. private _setRayOnPointerInfo;
  1552. /**
  1553. * Use this method to simulate a pointer move on a mesh
  1554. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1555. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1556. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1557. * @returns the current scene
  1558. */
  1559. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1560. private _processPointerMove;
  1561. private _checkPrePointerObservable;
  1562. /**
  1563. * Use this method to simulate a pointer down on a mesh
  1564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1567. * @returns the current scene
  1568. */
  1569. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1570. private _processPointerDown;
  1571. /**
  1572. * Use this method to simulate a pointer up on a mesh
  1573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1576. * @returns the current scene
  1577. */
  1578. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1579. private _processPointerUp;
  1580. /**
  1581. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1582. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1583. * @returns true if the pointer was captured
  1584. */
  1585. isPointerCaptured(pointerId?: number): boolean;
  1586. /** @hidden */
  1587. _isPointerSwiping(): boolean;
  1588. /**
  1589. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1590. * @param attachUp defines if you want to attach events to pointerup
  1591. * @param attachDown defines if you want to attach events to pointerdown
  1592. * @param attachMove defines if you want to attach events to pointermove
  1593. */
  1594. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1595. /** Detaches all event handlers*/
  1596. detachControl(): void;
  1597. /**
  1598. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1599. * Delay loaded resources are not taking in account
  1600. * @return true if all required resources are ready
  1601. */
  1602. isReady(): boolean;
  1603. /** Resets all cached information relative to material (including effect and visibility) */
  1604. resetCachedMaterial(): void;
  1605. /**
  1606. * Registers a function to be called before every frame render
  1607. * @param func defines the function to register
  1608. */
  1609. registerBeforeRender(func: () => void): void;
  1610. /**
  1611. * Unregisters a function called before every frame render
  1612. * @param func defines the function to unregister
  1613. */
  1614. unregisterBeforeRender(func: () => void): void;
  1615. /**
  1616. * Registers a function to be called after every frame render
  1617. * @param func defines the function to register
  1618. */
  1619. registerAfterRender(func: () => void): void;
  1620. /**
  1621. * Unregisters a function called after every frame render
  1622. * @param func defines the function to unregister
  1623. */
  1624. unregisterAfterRender(func: () => void): void;
  1625. private _executeOnceBeforeRender;
  1626. /**
  1627. * The provided function will run before render once and will be disposed afterwards.
  1628. * A timeout delay can be provided so that the function will be executed in N ms.
  1629. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1630. * @param func The function to be executed.
  1631. * @param timeout optional delay in ms
  1632. */
  1633. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1634. /** @hidden */
  1635. _addPendingData(data: any): void;
  1636. /** @hidden */
  1637. _removePendingData(data: any): void;
  1638. /**
  1639. * Returns the number of items waiting to be loaded
  1640. * @returns the number of items waiting to be loaded
  1641. */
  1642. getWaitingItemsCount(): number;
  1643. /**
  1644. * Returns a boolean indicating if the scene is still loading data
  1645. */
  1646. readonly isLoading: boolean;
  1647. /**
  1648. * Registers a function to be executed when the scene is ready
  1649. * @param {Function} func - the function to be executed
  1650. */
  1651. executeWhenReady(func: () => void): void;
  1652. /**
  1653. * Returns a promise that resolves when the scene is ready
  1654. * @returns A promise that resolves when the scene is ready
  1655. */
  1656. whenReadyAsync(): Promise<void>;
  1657. /** @hidden */
  1658. _checkIsReady(): void;
  1659. /**
  1660. * Will start the animation sequence of a given target
  1661. * @param target defines the target
  1662. * @param from defines from which frame should animation start
  1663. * @param to defines until which frame should animation run.
  1664. * @param weight defines the weight to apply to the animation (1.0 by default)
  1665. * @param loop defines if the animation loops
  1666. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1667. * @param onAnimationEnd defines the function to be executed when the animation ends
  1668. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1669. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1670. * @returns the animatable object created for this animation
  1671. */
  1672. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1673. /**
  1674. * Will start the animation sequence of a given target
  1675. * @param target defines the target
  1676. * @param from defines from which frame should animation start
  1677. * @param to defines until which frame should animation run.
  1678. * @param loop defines if the animation loops
  1679. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1680. * @param onAnimationEnd defines the function to be executed when the animation ends
  1681. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1682. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1683. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1684. * @returns the animatable object created for this animation
  1685. */
  1686. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1687. /**
  1688. * Begin a new animation on a given node
  1689. * @param target defines the target where the animation will take place
  1690. * @param animations defines the list of animations to start
  1691. * @param from defines the initial value
  1692. * @param to defines the final value
  1693. * @param loop defines if you want animation to loop (off by default)
  1694. * @param speedRatio defines the speed ratio to apply to all animations
  1695. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1696. * @returns the list of created animatables
  1697. */
  1698. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1699. /**
  1700. * Begin a new animation on a given node and its hierarchy
  1701. * @param target defines the root node where the animation will take place
  1702. * @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.
  1703. * @param animations defines the list of animations to start
  1704. * @param from defines the initial value
  1705. * @param to defines the final value
  1706. * @param loop defines if you want animation to loop (off by default)
  1707. * @param speedRatio defines the speed ratio to apply to all animations
  1708. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1709. * @returns the list of animatables created for all nodes
  1710. */
  1711. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1712. /**
  1713. * Gets the animatable associated with a specific target
  1714. * @param target defines the target of the animatable
  1715. * @returns the required animatable if found
  1716. */
  1717. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1718. /**
  1719. * Gets all animatables associated with a given target
  1720. * @param target defines the target to look animatables for
  1721. * @returns an array of Animatables
  1722. */
  1723. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1724. /**
  1725. * Gets all animatable attached to the scene
  1726. */
  1727. readonly animatables: Animatable[];
  1728. /**
  1729. * Will stop the animation of the given target
  1730. * @param target - the target
  1731. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1732. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1733. */
  1734. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1735. /**
  1736. * Stops and removes all animations that have been applied to the scene
  1737. */
  1738. stopAllAnimations(): void;
  1739. private _animate;
  1740. /** @hidden */
  1741. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1742. private _processLateAnimationBindingsForMatrices;
  1743. private _processLateAnimationBindingsForQuaternions;
  1744. private _processLateAnimationBindings;
  1745. /** @hidden */
  1746. _switchToAlternateCameraConfiguration(active: boolean): void;
  1747. /**
  1748. * Gets the current view matrix
  1749. * @returns a Matrix
  1750. */
  1751. getViewMatrix(): Matrix;
  1752. /**
  1753. * Gets the current projection matrix
  1754. * @returns a Matrix
  1755. */
  1756. getProjectionMatrix(): Matrix;
  1757. /**
  1758. * Gets the current transform matrix
  1759. * @returns a Matrix made of View * Projection
  1760. */
  1761. getTransformMatrix(): Matrix;
  1762. /**
  1763. * Sets the current transform matrix
  1764. * @param view defines the View matrix to use
  1765. * @param projection defines the Projection matrix to use
  1766. */
  1767. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1768. /** @hidden */
  1769. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1770. /**
  1771. * Gets the uniform buffer used to store scene data
  1772. * @returns a UniformBuffer
  1773. */
  1774. getSceneUniformBuffer(): UniformBuffer;
  1775. /**
  1776. * Gets an unique (relatively to the current scene) Id
  1777. * @returns an unique number for the scene
  1778. */
  1779. getUniqueId(): number;
  1780. /**
  1781. * Add a mesh to the list of scene's meshes
  1782. * @param newMesh defines the mesh to add
  1783. * @param recursive if all child meshes should also be added to the scene
  1784. */
  1785. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1786. /**
  1787. * Remove a mesh for the list of scene's meshes
  1788. * @param toRemove defines the mesh to remove
  1789. * @param recursive if all child meshes should also be removed from the scene
  1790. * @returns the index where the mesh was in the mesh list
  1791. */
  1792. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1793. /**
  1794. * Add a transform node to the list of scene's transform nodes
  1795. * @param newTransformNode defines the transform node to add
  1796. */
  1797. addTransformNode(newTransformNode: TransformNode): void;
  1798. /**
  1799. * Remove a transform node for the list of scene's transform nodes
  1800. * @param toRemove defines the transform node to remove
  1801. * @returns the index where the transform node was in the transform node list
  1802. */
  1803. removeTransformNode(toRemove: TransformNode): number;
  1804. /**
  1805. * Remove a skeleton for the list of scene's skeletons
  1806. * @param toRemove defines the skeleton to remove
  1807. * @returns the index where the skeleton was in the skeleton list
  1808. */
  1809. removeSkeleton(toRemove: Skeleton): number;
  1810. /**
  1811. * Remove a morph target for the list of scene's morph targets
  1812. * @param toRemove defines the morph target to remove
  1813. * @returns the index where the morph target was in the morph target list
  1814. */
  1815. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1816. /**
  1817. * Remove a light for the list of scene's lights
  1818. * @param toRemove defines the light to remove
  1819. * @returns the index where the light was in the light list
  1820. */
  1821. removeLight(toRemove: Light): number;
  1822. /**
  1823. * Remove a camera for the list of scene's cameras
  1824. * @param toRemove defines the camera to remove
  1825. * @returns the index where the camera was in the camera list
  1826. */
  1827. removeCamera(toRemove: Camera): number;
  1828. /**
  1829. * Remove a particle system for the list of scene's particle systems
  1830. * @param toRemove defines the particle system to remove
  1831. * @returns the index where the particle system was in the particle system list
  1832. */
  1833. removeParticleSystem(toRemove: IParticleSystem): number;
  1834. /**
  1835. * Remove a animation for the list of scene's animations
  1836. * @param toRemove defines the animation to remove
  1837. * @returns the index where the animation was in the animation list
  1838. */
  1839. removeAnimation(toRemove: Animation): number;
  1840. /**
  1841. * Removes the given animation group from this scene.
  1842. * @param toRemove The animation group to remove
  1843. * @returns The index of the removed animation group
  1844. */
  1845. removeAnimationGroup(toRemove: AnimationGroup): number;
  1846. /**
  1847. * Removes the given multi-material from this scene.
  1848. * @param toRemove The multi-material to remove
  1849. * @returns The index of the removed multi-material
  1850. */
  1851. removeMultiMaterial(toRemove: MultiMaterial): number;
  1852. /**
  1853. * Removes the given material from this scene.
  1854. * @param toRemove The material to remove
  1855. * @returns The index of the removed material
  1856. */
  1857. removeMaterial(toRemove: Material): number;
  1858. /**
  1859. * Removes the given action manager from this scene.
  1860. * @param toRemove The action manager to remove
  1861. * @returns The index of the removed action manager
  1862. */
  1863. removeActionManager(toRemove: ActionManager): number;
  1864. /**
  1865. * Removes the given texture from this scene.
  1866. * @param toRemove The texture to remove
  1867. * @returns The index of the removed texture
  1868. */
  1869. removeTexture(toRemove: BaseTexture): number;
  1870. /**
  1871. * Adds the given light to this scene
  1872. * @param newLight The light to add
  1873. */
  1874. addLight(newLight: Light): void;
  1875. /**
  1876. * Sorts the list list based on light priorities
  1877. */
  1878. sortLightsByPriority(): void;
  1879. /**
  1880. * Adds the given camera to this scene
  1881. * @param newCamera The camera to add
  1882. */
  1883. addCamera(newCamera: Camera): void;
  1884. /**
  1885. * Adds the given skeleton to this scene
  1886. * @param newSkeleton The skeleton to add
  1887. */
  1888. addSkeleton(newSkeleton: Skeleton): void;
  1889. /**
  1890. * Adds the given particle system to this scene
  1891. * @param newParticleSystem The particle system to add
  1892. */
  1893. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1894. /**
  1895. * Adds the given animation to this scene
  1896. * @param newAnimation The animation to add
  1897. */
  1898. addAnimation(newAnimation: Animation): void;
  1899. /**
  1900. * Adds the given animation group to this scene.
  1901. * @param newAnimationGroup The animation group to add
  1902. */
  1903. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1904. /**
  1905. * Adds the given multi-material to this scene
  1906. * @param newMultiMaterial The multi-material to add
  1907. */
  1908. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1909. /**
  1910. * Adds the given material to this scene
  1911. * @param newMaterial The material to add
  1912. */
  1913. addMaterial(newMaterial: Material): void;
  1914. /**
  1915. * Adds the given morph target to this scene
  1916. * @param newMorphTargetManager The morph target to add
  1917. */
  1918. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1919. /**
  1920. * Adds the given geometry to this scene
  1921. * @param newGeometry The geometry to add
  1922. */
  1923. addGeometry(newGeometry: Geometry): void;
  1924. /**
  1925. * Adds the given action manager to this scene
  1926. * @param newActionManager The action manager to add
  1927. */
  1928. addActionManager(newActionManager: ActionManager): void;
  1929. /**
  1930. * Adds the given texture to this scene.
  1931. * @param newTexture The texture to add
  1932. */
  1933. addTexture(newTexture: BaseTexture): void;
  1934. /**
  1935. * Switch active camera
  1936. * @param newCamera defines the new active camera
  1937. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1938. */
  1939. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1940. /**
  1941. * sets the active camera of the scene using its ID
  1942. * @param id defines the camera's ID
  1943. * @return the new active camera or null if none found.
  1944. */
  1945. setActiveCameraByID(id: string): Nullable<Camera>;
  1946. /**
  1947. * sets the active camera of the scene using its name
  1948. * @param name defines the camera's name
  1949. * @returns the new active camera or null if none found.
  1950. */
  1951. setActiveCameraByName(name: string): Nullable<Camera>;
  1952. /**
  1953. * get an animation group using its name
  1954. * @param name defines the material's name
  1955. * @return the animation group or null if none found.
  1956. */
  1957. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1958. /**
  1959. * get a material using its id
  1960. * @param id defines the material's ID
  1961. * @return the material or null if none found.
  1962. */
  1963. getMaterialByID(id: string): Nullable<Material>;
  1964. /**
  1965. * Gets a material using its name
  1966. * @param name defines the material's name
  1967. * @return the material or null if none found.
  1968. */
  1969. getMaterialByName(name: string): Nullable<Material>;
  1970. /**
  1971. * Gets a camera using its id
  1972. * @param id defines the id to look for
  1973. * @returns the camera or null if not found
  1974. */
  1975. getCameraByID(id: string): Nullable<Camera>;
  1976. /**
  1977. * Gets a camera using its unique id
  1978. * @param uniqueId defines the unique id to look for
  1979. * @returns the camera or null if not found
  1980. */
  1981. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1982. /**
  1983. * Gets a camera using its name
  1984. * @param name defines the camera's name
  1985. * @return the camera or null if none found.
  1986. */
  1987. getCameraByName(name: string): Nullable<Camera>;
  1988. /**
  1989. * Gets a bone using its id
  1990. * @param id defines the bone's id
  1991. * @return the bone or null if not found
  1992. */
  1993. getBoneByID(id: string): Nullable<Bone>;
  1994. /**
  1995. * Gets a bone using its id
  1996. * @param name defines the bone's name
  1997. * @return the bone or null if not found
  1998. */
  1999. getBoneByName(name: string): Nullable<Bone>;
  2000. /**
  2001. * Gets a light node using its name
  2002. * @param name defines the the light's name
  2003. * @return the light or null if none found.
  2004. */
  2005. getLightByName(name: string): Nullable<Light>;
  2006. /**
  2007. * Gets a light node using its id
  2008. * @param id defines the light's id
  2009. * @return the light or null if none found.
  2010. */
  2011. getLightByID(id: string): Nullable<Light>;
  2012. /**
  2013. * Gets a light node using its scene-generated unique ID
  2014. * @param uniqueId defines the light's unique id
  2015. * @return the light or null if none found.
  2016. */
  2017. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2018. /**
  2019. * Gets a particle system by id
  2020. * @param id defines the particle system id
  2021. * @return the corresponding system or null if none found
  2022. */
  2023. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2024. /**
  2025. * Gets a geometry using its ID
  2026. * @param id defines the geometry's id
  2027. * @return the geometry or null if none found.
  2028. */
  2029. getGeometryByID(id: string): Nullable<Geometry>;
  2030. /**
  2031. * Add a new geometry to this scene
  2032. * @param geometry defines the geometry to be added to the scene.
  2033. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2034. * @return a boolean defining if the geometry was added or not
  2035. */
  2036. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2037. /**
  2038. * Removes an existing geometry
  2039. * @param geometry defines the geometry to be removed from the scene
  2040. * @return a boolean defining if the geometry was removed or not
  2041. */
  2042. removeGeometry(geometry: Geometry): boolean;
  2043. /**
  2044. * Gets the list of geometries attached to the scene
  2045. * @returns an array of Geometry
  2046. */
  2047. getGeometries(): Geometry[];
  2048. /**
  2049. * Gets the first added mesh found of a given ID
  2050. * @param id defines the id to search for
  2051. * @return the mesh found or null if not found at all
  2052. */
  2053. getMeshByID(id: string): Nullable<AbstractMesh>;
  2054. /**
  2055. * Gets a list of meshes using their id
  2056. * @param id defines the id to search for
  2057. * @returns a list of meshes
  2058. */
  2059. getMeshesByID(id: string): Array<AbstractMesh>;
  2060. /**
  2061. * Gets the first added transform node found of a given ID
  2062. * @param id defines the id to search for
  2063. * @return the found transform node or null if not found at all.
  2064. */
  2065. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2066. /**
  2067. * Gets a list of transform nodes using their id
  2068. * @param id defines the id to search for
  2069. * @returns a list of transform nodes
  2070. */
  2071. getTransformNodesByID(id: string): Array<TransformNode>;
  2072. /**
  2073. * Gets a mesh with its auto-generated unique id
  2074. * @param uniqueId defines the unique id to search for
  2075. * @return the found mesh or null if not found at all.
  2076. */
  2077. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2078. /**
  2079. * Gets a the last added mesh using a given id
  2080. * @param id defines the id to search for
  2081. * @return the found mesh or null if not found at all.
  2082. */
  2083. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2084. /**
  2085. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2086. * @param id defines the id to search for
  2087. * @return the found node or null if not found at all
  2088. */
  2089. getLastEntryByID(id: string): Nullable<Node>;
  2090. /**
  2091. * Gets a node (Mesh, Camera, Light) using a given id
  2092. * @param id defines the id to search for
  2093. * @return the found node or null if not found at all
  2094. */
  2095. getNodeByID(id: string): Nullable<Node>;
  2096. /**
  2097. * Gets a node (Mesh, Camera, Light) using a given name
  2098. * @param name defines the name to search for
  2099. * @return the found node or null if not found at all.
  2100. */
  2101. getNodeByName(name: string): Nullable<Node>;
  2102. /**
  2103. * Gets a mesh using a given name
  2104. * @param name defines the name to search for
  2105. * @return the found mesh or null if not found at all.
  2106. */
  2107. getMeshByName(name: string): Nullable<AbstractMesh>;
  2108. /**
  2109. * Gets a transform node using a given name
  2110. * @param name defines the name to search for
  2111. * @return the found transform node or null if not found at all.
  2112. */
  2113. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2114. /**
  2115. * Gets a sound using a given name
  2116. * @param name defines the name to search for
  2117. * @return the found sound or null if not found at all.
  2118. */
  2119. getSoundByName(name: string): Nullable<Sound>;
  2120. /**
  2121. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2122. * @param id defines the id to search for
  2123. * @return the found skeleton or null if not found at all.
  2124. */
  2125. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2126. /**
  2127. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2128. * @param id defines the id to search for
  2129. * @return the found skeleton or null if not found at all.
  2130. */
  2131. getSkeletonById(id: string): Nullable<Skeleton>;
  2132. /**
  2133. * Gets a skeleton using a given name
  2134. * @param name defines the name to search for
  2135. * @return the found skeleton or null if not found at all.
  2136. */
  2137. getSkeletonByName(name: string): Nullable<Skeleton>;
  2138. /**
  2139. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2140. * @param id defines the id to search for
  2141. * @return the found morph target manager or null if not found at all.
  2142. */
  2143. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2144. /**
  2145. * Gets a boolean indicating if the given mesh is active
  2146. * @param mesh defines the mesh to look for
  2147. * @returns true if the mesh is in the active list
  2148. */
  2149. isActiveMesh(mesh: AbstractMesh): boolean;
  2150. /**
  2151. * Return a unique id as a string which can serve as an identifier for the scene
  2152. */
  2153. readonly uid: string;
  2154. /**
  2155. * Add an externaly attached data from its key.
  2156. * This method call will fail and return false, if such key already exists.
  2157. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2158. * @param key the unique key that identifies the data
  2159. * @param data the data object to associate to the key for this Engine instance
  2160. * @return true if no such key were already present and the data was added successfully, false otherwise
  2161. */
  2162. addExternalData<T>(key: string, data: T): boolean;
  2163. /**
  2164. * Get an externaly attached data from its key
  2165. * @param key the unique key that identifies the data
  2166. * @return the associated data, if present (can be null), or undefined if not present
  2167. */
  2168. getExternalData<T>(key: string): Nullable<T>;
  2169. /**
  2170. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2171. * @param key the unique key that identifies the data
  2172. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2173. * @return the associated data, can be null if the factory returned null.
  2174. */
  2175. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2176. /**
  2177. * Remove an externaly attached data from the Engine instance
  2178. * @param key the unique key that identifies the data
  2179. * @return true if the data was successfully removed, false if it doesn't exist
  2180. */
  2181. removeExternalData(key: string): boolean;
  2182. private _evaluateSubMesh;
  2183. /**
  2184. * Clear the processed materials smart array preventing retention point in material dispose.
  2185. */
  2186. freeProcessedMaterials(): void;
  2187. /**
  2188. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2189. */
  2190. freeActiveMeshes(): void;
  2191. /**
  2192. * Clear the info related to rendering groups preventing retention points during dispose.
  2193. */
  2194. freeRenderingGroups(): void;
  2195. /** @hidden */
  2196. _isInIntermediateRendering(): boolean;
  2197. private _activeMeshCandidateProvider;
  2198. /**
  2199. * Defines the current active mesh candidate provider
  2200. * @param provider defines the provider to use
  2201. */
  2202. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2203. /**
  2204. * Gets the current active mesh candidate provider
  2205. * @returns the current active mesh candidate provider
  2206. */
  2207. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2208. private _activeMeshesFrozen;
  2209. /**
  2210. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2211. * @returns the current scene
  2212. */
  2213. freezeActiveMeshes(): Scene;
  2214. /**
  2215. * Use this function to restart evaluating active meshes on every frame
  2216. * @returns the current scene
  2217. */
  2218. unfreezeActiveMeshes(): Scene;
  2219. private _evaluateActiveMeshes;
  2220. private _activeMesh;
  2221. /**
  2222. * Update the transform matrix to update from the current active camera
  2223. * @param force defines a boolean used to force the update even if cache is up to date
  2224. */
  2225. updateTransformMatrix(force?: boolean): void;
  2226. /**
  2227. * 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)
  2228. * @param alternateCamera defines the camera to use
  2229. */
  2230. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2231. /** @hidden */
  2232. _allowPostProcessClearColor: boolean;
  2233. private _renderForCamera;
  2234. private _processSubCameras;
  2235. private _checkIntersections;
  2236. /**
  2237. * Render the scene
  2238. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2239. */
  2240. render(updateCameras?: boolean): void;
  2241. private _updateAudioParameters;
  2242. /**
  2243. * Gets or sets if audio support is enabled
  2244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2245. */
  2246. audioEnabled: boolean;
  2247. private _disableAudio;
  2248. private _enableAudio;
  2249. /**
  2250. * Gets or sets if audio will be output to headphones
  2251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2252. */
  2253. headphone: boolean;
  2254. private _switchAudioModeForHeadphones;
  2255. private _switchAudioModeForNormalSpeakers;
  2256. /**
  2257. * Freeze all materials
  2258. * A frozen material will not be updatable but should be faster to render
  2259. */
  2260. freezeMaterials(): void;
  2261. /**
  2262. * Unfreeze all materials
  2263. * A frozen material will not be updatable but should be faster to render
  2264. */
  2265. unfreezeMaterials(): void;
  2266. /**
  2267. * Releases all held ressources
  2268. */
  2269. dispose(): void;
  2270. /**
  2271. * Gets if the scene is already disposed
  2272. */
  2273. readonly isDisposed: boolean;
  2274. /**
  2275. * Releases sounds & soundtracks
  2276. */
  2277. disposeSounds(): void;
  2278. /**
  2279. * Call this function to reduce memory footprint of the scene.
  2280. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2281. */
  2282. clearCachedVertexData(): void;
  2283. /**
  2284. * This function will remove the local cached buffer data from texture.
  2285. * It will save memory but will prevent the texture from being rebuilt
  2286. */
  2287. cleanCachedTextureBuffer(): void;
  2288. /**
  2289. * Get the world extend vectors with an optional filter
  2290. *
  2291. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2292. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2293. */
  2294. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2295. min: Vector3;
  2296. max: Vector3;
  2297. };
  2298. /**
  2299. * Creates or updates the octree used to boost selection (picking)
  2300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2301. * @param maxCapacity defines the maximum capacity per leaf
  2302. * @param maxDepth defines the maximum depth of the octree
  2303. * @returns an octree of AbstractMesh
  2304. */
  2305. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2306. /**
  2307. * Creates a ray that can be used to pick in the scene
  2308. * @param x defines the x coordinate of the origin (on-screen)
  2309. * @param y defines the y coordinate of the origin (on-screen)
  2310. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2311. * @param camera defines the camera to use for the picking
  2312. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2313. * @returns a Ray
  2314. */
  2315. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2316. /**
  2317. * Creates a ray that can be used to pick in the scene
  2318. * @param x defines the x coordinate of the origin (on-screen)
  2319. * @param y defines the y coordinate of the origin (on-screen)
  2320. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2321. * @param result defines the ray where to store the picking ray
  2322. * @param camera defines the camera to use for the picking
  2323. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2324. * @returns the current scene
  2325. */
  2326. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2327. /**
  2328. * Creates a ray that can be used to pick in the scene
  2329. * @param x defines the x coordinate of the origin (on-screen)
  2330. * @param y defines the y coordinate of the origin (on-screen)
  2331. * @param camera defines the camera to use for the picking
  2332. * @returns a Ray
  2333. */
  2334. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2335. /**
  2336. * Creates a ray that can be used to pick in the scene
  2337. * @param x defines the x coordinate of the origin (on-screen)
  2338. * @param y defines the y coordinate of the origin (on-screen)
  2339. * @param result defines the ray where to store the picking ray
  2340. * @param camera defines the camera to use for the picking
  2341. * @returns the current scene
  2342. */
  2343. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2344. private _internalPick;
  2345. private _internalMultiPick;
  2346. private _tempPickingRay;
  2347. /** Launch a ray to try to pick a mesh in the scene
  2348. * @param x position on screen
  2349. * @param y position on screen
  2350. * @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
  2351. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2352. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2353. * @returns a PickingInfo
  2354. */
  2355. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2356. private _cachedRayForTransform;
  2357. /** Use the given ray to pick a mesh in the scene
  2358. * @param ray The ray to use to pick meshes
  2359. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2360. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2361. * @returns a PickingInfo
  2362. */
  2363. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2364. /**
  2365. * Launch a ray to try to pick a mesh in the scene
  2366. * @param x X position on screen
  2367. * @param y Y position on screen
  2368. * @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
  2369. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2370. * @returns an array of PickingInfo
  2371. */
  2372. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2373. /**
  2374. * Launch a ray to try to pick a mesh in the scene
  2375. * @param ray Ray to use
  2376. * @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
  2377. * @returns an array of PickingInfo
  2378. */
  2379. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2380. /**
  2381. * Force the value of meshUnderPointer
  2382. * @param mesh defines the mesh to use
  2383. */
  2384. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2385. /**
  2386. * Gets the mesh under the pointer
  2387. * @returns a Mesh or null if no mesh is under the pointer
  2388. */
  2389. getPointerOverMesh(): Nullable<AbstractMesh>;
  2390. /**
  2391. * Gets the current physics engine
  2392. * @returns a PhysicsEngine or null if none attached
  2393. */
  2394. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2395. /**
  2396. * Enables physics to the current scene
  2397. * @param gravity defines the scene's gravity for the physics engine
  2398. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2399. * @return a boolean indicating if the physics engine was initialized
  2400. */
  2401. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2402. /**
  2403. * Disables and disposes the physics engine associated with the scene
  2404. */
  2405. disablePhysicsEngine(): void;
  2406. /**
  2407. * Gets a boolean indicating if there is an active physics engine
  2408. * @returns a boolean indicating if there is an active physics engine
  2409. */
  2410. isPhysicsEnabled(): boolean;
  2411. /**
  2412. * Deletes a physics compound impostor
  2413. * @param compound defines the compound to delete
  2414. */
  2415. deleteCompoundImpostor(compound: any): void;
  2416. /** @hidden */
  2417. _rebuildGeometries(): void;
  2418. /** @hidden */
  2419. _rebuildTextures(): void;
  2420. /**
  2421. * Creates a default light for the scene.
  2422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  2423. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  2424. */
  2425. createDefaultLight(replace?: boolean): void;
  2426. /**
  2427. * Creates a default camera for the scene.
  2428. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  2429. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2430. * @param replace has default false, when true replaces the active camera in the scene
  2431. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  2432. */
  2433. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2434. /**
  2435. * Creates a default camera and a default light.
  2436. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  2437. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2438. * @param replace has the default false, when true replaces the active camera/light in the scene
  2439. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  2440. */
  2441. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2442. /**
  2443. * Creates a new sky box
  2444. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  2445. * @param environmentTexture defines the texture to use as environment texture
  2446. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  2447. * @param scale defines the overall scale of the skybox
  2448. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  2449. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  2450. * @returns a new mesh holding the sky box
  2451. */
  2452. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2453. /**
  2454. * Creates a new environment
  2455. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  2456. * @param options defines the options you can use to configure the environment
  2457. * @returns the new EnvironmentHelper
  2458. */
  2459. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2460. /**
  2461. * Creates a new VREXperienceHelper
  2462. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2463. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2464. * @returns a new VREXperienceHelper
  2465. */
  2466. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2467. private _getByTags;
  2468. /**
  2469. * Get a list of meshes by tags
  2470. * @param tagsQuery defines the tags query to use
  2471. * @param forEach defines a predicate used to filter results
  2472. * @returns an array of Mesh
  2473. */
  2474. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2475. /**
  2476. * Get a list of cameras by tags
  2477. * @param tagsQuery defines the tags query to use
  2478. * @param forEach defines a predicate used to filter results
  2479. * @returns an array of Camera
  2480. */
  2481. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2482. /**
  2483. * Get a list of lights by tags
  2484. * @param tagsQuery defines the tags query to use
  2485. * @param forEach defines a predicate used to filter results
  2486. * @returns an array of Light
  2487. */
  2488. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2489. /**
  2490. * Get a list of materials by tags
  2491. * @param tagsQuery defines the tags query to use
  2492. * @param forEach defines a predicate used to filter results
  2493. * @returns an array of Material
  2494. */
  2495. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2496. /**
  2497. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2498. * This allowed control for front to back rendering or reversly depending of the special needs.
  2499. *
  2500. * @param renderingGroupId The rendering group id corresponding to its index
  2501. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2502. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2503. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2504. */
  2505. 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;
  2506. /**
  2507. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2508. *
  2509. * @param renderingGroupId The rendering group id corresponding to its index
  2510. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2511. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2512. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2513. */
  2514. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2515. /**
  2516. * Gets the current auto clear configuration for one rendering group of the rendering
  2517. * manager.
  2518. * @param index the rendering group index to get the information for
  2519. * @returns The auto clear setup for the requested rendering group
  2520. */
  2521. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2522. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2523. blockMaterialDirtyMechanism: boolean;
  2524. /**
  2525. * Will flag all materials as dirty to trigger new shader compilation
  2526. * @param flag defines the flag used to specify which material part must be marked as dirty
  2527. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2528. */
  2529. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2530. /** @hidden */
  2531. _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;
  2532. /** @hidden */
  2533. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2534. }
  2535. }
  2536. declare module BABYLON {
  2537. /**
  2538. * Groups all the scene component constants in one place to ease maintenance.
  2539. * @hidden
  2540. */
  2541. class SceneComponentConstants {
  2542. static readonly NAME_EFFECTLAYER: string;
  2543. static readonly NAME_LAYER: string;
  2544. static readonly NAME_LENSFLARESYSTEM: string;
  2545. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2546. static readonly NAME_PARTICLESYSTEM: string;
  2547. static readonly NAME_GAMEPAD: string;
  2548. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2549. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2550. static readonly NAME_DEPTHRENDERER: string;
  2551. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2552. static readonly NAME_SPRITE: string;
  2553. static readonly NAME_OUTLINERENDERER: string;
  2554. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2555. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2556. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2557. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2558. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2559. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2560. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2561. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2562. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2563. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2564. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2565. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2566. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2567. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2568. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2570. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2571. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2572. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2573. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2574. static readonly STEP_REBUILDGEOMETRY_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2575. static readonly STEP_POINTERMOVE_SPRITE: number;
  2576. static readonly STEP_POINTERDOWN_SPRITE: number;
  2577. static readonly STEP_POINTERUP_SPRITE: number;
  2578. }
  2579. /**
  2580. * This represents a scene component.
  2581. *
  2582. * This is used to decouple the dependency the scene is having on the different workloads like
  2583. * layers, post processes...
  2584. */
  2585. interface ISceneComponent {
  2586. /**
  2587. * The name of the component. Each component must have a unique name.
  2588. */
  2589. name: string;
  2590. /**
  2591. * The scene the component belongs to.
  2592. */
  2593. scene: Scene;
  2594. /**
  2595. * Register the component to one instance of a scene.
  2596. */
  2597. register(): void;
  2598. /**
  2599. * Rebuilds the elements related to this component in case of
  2600. * context lost for instance.
  2601. */
  2602. rebuild(): void;
  2603. /**
  2604. * Disposes the component and the associated ressources.
  2605. */
  2606. dispose(): void;
  2607. }
  2608. /**
  2609. * This represents a SERIALIZABLE scene component.
  2610. *
  2611. * This extends Scene Component to add Serialization methods on top.
  2612. */
  2613. interface ISceneSerializableComponent extends ISceneComponent {
  2614. /**
  2615. * Adds all the element from the container to the scene
  2616. * @param container the container holding the elements
  2617. */
  2618. addFromContainer(container: AbstractScene): void;
  2619. /**
  2620. * Removes all the elements in the container from the scene
  2621. * @param container contains the elements to remove
  2622. */
  2623. removeFromContainer(container: AbstractScene): void;
  2624. /**
  2625. * Serializes the component data to the specified json object
  2626. * @param serializationObject The object to serialize to
  2627. */
  2628. serialize(serializationObject: any): void;
  2629. }
  2630. /**
  2631. * Strong typing of a Mesh related stage step action
  2632. */
  2633. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2634. /**
  2635. * Strong typing of a Evaluate Sub Mesh related stage step action
  2636. */
  2637. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2638. /**
  2639. * Strong typing of a Active Mesh related stage step action
  2640. */
  2641. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2642. /**
  2643. * Strong typing of a Camera related stage step action
  2644. */
  2645. type CameraStageAction = (camera: Camera) => void;
  2646. /**
  2647. * Strong typing of a RenderingGroup related stage step action
  2648. */
  2649. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2650. /**
  2651. * Strong typing of a Mesh Render related stage step action
  2652. */
  2653. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2654. /**
  2655. * Strong typing of a simple stage step action
  2656. */
  2657. type SimpleStageAction = () => void;
  2658. /**
  2659. * Strong typing of a render target action.
  2660. */
  2661. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2662. /**
  2663. * Strong typing of a pointer move action.
  2664. */
  2665. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2666. /**
  2667. * Strong typing of a pointer up/down action.
  2668. */
  2669. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2670. /**
  2671. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2672. * @hidden
  2673. */
  2674. class Stage<T extends Function> extends Array<{
  2675. index: number;
  2676. component: ISceneComponent;
  2677. action: T;
  2678. }> {
  2679. /**
  2680. * Hide ctor from the rest of the world.
  2681. * @param items The items to add.
  2682. */
  2683. private constructor();
  2684. /**
  2685. * Creates a new Stage.
  2686. * @returns A new instance of a Stage
  2687. */
  2688. static Create<T extends Function>(): Stage<T>;
  2689. /**
  2690. * Registers a step in an ordered way in the targeted stage.
  2691. * @param index Defines the position to register the step in
  2692. * @param component Defines the component attached to the step
  2693. * @param action Defines the action to launch during the step
  2694. */
  2695. registerStep(index: number, component: ISceneComponent, action: T): void;
  2696. /**
  2697. * Clears all the steps from the stage.
  2698. */
  2699. clear(): void;
  2700. }
  2701. }
  2702. declare module BABYLON {
  2703. type Nullable<T> = T | null;
  2704. type float = number;
  2705. type double = number;
  2706. type int = number;
  2707. type FloatArray = number[] | Float32Array;
  2708. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2709. /**
  2710. * Alias for types that can be used by a Buffer or VertexBuffer.
  2711. */
  2712. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2713. }
  2714. declare module BABYLON {
  2715. /**
  2716. * The action to be carried out following a trigger
  2717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2718. */
  2719. class Action {
  2720. /** the trigger, with or without parameters, for the action */
  2721. triggerOptions: any;
  2722. /**
  2723. * Trigger for the action
  2724. */
  2725. trigger: number;
  2726. /**
  2727. * Internal only - manager for action
  2728. * @hidden
  2729. */
  2730. _actionManager: ActionManager;
  2731. private _nextActiveAction;
  2732. private _child;
  2733. private _condition?;
  2734. private _triggerParameter;
  2735. /**
  2736. * An event triggered prior to action being executed.
  2737. */
  2738. onBeforeExecuteObservable: Observable<Action>;
  2739. /**
  2740. * Creates a new Action
  2741. * @param triggerOptions the trigger, with or without parameters, for the action
  2742. * @param condition an optional determinant of action
  2743. */
  2744. constructor(
  2745. /** the trigger, with or without parameters, for the action */
  2746. triggerOptions: any, condition?: Condition);
  2747. /**
  2748. * Internal only
  2749. * @hidden
  2750. */
  2751. _prepare(): void;
  2752. /**
  2753. * Gets the trigger parameters
  2754. * @returns the trigger parameters
  2755. */
  2756. getTriggerParameter(): any;
  2757. /**
  2758. * Internal only - executes current action event
  2759. * @hidden
  2760. */
  2761. _executeCurrent(evt?: ActionEvent): void;
  2762. /**
  2763. * Execute placeholder for child classes
  2764. * @param evt optional action event
  2765. */
  2766. execute(evt?: ActionEvent): void;
  2767. /**
  2768. * Skips to next active action
  2769. */
  2770. skipToNextActiveAction(): void;
  2771. /**
  2772. * Adds action to chain of actions, may be a DoNothingAction
  2773. * @param action defines the next action to execute
  2774. * @returns The action passed in
  2775. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2776. */
  2777. then(action: Action): Action;
  2778. /**
  2779. * Internal only
  2780. * @hidden
  2781. */
  2782. _getProperty(propertyPath: string): string;
  2783. /**
  2784. * Internal only
  2785. * @hidden
  2786. */
  2787. _getEffectiveTarget(target: any, propertyPath: string): any;
  2788. /**
  2789. * Serialize placeholder for child classes
  2790. * @param parent of child
  2791. * @returns the serialized object
  2792. */
  2793. serialize(parent: any): any;
  2794. /**
  2795. * Internal only called by serialize
  2796. * @hidden
  2797. */
  2798. protected _serialize(serializedAction: any, parent?: any): any;
  2799. /**
  2800. * Internal only
  2801. * @hidden
  2802. */
  2803. static _SerializeValueAsString: (value: any) => string;
  2804. /**
  2805. * Internal only
  2806. * @hidden
  2807. */
  2808. static _GetTargetProperty: (target: Scene | Node) => {
  2809. name: string;
  2810. targetType: string;
  2811. value: string;
  2812. };
  2813. }
  2814. }
  2815. declare module BABYLON {
  2816. /**
  2817. * ActionEvent is the event being sent when an action is triggered.
  2818. */
  2819. class ActionEvent {
  2820. /** The mesh or sprite that triggered the action */
  2821. source: any;
  2822. /** The X mouse cursor position at the time of the event */
  2823. pointerX: number;
  2824. /** The Y mouse cursor position at the time of the event */
  2825. pointerY: number;
  2826. /** The mesh that is currently pointed at (can be null) */
  2827. meshUnderPointer: Nullable<AbstractMesh>;
  2828. /** the original (browser) event that triggered the ActionEvent */
  2829. sourceEvent?: any;
  2830. /** additional data for the event */
  2831. additionalData?: any;
  2832. /**
  2833. * Creates a new ActionEvent
  2834. * @param source The mesh or sprite that triggered the action
  2835. * @param pointerX The X mouse cursor position at the time of the event
  2836. * @param pointerY The Y mouse cursor position at the time of the event
  2837. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2838. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2839. * @param additionalData additional data for the event
  2840. */
  2841. constructor(
  2842. /** The mesh or sprite that triggered the action */
  2843. source: any,
  2844. /** The X mouse cursor position at the time of the event */
  2845. pointerX: number,
  2846. /** The Y mouse cursor position at the time of the event */
  2847. pointerY: number,
  2848. /** The mesh that is currently pointed at (can be null) */
  2849. meshUnderPointer: Nullable<AbstractMesh>,
  2850. /** the original (browser) event that triggered the ActionEvent */
  2851. sourceEvent?: any,
  2852. /** additional data for the event */
  2853. additionalData?: any);
  2854. /**
  2855. * Helper function to auto-create an ActionEvent from a source mesh.
  2856. * @param source The source mesh that triggered the event
  2857. * @param evt The original (browser) event
  2858. * @param additionalData additional data for the event
  2859. * @returns the new ActionEvent
  2860. */
  2861. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2862. /**
  2863. * Helper function to auto-create an ActionEvent from a source sprite
  2864. * @param source The source sprite that triggered the event
  2865. * @param scene Scene associated with the sprite
  2866. * @param evt The original (browser) event
  2867. * @param additionalData additional data for the event
  2868. * @returns the new ActionEvent
  2869. */
  2870. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2871. /**
  2872. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2873. * @param scene the scene where the event occurred
  2874. * @param evt The original (browser) event
  2875. * @returns the new ActionEvent
  2876. */
  2877. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2878. /**
  2879. * Helper function to auto-create an ActionEvent from a primitive
  2880. * @param prim defines the target primitive
  2881. * @param pointerPos defines the pointer position
  2882. * @param evt The original (browser) event
  2883. * @param additionalData additional data for the event
  2884. * @returns the new ActionEvent
  2885. */
  2886. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2887. }
  2888. /**
  2889. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2890. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2892. */
  2893. class ActionManager {
  2894. private static _NothingTrigger;
  2895. private static _OnPickTrigger;
  2896. private static _OnLeftPickTrigger;
  2897. private static _OnRightPickTrigger;
  2898. private static _OnCenterPickTrigger;
  2899. private static _OnPickDownTrigger;
  2900. private static _OnDoublePickTrigger;
  2901. private static _OnPickUpTrigger;
  2902. private static _OnLongPressTrigger;
  2903. private static _OnPointerOverTrigger;
  2904. private static _OnPointerOutTrigger;
  2905. private static _OnEveryFrameTrigger;
  2906. private static _OnIntersectionEnterTrigger;
  2907. private static _OnIntersectionExitTrigger;
  2908. private static _OnKeyDownTrigger;
  2909. private static _OnKeyUpTrigger;
  2910. private static _OnPickOutTrigger;
  2911. /**
  2912. * Nothing
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly NothingTrigger: number;
  2916. /**
  2917. * On pick
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnPickTrigger: number;
  2921. /**
  2922. * On left pick
  2923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2924. */
  2925. static readonly OnLeftPickTrigger: number;
  2926. /**
  2927. * On right pick
  2928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2929. */
  2930. static readonly OnRightPickTrigger: number;
  2931. /**
  2932. * On center pick
  2933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2934. */
  2935. static readonly OnCenterPickTrigger: number;
  2936. /**
  2937. * On pick down
  2938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2939. */
  2940. static readonly OnPickDownTrigger: number;
  2941. /**
  2942. * On double pick
  2943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2944. */
  2945. static readonly OnDoublePickTrigger: number;
  2946. /**
  2947. * On pick up
  2948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2949. */
  2950. static readonly OnPickUpTrigger: number;
  2951. /**
  2952. * On pick out.
  2953. * This trigger will only be raised if you also declared a OnPickDown
  2954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2955. */
  2956. static readonly OnPickOutTrigger: number;
  2957. /**
  2958. * On long press
  2959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2960. */
  2961. static readonly OnLongPressTrigger: number;
  2962. /**
  2963. * On pointer over
  2964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2965. */
  2966. static readonly OnPointerOverTrigger: number;
  2967. /**
  2968. * On pointer out
  2969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2970. */
  2971. static readonly OnPointerOutTrigger: number;
  2972. /**
  2973. * On every frame
  2974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2975. */
  2976. static readonly OnEveryFrameTrigger: number;
  2977. /**
  2978. * On intersection enter
  2979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2980. */
  2981. static readonly OnIntersectionEnterTrigger: number;
  2982. /**
  2983. * On intersection exit
  2984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2985. */
  2986. static readonly OnIntersectionExitTrigger: number;
  2987. /**
  2988. * On key down
  2989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2990. */
  2991. static readonly OnKeyDownTrigger: number;
  2992. /**
  2993. * On key up
  2994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2995. */
  2996. static readonly OnKeyUpTrigger: number;
  2997. /** Gets the list of active triggers */
  2998. static Triggers: {
  2999. [key: string]: number;
  3000. };
  3001. /** Gets the list of actions */
  3002. actions: Action[];
  3003. /** Gets the cursor to use when hovering items */
  3004. hoverCursor: string;
  3005. private _scene;
  3006. /**
  3007. * Creates a new action manager
  3008. * @param scene defines the hosting scene
  3009. */
  3010. constructor(scene: Scene);
  3011. /**
  3012. * Releases all associated resources
  3013. */
  3014. dispose(): void;
  3015. /**
  3016. * Gets hosting scene
  3017. * @returns the hosting scene
  3018. */
  3019. getScene(): Scene;
  3020. /**
  3021. * Does this action manager handles actions of any of the given triggers
  3022. * @param triggers defines the triggers to be tested
  3023. * @return a boolean indicating whether one (or more) of the triggers is handled
  3024. */
  3025. hasSpecificTriggers(triggers: number[]): boolean;
  3026. /**
  3027. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3028. * speed.
  3029. * @param triggerA defines the trigger to be tested
  3030. * @param triggerB defines the trigger to be tested
  3031. * @return a boolean indicating whether one (or more) of the triggers is handled
  3032. */
  3033. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3034. /**
  3035. * Does this action manager handles actions of a given trigger
  3036. * @param trigger defines the trigger to be tested
  3037. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3038. * @return whether the trigger is handled
  3039. */
  3040. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3041. /**
  3042. * Does this action manager has pointer triggers
  3043. */
  3044. readonly hasPointerTriggers: boolean;
  3045. /**
  3046. * Does this action manager has pick triggers
  3047. */
  3048. readonly hasPickTriggers: boolean;
  3049. /**
  3050. * Does exist one action manager with at least one trigger
  3051. **/
  3052. static readonly HasTriggers: boolean;
  3053. /**
  3054. * Does exist one action manager with at least one pick trigger
  3055. **/
  3056. static readonly HasPickTriggers: boolean;
  3057. /**
  3058. * Does exist one action manager that handles actions of a given trigger
  3059. * @param trigger defines the trigger to be tested
  3060. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3061. **/
  3062. static HasSpecificTrigger(trigger: number): boolean;
  3063. /**
  3064. * Registers an action to this action manager
  3065. * @param action defines the action to be registered
  3066. * @return the action amended (prepared) after registration
  3067. */
  3068. registerAction(action: Action): Nullable<Action>;
  3069. /**
  3070. * Unregisters an action to this action manager
  3071. * @param action defines the action to be unregistered
  3072. * @return a boolean indicating whether the action has been unregistered
  3073. */
  3074. unregisterAction(action: Action): Boolean;
  3075. /**
  3076. * Process a specific trigger
  3077. * @param trigger defines the trigger to process
  3078. * @param evt defines the event details to be processed
  3079. */
  3080. processTrigger(trigger: number, evt?: ActionEvent): void;
  3081. /** @hidden */
  3082. _getEffectiveTarget(target: any, propertyPath: string): any;
  3083. /** @hidden */
  3084. _getProperty(propertyPath: string): string;
  3085. /**
  3086. * Serialize this manager to a JSON object
  3087. * @param name defines the property name to store this manager
  3088. * @returns a JSON representation of this manager
  3089. */
  3090. serialize(name: string): any;
  3091. /**
  3092. * Creates a new ActionManager from a JSON data
  3093. * @param parsedActions defines the JSON data to read from
  3094. * @param object defines the hosting mesh
  3095. * @param scene defines the hosting scene
  3096. */
  3097. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3098. /**
  3099. * Get a trigger name by index
  3100. * @param trigger defines the trigger index
  3101. * @returns a trigger name
  3102. */
  3103. static GetTriggerName(trigger: number): string;
  3104. }
  3105. }
  3106. declare module BABYLON {
  3107. /**
  3108. * A Condition applied to an Action
  3109. */
  3110. class Condition {
  3111. /**
  3112. * Internal only - manager for action
  3113. * @hidden
  3114. */
  3115. _actionManager: ActionManager;
  3116. /**
  3117. * Internal only
  3118. * @hidden
  3119. */
  3120. _evaluationId: number;
  3121. /**
  3122. * Internal only
  3123. * @hidden
  3124. */
  3125. _currentResult: boolean;
  3126. /**
  3127. * Creates a new Condition
  3128. * @param actionManager the manager of the action the condition is applied to
  3129. */
  3130. constructor(actionManager: ActionManager);
  3131. /**
  3132. * Check if the current condition is valid
  3133. * @returns a boolean
  3134. */
  3135. isValid(): boolean;
  3136. /**
  3137. * Internal only
  3138. * @hidden
  3139. */
  3140. _getProperty(propertyPath: string): string;
  3141. /**
  3142. * Internal only
  3143. * @hidden
  3144. */
  3145. _getEffectiveTarget(target: any, propertyPath: string): any;
  3146. /**
  3147. * Serialize placeholder for child classes
  3148. * @returns the serialized object
  3149. */
  3150. serialize(): any;
  3151. /**
  3152. * Internal only
  3153. * @hidden
  3154. */
  3155. protected _serialize(serializedCondition: any): any;
  3156. }
  3157. /**
  3158. * Defines specific conditional operators as extensions of Condition
  3159. */
  3160. class ValueCondition extends Condition {
  3161. /** path to specify the property of the target the conditional operator uses */
  3162. propertyPath: string;
  3163. /** the value compared by the conditional operator against the current value of the property */
  3164. value: any;
  3165. /** the conditional operator, default ValueCondition.IsEqual */
  3166. operator: number;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. private static _IsEqual;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. private static _IsDifferent;
  3177. /**
  3178. * Internal only
  3179. * @hidden
  3180. */
  3181. private static _IsGreater;
  3182. /**
  3183. * Internal only
  3184. * @hidden
  3185. */
  3186. private static _IsLesser;
  3187. /**
  3188. * returns the number for IsEqual
  3189. */
  3190. static readonly IsEqual: number;
  3191. /**
  3192. * Returns the number for IsDifferent
  3193. */
  3194. static readonly IsDifferent: number;
  3195. /**
  3196. * Returns the number for IsGreater
  3197. */
  3198. static readonly IsGreater: number;
  3199. /**
  3200. * Returns the number for IsLesser
  3201. */
  3202. static readonly IsLesser: number;
  3203. /**
  3204. * Internal only The action manager for the condition
  3205. * @hidden
  3206. */
  3207. _actionManager: ActionManager;
  3208. /**
  3209. * Internal only
  3210. * @hidden
  3211. */
  3212. private _target;
  3213. /**
  3214. * Internal only
  3215. * @hidden
  3216. */
  3217. private _effectiveTarget;
  3218. /**
  3219. * Internal only
  3220. * @hidden
  3221. */
  3222. private _property;
  3223. /**
  3224. * Creates a new ValueCondition
  3225. * @param actionManager manager for the action the condition applies to
  3226. * @param target for the action
  3227. * @param propertyPath path to specify the property of the target the conditional operator uses
  3228. * @param value the value compared by the conditional operator against the current value of the property
  3229. * @param operator the conditional operator, default ValueCondition.IsEqual
  3230. */
  3231. constructor(actionManager: ActionManager, target: any,
  3232. /** path to specify the property of the target the conditional operator uses */
  3233. propertyPath: string,
  3234. /** the value compared by the conditional operator against the current value of the property */
  3235. value: any,
  3236. /** the conditional operator, default ValueCondition.IsEqual */
  3237. operator?: number);
  3238. /**
  3239. * Compares the given value with the property value for the specified conditional operator
  3240. * @returns the result of the comparison
  3241. */
  3242. isValid(): boolean;
  3243. /**
  3244. * Serialize the ValueCondition into a JSON compatible object
  3245. * @returns serialization object
  3246. */
  3247. serialize(): any;
  3248. /**
  3249. * Gets the name of the conditional operator for the ValueCondition
  3250. * @param operator the conditional operator
  3251. * @returns the name
  3252. */
  3253. static GetOperatorName(operator: number): string;
  3254. }
  3255. /**
  3256. * Defines a predicate condition as an extension of Condition
  3257. */
  3258. class PredicateCondition extends Condition {
  3259. /** defines the predicate function used to validate the condition */
  3260. predicate: () => boolean;
  3261. /**
  3262. * Internal only - manager for action
  3263. * @hidden
  3264. */
  3265. _actionManager: ActionManager;
  3266. /**
  3267. * Creates a new PredicateCondition
  3268. * @param actionManager manager for the action the condition applies to
  3269. * @param predicate defines the predicate function used to validate the condition
  3270. */
  3271. constructor(actionManager: ActionManager,
  3272. /** defines the predicate function used to validate the condition */
  3273. predicate: () => boolean);
  3274. /**
  3275. * @returns the validity of the predicate condition
  3276. */
  3277. isValid(): boolean;
  3278. }
  3279. /**
  3280. * Defines a state condition as an extension of Condition
  3281. */
  3282. class StateCondition extends Condition {
  3283. value: string;
  3284. /**
  3285. * Internal only - manager for action
  3286. * @hidden
  3287. */
  3288. _actionManager: ActionManager;
  3289. /**
  3290. * Internal only
  3291. * @hidden
  3292. */
  3293. private _target;
  3294. /**
  3295. * Creates a new StateCondition
  3296. * @param actionManager manager for the action the condition applies to
  3297. * @param target of the condition
  3298. * @param value to compare with target state
  3299. */
  3300. constructor(actionManager: ActionManager, target: any, value: string);
  3301. /**
  3302. * @returns the validity of the state
  3303. */
  3304. isValid(): boolean;
  3305. /**
  3306. * Serialize the StateCondition into a JSON compatible object
  3307. * @returns serialization object
  3308. */
  3309. serialize(): any;
  3310. }
  3311. }
  3312. declare module BABYLON {
  3313. class SwitchBooleanAction extends Action {
  3314. propertyPath: string;
  3315. private _target;
  3316. private _effectiveTarget;
  3317. private _property;
  3318. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3319. /** @hidden */
  3320. _prepare(): void;
  3321. execute(): void;
  3322. serialize(parent: any): any;
  3323. }
  3324. class SetStateAction extends Action {
  3325. value: string;
  3326. private _target;
  3327. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3328. execute(): void;
  3329. serialize(parent: any): any;
  3330. }
  3331. class SetValueAction extends Action {
  3332. propertyPath: string;
  3333. value: any;
  3334. private _target;
  3335. private _effectiveTarget;
  3336. private _property;
  3337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3338. /** @hidden */
  3339. _prepare(): void;
  3340. execute(): void;
  3341. serialize(parent: any): any;
  3342. }
  3343. class IncrementValueAction extends Action {
  3344. propertyPath: string;
  3345. value: any;
  3346. private _target;
  3347. private _effectiveTarget;
  3348. private _property;
  3349. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3350. /** @hidden */
  3351. _prepare(): void;
  3352. execute(): void;
  3353. serialize(parent: any): any;
  3354. }
  3355. class PlayAnimationAction extends Action {
  3356. from: number;
  3357. to: number;
  3358. loop?: boolean | undefined;
  3359. private _target;
  3360. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3361. /** @hidden */
  3362. _prepare(): void;
  3363. execute(): void;
  3364. serialize(parent: any): any;
  3365. }
  3366. class StopAnimationAction extends Action {
  3367. private _target;
  3368. constructor(triggerOptions: any, target: any, condition?: Condition);
  3369. /** @hidden */
  3370. _prepare(): void;
  3371. execute(): void;
  3372. serialize(parent: any): any;
  3373. }
  3374. class DoNothingAction extends Action {
  3375. constructor(triggerOptions?: any, condition?: Condition);
  3376. execute(): void;
  3377. serialize(parent: any): any;
  3378. }
  3379. class CombineAction extends Action {
  3380. children: Action[];
  3381. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3382. /** @hidden */
  3383. _prepare(): void;
  3384. execute(evt: ActionEvent): void;
  3385. serialize(parent: any): any;
  3386. }
  3387. class ExecuteCodeAction extends Action {
  3388. func: (evt: ActionEvent) => void;
  3389. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3390. execute(evt: ActionEvent): void;
  3391. }
  3392. class SetParentAction extends Action {
  3393. private _parent;
  3394. private _target;
  3395. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3396. /** @hidden */
  3397. _prepare(): void;
  3398. execute(): void;
  3399. serialize(parent: any): any;
  3400. }
  3401. class PlaySoundAction extends Action {
  3402. private _sound;
  3403. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3404. /** @hidden */
  3405. _prepare(): void;
  3406. execute(): void;
  3407. serialize(parent: any): any;
  3408. }
  3409. class StopSoundAction extends Action {
  3410. private _sound;
  3411. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3412. /** @hidden */
  3413. _prepare(): void;
  3414. execute(): void;
  3415. serialize(parent: any): any;
  3416. }
  3417. }
  3418. declare module BABYLON {
  3419. class InterpolateValueAction extends Action {
  3420. propertyPath: string;
  3421. value: any;
  3422. duration: number;
  3423. stopOtherAnimations?: boolean | undefined;
  3424. onInterpolationDone?: (() => void) | undefined;
  3425. private _target;
  3426. private _effectiveTarget;
  3427. private _property;
  3428. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3430. /** @hidden */
  3431. _prepare(): void;
  3432. execute(): void;
  3433. serialize(parent: any): any;
  3434. }
  3435. }
  3436. declare module BABYLON {
  3437. /**
  3438. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3440. */
  3441. class Analyser {
  3442. /**
  3443. * Gets or sets the smoothing
  3444. * @ignorenaming
  3445. */
  3446. SMOOTHING: number;
  3447. /**
  3448. * Gets or sets the FFT table size
  3449. * @ignorenaming
  3450. */
  3451. FFT_SIZE: number;
  3452. /**
  3453. * Gets or sets the bar graph amplitude
  3454. * @ignorenaming
  3455. */
  3456. BARGRAPHAMPLITUDE: number;
  3457. /**
  3458. * Gets or sets the position of the debug canvas
  3459. * @ignorenaming
  3460. */
  3461. DEBUGCANVASPOS: {
  3462. x: number;
  3463. y: number;
  3464. };
  3465. /**
  3466. * Gets or sets the debug canvas size
  3467. * @ignorenaming
  3468. */
  3469. DEBUGCANVASSIZE: {
  3470. width: number;
  3471. height: number;
  3472. };
  3473. private _byteFreqs;
  3474. private _byteTime;
  3475. private _floatFreqs;
  3476. private _webAudioAnalyser;
  3477. private _debugCanvas;
  3478. private _debugCanvasContext;
  3479. private _scene;
  3480. private _registerFunc;
  3481. private _audioEngine;
  3482. /**
  3483. * Creates a new analyser
  3484. * @param scene defines hosting scene
  3485. */
  3486. constructor(scene: Scene);
  3487. /**
  3488. * Get the number of data values you will have to play with for the visualization
  3489. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3490. * @returns a number
  3491. */
  3492. getFrequencyBinCount(): number;
  3493. /**
  3494. * Gets the current frequency data as a byte array
  3495. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3496. * @returns a Uint8Array
  3497. */
  3498. getByteFrequencyData(): Uint8Array;
  3499. /**
  3500. * Gets the current waveform as a byte array
  3501. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3502. * @returns a Uint8Array
  3503. */
  3504. getByteTimeDomainData(): Uint8Array;
  3505. /**
  3506. * Gets the current frequency data as a float array
  3507. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3508. * @returns a Float32Array
  3509. */
  3510. getFloatFrequencyData(): Float32Array;
  3511. /**
  3512. * Renders the debug canvas
  3513. */
  3514. drawDebugCanvas(): void;
  3515. /**
  3516. * Stops rendering the debug canvas and removes it
  3517. */
  3518. stopDebugCanvas(): void;
  3519. /**
  3520. * Connects two audio nodes
  3521. * @param inputAudioNode defines first node to connect
  3522. * @param outputAudioNode defines second node to connect
  3523. */
  3524. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3525. /**
  3526. * Releases all associated resources
  3527. */
  3528. dispose(): void;
  3529. }
  3530. }
  3531. declare module BABYLON {
  3532. class AudioEngine {
  3533. private _audioContext;
  3534. private _audioContextInitialized;
  3535. canUseWebAudio: boolean;
  3536. masterGain: GainNode;
  3537. private _connectedAnalyser;
  3538. WarnedWebAudioUnsupported: boolean;
  3539. unlocked: boolean;
  3540. onAudioUnlocked: () => any;
  3541. isMP3supported: boolean;
  3542. isOGGsupported: boolean;
  3543. readonly audioContext: Nullable<AudioContext>;
  3544. constructor();
  3545. private _unlockiOSaudio;
  3546. private _initializeAudioContext;
  3547. dispose(): void;
  3548. getGlobalVolume(): number;
  3549. setGlobalVolume(newVolume: number): void;
  3550. connectToAnalyser(analyser: Analyser): void;
  3551. }
  3552. }
  3553. declare module BABYLON {
  3554. class Sound {
  3555. name: string;
  3556. autoplay: boolean;
  3557. loop: boolean;
  3558. useCustomAttenuation: boolean;
  3559. soundTrackId: number;
  3560. spatialSound: boolean;
  3561. refDistance: number;
  3562. rolloffFactor: number;
  3563. maxDistance: number;
  3564. distanceModel: string;
  3565. private _panningModel;
  3566. onended: () => any;
  3567. /**
  3568. * Observable event when the current playing sound finishes.
  3569. */
  3570. onEndedObservable: Observable<Sound>;
  3571. private _playbackRate;
  3572. private _streaming;
  3573. private _startTime;
  3574. private _startOffset;
  3575. private _position;
  3576. /** @hidden */
  3577. _positionInEmitterSpace: boolean;
  3578. private _localDirection;
  3579. private _volume;
  3580. private _isReadyToPlay;
  3581. isPlaying: boolean;
  3582. isPaused: boolean;
  3583. private _isDirectional;
  3584. private _readyToPlayCallback;
  3585. private _audioBuffer;
  3586. private _soundSource;
  3587. private _streamingSource;
  3588. private _soundPanner;
  3589. private _soundGain;
  3590. private _inputAudioNode;
  3591. private _outputAudioNode;
  3592. private _coneInnerAngle;
  3593. private _coneOuterAngle;
  3594. private _coneOuterGain;
  3595. private _scene;
  3596. private _connectedMesh;
  3597. private _customAttenuationFunction;
  3598. private _registerFunc;
  3599. private _isOutputConnected;
  3600. private _htmlAudioElement;
  3601. private _urlType;
  3602. /**
  3603. * Create a sound and attach it to a scene
  3604. * @param name Name of your sound
  3605. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  3606. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3607. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3608. */
  3609. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3610. dispose(): void;
  3611. isReady(): boolean;
  3612. private _soundLoaded;
  3613. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3614. updateOptions(options: any): void;
  3615. private _createSpatialParameters;
  3616. private _updateSpatialParameters;
  3617. switchPanningModelToHRTF(): void;
  3618. switchPanningModelToEqualPower(): void;
  3619. private _switchPanningModel;
  3620. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3621. /**
  3622. * Transform this sound into a directional source
  3623. * @param coneInnerAngle Size of the inner cone in degree
  3624. * @param coneOuterAngle Size of the outer cone in degree
  3625. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3626. */
  3627. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3628. /**
  3629. * Gets or sets the inner angle for the directional cone.
  3630. */
  3631. /**
  3632. * Gets or sets the inner angle for the directional cone.
  3633. */
  3634. directionalConeInnerAngle: number;
  3635. /**
  3636. * Gets or sets the outer angle for the directional cone.
  3637. */
  3638. /**
  3639. * Gets or sets the outer angle for the directional cone.
  3640. */
  3641. directionalConeOuterAngle: number;
  3642. setPosition(newPosition: Vector3): void;
  3643. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3644. private _updateDirection;
  3645. updateDistanceFromListener(): void;
  3646. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3647. /**
  3648. * Play the sound
  3649. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3650. * @param offset (optional) Start the sound setting it at a specific time
  3651. */
  3652. play(time?: number, offset?: number): void;
  3653. private _onended;
  3654. /**
  3655. * Stop the sound
  3656. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3657. */
  3658. stop(time?: number): void;
  3659. pause(): void;
  3660. setVolume(newVolume: number, time?: number): void;
  3661. setPlaybackRate(newPlaybackRate: number): void;
  3662. getVolume(): number;
  3663. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3664. detachFromMesh(): void;
  3665. private _onRegisterAfterWorldMatrixUpdate;
  3666. clone(): Nullable<Sound>;
  3667. getAudioBuffer(): AudioBuffer | null;
  3668. serialize(): any;
  3669. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3670. }
  3671. }
  3672. declare module BABYLON {
  3673. class SoundTrack {
  3674. private _outputAudioNode;
  3675. private _scene;
  3676. id: number;
  3677. soundCollection: Array<Sound>;
  3678. private _isMainTrack;
  3679. private _connectedAnalyser;
  3680. private _options;
  3681. private _isInitialized;
  3682. constructor(scene: Scene, options?: any);
  3683. private _initializeSoundTrackAudioGraph;
  3684. dispose(): void;
  3685. AddSound(sound: Sound): void;
  3686. RemoveSound(sound: Sound): void;
  3687. setVolume(newVolume: number): void;
  3688. switchPanningModelToHRTF(): void;
  3689. switchPanningModelToEqualPower(): void;
  3690. connectToAnalyser(analyser: Analyser): void;
  3691. }
  3692. }
  3693. declare module BABYLON {
  3694. /**
  3695. * Wraps one or more Sound objects and selects one with random weight for playback.
  3696. */
  3697. class WeightedSound {
  3698. /** When true a Sound will be selected and played when the current playing Sound completes. */
  3699. loop: boolean;
  3700. private _coneInnerAngle;
  3701. private _coneOuterAngle;
  3702. private _volume;
  3703. /** A Sound is currently playing. */
  3704. isPlaying: boolean;
  3705. /** A Sound is currently paused. */
  3706. isPaused: boolean;
  3707. private _sounds;
  3708. private _weights;
  3709. private _currentIndex?;
  3710. /**
  3711. * Creates a new WeightedSound from the list of sounds given.
  3712. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  3713. * @param sounds Array of Sounds that will be selected from.
  3714. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  3715. */
  3716. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  3717. /**
  3718. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  3719. */
  3720. /**
  3721. * The size of cone in degress for a directional sound in which there will be no attenuation.
  3722. */
  3723. directionalConeInnerAngle: number;
  3724. /**
  3725. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  3726. * Listener angles between innerAngle and outerAngle will falloff linearly.
  3727. */
  3728. /**
  3729. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  3730. * Listener angles between innerAngle and outerAngle will falloff linearly.
  3731. */
  3732. directionalConeOuterAngle: number;
  3733. /**
  3734. * Playback volume.
  3735. */
  3736. /**
  3737. * Playback volume.
  3738. */
  3739. volume: number;
  3740. private _onended;
  3741. /**
  3742. * Suspend playback
  3743. */
  3744. pause(): void;
  3745. /**
  3746. * Stop playback
  3747. */
  3748. stop(): void;
  3749. /**
  3750. * Start playback.
  3751. * @param startOffset Position the clip head at a specific time in seconds.
  3752. */
  3753. play(startOffset?: number): void;
  3754. }
  3755. }
  3756. declare module BABYLON {
  3757. /**
  3758. * Class used to store an actual running animation
  3759. */
  3760. class Animatable {
  3761. /** defines the target object */
  3762. target: any;
  3763. /** defines the starting frame number (default is 0) */
  3764. fromFrame: number;
  3765. /** defines the ending frame number (default is 100) */
  3766. toFrame: number;
  3767. /** defines if the animation must loop (default is false) */
  3768. loopAnimation: boolean;
  3769. /** defines a callback to call when animation ends if it is not looping */
  3770. onAnimationEnd?: (() => void) | null | undefined;
  3771. private _localDelayOffset;
  3772. private _pausedDelay;
  3773. private _runtimeAnimations;
  3774. private _paused;
  3775. private _scene;
  3776. private _speedRatio;
  3777. private _weight;
  3778. private _syncRoot;
  3779. /**
  3780. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3781. * This will only apply for non looping animation (default is true)
  3782. */
  3783. disposeOnEnd: boolean;
  3784. /**
  3785. * Gets a boolean indicating if the animation has started
  3786. */
  3787. animationStarted: boolean;
  3788. /**
  3789. * Observer raised when the animation ends
  3790. */
  3791. onAnimationEndObservable: Observable<Animatable>;
  3792. /**
  3793. * Gets the root Animatable used to synchronize and normalize animations
  3794. */
  3795. readonly syncRoot: Animatable;
  3796. /**
  3797. * Gets the current frame of the first RuntimeAnimation
  3798. * Used to synchronize Animatables
  3799. */
  3800. readonly masterFrame: number;
  3801. /**
  3802. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3803. */
  3804. weight: number;
  3805. /**
  3806. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3807. */
  3808. speedRatio: number;
  3809. /**
  3810. * Creates a new Animatable
  3811. * @param scene defines the hosting scene
  3812. * @param target defines the target object
  3813. * @param fromFrame defines the starting frame number (default is 0)
  3814. * @param toFrame defines the ending frame number (default is 100)
  3815. * @param loopAnimation defines if the animation must loop (default is false)
  3816. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3817. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3818. * @param animations defines a group of animation to add to the new Animatable
  3819. */
  3820. constructor(scene: Scene,
  3821. /** defines the target object */
  3822. target: any,
  3823. /** defines the starting frame number (default is 0) */
  3824. fromFrame?: number,
  3825. /** defines the ending frame number (default is 100) */
  3826. toFrame?: number,
  3827. /** defines if the animation must loop (default is false) */
  3828. loopAnimation?: boolean, speedRatio?: number,
  3829. /** defines a callback to call when animation ends if it is not looping */
  3830. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3831. /**
  3832. * Synchronize and normalize current Animatable with a source Animatable
  3833. * This is useful when using animation weights and when animations are not of the same length
  3834. * @param root defines the root Animatable to synchronize with
  3835. * @returns the current Animatable
  3836. */
  3837. syncWith(root: Animatable): Animatable;
  3838. /**
  3839. * Gets the list of runtime animations
  3840. * @returns an array of RuntimeAnimation
  3841. */
  3842. getAnimations(): RuntimeAnimation[];
  3843. /**
  3844. * Adds more animations to the current animatable
  3845. * @param target defines the target of the animations
  3846. * @param animations defines the new animations to add
  3847. */
  3848. appendAnimations(target: any, animations: Animation[]): void;
  3849. /**
  3850. * Gets the source animation for a specific property
  3851. * @param property defines the propertyu to look for
  3852. * @returns null or the source animation for the given property
  3853. */
  3854. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3855. /**
  3856. * Gets the runtime animation for a specific property
  3857. * @param property defines the propertyu to look for
  3858. * @returns null or the runtime animation for the given property
  3859. */
  3860. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3861. /**
  3862. * Resets the animatable to its original state
  3863. */
  3864. reset(): void;
  3865. /**
  3866. * Allows the animatable to blend with current running animations
  3867. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3868. * @param blendingSpeed defines the blending speed to use
  3869. */
  3870. enableBlending(blendingSpeed: number): void;
  3871. /**
  3872. * Disable animation blending
  3873. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3874. */
  3875. disableBlending(): void;
  3876. /**
  3877. * Jump directly to a given frame
  3878. * @param frame defines the frame to jump to
  3879. */
  3880. goToFrame(frame: number): void;
  3881. /**
  3882. * Pause the animation
  3883. */
  3884. pause(): void;
  3885. /**
  3886. * Restart the animation
  3887. */
  3888. restart(): void;
  3889. private _raiseOnAnimationEnd;
  3890. /**
  3891. * Stop and delete the current animation
  3892. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3893. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3894. */
  3895. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3896. /**
  3897. * Wait asynchronously for the animation to end
  3898. * @returns a promise which will be fullfilled when the animation ends
  3899. */
  3900. waitAsync(): Promise<Animatable>;
  3901. /** @hidden */
  3902. _animate(delay: number): boolean;
  3903. }
  3904. }
  3905. declare module BABYLON {
  3906. /**
  3907. * Represents the range of an animation
  3908. */
  3909. class AnimationRange {
  3910. /**The name of the animation range**/
  3911. name: string;
  3912. /**The starting frame of the animation */
  3913. from: number;
  3914. /**The ending frame of the animation*/
  3915. to: number;
  3916. /**
  3917. * Initializes the range of an animation
  3918. * @param name The name of the animation range
  3919. * @param from The starting frame of the animation
  3920. * @param to The ending frame of the animation
  3921. */
  3922. constructor(
  3923. /**The name of the animation range**/
  3924. name: string,
  3925. /**The starting frame of the animation */
  3926. from: number,
  3927. /**The ending frame of the animation*/
  3928. to: number);
  3929. /**
  3930. * Makes a copy of the animation range
  3931. * @returns A copy of the animation range
  3932. */
  3933. clone(): AnimationRange;
  3934. }
  3935. /**
  3936. * Composed of a frame, and an action function
  3937. */
  3938. class AnimationEvent {
  3939. /** The frame for which the event is triggered **/
  3940. frame: number;
  3941. /** The event to perform when triggered **/
  3942. action: (currentFrame: number) => void;
  3943. /** Specifies if the event should be triggered only once**/
  3944. onlyOnce?: boolean | undefined;
  3945. /**
  3946. * Specifies if the animation event is done
  3947. */
  3948. isDone: boolean;
  3949. /**
  3950. * Initializes the animation event
  3951. * @param frame The frame for which the event is triggered
  3952. * @param action The event to perform when triggered
  3953. * @param onlyOnce Specifies if the event should be triggered only once
  3954. */
  3955. constructor(
  3956. /** The frame for which the event is triggered **/
  3957. frame: number,
  3958. /** The event to perform when triggered **/
  3959. action: (currentFrame: number) => void,
  3960. /** Specifies if the event should be triggered only once**/
  3961. onlyOnce?: boolean | undefined);
  3962. /** @hidden */
  3963. _clone(): AnimationEvent;
  3964. }
  3965. /**
  3966. * A cursor which tracks a point on a path
  3967. */
  3968. class PathCursor {
  3969. private path;
  3970. /**
  3971. * Stores path cursor callbacks for when an onchange event is triggered
  3972. */
  3973. private _onchange;
  3974. /**
  3975. * The value of the path cursor
  3976. */
  3977. value: number;
  3978. /**
  3979. * The animation array of the path cursor
  3980. */
  3981. animations: Animation[];
  3982. /**
  3983. * Initializes the path cursor
  3984. * @param path The path to track
  3985. */
  3986. constructor(path: Path2);
  3987. /**
  3988. * Gets the cursor point on the path
  3989. * @returns A point on the path cursor at the cursor location
  3990. */
  3991. getPoint(): Vector3;
  3992. /**
  3993. * Moves the cursor ahead by the step amount
  3994. * @param step The amount to move the cursor forward
  3995. * @returns This path cursor
  3996. */
  3997. moveAhead(step?: number): PathCursor;
  3998. /**
  3999. * Moves the cursor behind by the step amount
  4000. * @param step The amount to move the cursor back
  4001. * @returns This path cursor
  4002. */
  4003. moveBack(step?: number): PathCursor;
  4004. /**
  4005. * Moves the cursor by the step amount
  4006. * If the step amount is greater than one, an exception is thrown
  4007. * @param step The amount to move the cursor
  4008. * @returns This path cursor
  4009. */
  4010. move(step: number): PathCursor;
  4011. /**
  4012. * Ensures that the value is limited between zero and one
  4013. * @returns This path cursor
  4014. */
  4015. private ensureLimits;
  4016. /**
  4017. * Runs onchange callbacks on change (used by the animation engine)
  4018. * @returns This path cursor
  4019. */
  4020. private raiseOnChange;
  4021. /**
  4022. * Executes a function on change
  4023. * @param f A path cursor onchange callback
  4024. * @returns This path cursor
  4025. */
  4026. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4027. }
  4028. /**
  4029. * Defines an interface which represents an animation key frame
  4030. */
  4031. interface IAnimationKey {
  4032. /**
  4033. * Frame of the key frame
  4034. */
  4035. frame: number;
  4036. /**
  4037. * Value at the specifies key frame
  4038. */
  4039. value: any;
  4040. /**
  4041. * The input tangent for the cubic hermite spline
  4042. */
  4043. inTangent?: any;
  4044. /**
  4045. * The output tangent for the cubic hermite spline
  4046. */
  4047. outTangent?: any;
  4048. /**
  4049. * The animation interpolation type
  4050. */
  4051. interpolation?: AnimationKeyInterpolation;
  4052. }
  4053. /**
  4054. * Enum for the animation key frame interpolation type
  4055. */
  4056. enum AnimationKeyInterpolation {
  4057. /**
  4058. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4059. */
  4060. STEP = 1
  4061. }
  4062. /**
  4063. * Class used to store any kind of animation
  4064. */
  4065. class Animation {
  4066. /**Name of the animation */
  4067. name: string;
  4068. /**Property to animate */
  4069. targetProperty: string;
  4070. /**The frames per second of the animation */
  4071. framePerSecond: number;
  4072. /**The data type of the animation */
  4073. dataType: number;
  4074. /**The loop mode of the animation */
  4075. loopMode?: number | undefined;
  4076. /**Specifies if blending should be enabled */
  4077. enableBlending?: boolean | undefined;
  4078. /**
  4079. * Use matrix interpolation instead of using direct key value when animating matrices
  4080. */
  4081. static AllowMatricesInterpolation: boolean;
  4082. /**
  4083. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4084. */
  4085. static AllowMatrixDecomposeForInterpolation: boolean;
  4086. /**
  4087. * Stores the key frames of the animation
  4088. */
  4089. private _keys;
  4090. /**
  4091. * Stores the easing function of the animation
  4092. */
  4093. private _easingFunction;
  4094. /**
  4095. * @hidden Internal use only
  4096. */
  4097. _runtimeAnimations: RuntimeAnimation[];
  4098. /**
  4099. * The set of event that will be linked to this animation
  4100. */
  4101. private _events;
  4102. /**
  4103. * Stores an array of target property paths
  4104. */
  4105. targetPropertyPath: string[];
  4106. /**
  4107. * Stores the blending speed of the animation
  4108. */
  4109. blendingSpeed: number;
  4110. /**
  4111. * Stores the animation ranges for the animation
  4112. */
  4113. private _ranges;
  4114. /**
  4115. * @hidden Internal use
  4116. */
  4117. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4118. /**
  4119. * Sets up an animation
  4120. * @param property The property to animate
  4121. * @param animationType The animation type to apply
  4122. * @param framePerSecond The frames per second of the animation
  4123. * @param easingFunction The easing function used in the animation
  4124. * @returns The created animation
  4125. */
  4126. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4127. /**
  4128. * Create and start an animation on a node
  4129. * @param name defines the name of the global animation that will be run on all nodes
  4130. * @param node defines the root node where the animation will take place
  4131. * @param targetProperty defines property to animate
  4132. * @param framePerSecond defines the number of frame per second yo use
  4133. * @param totalFrame defines the number of frames in total
  4134. * @param from defines the initial value
  4135. * @param to defines the final value
  4136. * @param loopMode defines which loop mode you want to use (off by default)
  4137. * @param easingFunction defines the easing function to use (linear by default)
  4138. * @param onAnimationEnd defines the callback to call when animation end
  4139. * @returns the animatable created for this animation
  4140. */
  4141. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4142. /**
  4143. * Create and start an animation on a node and its descendants
  4144. * @param name defines the name of the global animation that will be run on all nodes
  4145. * @param node defines the root node where the animation will take place
  4146. * @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
  4147. * @param targetProperty defines property to animate
  4148. * @param framePerSecond defines the number of frame per second to use
  4149. * @param totalFrame defines the number of frames in total
  4150. * @param from defines the initial value
  4151. * @param to defines the final value
  4152. * @param loopMode defines which loop mode you want to use (off by default)
  4153. * @param easingFunction defines the easing function to use (linear by default)
  4154. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4155. * @returns the list of animatables created for all nodes
  4156. * @example https://www.babylonjs-playground.com/#MH0VLI
  4157. */
  4158. 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[]>;
  4159. /**
  4160. * Creates a new animation, merges it with the existing animations and starts it
  4161. * @param name Name of the animation
  4162. * @param node Node which contains the scene that begins the animations
  4163. * @param targetProperty Specifies which property to animate
  4164. * @param framePerSecond The frames per second of the animation
  4165. * @param totalFrame The total number of frames
  4166. * @param from The frame at the beginning of the animation
  4167. * @param to The frame at the end of the animation
  4168. * @param loopMode Specifies the loop mode of the animation
  4169. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4170. * @param onAnimationEnd Callback to run once the animation is complete
  4171. * @returns Nullable animation
  4172. */
  4173. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4174. /**
  4175. * Transition property of an host to the target Value
  4176. * @param property The property to transition
  4177. * @param targetValue The target Value of the property
  4178. * @param host The object where the property to animate belongs
  4179. * @param scene Scene used to run the animation
  4180. * @param frameRate Framerate (in frame/s) to use
  4181. * @param transition The transition type we want to use
  4182. * @param duration The duration of the animation, in milliseconds
  4183. * @param onAnimationEnd Callback trigger at the end of the animation
  4184. * @returns Nullable animation
  4185. */
  4186. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4187. /**
  4188. * Return the array of runtime animations currently using this animation
  4189. */
  4190. readonly runtimeAnimations: RuntimeAnimation[];
  4191. /**
  4192. * Specifies if any of the runtime animations are currently running
  4193. */
  4194. readonly hasRunningRuntimeAnimations: boolean;
  4195. /**
  4196. * Initializes the animation
  4197. * @param name Name of the animation
  4198. * @param targetProperty Property to animate
  4199. * @param framePerSecond The frames per second of the animation
  4200. * @param dataType The data type of the animation
  4201. * @param loopMode The loop mode of the animation
  4202. * @param enableBlendings Specifies if blending should be enabled
  4203. */
  4204. constructor(
  4205. /**Name of the animation */
  4206. name: string,
  4207. /**Property to animate */
  4208. targetProperty: string,
  4209. /**The frames per second of the animation */
  4210. framePerSecond: number,
  4211. /**The data type of the animation */
  4212. dataType: number,
  4213. /**The loop mode of the animation */
  4214. loopMode?: number | undefined,
  4215. /**Specifies if blending should be enabled */
  4216. enableBlending?: boolean | undefined);
  4217. /**
  4218. * Converts the animation to a string
  4219. * @param fullDetails support for multiple levels of logging within scene loading
  4220. * @returns String form of the animation
  4221. */
  4222. toString(fullDetails?: boolean): string;
  4223. /**
  4224. * Add an event to this animation
  4225. * @param event Event to add
  4226. */
  4227. addEvent(event: AnimationEvent): void;
  4228. /**
  4229. * Remove all events found at the given frame
  4230. * @param frame The frame to remove events from
  4231. */
  4232. removeEvents(frame: number): void;
  4233. /**
  4234. * Retrieves all the events from the animation
  4235. * @returns Events from the animation
  4236. */
  4237. getEvents(): AnimationEvent[];
  4238. /**
  4239. * Creates an animation range
  4240. * @param name Name of the animation range
  4241. * @param from Starting frame of the animation range
  4242. * @param to Ending frame of the animation
  4243. */
  4244. createRange(name: string, from: number, to: number): void;
  4245. /**
  4246. * Deletes an animation range by name
  4247. * @param name Name of the animation range to delete
  4248. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4249. */
  4250. deleteRange(name: string, deleteFrames?: boolean): void;
  4251. /**
  4252. * Gets the animation range by name, or null if not defined
  4253. * @param name Name of the animation range
  4254. * @returns Nullable animation range
  4255. */
  4256. getRange(name: string): Nullable<AnimationRange>;
  4257. /**
  4258. * Gets the key frames from the animation
  4259. * @returns The key frames of the animation
  4260. */
  4261. getKeys(): Array<IAnimationKey>;
  4262. /**
  4263. * Gets the highest frame rate of the animation
  4264. * @returns Highest frame rate of the animation
  4265. */
  4266. getHighestFrame(): number;
  4267. /**
  4268. * Gets the easing function of the animation
  4269. * @returns Easing function of the animation
  4270. */
  4271. getEasingFunction(): IEasingFunction;
  4272. /**
  4273. * Sets the easing function of the animation
  4274. * @param easingFunction A custom mathematical formula for animation
  4275. */
  4276. setEasingFunction(easingFunction: EasingFunction): void;
  4277. /**
  4278. * Interpolates a scalar linearly
  4279. * @param startValue Start value of the animation curve
  4280. * @param endValue End value of the animation curve
  4281. * @param gradient Scalar amount to interpolate
  4282. * @returns Interpolated scalar value
  4283. */
  4284. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4285. /**
  4286. * Interpolates a scalar cubically
  4287. * @param startValue Start value of the animation curve
  4288. * @param outTangent End tangent of the animation
  4289. * @param endValue End value of the animation curve
  4290. * @param inTangent Start tangent of the animation curve
  4291. * @param gradient Scalar amount to interpolate
  4292. * @returns Interpolated scalar value
  4293. */
  4294. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4295. /**
  4296. * Interpolates a quaternion using a spherical linear interpolation
  4297. * @param startValue Start value of the animation curve
  4298. * @param endValue End value of the animation curve
  4299. * @param gradient Scalar amount to interpolate
  4300. * @returns Interpolated quaternion value
  4301. */
  4302. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4303. /**
  4304. * Interpolates a quaternion cubically
  4305. * @param startValue Start value of the animation curve
  4306. * @param outTangent End tangent of the animation curve
  4307. * @param endValue End value of the animation curve
  4308. * @param inTangent Start tangent of the animation curve
  4309. * @param gradient Scalar amount to interpolate
  4310. * @returns Interpolated quaternion value
  4311. */
  4312. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4313. /**
  4314. * Interpolates a Vector3 linearl
  4315. * @param startValue Start value of the animation curve
  4316. * @param endValue End value of the animation curve
  4317. * @param gradient Scalar amount to interpolate
  4318. * @returns Interpolated scalar value
  4319. */
  4320. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4321. /**
  4322. * Interpolates a Vector3 cubically
  4323. * @param startValue Start value of the animation curve
  4324. * @param outTangent End tangent of the animation
  4325. * @param endValue End value of the animation curve
  4326. * @param inTangent Start tangent of the animation curve
  4327. * @param gradient Scalar amount to interpolate
  4328. * @returns InterpolatedVector3 value
  4329. */
  4330. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4331. /**
  4332. * Interpolates a Vector2 linearly
  4333. * @param startValue Start value of the animation curve
  4334. * @param endValue End value of the animation curve
  4335. * @param gradient Scalar amount to interpolate
  4336. * @returns Interpolated Vector2 value
  4337. */
  4338. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4339. /**
  4340. * Interpolates a Vector2 cubically
  4341. * @param startValue Start value of the animation curve
  4342. * @param outTangent End tangent of the animation
  4343. * @param endValue End value of the animation curve
  4344. * @param inTangent Start tangent of the animation curve
  4345. * @param gradient Scalar amount to interpolate
  4346. * @returns Interpolated Vector2 value
  4347. */
  4348. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4349. /**
  4350. * Interpolates a size linearly
  4351. * @param startValue Start value of the animation curve
  4352. * @param endValue End value of the animation curve
  4353. * @param gradient Scalar amount to interpolate
  4354. * @returns Interpolated Size value
  4355. */
  4356. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4357. /**
  4358. * Interpolates a Color3 linearly
  4359. * @param startValue Start value of the animation curve
  4360. * @param endValue End value of the animation curve
  4361. * @param gradient Scalar amount to interpolate
  4362. * @returns Interpolated Color3 value
  4363. */
  4364. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4365. /**
  4366. * @hidden Internal use only
  4367. */
  4368. _getKeyValue(value: any): any;
  4369. /**
  4370. * @hidden Internal use only
  4371. */
  4372. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4373. /**
  4374. * Defines the function to use to interpolate matrices
  4375. * @param startValue defines the start matrix
  4376. * @param endValue defines the end matrix
  4377. * @param gradient defines the gradient between both matrices
  4378. * @param result defines an optional target matrix where to store the interpolation
  4379. * @returns the interpolated matrix
  4380. */
  4381. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4382. /**
  4383. * Makes a copy of the animation
  4384. * @returns Cloned animation
  4385. */
  4386. clone(): Animation;
  4387. /**
  4388. * Sets the key frames of the animation
  4389. * @param values The animation key frames to set
  4390. */
  4391. setKeys(values: Array<IAnimationKey>): void;
  4392. /**
  4393. * Serializes the animation to an object
  4394. * @returns Serialized object
  4395. */
  4396. serialize(): any;
  4397. /**
  4398. * Float animation type
  4399. */
  4400. private static _ANIMATIONTYPE_FLOAT;
  4401. /**
  4402. * Vector3 animation type
  4403. */
  4404. private static _ANIMATIONTYPE_VECTOR3;
  4405. /**
  4406. * Quaternion animation type
  4407. */
  4408. private static _ANIMATIONTYPE_QUATERNION;
  4409. /**
  4410. * Matrix animation type
  4411. */
  4412. private static _ANIMATIONTYPE_MATRIX;
  4413. /**
  4414. * Color3 animation type
  4415. */
  4416. private static _ANIMATIONTYPE_COLOR3;
  4417. /**
  4418. * Vector2 animation type
  4419. */
  4420. private static _ANIMATIONTYPE_VECTOR2;
  4421. /**
  4422. * Size animation type
  4423. */
  4424. private static _ANIMATIONTYPE_SIZE;
  4425. /**
  4426. * Relative Loop Mode
  4427. */
  4428. private static _ANIMATIONLOOPMODE_RELATIVE;
  4429. /**
  4430. * Cycle Loop Mode
  4431. */
  4432. private static _ANIMATIONLOOPMODE_CYCLE;
  4433. /**
  4434. * Constant Loop Mode
  4435. */
  4436. private static _ANIMATIONLOOPMODE_CONSTANT;
  4437. /**
  4438. * Get the float animation type
  4439. */
  4440. static readonly ANIMATIONTYPE_FLOAT: number;
  4441. /**
  4442. * Get the Vector3 animation type
  4443. */
  4444. static readonly ANIMATIONTYPE_VECTOR3: number;
  4445. /**
  4446. * Get the Vector2 animation type
  4447. */
  4448. static readonly ANIMATIONTYPE_VECTOR2: number;
  4449. /**
  4450. * Get the Size animation type
  4451. */
  4452. static readonly ANIMATIONTYPE_SIZE: number;
  4453. /**
  4454. * Get the Quaternion animation type
  4455. */
  4456. static readonly ANIMATIONTYPE_QUATERNION: number;
  4457. /**
  4458. * Get the Matrix animation type
  4459. */
  4460. static readonly ANIMATIONTYPE_MATRIX: number;
  4461. /**
  4462. * Get the Color3 animation type
  4463. */
  4464. static readonly ANIMATIONTYPE_COLOR3: number;
  4465. /**
  4466. * Get the Relative Loop Mode
  4467. */
  4468. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4469. /**
  4470. * Get the Cycle Loop Mode
  4471. */
  4472. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4473. /**
  4474. * Get the Constant Loop Mode
  4475. */
  4476. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4477. /** @hidden */
  4478. static _UniversalLerp(left: any, right: any, amount: number): any;
  4479. /**
  4480. * Parses an animation object and creates an animation
  4481. * @param parsedAnimation Parsed animation object
  4482. * @returns Animation object
  4483. */
  4484. static Parse(parsedAnimation: any): Animation;
  4485. /**
  4486. * Appends the serialized animations from the source animations
  4487. * @param source Source containing the animations
  4488. * @param destination Target to store the animations
  4489. */
  4490. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4491. }
  4492. }
  4493. declare module BABYLON {
  4494. /**
  4495. * This class defines the direct association between an animation and a target
  4496. */
  4497. class TargetedAnimation {
  4498. animation: Animation;
  4499. target: any;
  4500. }
  4501. /**
  4502. * Use this class to create coordinated animations on multiple targets
  4503. */
  4504. class AnimationGroup implements IDisposable {
  4505. name: string;
  4506. private _scene;
  4507. private _targetedAnimations;
  4508. private _animatables;
  4509. private _from;
  4510. private _to;
  4511. private _isStarted;
  4512. private _speedRatio;
  4513. onAnimationEndObservable: Observable<TargetedAnimation>;
  4514. /**
  4515. * This observable will notify when all animations have ended.
  4516. */
  4517. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4518. /**
  4519. * This observable will notify when all animations have paused.
  4520. */
  4521. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4522. /**
  4523. * Gets the first frame
  4524. */
  4525. readonly from: number;
  4526. /**
  4527. * Gets the last frame
  4528. */
  4529. readonly to: number;
  4530. /**
  4531. * Define if the animations are started
  4532. */
  4533. readonly isStarted: boolean;
  4534. /**
  4535. * Gets or sets the speed ratio to use for all animations
  4536. */
  4537. /**
  4538. * Gets or sets the speed ratio to use for all animations
  4539. */
  4540. speedRatio: number;
  4541. /**
  4542. * Gets the targeted animations for this animation group
  4543. */
  4544. readonly targetedAnimations: Array<TargetedAnimation>;
  4545. /**
  4546. * returning the list of animatables controlled by this animation group.
  4547. */
  4548. readonly animatables: Array<Animatable>;
  4549. constructor(name: string, scene?: Nullable<Scene>);
  4550. /**
  4551. * Add an animation (with its target) in the group
  4552. * @param animation defines the animation we want to add
  4553. * @param target defines the target of the animation
  4554. * @returns the {BABYLON.TargetedAnimation} object
  4555. */
  4556. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4557. /**
  4558. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4559. * It can add constant keys at begin or end
  4560. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4561. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4562. */
  4563. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4564. /**
  4565. * Start all animations on given targets
  4566. * @param loop defines if animations must loop
  4567. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4568. * @param from defines the from key (optional)
  4569. * @param to defines the to key (optional)
  4570. * @returns the current animation group
  4571. */
  4572. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4573. /**
  4574. * Pause all animations
  4575. */
  4576. pause(): AnimationGroup;
  4577. /**
  4578. * Play all animations to initial state
  4579. * This function will start() the animations if they were not started or will restart() them if they were paused
  4580. * @param loop defines if animations must loop
  4581. */
  4582. play(loop?: boolean): AnimationGroup;
  4583. /**
  4584. * Reset all animations to initial state
  4585. */
  4586. reset(): AnimationGroup;
  4587. /**
  4588. * Restart animations from key 0
  4589. */
  4590. restart(): AnimationGroup;
  4591. /**
  4592. * Stop all animations
  4593. */
  4594. stop(): AnimationGroup;
  4595. /**
  4596. * Set animation weight for all animatables
  4597. * @param weight defines the weight to use
  4598. * @return the animationGroup
  4599. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4600. */
  4601. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4602. /**
  4603. * Synchronize and normalize all animatables with a source animatable
  4604. * @param root defines the root animatable to synchronize with
  4605. * @return the animationGroup
  4606. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4607. */
  4608. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4609. /**
  4610. * Goes to a specific frame in this animation group
  4611. * @param frame the frame number to go to
  4612. * @return the animationGroup
  4613. */
  4614. goToFrame(frame: number): AnimationGroup;
  4615. /**
  4616. * Dispose all associated resources
  4617. */
  4618. dispose(): void;
  4619. private _checkAnimationGroupEnded;
  4620. }
  4621. }
  4622. declare module BABYLON {
  4623. /**
  4624. * Class used to override all child animations of a given target
  4625. */
  4626. class AnimationPropertiesOverride {
  4627. /**
  4628. * Gets or sets a value indicating if animation blending must be used
  4629. */
  4630. enableBlending: boolean;
  4631. /**
  4632. * Gets or sets the blending speed to use when enableBlending is true
  4633. */
  4634. blendingSpeed: number;
  4635. /**
  4636. * Gets or sets the default loop mode to use
  4637. */
  4638. loopMode: number;
  4639. }
  4640. }
  4641. declare module BABYLON {
  4642. interface IEasingFunction {
  4643. ease(gradient: number): number;
  4644. }
  4645. class EasingFunction implements IEasingFunction {
  4646. private static _EASINGMODE_EASEIN;
  4647. private static _EASINGMODE_EASEOUT;
  4648. private static _EASINGMODE_EASEINOUT;
  4649. static readonly EASINGMODE_EASEIN: number;
  4650. static readonly EASINGMODE_EASEOUT: number;
  4651. static readonly EASINGMODE_EASEINOUT: number;
  4652. private _easingMode;
  4653. setEasingMode(easingMode: number): void;
  4654. getEasingMode(): number;
  4655. easeInCore(gradient: number): number;
  4656. ease(gradient: number): number;
  4657. }
  4658. class CircleEase extends EasingFunction implements IEasingFunction {
  4659. easeInCore(gradient: number): number;
  4660. }
  4661. class BackEase extends EasingFunction implements IEasingFunction {
  4662. amplitude: number;
  4663. constructor(amplitude?: number);
  4664. easeInCore(gradient: number): number;
  4665. }
  4666. class BounceEase extends EasingFunction implements IEasingFunction {
  4667. bounces: number;
  4668. bounciness: number;
  4669. constructor(bounces?: number, bounciness?: number);
  4670. easeInCore(gradient: number): number;
  4671. }
  4672. class CubicEase extends EasingFunction implements IEasingFunction {
  4673. easeInCore(gradient: number): number;
  4674. }
  4675. class ElasticEase extends EasingFunction implements IEasingFunction {
  4676. oscillations: number;
  4677. springiness: number;
  4678. constructor(oscillations?: number, springiness?: number);
  4679. easeInCore(gradient: number): number;
  4680. }
  4681. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4682. exponent: number;
  4683. constructor(exponent?: number);
  4684. easeInCore(gradient: number): number;
  4685. }
  4686. class PowerEase extends EasingFunction implements IEasingFunction {
  4687. power: number;
  4688. constructor(power?: number);
  4689. easeInCore(gradient: number): number;
  4690. }
  4691. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4692. easeInCore(gradient: number): number;
  4693. }
  4694. class QuarticEase extends EasingFunction implements IEasingFunction {
  4695. easeInCore(gradient: number): number;
  4696. }
  4697. class QuinticEase extends EasingFunction implements IEasingFunction {
  4698. easeInCore(gradient: number): number;
  4699. }
  4700. class SineEase extends EasingFunction implements IEasingFunction {
  4701. easeInCore(gradient: number): number;
  4702. }
  4703. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4704. x1: number;
  4705. y1: number;
  4706. x2: number;
  4707. y2: number;
  4708. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4709. easeInCore(gradient: number): number;
  4710. }
  4711. }
  4712. declare module BABYLON {
  4713. /**
  4714. * Defines a runtime animation
  4715. */
  4716. class RuntimeAnimation {
  4717. private _events;
  4718. /**
  4719. * The current frame of the runtime animation
  4720. */
  4721. private _currentFrame;
  4722. /**
  4723. * The animation used by the runtime animation
  4724. */
  4725. private _animation;
  4726. /**
  4727. * The target of the runtime animation
  4728. */
  4729. private _target;
  4730. /**
  4731. * The initiating animatable
  4732. */
  4733. private _host;
  4734. /**
  4735. * The original value of the runtime animation
  4736. */
  4737. private _originalValue;
  4738. /**
  4739. * The original blend value of the runtime animation
  4740. */
  4741. private _originalBlendValue;
  4742. /**
  4743. * The offsets cache of the runtime animation
  4744. */
  4745. private _offsetsCache;
  4746. /**
  4747. * The high limits cache of the runtime animation
  4748. */
  4749. private _highLimitsCache;
  4750. /**
  4751. * Specifies if the runtime animation has been stopped
  4752. */
  4753. private _stopped;
  4754. /**
  4755. * The blending factor of the runtime animation
  4756. */
  4757. private _blendingFactor;
  4758. /**
  4759. * The BabylonJS scene
  4760. */
  4761. private _scene;
  4762. /**
  4763. * The current value of the runtime animation
  4764. */
  4765. private _currentValue;
  4766. /** @hidden */
  4767. _workValue: any;
  4768. /**
  4769. * The active target of the runtime animation
  4770. */
  4771. private _activeTarget;
  4772. /**
  4773. * The target path of the runtime animation
  4774. */
  4775. private _targetPath;
  4776. /**
  4777. * The weight of the runtime animation
  4778. */
  4779. private _weight;
  4780. /**
  4781. * The ratio offset of the runtime animation
  4782. */
  4783. private _ratioOffset;
  4784. /**
  4785. * The previous delay of the runtime animation
  4786. */
  4787. private _previousDelay;
  4788. /**
  4789. * The previous ratio of the runtime animation
  4790. */
  4791. private _previousRatio;
  4792. /**
  4793. * Gets the current frame of the runtime animation
  4794. */
  4795. readonly currentFrame: number;
  4796. /**
  4797. * Gets the weight of the runtime animation
  4798. */
  4799. readonly weight: number;
  4800. /**
  4801. * Gets the current value of the runtime animation
  4802. */
  4803. readonly currentValue: any;
  4804. /**
  4805. * Gets the target path of the runtime animation
  4806. */
  4807. readonly targetPath: string;
  4808. /**
  4809. * Gets the actual target of the runtime animation
  4810. */
  4811. readonly target: any;
  4812. /**
  4813. * Create a new RuntimeAnimation object
  4814. * @param target defines the target of the animation
  4815. * @param animation defines the source animation object
  4816. * @param scene defines the hosting scene
  4817. * @param host defines the initiating Animatable
  4818. */
  4819. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4820. /**
  4821. * Gets the animation from the runtime animation
  4822. */
  4823. readonly animation: Animation;
  4824. /**
  4825. * Resets the runtime animation to the beginning
  4826. * @param restoreOriginal defines whether to restore the target property to the original value
  4827. */
  4828. reset(restoreOriginal?: boolean): void;
  4829. /**
  4830. * Specifies if the runtime animation is stopped
  4831. * @returns Boolean specifying if the runtime animation is stopped
  4832. */
  4833. isStopped(): boolean;
  4834. /**
  4835. * Disposes of the runtime animation
  4836. */
  4837. dispose(): void;
  4838. /**
  4839. * Interpolates the animation from the current frame
  4840. * @param currentFrame The frame to interpolate the animation to
  4841. * @param repeatCount The number of times that the animation should loop
  4842. * @param loopMode The type of looping mode to use
  4843. * @param offsetValue Animation offset value
  4844. * @param highLimitValue The high limit value
  4845. * @returns The interpolated value
  4846. */
  4847. private _interpolate;
  4848. /**
  4849. * Apply the interpolated value to the target
  4850. * @param currentValue defines the value computed by the animation
  4851. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4852. */
  4853. setValue(currentValue: any, weight?: number): void;
  4854. private _setValue;
  4855. /**
  4856. * Gets the loop pmode of the runtime animation
  4857. * @returns Loop Mode
  4858. */
  4859. private _getCorrectLoopMode;
  4860. /**
  4861. * Move the current animation to a given frame
  4862. * @param frame defines the frame to move to
  4863. */
  4864. goToFrame(frame: number): void;
  4865. /**
  4866. * @hidden Internal use only
  4867. */
  4868. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4869. /**
  4870. * Execute the current animation
  4871. * @param delay defines the delay to add to the current frame
  4872. * @param from defines the lower bound of the animation range
  4873. * @param to defines the upper bound of the animation range
  4874. * @param loop defines if the current animation must loop
  4875. * @param speedRatio defines the current speed ratio
  4876. * @param weight defines the weight of the animation (default is -1 so no weight)
  4877. * @returns a boolean indicating if the animation is running
  4878. */
  4879. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4880. }
  4881. }
  4882. declare module BABYLON {
  4883. /**
  4884. * Interface used to define a behavior
  4885. */
  4886. interface Behavior<T> {
  4887. /** gets or sets behavior's name */
  4888. name: string;
  4889. /**
  4890. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4891. */
  4892. init(): void;
  4893. /**
  4894. * Called when the behavior is attached to a target
  4895. * @param target defines the target where the behavior is attached to
  4896. */
  4897. attach(target: T): void;
  4898. /**
  4899. * Called when the behavior is detached from its target
  4900. */
  4901. detach(): void;
  4902. }
  4903. /**
  4904. * Interface implemented by classes supporting behaviors
  4905. */
  4906. interface IBehaviorAware<T> {
  4907. /**
  4908. * Attach a behavior
  4909. * @param behavior defines the behavior to attach
  4910. * @returns the current host
  4911. */
  4912. addBehavior(behavior: Behavior<T>): T;
  4913. /**
  4914. * Remove a behavior from the current object
  4915. * @param behavior defines the behavior to detach
  4916. * @returns the current host
  4917. */
  4918. removeBehavior(behavior: Behavior<T>): T;
  4919. /**
  4920. * Gets a behavior using its name to search
  4921. * @param name defines the name to search
  4922. * @returns the behavior or null if not found
  4923. */
  4924. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4925. }
  4926. }
  4927. declare module BABYLON {
  4928. class ArcRotateCamera extends TargetCamera {
  4929. alpha: number;
  4930. beta: number;
  4931. radius: number;
  4932. protected _target: Vector3;
  4933. protected _targetHost: Nullable<AbstractMesh>;
  4934. target: Vector3;
  4935. inertialAlphaOffset: number;
  4936. inertialBetaOffset: number;
  4937. inertialRadiusOffset: number;
  4938. lowerAlphaLimit: Nullable<number>;
  4939. upperAlphaLimit: Nullable<number>;
  4940. lowerBetaLimit: number;
  4941. upperBetaLimit: number;
  4942. lowerRadiusLimit: Nullable<number>;
  4943. upperRadiusLimit: Nullable<number>;
  4944. inertialPanningX: number;
  4945. inertialPanningY: number;
  4946. pinchToPanMaxDistance: number;
  4947. panningDistanceLimit: Nullable<number>;
  4948. panningOriginTarget: Vector3;
  4949. panningInertia: number;
  4950. angularSensibilityX: number;
  4951. angularSensibilityY: number;
  4952. pinchPrecision: number;
  4953. pinchDeltaPercentage: number;
  4954. panningSensibility: number;
  4955. keysUp: number[];
  4956. keysDown: number[];
  4957. keysLeft: number[];
  4958. keysRight: number[];
  4959. wheelPrecision: number;
  4960. wheelDeltaPercentage: number;
  4961. zoomOnFactor: number;
  4962. targetScreenOffset: Vector2;
  4963. allowUpsideDown: boolean;
  4964. /** @hidden */
  4965. _viewMatrix: Matrix;
  4966. /** @hidden */
  4967. _useCtrlForPanning: boolean;
  4968. /** @hidden */
  4969. _panningMouseButton: number;
  4970. inputs: ArcRotateCameraInputsManager;
  4971. /** @hidden */
  4972. _reset: () => void;
  4973. panningAxis: Vector3;
  4974. protected _localDirection: Vector3;
  4975. protected _transformedDirection: Vector3;
  4976. private _bouncingBehavior;
  4977. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  4978. useBouncingBehavior: boolean;
  4979. private _framingBehavior;
  4980. readonly framingBehavior: Nullable<FramingBehavior>;
  4981. useFramingBehavior: boolean;
  4982. private _autoRotationBehavior;
  4983. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  4984. useAutoRotationBehavior: boolean;
  4985. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  4986. onCollide: (collidedMesh: AbstractMesh) => void;
  4987. checkCollisions: boolean;
  4988. collisionRadius: Vector3;
  4989. protected _collider: Collider;
  4990. protected _previousPosition: Vector3;
  4991. protected _collisionVelocity: Vector3;
  4992. protected _newPosition: Vector3;
  4993. protected _previousAlpha: number;
  4994. protected _previousBeta: number;
  4995. protected _previousRadius: number;
  4996. protected _collisionTriggered: boolean;
  4997. protected _targetBoundingCenter: Nullable<Vector3>;
  4998. private _computationVector;
  4999. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5000. /** @hidden */
  5001. _initCache(): void;
  5002. /** @hidden */
  5003. _updateCache(ignoreParentClass?: boolean): void;
  5004. protected _getTargetPosition(): Vector3;
  5005. /**
  5006. * Store current camera state (fov, position, etc..)
  5007. */
  5008. private _storedAlpha;
  5009. private _storedBeta;
  5010. private _storedRadius;
  5011. private _storedTarget;
  5012. storeState(): Camera;
  5013. /**
  5014. * @hidden
  5015. * Restored camera state. You must call storeState() first
  5016. */
  5017. _restoreStateValues(): boolean;
  5018. /** @hidden */
  5019. _isSynchronizedViewMatrix(): boolean;
  5020. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5021. detachControl(element: HTMLElement): void;
  5022. /** @hidden */
  5023. _checkInputs(): void;
  5024. protected _checkLimits(): void;
  5025. rebuildAnglesAndRadius(): void;
  5026. setPosition(position: Vector3): void;
  5027. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5028. /** @hidden */
  5029. _getViewMatrix(): Matrix;
  5030. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5031. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5032. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5033. min: Vector3;
  5034. max: Vector3;
  5035. distance: number;
  5036. }, doNotUpdateMaxZ?: boolean): void;
  5037. /**
  5038. * @override
  5039. * Override Camera.createRigCamera
  5040. */
  5041. createRigCamera(name: string, cameraIndex: number): Camera;
  5042. /**
  5043. * @hidden
  5044. * @override
  5045. * Override Camera._updateRigCameras
  5046. */
  5047. _updateRigCameras(): void;
  5048. dispose(): void;
  5049. getClassName(): string;
  5050. }
  5051. }
  5052. declare module BABYLON {
  5053. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5054. constructor(camera: ArcRotateCamera);
  5055. addMouseWheel(): ArcRotateCameraInputsManager;
  5056. addPointers(): ArcRotateCameraInputsManager;
  5057. addKeyboard(): ArcRotateCameraInputsManager;
  5058. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. class Camera extends Node {
  5063. inputs: CameraInputsManager<Camera>;
  5064. private static _PERSPECTIVE_CAMERA;
  5065. private static _ORTHOGRAPHIC_CAMERA;
  5066. private static _FOVMODE_VERTICAL_FIXED;
  5067. private static _FOVMODE_HORIZONTAL_FIXED;
  5068. private static _RIG_MODE_NONE;
  5069. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5070. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5071. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5072. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5073. private static _RIG_MODE_VR;
  5074. private static _RIG_MODE_WEBVR;
  5075. static readonly PERSPECTIVE_CAMERA: number;
  5076. static readonly ORTHOGRAPHIC_CAMERA: number;
  5077. /**
  5078. * This is the default FOV mode for perspective cameras.
  5079. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5080. *
  5081. */
  5082. static readonly FOVMODE_VERTICAL_FIXED: number;
  5083. /**
  5084. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5085. *
  5086. */
  5087. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5088. static readonly RIG_MODE_NONE: number;
  5089. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5090. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5091. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5092. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5093. static readonly RIG_MODE_VR: number;
  5094. static readonly RIG_MODE_WEBVR: number;
  5095. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5096. static UseAlternateWebVRRendering: boolean;
  5097. position: Vector3;
  5098. /**
  5099. * The vector the camera should consider as up.
  5100. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5101. */
  5102. upVector: Vector3;
  5103. orthoLeft: Nullable<number>;
  5104. orthoRight: Nullable<number>;
  5105. orthoBottom: Nullable<number>;
  5106. orthoTop: Nullable<number>;
  5107. /**
  5108. * FOV is set in Radians. (default is 0.8)
  5109. */
  5110. fov: number;
  5111. minZ: number;
  5112. maxZ: number;
  5113. inertia: number;
  5114. mode: number;
  5115. isIntermediate: boolean;
  5116. viewport: Viewport;
  5117. /**
  5118. * Restricts the camera to viewing objects with the same layerMask.
  5119. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5120. */
  5121. layerMask: number;
  5122. /**
  5123. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5124. */
  5125. fovMode: number;
  5126. cameraRigMode: number;
  5127. interaxialDistance: number;
  5128. isStereoscopicSideBySide: boolean;
  5129. /** @hidden */
  5130. _cameraRigParams: any;
  5131. /** @hidden */
  5132. _rigCameras: Camera[];
  5133. /** @hidden */
  5134. _rigPostProcess: Nullable<PostProcess>;
  5135. protected _webvrViewMatrix: Matrix;
  5136. /** @hidden */
  5137. _skipRendering: boolean;
  5138. /** @hidden */
  5139. _alternateCamera: Camera;
  5140. customRenderTargets: RenderTargetTexture[];
  5141. onViewMatrixChangedObservable: Observable<Camera>;
  5142. onProjectionMatrixChangedObservable: Observable<Camera>;
  5143. onAfterCheckInputsObservable: Observable<Camera>;
  5144. onRestoreStateObservable: Observable<Camera>;
  5145. private _computedViewMatrix;
  5146. _projectionMatrix: Matrix;
  5147. private _doNotComputeProjectionMatrix;
  5148. private _worldMatrix;
  5149. _postProcesses: Nullable<PostProcess>[];
  5150. private _transformMatrix;
  5151. _activeMeshes: SmartArray<AbstractMesh>;
  5152. protected _globalPosition: Vector3;
  5153. private _frustumPlanes;
  5154. private _refreshFrustumPlanes;
  5155. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5156. private _storedFov;
  5157. private _stateStored;
  5158. /**
  5159. * Store current camera state (fov, position, etc..)
  5160. */
  5161. storeState(): Camera;
  5162. /**
  5163. * Restores the camera state values if it has been stored. You must call storeState() first
  5164. */
  5165. protected _restoreStateValues(): boolean;
  5166. /**
  5167. * Restored camera state. You must call storeState() first
  5168. */
  5169. restoreState(): boolean;
  5170. getClassName(): string;
  5171. /**
  5172. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5173. */
  5174. toString(fullDetails?: boolean): string;
  5175. readonly globalPosition: Vector3;
  5176. getActiveMeshes(): SmartArray<AbstractMesh>;
  5177. isActiveMesh(mesh: Mesh): boolean;
  5178. /**
  5179. * Is this camera ready to be used/rendered
  5180. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5181. * @return true if the camera is ready
  5182. */
  5183. isReady(completeCheck?: boolean): boolean;
  5184. /** @hidden */
  5185. _initCache(): void;
  5186. /** @hidden */
  5187. _updateCache(ignoreParentClass?: boolean): void;
  5188. /** @hidden */
  5189. _isSynchronized(): boolean;
  5190. /** @hidden */
  5191. _isSynchronizedViewMatrix(): boolean;
  5192. /** @hidden */
  5193. _isSynchronizedProjectionMatrix(): boolean;
  5194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5195. detachControl(element: HTMLElement): void;
  5196. update(): void;
  5197. /** @hidden */
  5198. _checkInputs(): void;
  5199. readonly rigCameras: Camera[];
  5200. readonly rigPostProcess: Nullable<PostProcess>;
  5201. /**
  5202. * Internal, gets the first post proces.
  5203. * @returns the first post process to be run on this camera.
  5204. */
  5205. _getFirstPostProcess(): Nullable<PostProcess>;
  5206. private _cascadePostProcessesToRigCams;
  5207. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5208. detachPostProcess(postProcess: PostProcess): void;
  5209. getWorldMatrix(): Matrix;
  5210. /** @hidden */
  5211. _getViewMatrix(): Matrix;
  5212. getViewMatrix(force?: boolean): Matrix;
  5213. freezeProjectionMatrix(projection?: Matrix): void;
  5214. unfreezeProjectionMatrix(): void;
  5215. getProjectionMatrix(force?: boolean): Matrix;
  5216. /**
  5217. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5218. * @returns a Matrix
  5219. */
  5220. getTransformationMatrix(): Matrix;
  5221. private updateFrustumPlanes;
  5222. isInFrustum(target: ICullable): boolean;
  5223. isCompletelyInFrustum(target: ICullable): boolean;
  5224. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5225. /**
  5226. * Releases resources associated with this node.
  5227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5229. */
  5230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5231. readonly leftCamera: Nullable<FreeCamera>;
  5232. readonly rightCamera: Nullable<FreeCamera>;
  5233. getLeftTarget(): Nullable<Vector3>;
  5234. getRightTarget(): Nullable<Vector3>;
  5235. setCameraRigMode(mode: number, rigParams: any): void;
  5236. private _getVRProjectionMatrix;
  5237. protected _updateCameraRotationMatrix(): void;
  5238. protected _updateWebVRCameraRotationMatrix(): void;
  5239. /**
  5240. * This function MUST be overwritten by the different WebVR cameras available.
  5241. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5242. */
  5243. protected _getWebVRProjectionMatrix(): Matrix;
  5244. /**
  5245. * This function MUST be overwritten by the different WebVR cameras available.
  5246. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5247. */
  5248. protected _getWebVRViewMatrix(): Matrix;
  5249. setCameraRigParameter(name: string, value: any): void;
  5250. /**
  5251. * needs to be overridden by children so sub has required properties to be copied
  5252. */
  5253. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5254. /**
  5255. * May need to be overridden by children
  5256. * @hidden
  5257. */
  5258. _updateRigCameras(): void;
  5259. /** @hidden */
  5260. _setupInputs(): void;
  5261. serialize(): any;
  5262. clone(name: string): Camera;
  5263. getDirection(localAxis: Vector3): Vector3;
  5264. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5265. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5266. computeWorldMatrix(): Matrix;
  5267. static Parse(parsedCamera: any, scene: Scene): Camera;
  5268. }
  5269. }
  5270. declare module BABYLON {
  5271. var CameraInputTypes: {};
  5272. interface ICameraInput<TCamera extends Camera> {
  5273. camera: Nullable<TCamera>;
  5274. getClassName(): string;
  5275. getSimpleName(): string;
  5276. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5277. detachControl: (element: Nullable<HTMLElement>) => void;
  5278. checkInputs?: () => void;
  5279. }
  5280. interface CameraInputsMap<TCamera extends Camera> {
  5281. [name: string]: ICameraInput<TCamera>;
  5282. [idx: number]: ICameraInput<TCamera>;
  5283. }
  5284. class CameraInputsManager<TCamera extends Camera> {
  5285. attached: CameraInputsMap<TCamera>;
  5286. attachedElement: Nullable<HTMLElement>;
  5287. noPreventDefault: boolean;
  5288. camera: TCamera;
  5289. checkInputs: () => void;
  5290. constructor(camera: TCamera);
  5291. /**
  5292. * Add an input method to a camera
  5293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5294. * @param input camera input method
  5295. */
  5296. add(input: ICameraInput<TCamera>): void;
  5297. /**
  5298. * Remove a specific input method from a camera
  5299. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5300. * @param inputToRemove camera input method
  5301. */
  5302. remove(inputToRemove: ICameraInput<TCamera>): void;
  5303. removeByType(inputType: string): void;
  5304. private _addCheckInputs;
  5305. attachInput(input: ICameraInput<TCamera>): void;
  5306. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5307. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5308. rebuildInputCheck(): void;
  5309. /**
  5310. * Remove all attached input methods from a camera
  5311. */
  5312. clear(): void;
  5313. serialize(serializedCamera: any): void;
  5314. parse(parsedCamera: any): void;
  5315. }
  5316. }
  5317. declare module BABYLON {
  5318. /**
  5319. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5320. * being tilted forward or back and left or right.
  5321. */
  5322. class DeviceOrientationCamera extends FreeCamera {
  5323. private _initialQuaternion;
  5324. private _quaternionCache;
  5325. /**
  5326. * Creates a new device orientation camera
  5327. * @param name The name of the camera
  5328. * @param position The start position camera
  5329. * @param scene The scene the camera belongs to
  5330. */
  5331. constructor(name: string, position: Vector3, scene: Scene);
  5332. /**
  5333. * Gets the current instance class name ("DeviceOrientationCamera").
  5334. * This helps avoiding instanceof at run time.
  5335. * @returns the class name
  5336. */
  5337. getClassName(): string;
  5338. /**
  5339. * @hidden
  5340. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5341. */
  5342. _checkInputs(): void;
  5343. /**
  5344. * Reset the camera to its default orientation on the specified axis only.
  5345. * @param axis The axis to reset
  5346. */
  5347. resetToCurrentRotation(axis?: Axis): void;
  5348. }
  5349. }
  5350. declare module BABYLON {
  5351. class FollowCamera extends TargetCamera {
  5352. radius: number;
  5353. rotationOffset: number;
  5354. heightOffset: number;
  5355. cameraAcceleration: number;
  5356. maxCameraSpeed: number;
  5357. lockedTarget: Nullable<AbstractMesh>;
  5358. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5359. private getRadians;
  5360. private follow;
  5361. /** @hidden */
  5362. _checkInputs(): void;
  5363. getClassName(): string;
  5364. }
  5365. class ArcFollowCamera extends TargetCamera {
  5366. alpha: number;
  5367. beta: number;
  5368. radius: number;
  5369. target: Nullable<AbstractMesh>;
  5370. private _cartesianCoordinates;
  5371. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5372. private follow;
  5373. /** @hidden */
  5374. _checkInputs(): void;
  5375. getClassName(): string;
  5376. }
  5377. }
  5378. declare module BABYLON {
  5379. class FreeCamera extends TargetCamera {
  5380. ellipsoid: Vector3;
  5381. ellipsoidOffset: Vector3;
  5382. checkCollisions: boolean;
  5383. applyGravity: boolean;
  5384. inputs: FreeCameraInputsManager;
  5385. /**
  5386. * Gets the input sensibility for a mouse input. (default is 2000.0)
  5387. * Higher values reduce sensitivity.
  5388. */
  5389. /**
  5390. * Sets the input sensibility for a mouse input. (default is 2000.0)
  5391. * Higher values reduce sensitivity.
  5392. */
  5393. angularSensibility: number;
  5394. keysUp: number[];
  5395. keysDown: number[];
  5396. keysLeft: number[];
  5397. keysRight: number[];
  5398. onCollide: (collidedMesh: AbstractMesh) => void;
  5399. private _collider;
  5400. private _needMoveForGravity;
  5401. private _oldPosition;
  5402. private _diffPosition;
  5403. private _newPosition;
  5404. /** @hidden */
  5405. _localDirection: Vector3;
  5406. /** @hidden */
  5407. _transformedDirection: Vector3;
  5408. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5410. detachControl(element: HTMLElement): void;
  5411. private _collisionMask;
  5412. collisionMask: number;
  5413. /** @hidden */
  5414. _collideWithWorld(displacement: Vector3): void;
  5415. private _onCollisionPositionChange;
  5416. /** @hidden */
  5417. _checkInputs(): void;
  5418. /** @hidden */
  5419. _decideIfNeedsToMove(): boolean;
  5420. /** @hidden */
  5421. _updatePosition(): void;
  5422. dispose(): void;
  5423. getClassName(): string;
  5424. }
  5425. }
  5426. declare module BABYLON {
  5427. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  5428. constructor(camera: FreeCamera);
  5429. addKeyboard(): FreeCameraInputsManager;
  5430. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  5431. addDeviceOrientation(): FreeCameraInputsManager;
  5432. addTouch(): FreeCameraInputsManager;
  5433. addVirtualJoystick(): FreeCameraInputsManager;
  5434. }
  5435. }
  5436. declare module BABYLON {
  5437. class GamepadCamera extends UniversalCamera {
  5438. gamepadAngularSensibility: number;
  5439. gamepadMoveSensibility: number;
  5440. constructor(name: string, position: Vector3, scene: Scene);
  5441. getClassName(): string;
  5442. }
  5443. }
  5444. declare module BABYLON {
  5445. class TargetCamera extends Camera {
  5446. cameraDirection: Vector3;
  5447. cameraRotation: Vector2;
  5448. rotation: Vector3;
  5449. rotationQuaternion: Quaternion;
  5450. speed: number;
  5451. noRotationConstraint: boolean;
  5452. lockedTarget: any;
  5453. /** @hidden */
  5454. _currentTarget: Vector3;
  5455. /** @hidden */
  5456. _viewMatrix: Matrix;
  5457. /** @hidden */
  5458. _camMatrix: Matrix;
  5459. /** @hidden */
  5460. _cameraTransformMatrix: Matrix;
  5461. /** @hidden */
  5462. _cameraRotationMatrix: Matrix;
  5463. private _rigCamTransformMatrix;
  5464. /** @hidden */
  5465. _referencePoint: Vector3;
  5466. /** @hidden */
  5467. _transformedReferencePoint: Vector3;
  5468. protected _globalCurrentTarget: Vector3;
  5469. protected _globalCurrentUpVector: Vector3;
  5470. /** @hidden */
  5471. _reset: () => void;
  5472. private _defaultUp;
  5473. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5474. getFrontPosition(distance: number): Vector3;
  5475. /** @hidden */
  5476. _getLockedTargetPosition(): Nullable<Vector3>;
  5477. /**
  5478. * Store current camera state (fov, position, etc..)
  5479. */
  5480. private _storedPosition;
  5481. private _storedRotation;
  5482. private _storedRotationQuaternion;
  5483. storeState(): Camera;
  5484. /**
  5485. * Restored camera state. You must call storeState() first
  5486. * @returns whether it was successful or not
  5487. * @hidden
  5488. */
  5489. _restoreStateValues(): boolean;
  5490. /** @hidden */
  5491. _initCache(): void;
  5492. /** @hidden */
  5493. _updateCache(ignoreParentClass?: boolean): void;
  5494. /** @hidden */
  5495. _isSynchronizedViewMatrix(): boolean;
  5496. /** @hidden */
  5497. _computeLocalCameraSpeed(): number;
  5498. /** @hidden */
  5499. setTarget(target: Vector3): void;
  5500. /**
  5501. * Return the current target position of the camera. This value is expressed in local space.
  5502. */
  5503. getTarget(): Vector3;
  5504. /** @hidden */
  5505. _decideIfNeedsToMove(): boolean;
  5506. /** @hidden */
  5507. _updatePosition(): void;
  5508. /** @hidden */
  5509. _checkInputs(): void;
  5510. protected _updateCameraRotationMatrix(): void;
  5511. /**
  5512. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  5513. * @returns the current camera
  5514. */
  5515. private _rotateUpVectorWithCameraRotationMatrix;
  5516. private _cachedRotationZ;
  5517. /** @hidden */
  5518. _getViewMatrix(): Matrix;
  5519. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  5520. /**
  5521. * @override
  5522. * Override Camera.createRigCamera
  5523. */
  5524. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5525. /**
  5526. * @hidden
  5527. * @override
  5528. * Override Camera._updateRigCameras
  5529. */
  5530. _updateRigCameras(): void;
  5531. private _getRigCamPosition;
  5532. getClassName(): string;
  5533. }
  5534. }
  5535. declare module BABYLON {
  5536. class TouchCamera extends FreeCamera {
  5537. touchAngularSensibility: number;
  5538. touchMoveSensibility: number;
  5539. constructor(name: string, position: Vector3, scene: Scene);
  5540. getClassName(): string;
  5541. /** @hidden */
  5542. _setupInputs(): void;
  5543. }
  5544. }
  5545. declare module BABYLON {
  5546. class UniversalCamera extends TouchCamera {
  5547. gamepadAngularSensibility: number;
  5548. gamepadMoveSensibility: number;
  5549. constructor(name: string, position: Vector3, scene: Scene);
  5550. getClassName(): string;
  5551. }
  5552. }
  5553. declare module BABYLON {
  5554. class VirtualJoysticksCamera extends FreeCamera {
  5555. constructor(name: string, position: Vector3, scene: Scene);
  5556. getClassName(): string;
  5557. }
  5558. }
  5559. interface VRDisplay extends EventTarget {
  5560. /**
  5561. * Dictionary of capabilities describing the VRDisplay.
  5562. */
  5563. readonly capabilities: VRDisplayCapabilities;
  5564. /**
  5565. * z-depth defining the far plane of the eye view frustum
  5566. * enables mapping of values in the render target depth
  5567. * attachment to scene coordinates. Initially set to 10000.0.
  5568. */
  5569. depthFar: number;
  5570. /**
  5571. * z-depth defining the near plane of the eye view frustum
  5572. * enables mapping of values in the render target depth
  5573. * attachment to scene coordinates. Initially set to 0.01.
  5574. */
  5575. depthNear: number;
  5576. /**
  5577. * An identifier for this distinct VRDisplay. Used as an
  5578. * association point in the Gamepad API.
  5579. */
  5580. readonly displayId: number;
  5581. /**
  5582. * A display name, a user-readable name identifying it.
  5583. */
  5584. readonly displayName: string;
  5585. readonly isConnected: boolean;
  5586. readonly isPresenting: boolean;
  5587. /**
  5588. * If this VRDisplay supports room-scale experiences, the optional
  5589. * stage attribute contains details on the room-scale parameters.
  5590. */
  5591. readonly stageParameters: VRStageParameters | null;
  5592. /**
  5593. * Passing the value returned by `requestAnimationFrame` to
  5594. * `cancelAnimationFrame` will unregister the callback.
  5595. */
  5596. cancelAnimationFrame(handle: number): void;
  5597. /**
  5598. * Stops presenting to the VRDisplay.
  5599. */
  5600. exitPresent(): Promise<void>;
  5601. getEyeParameters(whichEye: string): VREyeParameters;
  5602. /**
  5603. * Populates the passed VRFrameData with the information required to render
  5604. * the current frame.
  5605. */
  5606. getFrameData(frameData: VRFrameData): boolean;
  5607. /**
  5608. * Get the layers currently being presented.
  5609. */
  5610. getLayers(): VRLayer[];
  5611. /**
  5612. * Return a VRPose containing the future predicted pose of the VRDisplay
  5613. * when the current frame will be presented. The value returned will not
  5614. * change until JavaScript has returned control to the browser.
  5615. *
  5616. * The VRPose will contain the position, orientation, velocity,
  5617. * and acceleration of each of these properties.
  5618. */
  5619. getPose(): VRPose;
  5620. /**
  5621. * Return the current instantaneous pose of the VRDisplay, with no
  5622. * prediction applied.
  5623. */
  5624. getImmediatePose(): VRPose;
  5625. /**
  5626. * The callback passed to `requestAnimationFrame` will be called
  5627. * any time a new frame should be rendered. When the VRDisplay is
  5628. * presenting the callback will be called at the native refresh
  5629. * rate of the HMD. When not presenting this function acts
  5630. * identically to how window.requestAnimationFrame acts. Content should
  5631. * make no assumptions of frame rate or vsync behavior as the HMD runs
  5632. * asynchronously from other displays and at differing refresh rates.
  5633. */
  5634. requestAnimationFrame(callback: FrameRequestCallback): number;
  5635. /**
  5636. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  5637. * Repeat calls while already presenting will update the VRLayers being displayed.
  5638. */
  5639. requestPresent(layers: VRLayer[]): Promise<void>;
  5640. /**
  5641. * Reset the pose for this display, treating its current position and
  5642. * orientation as the "origin/zero" values. VRPose.position,
  5643. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  5644. * updated when calling resetPose(). This should be called in only
  5645. * sitting-space experiences.
  5646. */
  5647. resetPose(): void;
  5648. /**
  5649. * The VRLayer provided to the VRDisplay will be captured and presented
  5650. * in the HMD. Calling this function has the same effect on the source
  5651. * canvas as any other operation that uses its source image, and canvases
  5652. * created without preserveDrawingBuffer set to true will be cleared.
  5653. */
  5654. submitFrame(pose?: VRPose): void;
  5655. }
  5656. declare var VRDisplay: {
  5657. prototype: VRDisplay;
  5658. new (): VRDisplay;
  5659. };
  5660. interface VRLayer {
  5661. leftBounds?: number[] | Float32Array | null;
  5662. rightBounds?: number[] | Float32Array | null;
  5663. source?: HTMLCanvasElement | null;
  5664. }
  5665. interface VRDisplayCapabilities {
  5666. readonly canPresent: boolean;
  5667. readonly hasExternalDisplay: boolean;
  5668. readonly hasOrientation: boolean;
  5669. readonly hasPosition: boolean;
  5670. readonly maxLayers: number;
  5671. }
  5672. interface VREyeParameters {
  5673. /** @deprecated */
  5674. readonly fieldOfView: VRFieldOfView;
  5675. readonly offset: Float32Array;
  5676. readonly renderHeight: number;
  5677. readonly renderWidth: number;
  5678. }
  5679. interface VRFieldOfView {
  5680. readonly downDegrees: number;
  5681. readonly leftDegrees: number;
  5682. readonly rightDegrees: number;
  5683. readonly upDegrees: number;
  5684. }
  5685. interface VRFrameData {
  5686. readonly leftProjectionMatrix: Float32Array;
  5687. readonly leftViewMatrix: Float32Array;
  5688. readonly pose: VRPose;
  5689. readonly rightProjectionMatrix: Float32Array;
  5690. readonly rightViewMatrix: Float32Array;
  5691. readonly timestamp: number;
  5692. }
  5693. interface VRPose {
  5694. readonly angularAcceleration: Float32Array | null;
  5695. readonly angularVelocity: Float32Array | null;
  5696. readonly linearAcceleration: Float32Array | null;
  5697. readonly linearVelocity: Float32Array | null;
  5698. readonly orientation: Float32Array | null;
  5699. readonly position: Float32Array | null;
  5700. readonly timestamp: number;
  5701. }
  5702. interface VRStageParameters {
  5703. sittingToStandingTransform?: Float32Array;
  5704. sizeX?: number;
  5705. sizeY?: number;
  5706. }
  5707. interface Navigator {
  5708. getVRDisplays(): Promise<VRDisplay[]>;
  5709. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  5710. }
  5711. interface Window {
  5712. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  5713. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  5714. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  5715. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5716. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5717. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  5718. }
  5719. interface Gamepad {
  5720. readonly displayId: number;
  5721. }
  5722. declare module BABYLON {
  5723. /**
  5724. * Class used to store bone information
  5725. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5726. */
  5727. class Bone extends Node {
  5728. /**
  5729. * defines the bone name
  5730. */
  5731. name: string;
  5732. private static _tmpVecs;
  5733. private static _tmpQuat;
  5734. private static _tmpMats;
  5735. /**
  5736. * Gets the list of child bones
  5737. */
  5738. children: Bone[];
  5739. /** Gets the animations associated with this bone */
  5740. animations: Animation[];
  5741. /**
  5742. * Gets or sets bone length
  5743. */
  5744. length: number;
  5745. /**
  5746. * @hidden Internal only
  5747. * Set this value to map this bone to a different index in the transform matrices
  5748. * Set this value to -1 to exclude the bone from the transform matrices
  5749. */
  5750. _index: Nullable<number>;
  5751. private _skeleton;
  5752. private _localMatrix;
  5753. private _restPose;
  5754. private _baseMatrix;
  5755. private _absoluteTransform;
  5756. private _invertedAbsoluteTransform;
  5757. private _parent;
  5758. private _scalingDeterminant;
  5759. private _worldTransform;
  5760. private _localScaling;
  5761. private _localRotation;
  5762. private _localPosition;
  5763. private _needToDecompose;
  5764. private _needToCompose;
  5765. /** @hidden */
  5766. /** @hidden */
  5767. _matrix: Matrix;
  5768. /**
  5769. * Create a new bone
  5770. * @param name defines the bone name
  5771. * @param skeleton defines the parent skeleton
  5772. * @param parentBone defines the parent (can be null if the bone is the root)
  5773. * @param localMatrix defines the local matrix
  5774. * @param restPose defines the rest pose matrix
  5775. * @param baseMatrix defines the base matrix
  5776. * @param index defines index of the bone in the hiearchy
  5777. */
  5778. constructor(
  5779. /**
  5780. * defines the bone name
  5781. */
  5782. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5783. /**
  5784. * Gets the parent skeleton
  5785. * @returns a skeleton
  5786. */
  5787. getSkeleton(): Skeleton;
  5788. /**
  5789. * Gets parent bone
  5790. * @returns a bone or null if the bone is the root of the bone hierarchy
  5791. */
  5792. getParent(): Nullable<Bone>;
  5793. /**
  5794. * Sets the parent bone
  5795. * @param parent defines the parent (can be null if the bone is the root)
  5796. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5797. */
  5798. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5799. /**
  5800. * Gets the local matrix
  5801. * @returns a matrix
  5802. */
  5803. getLocalMatrix(): Matrix;
  5804. /**
  5805. * Gets the base matrix (initial matrix which remains unchanged)
  5806. * @returns a matrix
  5807. */
  5808. getBaseMatrix(): Matrix;
  5809. /**
  5810. * Gets the rest pose matrix
  5811. * @returns a matrix
  5812. */
  5813. getRestPose(): Matrix;
  5814. /**
  5815. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5816. */
  5817. getWorldMatrix(): Matrix;
  5818. /**
  5819. * Sets the local matrix to rest pose matrix
  5820. */
  5821. returnToRest(): void;
  5822. /**
  5823. * Gets the inverse of the absolute transform matrix.
  5824. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5825. * @returns a matrix
  5826. */
  5827. getInvertedAbsoluteTransform(): Matrix;
  5828. /**
  5829. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5830. * @returns a matrix
  5831. */
  5832. getAbsoluteTransform(): Matrix;
  5833. /** Gets or sets current position (in local space) */
  5834. position: Vector3;
  5835. /** Gets or sets current rotation (in local space) */
  5836. rotation: Vector3;
  5837. /** Gets or sets current rotation quaternion (in local space) */
  5838. rotationQuaternion: Quaternion;
  5839. /** Gets or sets current scaling (in local space) */
  5840. scaling: Vector3;
  5841. /**
  5842. * Gets the animation properties override
  5843. */
  5844. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5845. private _decompose;
  5846. private _compose;
  5847. /**
  5848. * Update the base and local matrices
  5849. * @param matrix defines the new base or local matrix
  5850. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5851. * @param updateLocalMatrix defines if the local matrix should be updated
  5852. */
  5853. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5854. /** @hidden */
  5855. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5856. /**
  5857. * Flag the bone as dirty (Forcing it to update everything)
  5858. */
  5859. markAsDirty(): void;
  5860. private _markAsDirtyAndCompose;
  5861. private _markAsDirtyAndDecompose;
  5862. /**
  5863. * Copy an animation range from another bone
  5864. * @param source defines the source bone
  5865. * @param rangeName defines the range name to copy
  5866. * @param frameOffset defines the frame offset
  5867. * @param rescaleAsRequired defines if rescaling must be applied if required
  5868. * @param skelDimensionsRatio defines the scaling ratio
  5869. * @returns true if operation was successful
  5870. */
  5871. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5872. /**
  5873. * Translate the bone in local or world space
  5874. * @param vec The amount to translate the bone
  5875. * @param space The space that the translation is in
  5876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5877. */
  5878. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5879. /**
  5880. * Set the postion of the bone in local or world space
  5881. * @param position The position to set the bone
  5882. * @param space The space that the position is in
  5883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5884. */
  5885. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5886. /**
  5887. * Set the absolute position of the bone (world space)
  5888. * @param position The position to set the bone
  5889. * @param mesh The mesh that this bone is attached to
  5890. */
  5891. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5892. /**
  5893. * Scale the bone on the x, y and z axes (in local space)
  5894. * @param x The amount to scale the bone on the x axis
  5895. * @param y The amount to scale the bone on the y axis
  5896. * @param z The amount to scale the bone on the z axis
  5897. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5898. */
  5899. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5900. /**
  5901. * Set the bone scaling in local space
  5902. * @param scale defines the scaling vector
  5903. */
  5904. setScale(scale: Vector3): void;
  5905. /**
  5906. * Gets the current scaling in local space
  5907. * @returns the current scaling vector
  5908. */
  5909. getScale(): Vector3;
  5910. /**
  5911. * Gets the current scaling in local space and stores it in a target vector
  5912. * @param result defines the target vector
  5913. */
  5914. getScaleToRef(result: Vector3): void;
  5915. /**
  5916. * Set the yaw, pitch, and roll of the bone in local or world space
  5917. * @param yaw The rotation of the bone on the y axis
  5918. * @param pitch The rotation of the bone on the x axis
  5919. * @param roll The rotation of the bone on the z axis
  5920. * @param space The space that the axes of rotation are in
  5921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5922. */
  5923. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5924. /**
  5925. * Add a rotation to the bone on an axis in local or world space
  5926. * @param axis The axis to rotate the bone on
  5927. * @param amount The amount to rotate the bone
  5928. * @param space The space that the axis is in
  5929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5930. */
  5931. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5932. /**
  5933. * Set the rotation of the bone to a particular axis angle in local or world space
  5934. * @param axis The axis to rotate the bone on
  5935. * @param angle The angle that the bone should be rotated to
  5936. * @param space The space that the axis is in
  5937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5938. */
  5939. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5940. /**
  5941. * Set the euler rotation of the bone in local of world space
  5942. * @param rotation The euler rotation that the bone should be set to
  5943. * @param space The space that the rotation is in
  5944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5945. */
  5946. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5947. /**
  5948. * Set the quaternion rotation of the bone in local of world space
  5949. * @param quat The quaternion rotation that the bone should be set to
  5950. * @param space The space that the rotation is in
  5951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5952. */
  5953. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5954. /**
  5955. * Set the rotation matrix of the bone in local of world space
  5956. * @param rotMat The rotation matrix that the bone should be set to
  5957. * @param space The space that the rotation is in
  5958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5959. */
  5960. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5961. private _rotateWithMatrix;
  5962. private _getNegativeRotationToRef;
  5963. /**
  5964. * Get the position of the bone in local or world space
  5965. * @param space The space that the returned position is in
  5966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5967. * @returns The position of the bone
  5968. */
  5969. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5970. /**
  5971. * Copy the position of the bone to a vector3 in local or world space
  5972. * @param space The space that the returned position is in
  5973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5974. * @param result The vector3 to copy the position to
  5975. */
  5976. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5977. /**
  5978. * Get the absolute position of the bone (world space)
  5979. * @param mesh The mesh that this bone is attached to
  5980. * @returns The absolute position of the bone
  5981. */
  5982. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5983. /**
  5984. * Copy the absolute position of the bone (world space) to the result param
  5985. * @param mesh The mesh that this bone is attached to
  5986. * @param result The vector3 to copy the absolute position to
  5987. */
  5988. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5989. /**
  5990. * Compute the absolute transforms of this bone and its children
  5991. */
  5992. computeAbsoluteTransforms(): void;
  5993. /**
  5994. * Get the world direction from an axis that is in the local space of the bone
  5995. * @param localAxis The local direction that is used to compute the world direction
  5996. * @param mesh The mesh that this bone is attached to
  5997. * @returns The world direction
  5998. */
  5999. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6000. /**
  6001. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6002. * @param localAxis The local direction that is used to compute the world direction
  6003. * @param mesh The mesh that this bone is attached to
  6004. * @param result The vector3 that the world direction will be copied to
  6005. */
  6006. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6007. /**
  6008. * Get the euler rotation of the bone in local or world space
  6009. * @param space The space that the rotation should be in
  6010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6011. * @returns The euler rotation
  6012. */
  6013. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6014. /**
  6015. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6016. * @param space The space that the rotation should be in
  6017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6018. * @param result The vector3 that the rotation should be copied to
  6019. */
  6020. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6021. /**
  6022. * Get the quaternion rotation of the bone in either local or world space
  6023. * @param space The space that the rotation should be in
  6024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6025. * @returns The quaternion rotation
  6026. */
  6027. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6028. /**
  6029. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6030. * @param space The space that the rotation should be in
  6031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6032. * @param result The quaternion that the rotation should be copied to
  6033. */
  6034. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6035. /**
  6036. * Get the rotation matrix of the bone in local or world space
  6037. * @param space The space that the rotation should be in
  6038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6039. * @returns The rotation matrix
  6040. */
  6041. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6042. /**
  6043. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6044. * @param space The space that the rotation should be in
  6045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6046. * @param result The quaternion that the rotation should be copied to
  6047. */
  6048. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6049. /**
  6050. * Get the world position of a point that is in the local space of the bone
  6051. * @param position The local position
  6052. * @param mesh The mesh that this bone is attached to
  6053. * @returns The world position
  6054. */
  6055. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6056. /**
  6057. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6058. * @param position The local position
  6059. * @param mesh The mesh that this bone is attached to
  6060. * @param result The vector3 that the world position should be copied to
  6061. */
  6062. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6063. /**
  6064. * Get the local position of a point that is in world space
  6065. * @param position The world position
  6066. * @param mesh The mesh that this bone is attached to
  6067. * @returns The local position
  6068. */
  6069. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6070. /**
  6071. * Get the local position of a point that is in world space and copy it to the result param
  6072. * @param position The world position
  6073. * @param mesh The mesh that this bone is attached to
  6074. * @param result The vector3 that the local position should be copied to
  6075. */
  6076. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6077. }
  6078. }
  6079. declare module BABYLON {
  6080. /**
  6081. * Class used to apply inverse kinematics to bones
  6082. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6083. */
  6084. class BoneIKController {
  6085. private static _tmpVecs;
  6086. private static _tmpQuat;
  6087. private static _tmpMats;
  6088. /**
  6089. * Gets or sets the target mesh
  6090. */
  6091. targetMesh: AbstractMesh;
  6092. /** Gets or sets the mesh used as pole */
  6093. poleTargetMesh: AbstractMesh;
  6094. /**
  6095. * Gets or sets the bone used as pole
  6096. */
  6097. poleTargetBone: Nullable<Bone>;
  6098. /**
  6099. * Gets or sets the target position
  6100. */
  6101. targetPosition: Vector3;
  6102. /**
  6103. * Gets or sets the pole target position
  6104. */
  6105. poleTargetPosition: Vector3;
  6106. /**
  6107. * Gets or sets the pole target local offset
  6108. */
  6109. poleTargetLocalOffset: Vector3;
  6110. /**
  6111. * Gets or sets the pole angle
  6112. */
  6113. poleAngle: number;
  6114. /**
  6115. * Gets or sets the mesh associated with the controller
  6116. */
  6117. mesh: AbstractMesh;
  6118. /**
  6119. * 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)
  6120. */
  6121. slerpAmount: number;
  6122. private _bone1Quat;
  6123. private _bone1Mat;
  6124. private _bone2Ang;
  6125. private _bone1;
  6126. private _bone2;
  6127. private _bone1Length;
  6128. private _bone2Length;
  6129. private _maxAngle;
  6130. private _maxReach;
  6131. private _rightHandedSystem;
  6132. private _bendAxis;
  6133. private _slerping;
  6134. private _adjustRoll;
  6135. /**
  6136. * Gets or sets maximum allowed angle
  6137. */
  6138. maxAngle: number;
  6139. /**
  6140. * Creates a new BoneIKController
  6141. * @param mesh defines the mesh to control
  6142. * @param bone defines the bone to control
  6143. * @param options defines options to set up the controller
  6144. */
  6145. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6146. targetMesh?: AbstractMesh;
  6147. poleTargetMesh?: AbstractMesh;
  6148. poleTargetBone?: Bone;
  6149. poleTargetLocalOffset?: Vector3;
  6150. poleAngle?: number;
  6151. bendAxis?: Vector3;
  6152. maxAngle?: number;
  6153. slerpAmount?: number;
  6154. });
  6155. private _setMaxAngle;
  6156. /**
  6157. * Force the controller to update the bones
  6158. */
  6159. update(): void;
  6160. }
  6161. }
  6162. declare module BABYLON {
  6163. /**
  6164. * Class used to make a bone look toward a point in space
  6165. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6166. */
  6167. class BoneLookController {
  6168. private static _tmpVecs;
  6169. private static _tmpQuat;
  6170. private static _tmpMats;
  6171. /**
  6172. * The target Vector3 that the bone will look at
  6173. */
  6174. target: Vector3;
  6175. /**
  6176. * The mesh that the bone is attached to
  6177. */
  6178. mesh: AbstractMesh;
  6179. /**
  6180. * The bone that will be looking to the target
  6181. */
  6182. bone: Bone;
  6183. /**
  6184. * The up axis of the coordinate system that is used when the bone is rotated
  6185. */
  6186. upAxis: Vector3;
  6187. /**
  6188. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6189. */
  6190. upAxisSpace: Space;
  6191. /**
  6192. * Used to make an adjustment to the yaw of the bone
  6193. */
  6194. adjustYaw: number;
  6195. /**
  6196. * Used to make an adjustment to the pitch of the bone
  6197. */
  6198. adjustPitch: number;
  6199. /**
  6200. * Used to make an adjustment to the roll of the bone
  6201. */
  6202. adjustRoll: number;
  6203. /**
  6204. * 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)
  6205. */
  6206. slerpAmount: number;
  6207. private _minYaw;
  6208. private _maxYaw;
  6209. private _minPitch;
  6210. private _maxPitch;
  6211. private _minYawSin;
  6212. private _minYawCos;
  6213. private _maxYawSin;
  6214. private _maxYawCos;
  6215. private _midYawConstraint;
  6216. private _minPitchTan;
  6217. private _maxPitchTan;
  6218. private _boneQuat;
  6219. private _slerping;
  6220. private _transformYawPitch;
  6221. private _transformYawPitchInv;
  6222. private _firstFrameSkipped;
  6223. private _yawRange;
  6224. private _fowardAxis;
  6225. /**
  6226. * Gets or sets the minimum yaw angle that the bone can look to
  6227. */
  6228. minYaw: number;
  6229. /**
  6230. * Gets or sets the maximum yaw angle that the bone can look to
  6231. */
  6232. maxYaw: number;
  6233. /**
  6234. * Gets or sets the minimum pitch angle that the bone can look to
  6235. */
  6236. minPitch: number;
  6237. /**
  6238. * Gets or sets the maximum pitch angle that the bone can look to
  6239. */
  6240. maxPitch: number;
  6241. /**
  6242. * Create a BoneLookController
  6243. * @param mesh the mesh that the bone belongs to
  6244. * @param bone the bone that will be looking to the target
  6245. * @param target the target Vector3 to look at
  6246. * @param settings optional settings:
  6247. * * maxYaw: the maximum angle the bone will yaw to
  6248. * * minYaw: the minimum angle the bone will yaw to
  6249. * * maxPitch: the maximum angle the bone will pitch to
  6250. * * minPitch: the minimum angle the bone will yaw to
  6251. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6252. * * upAxis: the up axis of the coordinate system
  6253. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6254. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6255. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6256. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6257. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6258. * * adjustRoll: used to make an adjustment to the roll of the bone
  6259. **/
  6260. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6261. maxYaw?: number;
  6262. minYaw?: number;
  6263. maxPitch?: number;
  6264. minPitch?: number;
  6265. slerpAmount?: number;
  6266. upAxis?: Vector3;
  6267. upAxisSpace?: Space;
  6268. yawAxis?: Vector3;
  6269. pitchAxis?: Vector3;
  6270. adjustYaw?: number;
  6271. adjustPitch?: number;
  6272. adjustRoll?: number;
  6273. });
  6274. /**
  6275. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6276. */
  6277. update(): void;
  6278. private _getAngleDiff;
  6279. private _getAngleBetween;
  6280. private _isAngleBetween;
  6281. }
  6282. }
  6283. declare module BABYLON {
  6284. /**
  6285. * Class used to handle skinning animations
  6286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6287. */
  6288. class Skeleton implements IAnimatable {
  6289. /** defines the skeleton name */
  6290. name: string;
  6291. /** defines the skeleton Id */
  6292. id: string;
  6293. /**
  6294. * Gets the list of child bones
  6295. */
  6296. bones: Bone[];
  6297. /**
  6298. * Gets an estimate of the dimension of the skeleton at rest
  6299. */
  6300. dimensionsAtRest: Vector3;
  6301. /**
  6302. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6303. */
  6304. needInitialSkinMatrix: boolean;
  6305. /**
  6306. * Gets the list of animations attached to this skeleton
  6307. */
  6308. animations: Array<Animation>;
  6309. private _scene;
  6310. private _isDirty;
  6311. private _transformMatrices;
  6312. private _meshesWithPoseMatrix;
  6313. private _animatables;
  6314. private _identity;
  6315. private _synchronizedWithMesh;
  6316. private _ranges;
  6317. private _lastAbsoluteTransformsUpdateId;
  6318. /**
  6319. * Specifies if the skeleton should be serialized
  6320. */
  6321. doNotSerialize: boolean;
  6322. private _animationPropertiesOverride;
  6323. /**
  6324. * Gets or sets the animation properties override
  6325. */
  6326. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6327. /**
  6328. * An observable triggered before computing the skeleton's matrices
  6329. */
  6330. onBeforeComputeObservable: Observable<Skeleton>;
  6331. /**
  6332. * Creates a new skeleton
  6333. * @param name defines the skeleton name
  6334. * @param id defines the skeleton Id
  6335. * @param scene defines the hosting scene
  6336. */
  6337. constructor(
  6338. /** defines the skeleton name */
  6339. name: string,
  6340. /** defines the skeleton Id */
  6341. id: string, scene: Scene);
  6342. /**
  6343. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6344. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6345. * @returns a Float32Array containing matrices data
  6346. */
  6347. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6348. /**
  6349. * Gets the current hosting scene
  6350. * @returns a scene object
  6351. */
  6352. getScene(): Scene;
  6353. /**
  6354. * Gets a string representing the current skeleton data
  6355. * @param fullDetails defines a boolean indicating if we want a verbose version
  6356. * @returns a string representing the current skeleton data
  6357. */
  6358. toString(fullDetails?: boolean): string;
  6359. /**
  6360. * Get bone's index searching by name
  6361. * @param name defines bone's name to search for
  6362. * @return the indice of the bone. Returns -1 if not found
  6363. */
  6364. getBoneIndexByName(name: string): number;
  6365. /**
  6366. * Creater a new animation range
  6367. * @param name defines the name of the range
  6368. * @param from defines the start key
  6369. * @param to defines the end key
  6370. */
  6371. createAnimationRange(name: string, from: number, to: number): void;
  6372. /**
  6373. * Delete a specific animation range
  6374. * @param name defines the name of the range
  6375. * @param deleteFrames defines if frames must be removed as well
  6376. */
  6377. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6378. /**
  6379. * Gets a specific animation range
  6380. * @param name defines the name of the range to look for
  6381. * @returns the requested animation range or null if not found
  6382. */
  6383. getAnimationRange(name: string): Nullable<AnimationRange>;
  6384. /**
  6385. * Gets the list of all animation ranges defined on this skeleton
  6386. * @returns an array
  6387. */
  6388. getAnimationRanges(): Nullable<AnimationRange>[];
  6389. /**
  6390. * Copy animation range from a source skeleton.
  6391. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6392. * @param source defines the source skeleton
  6393. * @param name defines the name of the range to copy
  6394. * @param rescaleAsRequired defines if rescaling must be applied if required
  6395. * @returns true if operation was successful
  6396. */
  6397. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6398. /**
  6399. * Forces the skeleton to go to rest pose
  6400. */
  6401. returnToRest(): void;
  6402. private _getHighestAnimationFrame;
  6403. /**
  6404. * Begin a specific animation range
  6405. * @param name defines the name of the range to start
  6406. * @param loop defines if looping must be turned on (false by default)
  6407. * @param speedRatio defines the speed ratio to apply (1 by default)
  6408. * @param onAnimationEnd defines a callback which will be called when animation will end
  6409. * @returns a new animatable
  6410. */
  6411. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6412. /** @hidden */
  6413. _markAsDirty(): void;
  6414. /** @hidden */
  6415. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6416. /** @hidden */
  6417. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6418. /** @hidden */
  6419. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6420. /**
  6421. * Build all resources required to render a skeleton
  6422. */
  6423. prepare(): void;
  6424. /**
  6425. * Gets the list of animatables currently running for this skeleton
  6426. * @returns an array of animatables
  6427. */
  6428. getAnimatables(): IAnimatable[];
  6429. /**
  6430. * Clone the current skeleton
  6431. * @param name defines the name of the new skeleton
  6432. * @param id defines the id of the enw skeleton
  6433. * @returns the new skeleton
  6434. */
  6435. clone(name: string, id: string): Skeleton;
  6436. /**
  6437. * Enable animation blending for this skeleton
  6438. * @param blendingSpeed defines the blending speed to apply
  6439. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6440. */
  6441. enableBlending(blendingSpeed?: number): void;
  6442. /**
  6443. * Releases all resources associated with the current skeleton
  6444. */
  6445. dispose(): void;
  6446. /**
  6447. * Serialize the skeleton in a JSON object
  6448. * @returns a JSON object
  6449. */
  6450. serialize(): any;
  6451. /**
  6452. * Creates a new skeleton from serialized data
  6453. * @param parsedSkeleton defines the serialized data
  6454. * @param scene defines the hosting scene
  6455. * @returns a new skeleton
  6456. */
  6457. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6458. /**
  6459. * Compute all node absolute transforms
  6460. * @param forceUpdate defines if computation must be done even if cache is up to date
  6461. */
  6462. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6463. /**
  6464. * Gets the root pose matrix
  6465. * @returns a matrix
  6466. */
  6467. getPoseMatrix(): Nullable<Matrix>;
  6468. /**
  6469. * Sorts bones per internal index
  6470. */
  6471. sortBones(): void;
  6472. private _sortBones;
  6473. }
  6474. }
  6475. declare module BABYLON {
  6476. class Collider {
  6477. /** Define if a collision was found */
  6478. collisionFound: boolean;
  6479. /**
  6480. * Define last intersection point in local space
  6481. */
  6482. intersectionPoint: Vector3;
  6483. /**
  6484. * Define last collided mesh
  6485. */
  6486. collidedMesh: Nullable<AbstractMesh>;
  6487. private _collisionPoint;
  6488. private _planeIntersectionPoint;
  6489. private _tempVector;
  6490. private _tempVector2;
  6491. private _tempVector3;
  6492. private _tempVector4;
  6493. private _edge;
  6494. private _baseToVertex;
  6495. private _destinationPoint;
  6496. private _slidePlaneNormal;
  6497. private _displacementVector;
  6498. /** @hidden */
  6499. _radius: Vector3;
  6500. /** @hidden */
  6501. _retry: number;
  6502. private _velocity;
  6503. private _basePoint;
  6504. private _epsilon;
  6505. /** @hidden */
  6506. _velocityWorldLength: number;
  6507. /** @hidden */
  6508. _basePointWorld: Vector3;
  6509. private _velocityWorld;
  6510. private _normalizedVelocity;
  6511. /** @hidden */
  6512. _initialVelocity: Vector3;
  6513. /** @hidden */
  6514. _initialPosition: Vector3;
  6515. private _nearestDistance;
  6516. private _collisionMask;
  6517. collisionMask: number;
  6518. /**
  6519. * Gets the plane normal used to compute the sliding response (in local space)
  6520. */
  6521. readonly slidePlaneNormal: Vector3;
  6522. /** @hidden */
  6523. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6524. /** @hidden */
  6525. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6526. /** @hidden */
  6527. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6528. /** @hidden */
  6529. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6530. /** @hidden */
  6531. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6532. /** @hidden */
  6533. _getResponse(pos: Vector3, vel: Vector3): void;
  6534. }
  6535. }
  6536. declare module BABYLON {
  6537. var CollisionWorker: string;
  6538. interface ICollisionCoordinator {
  6539. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6540. init(scene: Scene): void;
  6541. destroy(): void;
  6542. onMeshAdded(mesh: AbstractMesh): void;
  6543. onMeshUpdated(mesh: AbstractMesh): void;
  6544. onMeshRemoved(mesh: AbstractMesh): void;
  6545. onGeometryAdded(geometry: Geometry): void;
  6546. onGeometryUpdated(geometry: Geometry): void;
  6547. onGeometryDeleted(geometry: Geometry): void;
  6548. }
  6549. interface SerializedMesh {
  6550. id: string;
  6551. name: string;
  6552. uniqueId: number;
  6553. geometryId: Nullable<string>;
  6554. sphereCenter: Array<number>;
  6555. sphereRadius: number;
  6556. boxMinimum: Array<number>;
  6557. boxMaximum: Array<number>;
  6558. worldMatrixFromCache: any;
  6559. subMeshes: Array<SerializedSubMesh>;
  6560. checkCollisions: boolean;
  6561. }
  6562. interface SerializedSubMesh {
  6563. position: number;
  6564. verticesStart: number;
  6565. verticesCount: number;
  6566. indexStart: number;
  6567. indexCount: number;
  6568. hasMaterial: boolean;
  6569. sphereCenter: Array<number>;
  6570. sphereRadius: number;
  6571. boxMinimum: Array<number>;
  6572. boxMaximum: Array<number>;
  6573. }
  6574. /**
  6575. * Interface describing the value associated with a geometry
  6576. */
  6577. interface SerializedGeometry {
  6578. /**
  6579. * Defines the unique ID of the geometry
  6580. */
  6581. id: string;
  6582. /**
  6583. * Defines the array containing the positions
  6584. */
  6585. positions: Float32Array;
  6586. /**
  6587. * Defines the array containing the indices
  6588. */
  6589. indices: Uint32Array;
  6590. /**
  6591. * Defines the array containing the normals
  6592. */
  6593. normals: Float32Array;
  6594. }
  6595. interface BabylonMessage {
  6596. taskType: WorkerTaskType;
  6597. payload: InitPayload | CollidePayload | UpdatePayload;
  6598. }
  6599. interface SerializedColliderToWorker {
  6600. position: Array<number>;
  6601. velocity: Array<number>;
  6602. radius: Array<number>;
  6603. }
  6604. /** Defines supported task for worker process */
  6605. enum WorkerTaskType {
  6606. /** Initialization */
  6607. INIT = 0,
  6608. /** Update of geometry */
  6609. UPDATE = 1,
  6610. /** Evaluate collision */
  6611. COLLIDE = 2
  6612. }
  6613. interface WorkerReply {
  6614. error: WorkerReplyType;
  6615. taskType: WorkerTaskType;
  6616. payload?: any;
  6617. }
  6618. interface CollisionReplyPayload {
  6619. newPosition: Array<number>;
  6620. collisionId: number;
  6621. collidedMeshUniqueId: number;
  6622. }
  6623. interface InitPayload {
  6624. }
  6625. interface CollidePayload {
  6626. collisionId: number;
  6627. collider: SerializedColliderToWorker;
  6628. maximumRetry: number;
  6629. excludedMeshUniqueId: Nullable<number>;
  6630. }
  6631. interface UpdatePayload {
  6632. updatedMeshes: {
  6633. [n: number]: SerializedMesh;
  6634. };
  6635. updatedGeometries: {
  6636. [s: string]: SerializedGeometry;
  6637. };
  6638. removedMeshes: Array<number>;
  6639. removedGeometries: Array<string>;
  6640. }
  6641. /** Defines kind of replies returned by worker */
  6642. enum WorkerReplyType {
  6643. /** Success */
  6644. SUCCESS = 0,
  6645. /** Unkown error */
  6646. UNKNOWN_ERROR = 1
  6647. }
  6648. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6649. private _scene;
  6650. private _scaledPosition;
  6651. private _scaledVelocity;
  6652. private _collisionsCallbackArray;
  6653. private _init;
  6654. private _runningUpdated;
  6655. private _worker;
  6656. private _addUpdateMeshesList;
  6657. private _addUpdateGeometriesList;
  6658. private _toRemoveMeshesArray;
  6659. private _toRemoveGeometryArray;
  6660. constructor();
  6661. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6662. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6663. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6664. init(scene: Scene): void;
  6665. destroy(): void;
  6666. onMeshAdded(mesh: AbstractMesh): void;
  6667. onMeshUpdated: (transformNode: TransformNode) => void;
  6668. onMeshRemoved(mesh: AbstractMesh): void;
  6669. onGeometryAdded(geometry: Geometry): void;
  6670. onGeometryUpdated: (geometry: Geometry) => void;
  6671. onGeometryDeleted(geometry: Geometry): void;
  6672. private _afterRender;
  6673. private _onMessageFromWorker;
  6674. }
  6675. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6676. private _scene;
  6677. private _scaledPosition;
  6678. private _scaledVelocity;
  6679. private _finalPosition;
  6680. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6681. init(scene: Scene): void;
  6682. destroy(): void;
  6683. onMeshAdded(mesh: AbstractMesh): void;
  6684. onMeshUpdated(mesh: AbstractMesh): void;
  6685. onMeshRemoved(mesh: AbstractMesh): void;
  6686. onGeometryAdded(geometry: Geometry): void;
  6687. onGeometryUpdated(geometry: Geometry): void;
  6688. onGeometryDeleted(geometry: Geometry): void;
  6689. private _collideWithWorld;
  6690. }
  6691. }
  6692. declare function importScripts(...urls: string[]): void;
  6693. declare const safePostMessage: any;
  6694. declare module BABYLON {
  6695. var WorkerIncluded: boolean;
  6696. class CollisionCache {
  6697. private _meshes;
  6698. private _geometries;
  6699. getMeshes(): {
  6700. [n: number]: SerializedMesh;
  6701. };
  6702. getGeometries(): {
  6703. [s: number]: SerializedGeometry;
  6704. };
  6705. getMesh(id: any): SerializedMesh;
  6706. addMesh(mesh: SerializedMesh): void;
  6707. removeMesh(uniqueId: number): void;
  6708. getGeometry(id: string): SerializedGeometry;
  6709. addGeometry(geometry: SerializedGeometry): void;
  6710. removeGeometry(id: string): void;
  6711. }
  6712. class CollideWorker {
  6713. collider: Collider;
  6714. private _collisionCache;
  6715. private finalPosition;
  6716. private collisionsScalingMatrix;
  6717. private collisionTranformationMatrix;
  6718. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6719. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6720. private checkCollision;
  6721. private processCollisionsForSubMeshes;
  6722. private collideForSubMesh;
  6723. private checkSubmeshCollision;
  6724. }
  6725. interface ICollisionDetector {
  6726. onInit(payload: InitPayload): void;
  6727. onUpdate(payload: UpdatePayload): void;
  6728. onCollision(payload: CollidePayload): void;
  6729. }
  6730. class CollisionDetectorTransferable implements ICollisionDetector {
  6731. private _collisionCache;
  6732. onInit(payload: InitPayload): void;
  6733. onUpdate(payload: UpdatePayload): void;
  6734. onCollision(payload: CollidePayload): void;
  6735. }
  6736. }
  6737. declare module BABYLON {
  6738. class IntersectionInfo {
  6739. bu: Nullable<number>;
  6740. bv: Nullable<number>;
  6741. distance: number;
  6742. faceId: number;
  6743. subMeshId: number;
  6744. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6745. }
  6746. /**
  6747. * Information about the result of picking within a scene
  6748. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6749. */
  6750. class PickingInfo {
  6751. /**
  6752. * If the pick collided with an object
  6753. */
  6754. hit: boolean;
  6755. /**
  6756. * Distance away where the pick collided
  6757. */
  6758. distance: number;
  6759. /**
  6760. * The location of pick collision
  6761. */
  6762. pickedPoint: Nullable<Vector3>;
  6763. /**
  6764. * The mesh corresponding the the pick collision
  6765. */
  6766. pickedMesh: Nullable<AbstractMesh>;
  6767. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6768. bu: number;
  6769. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6770. bv: number;
  6771. /** The id of the face on the mesh that was picked */
  6772. faceId: number;
  6773. /** Id of the the submesh that was picked */
  6774. subMeshId: number;
  6775. /** If a sprite was picked, this will be the sprite the pick collided with */
  6776. pickedSprite: Nullable<Sprite>;
  6777. /**
  6778. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6779. */
  6780. originMesh: Nullable<AbstractMesh>;
  6781. /**
  6782. * The ray that was used to perform the picking.
  6783. */
  6784. ray: Nullable<Ray>;
  6785. /**
  6786. * Gets the normal correspodning to the face the pick collided with
  6787. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6788. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6789. * @returns The normal correspodning to the face the pick collided with
  6790. */
  6791. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6792. /**
  6793. * Gets the texture coordinates of where the pick occured
  6794. * @returns the vector containing the coordnates of the texture
  6795. */
  6796. getTextureCoordinates(): Nullable<Vector2>;
  6797. }
  6798. }
  6799. declare module BABYLON {
  6800. class BoundingBox implements ICullable {
  6801. vectors: Vector3[];
  6802. center: Vector3;
  6803. centerWorld: Vector3;
  6804. extendSize: Vector3;
  6805. extendSizeWorld: Vector3;
  6806. directions: Vector3[];
  6807. vectorsWorld: Vector3[];
  6808. minimumWorld: Vector3;
  6809. maximumWorld: Vector3;
  6810. minimum: Vector3;
  6811. maximum: Vector3;
  6812. private _worldMatrix;
  6813. /**
  6814. * Creates a new bounding box
  6815. * @param min defines the minimum vector (in local space)
  6816. * @param max defines the maximum vector (in local space)
  6817. */
  6818. constructor(min: Vector3, max: Vector3);
  6819. /**
  6820. * Recreates the entire bounding box from scratch
  6821. * @param min defines the new minimum vector (in local space)
  6822. * @param max defines the new maximum vector (in local space)
  6823. */
  6824. reConstruct(min: Vector3, max: Vector3): void;
  6825. /**
  6826. * Scale the current bounding box by applying a scale factor
  6827. * @param factor defines the scale factor to apply
  6828. * @returns the current bounding box
  6829. */
  6830. scale(factor: number): BoundingBox;
  6831. getWorldMatrix(): Matrix;
  6832. setWorldMatrix(matrix: Matrix): BoundingBox;
  6833. /** @hidden */
  6834. _update(world: Matrix): void;
  6835. isInFrustum(frustumPlanes: Plane[]): boolean;
  6836. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6837. intersectsPoint(point: Vector3): boolean;
  6838. intersectsSphere(sphere: BoundingSphere): boolean;
  6839. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6840. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6841. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6842. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6843. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6844. }
  6845. }
  6846. declare module BABYLON {
  6847. interface ICullable {
  6848. isInFrustum(frustumPlanes: Plane[]): boolean;
  6849. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6850. }
  6851. class BoundingInfo implements ICullable {
  6852. minimum: Vector3;
  6853. maximum: Vector3;
  6854. boundingBox: BoundingBox;
  6855. boundingSphere: BoundingSphere;
  6856. private _isLocked;
  6857. constructor(minimum: Vector3, maximum: Vector3);
  6858. isLocked: boolean;
  6859. update(world: Matrix): void;
  6860. /**
  6861. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6862. * @param center New center of the bounding info
  6863. * @param extend New extend of the bounding info
  6864. */
  6865. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6866. /**
  6867. * Scale the current bounding info by applying a scale factor
  6868. * @param factor defines the scale factor to apply
  6869. * @returns the current bounding info
  6870. */
  6871. scale(factor: number): BoundingInfo;
  6872. /**
  6873. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6874. * @param frustumPlanes defines the frustum to test
  6875. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6876. * @returns true if the bounding info is in the frustum planes
  6877. */
  6878. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6879. /**
  6880. * Gets the world distance between the min and max points of the bounding box
  6881. */
  6882. readonly diagonalLength: number;
  6883. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6884. /** @hidden */
  6885. _checkCollision(collider: Collider): boolean;
  6886. intersectsPoint(point: Vector3): boolean;
  6887. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6888. }
  6889. }
  6890. declare module BABYLON {
  6891. class BoundingSphere {
  6892. center: Vector3;
  6893. radius: number;
  6894. centerWorld: Vector3;
  6895. radiusWorld: number;
  6896. minimum: Vector3;
  6897. maximum: Vector3;
  6898. /**
  6899. * Creates a new bounding sphere
  6900. * @param min defines the minimum vector (in local space)
  6901. * @param max defines the maximum vector (in local space)
  6902. */
  6903. constructor(min: Vector3, max: Vector3);
  6904. /**
  6905. * Recreates the entire bounding sphere from scratch
  6906. * @param min defines the new minimum vector (in local space)
  6907. * @param max defines the new maximum vector (in local space)
  6908. */
  6909. reConstruct(min: Vector3, max: Vector3): void;
  6910. /**
  6911. * Scale the current bounding sphere by applying a scale factor
  6912. * @param factor defines the scale factor to apply
  6913. * @returns the current bounding box
  6914. */
  6915. scale(factor: number): BoundingSphere;
  6916. /** @hidden */
  6917. _update(world: Matrix): void;
  6918. isInFrustum(frustumPlanes: Plane[]): boolean;
  6919. intersectsPoint(point: Vector3): boolean;
  6920. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6921. }
  6922. }
  6923. declare module BABYLON {
  6924. class Ray {
  6925. origin: Vector3;
  6926. direction: Vector3;
  6927. length: number;
  6928. private _edge1;
  6929. private _edge2;
  6930. private _pvec;
  6931. private _tvec;
  6932. private _qvec;
  6933. private _tmpRay;
  6934. constructor(origin: Vector3, direction: Vector3, length?: number);
  6935. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6936. intersectsBox(box: BoundingBox): boolean;
  6937. intersectsSphere(sphere: BoundingSphere): boolean;
  6938. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6939. intersectsPlane(plane: Plane): Nullable<number>;
  6940. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6941. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6942. private _comparePickingInfo;
  6943. private static smallnum;
  6944. private static rayl;
  6945. /**
  6946. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6947. * @param sega the first point of the segment to test the intersection against
  6948. * @param segb the second point of the segment to test the intersection against
  6949. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6950. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6951. */
  6952. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6953. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6954. static Zero(): Ray;
  6955. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6956. /**
  6957. * 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
  6958. * transformed to the given world matrix.
  6959. * @param origin The origin point
  6960. * @param end The end point
  6961. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6962. */
  6963. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6964. static Transform(ray: Ray, matrix: Matrix): Ray;
  6965. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6966. }
  6967. }
  6968. /**
  6969. * Module Debug contains the (visual) components to debug a scene correctly
  6970. */
  6971. declare module BABYLON.Debug {
  6972. /**
  6973. * The Axes viewer will show 3 axes in a specific point in space
  6974. */
  6975. class AxesViewer {
  6976. private _xline;
  6977. private _yline;
  6978. private _zline;
  6979. private _xmesh;
  6980. private _ymesh;
  6981. private _zmesh;
  6982. /**
  6983. * Gets the hosting scene
  6984. */
  6985. scene: Nullable<Scene>;
  6986. /**
  6987. * Gets or sets a number used to scale line length
  6988. */
  6989. scaleLines: number;
  6990. /**
  6991. * Creates a new AxesViewer
  6992. * @param scene defines the hosting scene
  6993. * @param scaleLines defines a number used to scale line length (1 by default)
  6994. */
  6995. constructor(scene: Scene, scaleLines?: number);
  6996. /**
  6997. * Force the viewer to update
  6998. * @param position defines the position of the viewer
  6999. * @param xaxis defines the x axis of the viewer
  7000. * @param yaxis defines the y axis of the viewer
  7001. * @param zaxis defines the z axis of the viewer
  7002. */
  7003. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  7004. /** Releases resources */
  7005. dispose(): void;
  7006. }
  7007. }
  7008. declare module BABYLON.Debug {
  7009. /**
  7010. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  7011. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  7012. */
  7013. class BoneAxesViewer extends AxesViewer {
  7014. /**
  7015. * Gets or sets the target mesh where to display the axes viewer
  7016. */
  7017. mesh: Nullable<Mesh>;
  7018. /**
  7019. * Gets or sets the target bone where to display the axes viewer
  7020. */
  7021. bone: Nullable<Bone>;
  7022. /** Gets current position */
  7023. pos: Vector3;
  7024. /** Gets direction of X axis */
  7025. xaxis: Vector3;
  7026. /** Gets direction of Y axis */
  7027. yaxis: Vector3;
  7028. /** Gets direction of Z axis */
  7029. zaxis: Vector3;
  7030. /**
  7031. * Creates a new BoneAxesViewer
  7032. * @param scene defines the hosting scene
  7033. * @param bone defines the target bone
  7034. * @param mesh defines the target mesh
  7035. * @param scaleLines defines a scaling factor for line length (1 by default)
  7036. */
  7037. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7038. /**
  7039. * Force the viewer to update
  7040. */
  7041. update(): void;
  7042. /** Releases resources */
  7043. dispose(): void;
  7044. }
  7045. }
  7046. declare module BABYLON {
  7047. class DebugLayer {
  7048. private _scene;
  7049. static InspectorURL: string;
  7050. private _inspector;
  7051. private BJSINSPECTOR;
  7052. onPropertyChangedObservable: Observable<{
  7053. object: any;
  7054. property: string;
  7055. value: any;
  7056. initialValue: any;
  7057. }>;
  7058. constructor(scene: Scene);
  7059. /** Creates the inspector window. */
  7060. private _createInspector;
  7061. isVisible(): boolean;
  7062. hide(): void;
  7063. /**
  7064. *
  7065. * Launch the debugLayer.
  7066. *
  7067. * initialTab:
  7068. * | Value | Tab Name |
  7069. * | --- | --- |
  7070. * | 0 | Scene |
  7071. * | 1 | Console |
  7072. * | 2 | Stats |
  7073. * | 3 | Textures |
  7074. * | 4 | Mesh |
  7075. * | 5 | Light |
  7076. * | 6 | Material |
  7077. * | 7 | GLTF |
  7078. * | 8 | GUI |
  7079. * | 9 | Physics |
  7080. * | 10 | Camera |
  7081. * | 11 | Audio |
  7082. *
  7083. */
  7084. show(config?: {
  7085. popup?: boolean;
  7086. initialTab?: number;
  7087. parentElement?: HTMLElement;
  7088. newColors?: {
  7089. backgroundColor?: string;
  7090. backgroundColorLighter?: string;
  7091. backgroundColorLighter2?: string;
  7092. backgroundColorLighter3?: string;
  7093. color?: string;
  7094. colorTop?: string;
  7095. colorBot?: string;
  7096. };
  7097. }): void;
  7098. /**
  7099. * Gets the active tab
  7100. * @return the index of the active tab or -1 if the inspector is hidden
  7101. */
  7102. getActiveTab(): number;
  7103. }
  7104. }
  7105. declare module BABYLON.Debug {
  7106. /**
  7107. * Used to show the physics impostor around the specific mesh
  7108. */
  7109. class PhysicsViewer {
  7110. /** @hidden */
  7111. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7112. /** @hidden */
  7113. protected _meshes: Array<Nullable<AbstractMesh>>;
  7114. /** @hidden */
  7115. protected _scene: Nullable<Scene>;
  7116. /** @hidden */
  7117. protected _numMeshes: number;
  7118. /** @hidden */
  7119. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7120. private _renderFunction;
  7121. private _debugBoxMesh;
  7122. private _debugSphereMesh;
  7123. private _debugMaterial;
  7124. /**
  7125. * Creates a new PhysicsViewer
  7126. * @param scene defines the hosting scene
  7127. */
  7128. constructor(scene: Scene);
  7129. /** @hidden */
  7130. protected _updateDebugMeshes(): void;
  7131. /**
  7132. * Renders a specified physic impostor
  7133. * @param impostor defines the impostor to render
  7134. */
  7135. showImpostor(impostor: PhysicsImpostor): void;
  7136. /**
  7137. * Hides a specified physic impostor
  7138. * @param impostor defines the impostor to hide
  7139. */
  7140. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7141. private _getDebugMaterial;
  7142. private _getDebugBoxMesh;
  7143. private _getDebugSphereMesh;
  7144. private _getDebugMesh;
  7145. /** Releases all resources */
  7146. dispose(): void;
  7147. }
  7148. }
  7149. declare module BABYLON {
  7150. class RayHelper {
  7151. ray: Nullable<Ray>;
  7152. private _renderPoints;
  7153. private _renderLine;
  7154. private _renderFunction;
  7155. private _scene;
  7156. private _updateToMeshFunction;
  7157. private _attachedToMesh;
  7158. private _meshSpaceDirection;
  7159. private _meshSpaceOrigin;
  7160. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7161. constructor(ray: Ray);
  7162. show(scene: Scene, color?: Color3): void;
  7163. hide(): void;
  7164. private _render;
  7165. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7166. detachFromMesh(): void;
  7167. private _updateToMesh;
  7168. dispose(): void;
  7169. }
  7170. }
  7171. declare module BABYLON.Debug {
  7172. /**
  7173. * Class used to render a debug view of a given skeleton
  7174. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7175. */
  7176. class SkeletonViewer {
  7177. /** defines the skeleton to render */
  7178. skeleton: Skeleton;
  7179. /** defines the mesh attached to the skeleton */
  7180. mesh: AbstractMesh;
  7181. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7182. autoUpdateBonesMatrices: boolean;
  7183. /** defines the rendering group id to use with the viewer */
  7184. renderingGroupId: number;
  7185. /** Gets or sets the color used to render the skeleton */
  7186. color: Color3;
  7187. private _scene;
  7188. private _debugLines;
  7189. private _debugMesh;
  7190. private _isEnabled;
  7191. private _renderFunction;
  7192. /**
  7193. * Creates a new SkeletonViewer
  7194. * @param skeleton defines the skeleton to render
  7195. * @param mesh defines the mesh attached to the skeleton
  7196. * @param scene defines the hosting scene
  7197. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  7198. * @param renderingGroupId defines the rendering group id to use with the viewer
  7199. */
  7200. constructor(
  7201. /** defines the skeleton to render */
  7202. skeleton: Skeleton,
  7203. /** defines the mesh attached to the skeleton */
  7204. mesh: AbstractMesh, scene: Scene,
  7205. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7206. autoUpdateBonesMatrices?: boolean,
  7207. /** defines the rendering group id to use with the viewer */
  7208. renderingGroupId?: number);
  7209. /** Gets or sets a boolean indicating if the viewer is enabled */
  7210. isEnabled: boolean;
  7211. private _getBonePosition;
  7212. private _getLinesForBonesWithLength;
  7213. private _getLinesForBonesNoLength;
  7214. /** Update the viewer to sync with current skeleton state */
  7215. update(): void;
  7216. /** Release associated resources */
  7217. dispose(): void;
  7218. }
  7219. }
  7220. declare module BABYLON {
  7221. class KeyboardEventTypes {
  7222. static _KEYDOWN: number;
  7223. static _KEYUP: number;
  7224. static readonly KEYDOWN: number;
  7225. static readonly KEYUP: number;
  7226. }
  7227. class KeyboardInfo {
  7228. type: number;
  7229. event: KeyboardEvent;
  7230. constructor(type: number, event: KeyboardEvent);
  7231. }
  7232. /**
  7233. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  7234. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  7235. */
  7236. class KeyboardInfoPre extends KeyboardInfo {
  7237. constructor(type: number, event: KeyboardEvent);
  7238. skipOnPointerObservable: boolean;
  7239. }
  7240. }
  7241. declare module BABYLON {
  7242. class PointerEventTypes {
  7243. static _POINTERDOWN: number;
  7244. static _POINTERUP: number;
  7245. static _POINTERMOVE: number;
  7246. static _POINTERWHEEL: number;
  7247. static _POINTERPICK: number;
  7248. static _POINTERTAP: number;
  7249. static _POINTERDOUBLETAP: number;
  7250. static readonly POINTERDOWN: number;
  7251. static readonly POINTERUP: number;
  7252. static readonly POINTERMOVE: number;
  7253. static readonly POINTERWHEEL: number;
  7254. static readonly POINTERPICK: number;
  7255. static readonly POINTERTAP: number;
  7256. static readonly POINTERDOUBLETAP: number;
  7257. }
  7258. class PointerInfoBase {
  7259. type: number;
  7260. event: PointerEvent | MouseWheelEvent;
  7261. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  7262. }
  7263. /**
  7264. * This class is used to store pointer related info for the onPrePointerObservable event.
  7265. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  7266. */
  7267. class PointerInfoPre extends PointerInfoBase {
  7268. /**
  7269. * Ray from a pointer if availible (eg. 6dof controller)
  7270. */
  7271. ray: Nullable<Ray>;
  7272. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  7273. localPosition: Vector2;
  7274. skipOnPointerObservable: boolean;
  7275. }
  7276. /**
  7277. * This type contains all the data related to a pointer event in Babylon.js.
  7278. * 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.
  7279. */
  7280. class PointerInfo extends PointerInfoBase {
  7281. pickInfo: Nullable<PickingInfo>;
  7282. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  7283. }
  7284. }
  7285. declare module BABYLON {
  7286. /**
  7287. * Interface for attribute information associated with buffer instanciation
  7288. */
  7289. class InstancingAttributeInfo {
  7290. /**
  7291. * Index/offset of the attribute in the vertex shader
  7292. */
  7293. index: number;
  7294. /**
  7295. * size of the attribute, 1, 2, 3 or 4
  7296. */
  7297. attributeSize: number;
  7298. /**
  7299. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7300. * default is FLOAT
  7301. */
  7302. attribyteType: number;
  7303. /**
  7304. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7305. */
  7306. normalized: boolean;
  7307. /**
  7308. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7309. */
  7310. offset: number;
  7311. /**
  7312. * Name of the GLSL attribute, for debugging purpose only
  7313. */
  7314. attributeName: string;
  7315. }
  7316. /**
  7317. * Define options used to create a render target texture
  7318. */
  7319. class RenderTargetCreationOptions {
  7320. /**
  7321. * Specifies is mipmaps must be generated
  7322. */
  7323. generateMipMaps?: boolean;
  7324. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7325. generateDepthBuffer?: boolean;
  7326. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7327. generateStencilBuffer?: boolean;
  7328. /** Defines texture type (int by default) */
  7329. type?: number;
  7330. /** Defines sampling mode (trilinear by default) */
  7331. samplingMode?: number;
  7332. /** Defines format (RGBA by default) */
  7333. format?: number;
  7334. }
  7335. /**
  7336. * Define options used to create a depth texture
  7337. */
  7338. class DepthTextureCreationOptions {
  7339. /** Specifies whether or not a stencil should be allocated in the texture */
  7340. generateStencil?: boolean;
  7341. /** Specifies whether or not bilinear filtering is enable on the texture */
  7342. bilinearFiltering?: boolean;
  7343. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7344. comparisonFunction?: number;
  7345. /** Specifies if the created texture is a cube texture */
  7346. isCube?: boolean;
  7347. }
  7348. /**
  7349. * Class used to describe the capabilities of the engine relatively to the current browser
  7350. */
  7351. class EngineCapabilities {
  7352. /** Maximum textures units per fragment shader */
  7353. maxTexturesImageUnits: number;
  7354. /** Maximum texture units per vertex shader */
  7355. maxVertexTextureImageUnits: number;
  7356. /** Maximum textures units in the entire pipeline */
  7357. maxCombinedTexturesImageUnits: number;
  7358. /** Maximum texture size */
  7359. maxTextureSize: number;
  7360. /** Maximum cube texture size */
  7361. maxCubemapTextureSize: number;
  7362. /** Maximum render texture size */
  7363. maxRenderTextureSize: number;
  7364. /** Maximum number of vertex attributes */
  7365. maxVertexAttribs: number;
  7366. /** Maximum number of varyings */
  7367. maxVaryingVectors: number;
  7368. /** Maximum number of uniforms per vertex shader */
  7369. maxVertexUniformVectors: number;
  7370. /** Maximum number of uniforms per fragment shader */
  7371. maxFragmentUniformVectors: number;
  7372. /** Defines if standard derivates (dx/dy) are supported */
  7373. standardDerivatives: boolean;
  7374. /** Defines if s3tc texture compression is supported */
  7375. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7376. /** Defines if pvrtc texture compression is supported */
  7377. pvrtc: any;
  7378. /** Defines if etc1 texture compression is supported */
  7379. etc1: any;
  7380. /** Defines if etc2 texture compression is supported */
  7381. etc2: any;
  7382. /** Defines if astc texture compression is supported */
  7383. astc: any;
  7384. /** Defines if float textures are supported */
  7385. textureFloat: boolean;
  7386. /** Defines if vertex array objects are supported */
  7387. vertexArrayObject: boolean;
  7388. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7389. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7390. /** Gets the maximum level of anisotropy supported */
  7391. maxAnisotropy: number;
  7392. /** Defines if instancing is supported */
  7393. instancedArrays: boolean;
  7394. /** Defines if 32 bits indices are supported */
  7395. uintIndices: boolean;
  7396. /** Defines if high precision shaders are supported */
  7397. highPrecisionShaderSupported: boolean;
  7398. /** Defines if depth reading in the fragment shader is supported */
  7399. fragmentDepthSupported: boolean;
  7400. /** Defines if float texture linear filtering is supported*/
  7401. textureFloatLinearFiltering: boolean;
  7402. /** Defines if rendering to float textures is supported */
  7403. textureFloatRender: boolean;
  7404. /** Defines if half float textures are supported*/
  7405. textureHalfFloat: boolean;
  7406. /** Defines if half float texture linear filtering is supported*/
  7407. textureHalfFloatLinearFiltering: boolean;
  7408. /** Defines if rendering to half float textures is supported */
  7409. textureHalfFloatRender: boolean;
  7410. /** Defines if textureLOD shader command is supported */
  7411. textureLOD: boolean;
  7412. /** Defines if draw buffers extension is supported */
  7413. drawBuffersExtension: boolean;
  7414. /** Defines if depth textures are supported */
  7415. depthTextureExtension: boolean;
  7416. /** Defines if float color buffer are supported */
  7417. colorBufferFloat: boolean;
  7418. /** Gets disjoint timer query extension (null if not supported) */
  7419. timerQuery: EXT_disjoint_timer_query;
  7420. /** Defines if timestamp can be used with timer query */
  7421. canUseTimestampForTimerQuery: boolean;
  7422. }
  7423. /** Interface defining initialization parameters for Engine class */
  7424. interface EngineOptions extends WebGLContextAttributes {
  7425. /**
  7426. * Defines if the engine should no exceed a specified device ratio
  7427. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7428. */
  7429. limitDeviceRatio?: number;
  7430. /**
  7431. * Defines if webvr should be enabled automatically
  7432. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7433. */
  7434. autoEnableWebVR?: boolean;
  7435. /**
  7436. * Defines if webgl2 should be turned off even if supported
  7437. * @see http://doc.babylonjs.com/features/webgl2
  7438. */
  7439. disableWebGL2Support?: boolean;
  7440. /**
  7441. * Defines if webaudio should be initialized as well
  7442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7443. */
  7444. audioEngine?: boolean;
  7445. /**
  7446. * Defines if animations should run using a deterministic lock step
  7447. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7448. */
  7449. deterministicLockstep?: boolean;
  7450. /** Defines the maximum steps to use with deterministic lock step mode */
  7451. lockstepMaxSteps?: number;
  7452. /**
  7453. * Defines that engine should ignore context lost events
  7454. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7455. */
  7456. doNotHandleContextLost?: boolean;
  7457. }
  7458. /**
  7459. * Defines the interface used by display changed events
  7460. */
  7461. interface IDisplayChangedEventArgs {
  7462. /** Gets the vrDisplay object (if any) */
  7463. vrDisplay: Nullable<any>;
  7464. /** Gets a boolean indicating if webVR is supported */
  7465. vrSupported: boolean;
  7466. }
  7467. /**
  7468. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7469. */
  7470. class Engine {
  7471. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7472. static ExceptionList: ({
  7473. key: string;
  7474. capture: string;
  7475. captureConstraint: number;
  7476. targets: string[];
  7477. } | {
  7478. key: string;
  7479. capture: null;
  7480. captureConstraint: null;
  7481. targets: string[];
  7482. })[];
  7483. /** Gets the list of created engines */
  7484. static Instances: Engine[];
  7485. /**
  7486. * Gets the latest created engine
  7487. */
  7488. static readonly LastCreatedEngine: Nullable<Engine>;
  7489. /**
  7490. * Gets the latest created scene
  7491. */
  7492. static readonly LastCreatedScene: Nullable<Scene>;
  7493. /**
  7494. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7495. * @param flag defines which part of the materials must be marked as dirty
  7496. * @param predicate defines a predicate used to filter which materials should be affected
  7497. */
  7498. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7499. /**
  7500. * Hidden
  7501. */
  7502. static _TextureLoaders: IInternalTextureLoader[];
  7503. /** Defines that alpha blending is disabled */
  7504. static readonly ALPHA_DISABLE: number;
  7505. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7506. static readonly ALPHA_ADD: number;
  7507. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7508. static readonly ALPHA_COMBINE: number;
  7509. /** Defines that alpha blending to DEST - SRC * DEST */
  7510. static readonly ALPHA_SUBTRACT: number;
  7511. /** Defines that alpha blending to SRC * DEST */
  7512. static readonly ALPHA_MULTIPLY: number;
  7513. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7514. static readonly ALPHA_MAXIMIZED: number;
  7515. /** Defines that alpha blending to SRC + DEST */
  7516. static readonly ALPHA_ONEONE: number;
  7517. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7518. static readonly ALPHA_PREMULTIPLIED: number;
  7519. /**
  7520. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7521. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7522. */
  7523. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7524. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7525. static readonly ALPHA_INTERPOLATE: number;
  7526. /**
  7527. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7528. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7529. */
  7530. static readonly ALPHA_SCREENMODE: number;
  7531. /** Defines that the ressource is not delayed*/
  7532. static readonly DELAYLOADSTATE_NONE: number;
  7533. /** Defines that the ressource was successfully delay loaded */
  7534. static readonly DELAYLOADSTATE_LOADED: number;
  7535. /** Defines that the ressource is currently delay loading */
  7536. static readonly DELAYLOADSTATE_LOADING: number;
  7537. /** Defines that the ressource is delayed and has not started loading */
  7538. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7539. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7540. static readonly NEVER: number;
  7541. /** 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 */
  7542. static readonly ALWAYS: number;
  7543. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7544. static readonly LESS: number;
  7545. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7546. static readonly EQUAL: number;
  7547. /** 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 */
  7548. static readonly LEQUAL: number;
  7549. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7550. static readonly GREATER: number;
  7551. /** 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 */
  7552. static readonly GEQUAL: number;
  7553. /** 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 */
  7554. static readonly NOTEQUAL: number;
  7555. /** Passed to stencilOperation to specify that stencil value must be kept */
  7556. static readonly KEEP: number;
  7557. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7558. static readonly REPLACE: number;
  7559. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7560. static readonly INCR: number;
  7561. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7562. static readonly DECR: number;
  7563. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7564. static readonly INVERT: number;
  7565. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7566. static readonly INCR_WRAP: number;
  7567. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7568. static readonly DECR_WRAP: number;
  7569. /** Texture is not repeating outside of 0..1 UVs */
  7570. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7571. /** Texture is repeating outside of 0..1 UVs */
  7572. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7573. /** Texture is repeating and mirrored */
  7574. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7575. /** ALPHA */
  7576. static readonly TEXTUREFORMAT_ALPHA: number;
  7577. /** LUMINANCE */
  7578. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7579. /** LUMINANCE_ALPHA */
  7580. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7581. /** RGB */
  7582. static readonly TEXTUREFORMAT_RGB: number;
  7583. /** RGBA */
  7584. static readonly TEXTUREFORMAT_RGBA: number;
  7585. /** RED */
  7586. static readonly TEXTUREFORMAT_RED: number;
  7587. /** RED (2nd reference) */
  7588. static readonly TEXTUREFORMAT_R: number;
  7589. /** RG */
  7590. static readonly TEXTUREFORMAT_RG: number;
  7591. /** RED_INTEGER */
  7592. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7593. /** RED_INTEGER (2nd reference) */
  7594. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7595. /** RG_INTEGER */
  7596. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7597. /** RGB_INTEGER */
  7598. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7599. /** RGBA_INTEGER */
  7600. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7601. /** UNSIGNED_BYTE */
  7602. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7603. /** UNSIGNED_BYTE (2nd reference) */
  7604. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7605. /** FLOAT */
  7606. static readonly TEXTURETYPE_FLOAT: number;
  7607. /** HALF_FLOAT */
  7608. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7609. /** BYTE */
  7610. static readonly TEXTURETYPE_BYTE: number;
  7611. /** SHORT */
  7612. static readonly TEXTURETYPE_SHORT: number;
  7613. /** UNSIGNED_SHORT */
  7614. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7615. /** INT */
  7616. static readonly TEXTURETYPE_INT: number;
  7617. /** UNSIGNED_INT */
  7618. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7619. /** UNSIGNED_SHORT_4_4_4_4 */
  7620. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7621. /** UNSIGNED_SHORT_5_5_5_1 */
  7622. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7623. /** UNSIGNED_SHORT_5_6_5 */
  7624. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7625. /** UNSIGNED_INT_2_10_10_10_REV */
  7626. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7627. /** UNSIGNED_INT_24_8 */
  7628. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7629. /** UNSIGNED_INT_10F_11F_11F_REV */
  7630. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7631. /** UNSIGNED_INT_5_9_9_9_REV */
  7632. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7633. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7634. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7635. /** nearest is mag = nearest and min = nearest and mip = linear */
  7636. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7637. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7638. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7639. /** Trilinear is mag = linear and min = linear and mip = linear */
  7640. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7641. /** nearest is mag = nearest and min = nearest and mip = linear */
  7642. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7643. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7644. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7645. /** Trilinear is mag = linear and min = linear and mip = linear */
  7646. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7647. /** mag = nearest and min = nearest and mip = nearest */
  7648. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7649. /** mag = nearest and min = linear and mip = nearest */
  7650. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7651. /** mag = nearest and min = linear and mip = linear */
  7652. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7653. /** mag = nearest and min = linear and mip = none */
  7654. static readonly TEXTURE_NEAREST_LINEAR: number;
  7655. /** mag = nearest and min = nearest and mip = none */
  7656. static readonly TEXTURE_NEAREST_NEAREST: number;
  7657. /** mag = linear and min = nearest and mip = nearest */
  7658. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7659. /** mag = linear and min = nearest and mip = linear */
  7660. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7661. /** mag = linear and min = linear and mip = none */
  7662. static readonly TEXTURE_LINEAR_LINEAR: number;
  7663. /** mag = linear and min = nearest and mip = none */
  7664. static readonly TEXTURE_LINEAR_NEAREST: number;
  7665. /** Explicit coordinates mode */
  7666. static readonly TEXTURE_EXPLICIT_MODE: number;
  7667. /** Spherical coordinates mode */
  7668. static readonly TEXTURE_SPHERICAL_MODE: number;
  7669. /** Planar coordinates mode */
  7670. static readonly TEXTURE_PLANAR_MODE: number;
  7671. /** Cubic coordinates mode */
  7672. static readonly TEXTURE_CUBIC_MODE: number;
  7673. /** Projection coordinates mode */
  7674. static readonly TEXTURE_PROJECTION_MODE: number;
  7675. /** Skybox coordinates mode */
  7676. static readonly TEXTURE_SKYBOX_MODE: number;
  7677. /** Inverse Cubic coordinates mode */
  7678. static readonly TEXTURE_INVCUBIC_MODE: number;
  7679. /** Equirectangular coordinates mode */
  7680. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7681. /** Equirectangular Fixed coordinates mode */
  7682. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7683. /** Equirectangular Fixed Mirrored coordinates mode */
  7684. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7685. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7686. static readonly SCALEMODE_FLOOR: number;
  7687. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7688. static readonly SCALEMODE_NEAREST: number;
  7689. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7690. static readonly SCALEMODE_CEILING: number;
  7691. /**
  7692. * Returns the current version of the framework
  7693. */
  7694. static readonly Version: string;
  7695. /**
  7696. * Gets or sets the epsilon value used by collision engine
  7697. */
  7698. static CollisionsEpsilon: number;
  7699. /**
  7700. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7701. */
  7702. static CodeRepository: string;
  7703. /**
  7704. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7705. */
  7706. static ShadersRepository: string;
  7707. /**
  7708. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7709. */
  7710. forcePOTTextures: boolean;
  7711. /**
  7712. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7713. */
  7714. isFullscreen: boolean;
  7715. /**
  7716. * Gets a boolean indicating if the pointer is currently locked
  7717. */
  7718. isPointerLock: boolean;
  7719. /**
  7720. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7721. */
  7722. cullBackFaces: boolean;
  7723. /**
  7724. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7725. */
  7726. renderEvenInBackground: boolean;
  7727. /**
  7728. * Gets or sets a boolean indicating that cache can be kept between frames
  7729. */
  7730. preventCacheWipeBetweenFrames: boolean;
  7731. /**
  7732. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7733. **/
  7734. enableOfflineSupport: boolean;
  7735. /**
  7736. * 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)
  7737. **/
  7738. disableManifestCheck: boolean;
  7739. /**
  7740. * Gets the list of created scenes
  7741. */
  7742. scenes: Scene[];
  7743. /**
  7744. * Gets the list of created postprocesses
  7745. */
  7746. postProcesses: PostProcess[];
  7747. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7748. validateShaderPrograms: boolean;
  7749. /**
  7750. * Observable event triggered each time the rendering canvas is resized
  7751. */
  7752. onResizeObservable: Observable<Engine>;
  7753. /**
  7754. * Observable event triggered each time the canvas loses focus
  7755. */
  7756. onCanvasBlurObservable: Observable<Engine>;
  7757. /**
  7758. * Observable event triggered each time the canvas gains focus
  7759. */
  7760. onCanvasFocusObservable: Observable<Engine>;
  7761. /**
  7762. * Observable event triggered each time the canvas receives pointerout event
  7763. */
  7764. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7765. /**
  7766. * Observable event triggered before each texture is initialized
  7767. */
  7768. onBeforeTextureInitObservable: Observable<Texture>;
  7769. private _vrDisplay;
  7770. private _vrSupported;
  7771. private _oldSize;
  7772. private _oldHardwareScaleFactor;
  7773. private _vrExclusivePointerMode;
  7774. private _webVRInitPromise;
  7775. /**
  7776. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7777. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7778. */
  7779. readonly isInVRExclusivePointerMode: boolean;
  7780. /**
  7781. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7782. */
  7783. disableUniformBuffers: boolean;
  7784. /** @hidden */
  7785. _uniformBuffers: UniformBuffer[];
  7786. /**
  7787. * Gets a boolean indicating that the engine supports uniform buffers
  7788. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7789. */
  7790. readonly supportsUniformBuffers: boolean;
  7791. /**
  7792. * Observable raised when the engine begins a new frame
  7793. */
  7794. onBeginFrameObservable: Observable<Engine>;
  7795. /**
  7796. * Observable raised when the engine ends the current frame
  7797. */
  7798. onEndFrameObservable: Observable<Engine>;
  7799. /**
  7800. * Observable raised when the engine is about to compile a shader
  7801. */
  7802. onBeforeShaderCompilationObservable: Observable<Engine>;
  7803. /**
  7804. * Observable raised when the engine has jsut compiled a shader
  7805. */
  7806. onAfterShaderCompilationObservable: Observable<Engine>;
  7807. /** @hidden */
  7808. _gl: WebGLRenderingContext;
  7809. private _renderingCanvas;
  7810. private _windowIsBackground;
  7811. private _webGLVersion;
  7812. /**
  7813. * Gets a boolean indicating that only power of 2 textures are supported
  7814. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7815. */
  7816. readonly needPOTTextures: boolean;
  7817. /** @hidden */
  7818. _badOS: boolean;
  7819. /** @hidden */
  7820. _badDesktopOS: boolean;
  7821. /**
  7822. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7823. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7824. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7825. */
  7826. disableTextureBindingOptimization: boolean;
  7827. /**
  7828. * Gets the audio engine
  7829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7830. * @ignorenaming
  7831. */
  7832. static audioEngine: AudioEngine;
  7833. private _onFocus;
  7834. private _onBlur;
  7835. private _onCanvasPointerOut;
  7836. private _onCanvasBlur;
  7837. private _onCanvasFocus;
  7838. private _onFullscreenChange;
  7839. private _onPointerLockChange;
  7840. private _onVRDisplayPointerRestricted;
  7841. private _onVRDisplayPointerUnrestricted;
  7842. private _onVrDisplayConnect;
  7843. private _onVrDisplayDisconnect;
  7844. private _onVrDisplayPresentChange;
  7845. /**
  7846. * Observable signaled when VR display mode changes
  7847. */
  7848. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7849. /**
  7850. * Observable signaled when VR request present is complete
  7851. */
  7852. onVRRequestPresentComplete: Observable<boolean>;
  7853. /**
  7854. * Observable signaled when VR request present starts
  7855. */
  7856. onVRRequestPresentStart: Observable<Engine>;
  7857. private _hardwareScalingLevel;
  7858. /** @hidden */
  7859. protected _caps: EngineCapabilities;
  7860. private _pointerLockRequested;
  7861. private _isStencilEnable;
  7862. private _colorWrite;
  7863. private _loadingScreen;
  7864. /** @hidden */
  7865. _drawCalls: PerfCounter;
  7866. /** @hidden */
  7867. _textureCollisions: PerfCounter;
  7868. private _glVersion;
  7869. private _glRenderer;
  7870. private _glVendor;
  7871. private _videoTextureSupported;
  7872. private _renderingQueueLaunched;
  7873. private _activeRenderLoops;
  7874. private _deterministicLockstep;
  7875. private _lockstepMaxSteps;
  7876. /**
  7877. * Observable signaled when a context lost event is raised
  7878. */
  7879. onContextLostObservable: Observable<Engine>;
  7880. /**
  7881. * Observable signaled when a context restored event is raised
  7882. */
  7883. onContextRestoredObservable: Observable<Engine>;
  7884. private _onContextLost;
  7885. private _onContextRestored;
  7886. private _contextWasLost;
  7887. private _doNotHandleContextLost;
  7888. /**
  7889. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7891. */
  7892. doNotHandleContextLost: boolean;
  7893. private _performanceMonitor;
  7894. private _fps;
  7895. private _deltaTime;
  7896. /**
  7897. * Turn this value on if you want to pause FPS computation when in background
  7898. */
  7899. disablePerformanceMonitorInBackground: boolean;
  7900. /**
  7901. * Gets the performance monitor attached to this engine
  7902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7903. */
  7904. readonly performanceMonitor: PerformanceMonitor;
  7905. /** @hidden */
  7906. protected _depthCullingState: _DepthCullingState;
  7907. /** @hidden */
  7908. protected _stencilState: _StencilState;
  7909. /** @hidden */
  7910. protected _alphaState: _AlphaState;
  7911. /** @hidden */
  7912. protected _alphaMode: number;
  7913. protected _internalTexturesCache: InternalTexture[];
  7914. /** @hidden */
  7915. protected _activeChannel: number;
  7916. private _currentTextureChannel;
  7917. /** @hidden */
  7918. protected _boundTexturesCache: {
  7919. [key: string]: Nullable<InternalTexture>;
  7920. };
  7921. /** @hidden */
  7922. protected _currentEffect: Nullable<Effect>;
  7923. /** @hidden */
  7924. protected _currentProgram: Nullable<WebGLProgram>;
  7925. private _compiledEffects;
  7926. private _vertexAttribArraysEnabled;
  7927. /** @hidden */
  7928. protected _cachedViewport: Nullable<Viewport>;
  7929. private _cachedVertexArrayObject;
  7930. /** @hidden */
  7931. protected _cachedVertexBuffers: any;
  7932. /** @hidden */
  7933. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7934. /** @hidden */
  7935. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7936. /** @hidden */
  7937. protected _currentRenderTarget: Nullable<InternalTexture>;
  7938. private _uintIndicesCurrentlySet;
  7939. private _currentBoundBuffer;
  7940. /** @hidden */
  7941. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7942. private _currentBufferPointers;
  7943. private _currentInstanceLocations;
  7944. private _currentInstanceBuffers;
  7945. private _textureUnits;
  7946. private _firstBoundInternalTextureTracker;
  7947. private _lastBoundInternalTextureTracker;
  7948. private _workingCanvas;
  7949. private _workingContext;
  7950. private _rescalePostProcess;
  7951. private _dummyFramebuffer;
  7952. private _externalData;
  7953. private _bindedRenderFunction;
  7954. private _vaoRecordInProgress;
  7955. private _mustWipeVertexAttributes;
  7956. private _emptyTexture;
  7957. private _emptyCubeTexture;
  7958. private _emptyTexture3D;
  7959. private _frameHandler;
  7960. private _nextFreeTextureSlots;
  7961. private _maxSimultaneousTextures;
  7962. private _activeRequests;
  7963. private _texturesSupported;
  7964. private _textureFormatInUse;
  7965. /**
  7966. * Gets the list of texture formats supported
  7967. */
  7968. readonly texturesSupported: Array<string>;
  7969. /**
  7970. * Gets the list of texture formats in use
  7971. */
  7972. readonly textureFormatInUse: Nullable<string>;
  7973. /**
  7974. * Gets the current viewport
  7975. */
  7976. readonly currentViewport: Nullable<Viewport>;
  7977. /**
  7978. * Gets the default empty texture
  7979. */
  7980. readonly emptyTexture: InternalTexture;
  7981. /**
  7982. * Gets the default empty 3D texture
  7983. */
  7984. readonly emptyTexture3D: InternalTexture;
  7985. /**
  7986. * Gets the default empty cube texture
  7987. */
  7988. readonly emptyCubeTexture: InternalTexture;
  7989. /**
  7990. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7991. */
  7992. readonly premultipliedAlpha: boolean;
  7993. /**
  7994. * Creates a new engine
  7995. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  7996. * @param antialias defines enable antialiasing (default: false)
  7997. * @param options defines further options to be sent to the getContext() function
  7998. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7999. */
  8000. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  8001. private _rebuildInternalTextures;
  8002. private _rebuildEffects;
  8003. private _rebuildBuffers;
  8004. private _initGLContext;
  8005. /**
  8006. * Gets version of the current webGL context
  8007. */
  8008. readonly webGLVersion: number;
  8009. /**
  8010. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  8011. */
  8012. readonly isStencilEnable: boolean;
  8013. private _prepareWorkingCanvas;
  8014. /**
  8015. * Reset the texture cache to empty state
  8016. */
  8017. resetTextureCache(): void;
  8018. /**
  8019. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  8020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  8021. * @returns true if engine is in deterministic lock step mode
  8022. */
  8023. isDeterministicLockStep(): boolean;
  8024. /**
  8025. * Gets the max steps when engine is running in deterministic lock step
  8026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  8027. * @returns the max steps
  8028. */
  8029. getLockstepMaxSteps(): number;
  8030. /**
  8031. * Gets an object containing information about the current webGL context
  8032. * @returns an object containing the vender, the renderer and the version of the current webGL context
  8033. */
  8034. getGlInfo(): {
  8035. vendor: string;
  8036. renderer: string;
  8037. version: string;
  8038. };
  8039. /**
  8040. * Gets current aspect ratio
  8041. * @param camera defines the camera to use to get the aspect ratio
  8042. * @param useScreen defines if screen size must be used (or the current render target if any)
  8043. * @returns a number defining the aspect ratio
  8044. */
  8045. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  8046. /**
  8047. * Gets current screen aspect ratio
  8048. * @returns a number defining the aspect ratio
  8049. */
  8050. getScreenAspectRatio(): number;
  8051. /**
  8052. * Gets the current render width
  8053. * @param useScreen defines if screen size must be used (or the current render target if any)
  8054. * @returns a number defining the current render width
  8055. */
  8056. getRenderWidth(useScreen?: boolean): number;
  8057. /**
  8058. * Gets the current render height
  8059. * @param useScreen defines if screen size must be used (or the current render target if any)
  8060. * @returns a number defining the current render height
  8061. */
  8062. getRenderHeight(useScreen?: boolean): number;
  8063. /**
  8064. * Gets the HTML canvas attached with the current webGL context
  8065. * @returns a HTML canvas
  8066. */
  8067. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  8068. /**
  8069. * Gets the client rect of the HTML canvas attached with the current webGL context
  8070. * @returns a client rectanglee
  8071. */
  8072. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  8073. /**
  8074. * Defines the hardware scaling level.
  8075. * By default the hardware scaling level is computed from the window device ratio.
  8076. * 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.
  8077. * @param level defines the level to use
  8078. */
  8079. setHardwareScalingLevel(level: number): void;
  8080. /**
  8081. * Gets the current hardware scaling level.
  8082. * By default the hardware scaling level is computed from the window device ratio.
  8083. * 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.
  8084. * @returns a number indicating the current hardware scaling level
  8085. */
  8086. getHardwareScalingLevel(): number;
  8087. /**
  8088. * Gets the list of loaded textures
  8089. * @returns an array containing all loaded textures
  8090. */
  8091. getLoadedTexturesCache(): InternalTexture[];
  8092. /**
  8093. * Gets the object containing all engine capabilities
  8094. * @returns the EngineCapabilities object
  8095. */
  8096. getCaps(): EngineCapabilities;
  8097. /** @hidden */
  8098. readonly drawCalls: number;
  8099. /** @hidden */
  8100. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  8101. /**
  8102. * Gets the current depth function
  8103. * @returns a number defining the depth function
  8104. */
  8105. getDepthFunction(): Nullable<number>;
  8106. /**
  8107. * Sets the current depth function
  8108. * @param depthFunc defines the function to use
  8109. */
  8110. setDepthFunction(depthFunc: number): void;
  8111. /**
  8112. * Sets the current depth function to GREATER
  8113. */
  8114. setDepthFunctionToGreater(): void;
  8115. /**
  8116. * Sets the current depth function to GEQUAL
  8117. */
  8118. setDepthFunctionToGreaterOrEqual(): void;
  8119. /**
  8120. * Sets the current depth function to LESS
  8121. */
  8122. setDepthFunctionToLess(): void;
  8123. /**
  8124. * Sets the current depth function to LEQUAL
  8125. */
  8126. setDepthFunctionToLessOrEqual(): void;
  8127. /**
  8128. * Gets a boolean indicating if stencil buffer is enabled
  8129. * @returns the current stencil buffer state
  8130. */
  8131. getStencilBuffer(): boolean;
  8132. /**
  8133. * Enable or disable the stencil buffer
  8134. * @param enable defines if the stencil buffer must be enabled or disabled
  8135. */
  8136. setStencilBuffer(enable: boolean): void;
  8137. /**
  8138. * Gets the current stencil mask
  8139. * @returns a number defining the new stencil mask to use
  8140. */
  8141. getStencilMask(): number;
  8142. /**
  8143. * Sets the current stencil mask
  8144. * @param mask defines the new stencil mask to use
  8145. */
  8146. setStencilMask(mask: number): void;
  8147. /**
  8148. * Gets the current stencil function
  8149. * @returns a number defining the stencil function to use
  8150. */
  8151. getStencilFunction(): number;
  8152. /**
  8153. * Gets the current stencil reference value
  8154. * @returns a number defining the stencil reference value to use
  8155. */
  8156. getStencilFunctionReference(): number;
  8157. /**
  8158. * Gets the current stencil mask
  8159. * @returns a number defining the stencil mask to use
  8160. */
  8161. getStencilFunctionMask(): number;
  8162. /**
  8163. * Sets the current stencil function
  8164. * @param stencilFunc defines the new stencil function to use
  8165. */
  8166. setStencilFunction(stencilFunc: number): void;
  8167. /**
  8168. * Sets the current stencil reference
  8169. * @param reference defines the new stencil reference to use
  8170. */
  8171. setStencilFunctionReference(reference: number): void;
  8172. /**
  8173. * Sets the current stencil mask
  8174. * @param mask defines the new stencil mask to use
  8175. */
  8176. setStencilFunctionMask(mask: number): void;
  8177. /**
  8178. * Gets the current stencil operation when stencil fails
  8179. * @returns a number defining stencil operation to use when stencil fails
  8180. */
  8181. getStencilOperationFail(): number;
  8182. /**
  8183. * Gets the current stencil operation when depth fails
  8184. * @returns a number defining stencil operation to use when depth fails
  8185. */
  8186. getStencilOperationDepthFail(): number;
  8187. /**
  8188. * Gets the current stencil operation when stencil passes
  8189. * @returns a number defining stencil operation to use when stencil passes
  8190. */
  8191. getStencilOperationPass(): number;
  8192. /**
  8193. * Sets the stencil operation to use when stencil fails
  8194. * @param operation defines the stencil operation to use when stencil fails
  8195. */
  8196. setStencilOperationFail(operation: number): void;
  8197. /**
  8198. * Sets the stencil operation to use when depth fails
  8199. * @param operation defines the stencil operation to use when depth fails
  8200. */
  8201. setStencilOperationDepthFail(operation: number): void;
  8202. /**
  8203. * Sets the stencil operation to use when stencil passes
  8204. * @param operation defines the stencil operation to use when stencil passes
  8205. */
  8206. setStencilOperationPass(operation: number): void;
  8207. /**
  8208. * Sets a boolean indicating if the dithering state is enabled or disabled
  8209. * @param value defines the dithering state
  8210. */
  8211. setDitheringState(value: boolean): void;
  8212. /**
  8213. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8214. * @param value defines the rasterizer state
  8215. */
  8216. setRasterizerState(value: boolean): void;
  8217. /**
  8218. * stop executing a render loop function and remove it from the execution array
  8219. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8220. */
  8221. stopRenderLoop(renderFunction?: () => void): void;
  8222. /** @hidden */
  8223. _renderLoop(): void;
  8224. /**
  8225. * Register and execute a render loop. The engine can have more than one render function
  8226. * @param renderFunction defines the function to continuously execute
  8227. */
  8228. runRenderLoop(renderFunction: () => void): void;
  8229. /**
  8230. * Toggle full screen mode
  8231. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8232. * @param options defines an option object to be sent to the requestFullscreen function
  8233. */
  8234. switchFullscreen(requestPointerLock: boolean): void;
  8235. /**
  8236. * Clear the current render buffer or the current render target (if any is set up)
  8237. * @param color defines the color to use
  8238. * @param backBuffer defines if the back buffer must be cleared
  8239. * @param depth defines if the depth buffer must be cleared
  8240. * @param stencil defines if the stencil buffer must be cleared
  8241. */
  8242. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8243. /**
  8244. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8245. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8246. * @param y defines the y-coordinate of the corner of the clear rectangle
  8247. * @param width defines the width of the clear rectangle
  8248. * @param height defines the height of the clear rectangle
  8249. * @param clearColor defines the clear color
  8250. */
  8251. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8252. private _viewportCached;
  8253. /** @hidden */
  8254. _viewport(x: number, y: number, width: number, height: number): void;
  8255. /**
  8256. * Set the WebGL's viewport
  8257. * @param viewport defines the viewport element to be used
  8258. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8259. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8260. */
  8261. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8262. /**
  8263. * Directly set the WebGL Viewport
  8264. * @param x defines the x coordinate of the viewport (in screen space)
  8265. * @param y defines the y coordinate of the viewport (in screen space)
  8266. * @param width defines the width of the viewport (in screen space)
  8267. * @param height defines the height of the viewport (in screen space)
  8268. * @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
  8269. */
  8270. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8271. /**
  8272. * Begin a new frame
  8273. */
  8274. beginFrame(): void;
  8275. /**
  8276. * Enf the current frame
  8277. */
  8278. endFrame(): void;
  8279. /**
  8280. * Resize the view according to the canvas' size
  8281. */
  8282. resize(): void;
  8283. /**
  8284. * Force a specific size of the canvas
  8285. * @param width defines the new canvas' width
  8286. * @param height defines the new canvas' height
  8287. */
  8288. setSize(width: number, height: number): void;
  8289. /**
  8290. * Gets a boolean indicating if a webVR device was detected
  8291. * @returns true if a webVR device was detected
  8292. */
  8293. isVRDevicePresent(): boolean;
  8294. /**
  8295. * Gets the current webVR device
  8296. * @returns the current webVR device (or null)
  8297. */
  8298. getVRDevice(): any;
  8299. /**
  8300. * Initializes a webVR display and starts listening to display change events
  8301. * The onVRDisplayChangedObservable will be notified upon these changes
  8302. * @returns The onVRDisplayChangedObservable
  8303. */
  8304. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8305. /**
  8306. * Initializes a webVR display and starts listening to display change events
  8307. * The onVRDisplayChangedObservable will be notified upon these changes
  8308. * @returns A promise containing a VRDisplay and if vr is supported
  8309. */
  8310. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8311. /**
  8312. * Call this function to switch to webVR mode
  8313. * Will do nothing if webVR is not supported or if there is no webVR device
  8314. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8315. */
  8316. enableVR(): void;
  8317. /**
  8318. * Call this function to leave webVR mode
  8319. * Will do nothing if webVR is not supported or if there is no webVR device
  8320. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8321. */
  8322. disableVR(): void;
  8323. private _onVRFullScreenTriggered;
  8324. private _getVRDisplaysAsync;
  8325. /**
  8326. * Binds the frame buffer to the specified texture.
  8327. * @param texture The texture to render to or null for the default canvas
  8328. * @param faceIndex The face of the texture to render to in case of cube texture
  8329. * @param requiredWidth The width of the target to render to
  8330. * @param requiredHeight The height of the target to render to
  8331. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8332. * @param depthStencilTexture The depth stencil texture to use to render
  8333. * @param lodLevel defines le lod level to bind to the frame buffer
  8334. */
  8335. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8336. private bindUnboundFramebuffer;
  8337. /**
  8338. * Unbind the current render target texture from the webGL context
  8339. * @param texture defines the render target texture to unbind
  8340. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8341. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8342. */
  8343. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8344. /**
  8345. * Unbind a list of render target textures from the webGL context
  8346. * This is used only when drawBuffer extension or webGL2 are active
  8347. * @param textures defines the render target textures to unbind
  8348. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8349. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8350. */
  8351. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8352. /**
  8353. * Force the mipmap generation for the given render target texture
  8354. * @param texture defines the render target texture to use
  8355. */
  8356. generateMipMapsForCubemap(texture: InternalTexture): void;
  8357. /**
  8358. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8359. */
  8360. flushFramebuffer(): void;
  8361. /**
  8362. * Unbind the current render target and bind the default framebuffer
  8363. */
  8364. restoreDefaultFramebuffer(): void;
  8365. /**
  8366. * Create an uniform buffer
  8367. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8368. * @param elements defines the content of the uniform buffer
  8369. * @returns the webGL uniform buffer
  8370. */
  8371. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8372. /**
  8373. * Create a dynamic uniform buffer
  8374. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8375. * @param elements defines the content of the uniform buffer
  8376. * @returns the webGL uniform buffer
  8377. */
  8378. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8379. /**
  8380. * Update an existing uniform buffer
  8381. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8382. * @param uniformBuffer defines the target uniform buffer
  8383. * @param elements defines the content to update
  8384. * @param offset defines the offset in the uniform buffer where update should start
  8385. * @param count defines the size of the data to update
  8386. */
  8387. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8388. private _resetVertexBufferBinding;
  8389. /**
  8390. * Creates a vertex buffer
  8391. * @param data the data for the vertex buffer
  8392. * @returns the new WebGL static buffer
  8393. */
  8394. createVertexBuffer(data: DataArray): WebGLBuffer;
  8395. /**
  8396. * Creates a dynamic vertex buffer
  8397. * @param data the data for the dynamic vertex buffer
  8398. * @returns the new WebGL dynamic buffer
  8399. */
  8400. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8401. /**
  8402. * Update a dynamic index buffer
  8403. * @param indexBuffer defines the target index buffer
  8404. * @param indices defines the data to update
  8405. * @param offset defines the offset in the target index buffer where update should start
  8406. */
  8407. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8408. /**
  8409. * Updates a dynamic vertex buffer.
  8410. * @param vertexBuffer the vertex buffer to update
  8411. * @param data the data used to update the vertex buffer
  8412. * @param byteOffset the byte offset of the data
  8413. * @param byteLength the byte length of the data
  8414. */
  8415. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8416. private _resetIndexBufferBinding;
  8417. /**
  8418. * Creates a new index buffer
  8419. * @param indices defines the content of the index buffer
  8420. * @param updatable defines if the index buffer must be updatable
  8421. * @returns a new webGL buffer
  8422. */
  8423. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8424. /**
  8425. * Bind a webGL buffer to the webGL context
  8426. * @param buffer defines the buffer to bind
  8427. */
  8428. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8429. /**
  8430. * Bind an uniform buffer to the current webGL context
  8431. * @param buffer defines the buffer to bind
  8432. */
  8433. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8434. /**
  8435. * Bind a buffer to the current webGL context at a given location
  8436. * @param buffer defines the buffer to bind
  8437. * @param location defines the index where to bind the buffer
  8438. */
  8439. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8440. /**
  8441. * Bind a specific block at a given index in a specific shader program
  8442. * @param shaderProgram defines the shader program
  8443. * @param blockName defines the block name
  8444. * @param index defines the index where to bind the block
  8445. */
  8446. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8447. private bindIndexBuffer;
  8448. private bindBuffer;
  8449. /**
  8450. * update the bound buffer with the given data
  8451. * @param data defines the data to update
  8452. */
  8453. updateArrayBuffer(data: Float32Array): void;
  8454. private _vertexAttribPointer;
  8455. private _bindIndexBufferWithCache;
  8456. private _bindVertexBuffersAttributes;
  8457. /**
  8458. * Records a vertex array object
  8459. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8460. * @param vertexBuffers defines the list of vertex buffers to store
  8461. * @param indexBuffer defines the index buffer to store
  8462. * @param effect defines the effect to store
  8463. * @returns the new vertex array object
  8464. */
  8465. recordVertexArrayObject(vertexBuffers: {
  8466. [key: string]: VertexBuffer;
  8467. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8468. /**
  8469. * Bind a specific vertex array object
  8470. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8471. * @param vertexArrayObject defines the vertex array object to bind
  8472. * @param indexBuffer defines the index buffer to bind
  8473. */
  8474. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8475. /**
  8476. * Bind webGl buffers directly to the webGL context
  8477. * @param vertexBuffer defines the vertex buffer to bind
  8478. * @param indexBuffer defines the index buffer to bind
  8479. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8480. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8481. * @param effect defines the effect associated with the vertex buffer
  8482. */
  8483. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8484. private _unbindVertexArrayObject;
  8485. /**
  8486. * Bind a list of vertex buffers to the webGL context
  8487. * @param vertexBuffers defines the list of vertex buffers to bind
  8488. * @param indexBuffer defines the index buffer to bind
  8489. * @param effect defines the effect associated with the vertex buffers
  8490. */
  8491. bindBuffers(vertexBuffers: {
  8492. [key: string]: Nullable<VertexBuffer>;
  8493. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8494. /**
  8495. * Unbind all instance attributes
  8496. */
  8497. unbindInstanceAttributes(): void;
  8498. /**
  8499. * Release and free the memory of a vertex array object
  8500. * @param vao defines the vertex array object to delete
  8501. */
  8502. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8503. /** @hidden */
  8504. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8505. /**
  8506. * Creates a webGL buffer to use with instanciation
  8507. * @param capacity defines the size of the buffer
  8508. * @returns the webGL buffer
  8509. */
  8510. createInstancesBuffer(capacity: number): WebGLBuffer;
  8511. /**
  8512. * Delete a webGL buffer used with instanciation
  8513. * @param buffer defines the webGL buffer to delete
  8514. */
  8515. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8516. /**
  8517. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8518. * @param instancesBuffer defines the webGL buffer to update and bind
  8519. * @param data defines the data to store in the buffer
  8520. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8521. */
  8522. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8523. /**
  8524. * Apply all cached states (depth, culling, stencil and alpha)
  8525. */
  8526. applyStates(): void;
  8527. /**
  8528. * Send a draw order
  8529. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8530. * @param indexStart defines the starting index
  8531. * @param indexCount defines the number of index to draw
  8532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8533. */
  8534. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8535. /**
  8536. * Draw a list of points
  8537. * @param verticesStart defines the index of first vertex to draw
  8538. * @param verticesCount defines the count of vertices to draw
  8539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8540. */
  8541. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8542. /**
  8543. * Draw a list of unindexed primitives
  8544. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8545. * @param verticesStart defines the index of first vertex to draw
  8546. * @param verticesCount defines the count of vertices to draw
  8547. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8548. */
  8549. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8550. /**
  8551. * Draw a list of indexed primitives
  8552. * @param fillMode defines the primitive to use
  8553. * @param indexStart defines the starting index
  8554. * @param indexCount defines the number of index to draw
  8555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8556. */
  8557. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8558. /**
  8559. * Draw a list of unindexed primitives
  8560. * @param fillMode defines the primitive to use
  8561. * @param verticesStart defines the index of first vertex to draw
  8562. * @param verticesCount defines the count of vertices to draw
  8563. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8564. */
  8565. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8566. private _drawMode;
  8567. /** @hidden */
  8568. _releaseEffect(effect: Effect): void;
  8569. /** @hidden */
  8570. _deleteProgram(program: WebGLProgram): void;
  8571. /**
  8572. * Create a new effect (used to store vertex/fragment shaders)
  8573. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8574. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8575. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8576. * @param samplers defines an array of string used to represent textures
  8577. * @param defines defines the string containing the defines to use to compile the shaders
  8578. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8579. * @param onCompiled defines a function to call when the effect creation is successful
  8580. * @param onError defines a function to call when the effect creation has failed
  8581. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8582. * @returns the new Effect
  8583. */
  8584. 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;
  8585. private _compileShader;
  8586. private _compileRawShader;
  8587. /**
  8588. * Directly creates a webGL program
  8589. * @param vertexCode defines the vertex shader code to use
  8590. * @param fragmentCode defines the fragment shader code to use
  8591. * @param context defines the webGL context to use (if not set, the current one will be used)
  8592. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8593. * @returns the new webGL program
  8594. */
  8595. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8596. /**
  8597. * Creates a webGL program
  8598. * @param vertexCode defines the vertex shader code to use
  8599. * @param fragmentCode defines the fragment shader code to use
  8600. * @param defines defines the string containing the defines to use to compile the shaders
  8601. * @param context defines the webGL context to use (if not set, the current one will be used)
  8602. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8603. * @returns the new webGL program
  8604. */
  8605. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8606. private _createShaderProgram;
  8607. /**
  8608. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8609. * @param shaderProgram defines the webGL program to use
  8610. * @param uniformsNames defines the list of uniform names
  8611. * @returns an array of webGL uniform locations
  8612. */
  8613. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8614. /**
  8615. * Gets the lsit of active attributes for a given webGL program
  8616. * @param shaderProgram defines the webGL program to use
  8617. * @param attributesNames defines the list of attribute names to get
  8618. * @returns an array of indices indicating the offset of each attribute
  8619. */
  8620. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8621. /**
  8622. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8623. * @param effect defines the effect to activate
  8624. */
  8625. enableEffect(effect: Nullable<Effect>): void;
  8626. /**
  8627. * Set the value of an uniform to an array of int32
  8628. * @param uniform defines the webGL uniform location where to store the value
  8629. * @param array defines the array of int32 to store
  8630. */
  8631. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8632. /**
  8633. * Set the value of an uniform to an array of int32 (stored as vec2)
  8634. * @param uniform defines the webGL uniform location where to store the value
  8635. * @param array defines the array of int32 to store
  8636. */
  8637. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8638. /**
  8639. * Set the value of an uniform to an array of int32 (stored as vec3)
  8640. * @param uniform defines the webGL uniform location where to store the value
  8641. * @param array defines the array of int32 to store
  8642. */
  8643. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8644. /**
  8645. * Set the value of an uniform to an array of int32 (stored as vec4)
  8646. * @param uniform defines the webGL uniform location where to store the value
  8647. * @param array defines the array of int32 to store
  8648. */
  8649. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8650. /**
  8651. * Set the value of an uniform to an array of float32
  8652. * @param uniform defines the webGL uniform location where to store the value
  8653. * @param array defines the array of float32 to store
  8654. */
  8655. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8656. /**
  8657. * Set the value of an uniform to an array of float32 (stored as vec2)
  8658. * @param uniform defines the webGL uniform location where to store the value
  8659. * @param array defines the array of float32 to store
  8660. */
  8661. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8662. /**
  8663. * Set the value of an uniform to an array of float32 (stored as vec3)
  8664. * @param uniform defines the webGL uniform location where to store the value
  8665. * @param array defines the array of float32 to store
  8666. */
  8667. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8668. /**
  8669. * Set the value of an uniform to an array of float32 (stored as vec4)
  8670. * @param uniform defines the webGL uniform location where to store the value
  8671. * @param array defines the array of float32 to store
  8672. */
  8673. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8674. /**
  8675. * Set the value of an uniform to an array of number
  8676. * @param uniform defines the webGL uniform location where to store the value
  8677. * @param array defines the array of number to store
  8678. */
  8679. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8680. /**
  8681. * Set the value of an uniform to an array of number (stored as vec2)
  8682. * @param uniform defines the webGL uniform location where to store the value
  8683. * @param array defines the array of number to store
  8684. */
  8685. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8686. /**
  8687. * Set the value of an uniform to an array of number (stored as vec3)
  8688. * @param uniform defines the webGL uniform location where to store the value
  8689. * @param array defines the array of number to store
  8690. */
  8691. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8692. /**
  8693. * Set the value of an uniform to an array of number (stored as vec4)
  8694. * @param uniform defines the webGL uniform location where to store the value
  8695. * @param array defines the array of number to store
  8696. */
  8697. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8698. /**
  8699. * Set the value of an uniform to an array of float32 (stored as matrices)
  8700. * @param uniform defines the webGL uniform location where to store the value
  8701. * @param matrices defines the array of float32 to store
  8702. */
  8703. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8704. /**
  8705. * Set the value of an uniform to a matrix
  8706. * @param uniform defines the webGL uniform location where to store the value
  8707. * @param matrix defines the matrix to store
  8708. */
  8709. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8710. /**
  8711. * Set the value of an uniform to a matrix (3x3)
  8712. * @param uniform defines the webGL uniform location where to store the value
  8713. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8714. */
  8715. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8716. /**
  8717. * Set the value of an uniform to a matrix (2x2)
  8718. * @param uniform defines the webGL uniform location where to store the value
  8719. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8720. */
  8721. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8722. /**
  8723. * Set the value of an uniform to a number (int)
  8724. * @param uniform defines the webGL uniform location where to store the value
  8725. * @param value defines the int number to store
  8726. */
  8727. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8728. /**
  8729. * Set the value of an uniform to a number (float)
  8730. * @param uniform defines the webGL uniform location where to store the value
  8731. * @param value defines the float number to store
  8732. */
  8733. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8734. /**
  8735. * Set the value of an uniform to a vec2
  8736. * @param uniform defines the webGL uniform location where to store the value
  8737. * @param x defines the 1st component of the value
  8738. * @param y defines the 2nd component of the value
  8739. */
  8740. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8741. /**
  8742. * Set the value of an uniform to a vec3
  8743. * @param uniform defines the webGL uniform location where to store the value
  8744. * @param x defines the 1st component of the value
  8745. * @param y defines the 2nd component of the value
  8746. * @param z defines the 3rd component of the value
  8747. */
  8748. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8749. /**
  8750. * Set the value of an uniform to a boolean
  8751. * @param uniform defines the webGL uniform location where to store the value
  8752. * @param bool defines the boolean to store
  8753. */
  8754. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8755. /**
  8756. * Set the value of an uniform to a vec4
  8757. * @param uniform defines the webGL uniform location where to store the value
  8758. * @param x defines the 1st component of the value
  8759. * @param y defines the 2nd component of the value
  8760. * @param z defines the 3rd component of the value
  8761. * @param w defines the 4th component of the value
  8762. */
  8763. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8764. /**
  8765. * Set the value of an uniform to a Color3
  8766. * @param uniform defines the webGL uniform location where to store the value
  8767. * @param color3 defines the color to store
  8768. */
  8769. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8770. /**
  8771. * Set the value of an uniform to a Color3 and an alpha value
  8772. * @param uniform defines the webGL uniform location where to store the value
  8773. * @param color3 defines the color to store
  8774. * @param alpha defines the alpha component to store
  8775. */
  8776. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8777. /**
  8778. * Sets a Color4 on a uniform variable
  8779. * @param uniform defines the uniform location
  8780. * @param color4 defines the value to be set
  8781. */
  8782. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8783. /**
  8784. * Set various states to the webGL context
  8785. * @param culling defines backface culling state
  8786. * @param zOffset defines the value to apply to zOffset (0 by default)
  8787. * @param force defines if states must be applied even if cache is up to date
  8788. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8789. */
  8790. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8791. /**
  8792. * Set the z offset to apply to current rendering
  8793. * @param value defines the offset to apply
  8794. */
  8795. setZOffset(value: number): void;
  8796. /**
  8797. * Gets the current value of the zOffset
  8798. * @returns the current zOffset state
  8799. */
  8800. getZOffset(): number;
  8801. /**
  8802. * Enable or disable depth buffering
  8803. * @param enable defines the state to set
  8804. */
  8805. setDepthBuffer(enable: boolean): void;
  8806. /**
  8807. * Gets a boolean indicating if depth writing is enabled
  8808. * @returns the current depth writing state
  8809. */
  8810. getDepthWrite(): boolean;
  8811. /**
  8812. * Enable or disable depth writing
  8813. * @param enable defines the state to set
  8814. */
  8815. setDepthWrite(enable: boolean): void;
  8816. /**
  8817. * Enable or disable color writing
  8818. * @param enable defines the state to set
  8819. */
  8820. setColorWrite(enable: boolean): void;
  8821. /**
  8822. * Gets a boolean indicating if color writing is enabled
  8823. * @returns the current color writing state
  8824. */
  8825. getColorWrite(): boolean;
  8826. /**
  8827. * Sets alpha constants used by some alpha blending modes
  8828. * @param r defines the red component
  8829. * @param g defines the green component
  8830. * @param b defines the blue component
  8831. * @param a defines the alpha component
  8832. */
  8833. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8834. /**
  8835. * Sets the current alpha mode
  8836. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8837. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8838. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8839. */
  8840. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8841. /**
  8842. * Gets the current alpha mode
  8843. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8844. * @returns the current alpha mode
  8845. */
  8846. getAlphaMode(): number;
  8847. /**
  8848. * Clears the list of texture accessible through engine.
  8849. * This can help preventing texture load conflict due to name collision.
  8850. */
  8851. clearInternalTexturesCache(): void;
  8852. /**
  8853. * Force the entire cache to be cleared
  8854. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8855. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8856. */
  8857. wipeCaches(bruteForce?: boolean): void;
  8858. /**
  8859. * Set the compressed texture format to use, based on the formats you have, and the formats
  8860. * supported by the hardware / browser.
  8861. *
  8862. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8863. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8864. * to API arguments needed to compressed textures. This puts the burden on the container
  8865. * generator to house the arcane code for determining these for current & future formats.
  8866. *
  8867. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8868. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8869. *
  8870. * Note: The result of this call is not taken into account when a texture is base64.
  8871. *
  8872. * @param formatsAvailable defines the list of those format families you have created
  8873. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8874. *
  8875. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8876. * @returns The extension selected.
  8877. */
  8878. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8879. private _getSamplingParameters;
  8880. private _partialLoadImg;
  8881. private _cascadeLoadImgs;
  8882. /** @hidden */
  8883. _createTexture(): WebGLTexture;
  8884. /**
  8885. * Usually called from BABYLON.Texture.ts.
  8886. * Passed information to create a WebGLTexture
  8887. * @param urlArg defines a value which contains one of the following:
  8888. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8889. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8890. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8892. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8893. * @param scene needed for loading to the correct scene
  8894. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8895. * @param onLoad optional callback to be called upon successful completion
  8896. * @param onError optional callback to be called upon failure
  8897. * @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
  8898. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8899. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8900. * @param forcedExtension defines the extension to use to pick the right loader
  8901. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8902. */
  8903. 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>, forcedExtension?: Nullable<string>): InternalTexture;
  8904. private _rescaleTexture;
  8905. /**
  8906. * Update a raw texture
  8907. * @param texture defines the texture to update
  8908. * @param data defines the data to store in the texture
  8909. * @param format defines the format of the data
  8910. * @param invertY defines if data must be stored with Y axis inverted
  8911. * @param compression defines the compression used (null by default)
  8912. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8913. */
  8914. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8915. /**
  8916. * Creates a raw texture
  8917. * @param data defines the data to store in the texture
  8918. * @param width defines the width of the texture
  8919. * @param height defines the height of the texture
  8920. * @param format defines the format of the data
  8921. * @param generateMipMaps defines if the engine should generate the mip levels
  8922. * @param invertY defines if data must be stored with Y axis inverted
  8923. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8924. * @param compression defines the compression used (null by default)
  8925. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8926. * @returns the raw texture inside an InternalTexture
  8927. */
  8928. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8929. private _unpackFlipYCached;
  8930. /** @hidden */
  8931. _unpackFlipY(value: boolean): void;
  8932. /** @hidden */
  8933. _getUnpackAlignement(): number;
  8934. /**
  8935. * Creates a dynamic texture
  8936. * @param width defines the width of the texture
  8937. * @param height defines the height of the texture
  8938. * @param generateMipMaps defines if the engine should generate the mip levels
  8939. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8940. * @returns the dynamic texture inside an InternalTexture
  8941. */
  8942. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8943. /**
  8944. * Update the sampling mode of a given texture
  8945. * @param samplingMode defines the required sampling mode
  8946. * @param texture defines the texture to update
  8947. */
  8948. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8949. /**
  8950. * Update the content of a dynamic texture
  8951. * @param texture defines the texture to update
  8952. * @param canvas defines the canvas containing the source
  8953. * @param invertY defines if data must be stored with Y axis inverted
  8954. * @param premulAlpha defines if alpha is stored as premultiplied
  8955. * @param format defines the format of the data
  8956. */
  8957. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8958. /**
  8959. * Update a video texture
  8960. * @param texture defines the texture to update
  8961. * @param video defines the video element to use
  8962. * @param invertY defines if data must be stored with Y axis inverted
  8963. */
  8964. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8965. /**
  8966. * Updates a depth texture Comparison Mode and Function.
  8967. * If the comparison Function is equal to 0, the mode will be set to none.
  8968. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8969. * @param texture The texture to set the comparison function for
  8970. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8971. */
  8972. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8973. private _setupDepthStencilTexture;
  8974. /**
  8975. * Creates a depth stencil texture.
  8976. * This is only available in WebGL 2 or with the depth texture extension available.
  8977. * @param size The size of face edge in the texture.
  8978. * @param options The options defining the texture.
  8979. * @returns The texture
  8980. */
  8981. createDepthStencilTexture(size: number | {
  8982. width: number;
  8983. height: number;
  8984. }, options: DepthTextureCreationOptions): InternalTexture;
  8985. /**
  8986. * Creates a depth stencil texture.
  8987. * This is only available in WebGL 2 or with the depth texture extension available.
  8988. * @param size The size of face edge in the texture.
  8989. * @param options The options defining the texture.
  8990. * @returns The texture
  8991. */
  8992. private _createDepthStencilTexture;
  8993. /**
  8994. * Creates a depth stencil cube texture.
  8995. * This is only available in WebGL 2.
  8996. * @param size The size of face edge in the cube texture.
  8997. * @param options The options defining the cube texture.
  8998. * @returns The cube texture
  8999. */
  9000. private _createDepthStencilCubeTexture;
  9001. /**
  9002. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  9003. * @param renderTarget The render target to set the frame buffer for
  9004. */
  9005. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  9006. /**
  9007. * Creates a new render target texture
  9008. * @param size defines the size of the texture
  9009. * @param options defines the options used to create the texture
  9010. * @returns a new render target texture stored in an InternalTexture
  9011. */
  9012. createRenderTargetTexture(size: number | {
  9013. width: number;
  9014. height: number;
  9015. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9016. /**
  9017. * Create a multi render target texture
  9018. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  9019. * @param size defines the size of the texture
  9020. * @param options defines the creation options
  9021. * @returns the cube texture as an InternalTexture
  9022. */
  9023. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  9024. private _setupFramebufferDepthAttachments;
  9025. /**
  9026. * Updates the sample count of a render target texture
  9027. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  9028. * @param texture defines the texture to update
  9029. * @param samples defines the sample count to set
  9030. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  9031. */
  9032. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  9033. /**
  9034. * Update the sample count for a given multiple render target texture
  9035. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  9036. * @param textures defines the textures to update
  9037. * @param samples defines the sample count to set
  9038. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  9039. */
  9040. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  9041. /** @hidden */
  9042. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9043. /** @hidden */
  9044. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9045. /** @hidden */
  9046. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9047. /** @hidden */
  9048. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9049. /**
  9050. * Creates a new render target cube texture
  9051. * @param size defines the size of the texture
  9052. * @param options defines the options used to create the texture
  9053. * @returns a new render target cube texture stored in an InternalTexture
  9054. */
  9055. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  9056. /**
  9057. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  9058. * @param rootUrl defines the url where the file to load is located
  9059. * @param scene defines the current scene
  9060. * @param lodScale defines scale to apply to the mip map selection
  9061. * @param lodOffset defines offset to apply to the mip map selection
  9062. * @param onLoad defines an optional callback raised when the texture is loaded
  9063. * @param onError defines an optional callback raised if there is an issue to load the texture
  9064. * @param format defines the format of the data
  9065. * @param forcedExtension defines the extension to use to pick the right loader
  9066. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  9067. * @returns the cube texture as an InternalTexture
  9068. */
  9069. 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;
  9070. /**
  9071. * Creates a cube texture
  9072. * @param rootUrl defines the url where the files to load is located
  9073. * @param scene defines the current scene
  9074. * @param files defines the list of files to load (1 per face)
  9075. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  9076. * @param onLoad defines an optional callback raised when the texture is loaded
  9077. * @param onError defines an optional callback raised if there is an issue to load the texture
  9078. * @param format defines the format of the data
  9079. * @param forcedExtension defines the extension to use to pick the right loader
  9080. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  9081. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  9082. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  9083. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  9084. * @returns the cube texture as an InternalTexture
  9085. */
  9086. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  9087. /**
  9088. * @hidden
  9089. */
  9090. _setCubeMapTextureParams(loadMipmap: boolean): void;
  9091. /**
  9092. * Update a raw cube texture
  9093. * @param texture defines the texture to udpdate
  9094. * @param data defines the data to store
  9095. * @param format defines the data format
  9096. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9097. * @param invertY defines if data must be stored with Y axis inverted
  9098. * @param compression defines the compression used (null by default)
  9099. * @param level defines which level of the texture to update
  9100. */
  9101. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  9102. /**
  9103. * Creates a new raw cube texture
  9104. * @param data defines the array of data to use to create each face
  9105. * @param size defines the size of the textures
  9106. * @param format defines the format of the data
  9107. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9108. * @param generateMipMaps defines if the engine should generate the mip levels
  9109. * @param invertY defines if data must be stored with Y axis inverted
  9110. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9111. * @param compression defines the compression used (null by default)
  9112. * @returns the cube texture as an InternalTexture
  9113. */
  9114. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  9115. /**
  9116. * Creates a new raw cube texture from a specified url
  9117. * @param url defines the url where the data is located
  9118. * @param scene defines the current scene
  9119. * @param size defines the size of the textures
  9120. * @param format defines the format of the data
  9121. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9122. * @param noMipmap defines if the engine should avoid generating the mip levels
  9123. * @param callback defines a callback used to extract texture data from loaded data
  9124. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9125. * @param onLoad defines a callback called when texture is loaded
  9126. * @param onError defines a callback called if there is an error
  9127. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9128. * @param invertY defines if data must be stored with Y axis inverted
  9129. * @returns the cube texture as an InternalTexture
  9130. */
  9131. 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;
  9132. /**
  9133. * Update a raw 3D texture
  9134. * @param texture defines the texture to update
  9135. * @param data defines the data to store
  9136. * @param format defines the data format
  9137. * @param invertY defines if data must be stored with Y axis inverted
  9138. * @param compression defines the used compression (can be null)
  9139. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9140. */
  9141. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  9142. /**
  9143. * Creates a new raw 3D texture
  9144. * @param data defines the data used to create the texture
  9145. * @param width defines the width of the texture
  9146. * @param height defines the height of the texture
  9147. * @param depth defines the depth of the texture
  9148. * @param format defines the format of the texture
  9149. * @param generateMipMaps defines if the engine must generate mip levels
  9150. * @param invertY defines if data must be stored with Y axis inverted
  9151. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9152. * @param compression defines the compressed used (can be null)
  9153. * @param textureType defines the compressed used (can be null)
  9154. * @returns a new raw 3D texture (stored in an InternalTexture)
  9155. */
  9156. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  9157. private _prepareWebGLTextureContinuation;
  9158. private _prepareWebGLTexture;
  9159. private _convertRGBtoRGBATextureData;
  9160. /** @hidden */
  9161. _releaseFramebufferObjects(texture: InternalTexture): void;
  9162. /** @hidden */
  9163. _releaseTexture(texture: InternalTexture): void;
  9164. private setProgram;
  9165. private _boundUniforms;
  9166. /**
  9167. * Binds an effect to the webGL context
  9168. * @param effect defines the effect to bind
  9169. */
  9170. bindSamplers(effect: Effect): void;
  9171. private _moveBoundTextureOnTop;
  9172. private _getCorrectTextureChannel;
  9173. private _linkTrackers;
  9174. private _removeDesignatedSlot;
  9175. private _activateCurrentTexture;
  9176. /** @hidden */
  9177. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  9178. /** @hidden */
  9179. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  9180. /**
  9181. * Sets a texture to the webGL context from a postprocess
  9182. * @param channel defines the channel to use
  9183. * @param postProcess defines the source postprocess
  9184. */
  9185. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  9186. /**
  9187. * Binds the output of the passed in post process to the texture channel specified
  9188. * @param channel The channel the texture should be bound to
  9189. * @param postProcess The post process which's output should be bound
  9190. */
  9191. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  9192. /**
  9193. * Unbind all textures from the webGL context
  9194. */
  9195. unbindAllTextures(): void;
  9196. /**
  9197. * Sets a texture to the according uniform.
  9198. * @param channel The texture channel
  9199. * @param uniform The uniform to set
  9200. * @param texture The texture to apply
  9201. */
  9202. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  9203. /**
  9204. * Sets a depth stencil texture from a render target to the according uniform.
  9205. * @param channel The texture channel
  9206. * @param uniform The uniform to set
  9207. * @param texture The render target texture containing the depth stencil texture to apply
  9208. */
  9209. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  9210. private _bindSamplerUniformToChannel;
  9211. private _getTextureWrapMode;
  9212. private _setTexture;
  9213. /**
  9214. * Sets an array of texture to the webGL context
  9215. * @param channel defines the channel where the texture array must be set
  9216. * @param uniform defines the associated uniform location
  9217. * @param textures defines the array of textures to bind
  9218. */
  9219. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9220. /** @hidden */
  9221. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9222. private _setTextureParameterFloat;
  9223. private _setTextureParameterInteger;
  9224. /**
  9225. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9226. * @param x defines the x coordinate of the rectangle where pixels must be read
  9227. * @param y defines the y coordinate of the rectangle where pixels must be read
  9228. * @param width defines the width of the rectangle where pixels must be read
  9229. * @param height defines the height of the rectangle where pixels must be read
  9230. * @returns a Uint8Array containing RGBA colors
  9231. */
  9232. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9233. /**
  9234. * Add an externaly attached data from its key.
  9235. * This method call will fail and return false, if such key already exists.
  9236. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9237. * @param key the unique key that identifies the data
  9238. * @param data the data object to associate to the key for this Engine instance
  9239. * @return true if no such key were already present and the data was added successfully, false otherwise
  9240. */
  9241. addExternalData<T>(key: string, data: T): boolean;
  9242. /**
  9243. * Get an externaly attached data from its key
  9244. * @param key the unique key that identifies the data
  9245. * @return the associated data, if present (can be null), or undefined if not present
  9246. */
  9247. getExternalData<T>(key: string): T;
  9248. /**
  9249. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9250. * @param key the unique key that identifies the data
  9251. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9252. * @return the associated data, can be null if the factory returned null.
  9253. */
  9254. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9255. /**
  9256. * Remove an externaly attached data from the Engine instance
  9257. * @param key the unique key that identifies the data
  9258. * @return true if the data was successfully removed, false if it doesn't exist
  9259. */
  9260. removeExternalData(key: string): boolean;
  9261. /**
  9262. * Unbind all vertex attributes from the webGL context
  9263. */
  9264. unbindAllAttributes(): void;
  9265. /**
  9266. * 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
  9267. */
  9268. releaseEffects(): void;
  9269. /**
  9270. * Dispose and release all associated resources
  9271. */
  9272. dispose(): void;
  9273. /**
  9274. * Display the loading screen
  9275. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9276. */
  9277. displayLoadingUI(): void;
  9278. /**
  9279. * Hide the loading screen
  9280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9281. */
  9282. hideLoadingUI(): void;
  9283. /**
  9284. * Gets the current loading screen object
  9285. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9286. */
  9287. /**
  9288. * Sets the current loading screen object
  9289. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9290. */
  9291. loadingScreen: ILoadingScreen;
  9292. /**
  9293. * Sets the current loading screen text
  9294. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9295. */
  9296. loadingUIText: string;
  9297. /**
  9298. * Sets the current loading screen background color
  9299. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9300. */
  9301. loadingUIBackgroundColor: string;
  9302. /**
  9303. * Attach a new callback raised when context lost event is fired
  9304. * @param callback defines the callback to call
  9305. */
  9306. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9307. /**
  9308. * Attach a new callback raised when context restored event is fired
  9309. * @param callback defines the callback to call
  9310. */
  9311. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9312. /**
  9313. * Gets the source code of the vertex shader associated with a specific webGL program
  9314. * @param program defines the program to use
  9315. * @returns a string containing the source code of the vertex shader associated with the program
  9316. */
  9317. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9318. /**
  9319. * Gets the source code of the fragment shader associated with a specific webGL program
  9320. * @param program defines the program to use
  9321. * @returns a string containing the source code of the fragment shader associated with the program
  9322. */
  9323. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9324. /**
  9325. * Get the current error code of the webGL context
  9326. * @returns the error code
  9327. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9328. */
  9329. getError(): number;
  9330. /**
  9331. * Gets the current framerate
  9332. * @returns a number representing the framerate
  9333. */
  9334. getFps(): number;
  9335. /**
  9336. * Gets the time spent between current and previous frame
  9337. * @returns a number representing the delta time in ms
  9338. */
  9339. getDeltaTime(): number;
  9340. private _measureFps;
  9341. /** @hidden */
  9342. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9343. private _canRenderToFloatFramebuffer;
  9344. private _canRenderToHalfFloatFramebuffer;
  9345. private _canRenderToFramebuffer;
  9346. /** @hidden */
  9347. _getWebGLTextureType(type: number): number;
  9348. private _getInternalFormat;
  9349. /** @hidden */
  9350. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9351. /** @hidden */
  9352. _getRGBAMultiSampleBufferFormat(type: number): number;
  9353. /** @hidden */
  9354. _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;
  9355. /** @hidden */
  9356. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9357. private _partialLoadFile;
  9358. private _cascadeLoadFiles;
  9359. /**
  9360. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9361. * @returns true if the engine can be created
  9362. * @ignorenaming
  9363. */
  9364. static isSupported(): boolean;
  9365. }
  9366. }
  9367. declare module BABYLON {
  9368. class NullEngineOptions {
  9369. renderWidth: number;
  9370. renderHeight: number;
  9371. textureSize: number;
  9372. deterministicLockstep: boolean;
  9373. lockstepMaxSteps: number;
  9374. }
  9375. /**
  9376. * The null engine class provides support for headless version of babylon.js.
  9377. * This can be used in server side scenario or for testing purposes
  9378. */
  9379. class NullEngine extends Engine {
  9380. private _options;
  9381. isDeterministicLockStep(): boolean;
  9382. getLockstepMaxSteps(): number;
  9383. getHardwareScalingLevel(): number;
  9384. constructor(options?: NullEngineOptions);
  9385. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9386. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9387. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9388. getRenderWidth(useScreen?: boolean): number;
  9389. getRenderHeight(useScreen?: boolean): number;
  9390. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9391. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9392. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9393. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9394. bindSamplers(effect: Effect): void;
  9395. enableEffect(effect: Effect): void;
  9396. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9397. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9398. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9399. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9400. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9401. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9402. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9403. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9404. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9405. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9406. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9407. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9408. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9409. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9410. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9411. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9412. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9413. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9414. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9415. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9416. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9417. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9418. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9419. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9420. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9421. bindBuffers(vertexBuffers: {
  9422. [key: string]: VertexBuffer;
  9423. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9424. wipeCaches(bruteForce?: boolean): void;
  9425. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9426. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9427. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9428. /** @hidden */
  9429. _createTexture(): WebGLTexture;
  9430. /** @hidden */
  9431. _releaseTexture(texture: InternalTexture): void;
  9432. 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;
  9433. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9434. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9435. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9436. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9437. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9438. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9439. /**
  9440. * @hidden
  9441. * Get the current error code of the webGL context
  9442. * @returns the error code
  9443. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9444. */
  9445. getError(): number;
  9446. /** @hidden */
  9447. _getUnpackAlignement(): number;
  9448. /** @hidden */
  9449. _unpackFlipY(value: boolean): void;
  9450. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9451. /**
  9452. * Updates a dynamic vertex buffer.
  9453. * @param vertexBuffer the vertex buffer to update
  9454. * @param data the data used to update the vertex buffer
  9455. * @param byteOffset the byte offset of the data (optional)
  9456. * @param byteLength the byte length of the data (optional)
  9457. */
  9458. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9459. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9460. /** @hidden */
  9461. _bindTexture(channel: number, texture: InternalTexture): void;
  9462. /** @hidden */
  9463. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9464. releaseEffects(): void;
  9465. displayLoadingUI(): void;
  9466. hideLoadingUI(): void;
  9467. /** @hidden */
  9468. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9469. /** @hidden */
  9470. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9471. /** @hidden */
  9472. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9473. /** @hidden */
  9474. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9475. }
  9476. }
  9477. interface WebGLRenderingContext {
  9478. readonly RASTERIZER_DISCARD: number;
  9479. readonly DEPTH_COMPONENT24: number;
  9480. readonly TEXTURE_3D: number;
  9481. readonly TEXTURE_2D_ARRAY: number;
  9482. readonly TEXTURE_COMPARE_FUNC: number;
  9483. readonly TEXTURE_COMPARE_MODE: number;
  9484. readonly COMPARE_REF_TO_TEXTURE: number;
  9485. readonly TEXTURE_WRAP_R: number;
  9486. readonly HALF_FLOAT: number;
  9487. readonly RGB8: number;
  9488. readonly RED_INTEGER: number;
  9489. readonly RG_INTEGER: number;
  9490. readonly RGB_INTEGER: number;
  9491. readonly RGBA_INTEGER: number;
  9492. readonly R8_SNORM: number;
  9493. readonly RG8_SNORM: number;
  9494. readonly RGB8_SNORM: number;
  9495. readonly RGBA8_SNORM: number;
  9496. readonly R8I: number;
  9497. readonly RG8I: number;
  9498. readonly RGB8I: number;
  9499. readonly RGBA8I: number;
  9500. readonly R8UI: number;
  9501. readonly RG8UI: number;
  9502. readonly RGB8UI: number;
  9503. readonly RGBA8UI: number;
  9504. readonly R16I: number;
  9505. readonly RG16I: number;
  9506. readonly RGB16I: number;
  9507. readonly RGBA16I: number;
  9508. readonly R16UI: number;
  9509. readonly RG16UI: number;
  9510. readonly RGB16UI: number;
  9511. readonly RGBA16UI: number;
  9512. readonly R32I: number;
  9513. readonly RG32I: number;
  9514. readonly RGB32I: number;
  9515. readonly RGBA32I: number;
  9516. readonly R32UI: number;
  9517. readonly RG32UI: number;
  9518. readonly RGB32UI: number;
  9519. readonly RGBA32UI: number;
  9520. readonly RGB10_A2UI: number;
  9521. readonly R11F_G11F_B10F: number;
  9522. readonly RGB9_E5: number;
  9523. readonly RGB10_A2: number;
  9524. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9525. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9526. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9527. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9528. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9529. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9530. 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;
  9531. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9532. readonly TRANSFORM_FEEDBACK: number;
  9533. readonly INTERLEAVED_ATTRIBS: number;
  9534. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9535. createTransformFeedback(): WebGLTransformFeedback;
  9536. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9537. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9538. beginTransformFeedback(primitiveMode: number): void;
  9539. endTransformFeedback(): void;
  9540. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9541. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9542. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9543. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9544. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9545. }
  9546. interface ImageBitmap {
  9547. readonly width: number;
  9548. readonly height: number;
  9549. close(): void;
  9550. }
  9551. interface WebGLQuery extends WebGLObject {
  9552. }
  9553. declare var WebGLQuery: {
  9554. prototype: WebGLQuery;
  9555. new (): WebGLQuery;
  9556. };
  9557. interface WebGLSampler extends WebGLObject {
  9558. }
  9559. declare var WebGLSampler: {
  9560. prototype: WebGLSampler;
  9561. new (): WebGLSampler;
  9562. };
  9563. interface WebGLSync extends WebGLObject {
  9564. }
  9565. declare var WebGLSync: {
  9566. prototype: WebGLSync;
  9567. new (): WebGLSync;
  9568. };
  9569. interface WebGLTransformFeedback extends WebGLObject {
  9570. }
  9571. declare var WebGLTransformFeedback: {
  9572. prototype: WebGLTransformFeedback;
  9573. new (): WebGLTransformFeedback;
  9574. };
  9575. interface WebGLVertexArrayObject extends WebGLObject {
  9576. }
  9577. declare var WebGLVertexArrayObject: {
  9578. prototype: WebGLVertexArrayObject;
  9579. new (): WebGLVertexArrayObject;
  9580. };
  9581. declare module BABYLON {
  9582. class StickValues {
  9583. x: number;
  9584. y: number;
  9585. constructor(x: number, y: number);
  9586. }
  9587. interface GamepadButtonChanges {
  9588. changed: boolean;
  9589. pressChanged: boolean;
  9590. touchChanged: boolean;
  9591. valueChanged: boolean;
  9592. }
  9593. class Gamepad {
  9594. id: string;
  9595. index: number;
  9596. browserGamepad: any;
  9597. type: number;
  9598. private _leftStick;
  9599. private _rightStick;
  9600. /** @hidden */
  9601. _isConnected: boolean;
  9602. private _leftStickAxisX;
  9603. private _leftStickAxisY;
  9604. private _rightStickAxisX;
  9605. private _rightStickAxisY;
  9606. private _onleftstickchanged;
  9607. private _onrightstickchanged;
  9608. static GAMEPAD: number;
  9609. static GENERIC: number;
  9610. static XBOX: number;
  9611. static POSE_ENABLED: number;
  9612. protected _invertLeftStickY: boolean;
  9613. readonly isConnected: boolean;
  9614. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9615. onleftstickchanged(callback: (values: StickValues) => void): void;
  9616. onrightstickchanged(callback: (values: StickValues) => void): void;
  9617. leftStick: StickValues;
  9618. rightStick: StickValues;
  9619. update(): void;
  9620. dispose(): void;
  9621. }
  9622. class GenericPad extends Gamepad {
  9623. private _buttons;
  9624. private _onbuttondown;
  9625. private _onbuttonup;
  9626. onButtonDownObservable: Observable<number>;
  9627. onButtonUpObservable: Observable<number>;
  9628. onbuttondown(callback: (buttonPressed: number) => void): void;
  9629. onbuttonup(callback: (buttonReleased: number) => void): void;
  9630. constructor(id: string, index: number, browserGamepad: any);
  9631. private _setButtonValue;
  9632. update(): void;
  9633. dispose(): void;
  9634. }
  9635. }
  9636. declare module BABYLON {
  9637. class GamepadManager {
  9638. private _scene?;
  9639. private _babylonGamepads;
  9640. private _oneGamepadConnected;
  9641. /** @hidden */
  9642. _isMonitoring: boolean;
  9643. private _gamepadEventSupported;
  9644. private _gamepadSupport;
  9645. onGamepadConnectedObservable: Observable<Gamepad>;
  9646. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9647. private _onGamepadConnectedEvent;
  9648. private _onGamepadDisconnectedEvent;
  9649. constructor(_scene?: Scene | undefined);
  9650. readonly gamepads: Gamepad[];
  9651. getGamepadByType(type?: number): Nullable<Gamepad>;
  9652. dispose(): void;
  9653. private _addNewGamepad;
  9654. private _startMonitoringGamepads;
  9655. private _stopMonitoringGamepads;
  9656. /** @hidden */
  9657. _checkGamepadsStatus(): void;
  9658. private _updateGamepadObjects;
  9659. }
  9660. }
  9661. declare module BABYLON {
  9662. interface Scene {
  9663. /** @hidden */
  9664. _gamepadManager: Nullable<GamepadManager>;
  9665. /**
  9666. * Gets the gamepad manager associated with the scene
  9667. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9668. */
  9669. gamepadManager: GamepadManager;
  9670. }
  9671. interface FreeCameraInputsManager {
  9672. addGamepad(): FreeCameraInputsManager;
  9673. }
  9674. interface ArcRotateCameraInputsManager {
  9675. addGamepad(): ArcRotateCameraInputsManager;
  9676. }
  9677. /**
  9678. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9679. */
  9680. class GamepadSystemSceneComponent implements ISceneComponent {
  9681. /**
  9682. * The component name helpfull to identify the component in the list of scene components.
  9683. */
  9684. readonly name: string;
  9685. /**
  9686. * The scene the component belongs to.
  9687. */
  9688. scene: Scene;
  9689. /**
  9690. * Creates a new instance of the component for the given scene
  9691. * @param scene Defines the scene to register the component in
  9692. */
  9693. constructor(scene: Scene);
  9694. /**
  9695. * Registers the component in a given scene
  9696. */
  9697. register(): void;
  9698. /**
  9699. * Rebuilds the elements related to this component in case of
  9700. * context lost for instance.
  9701. */
  9702. rebuild(): void;
  9703. /**
  9704. * Disposes the component and the associated ressources
  9705. */
  9706. dispose(): void;
  9707. private _beforeCameraUpdate;
  9708. }
  9709. }
  9710. declare module BABYLON {
  9711. /**
  9712. * Defines supported buttons for XBox360 compatible gamepads
  9713. */
  9714. enum Xbox360Button {
  9715. /** A */
  9716. A = 0,
  9717. /** B */
  9718. B = 1,
  9719. /** X */
  9720. X = 2,
  9721. /** Y */
  9722. Y = 3,
  9723. /** Start */
  9724. Start = 4,
  9725. /** Back */
  9726. Back = 5,
  9727. /** Left button */
  9728. LB = 6,
  9729. /** Right button */
  9730. RB = 7,
  9731. /** Left stick */
  9732. LeftStick = 8,
  9733. /** Right stick */
  9734. RightStick = 9
  9735. }
  9736. /** Defines values for XBox360 DPad */
  9737. enum Xbox360Dpad {
  9738. /** Up */
  9739. Up = 0,
  9740. /** Down */
  9741. Down = 1,
  9742. /** Left */
  9743. Left = 2,
  9744. /** Right */
  9745. Right = 3
  9746. }
  9747. /**
  9748. * Defines a XBox360 gamepad
  9749. */
  9750. class Xbox360Pad extends Gamepad {
  9751. private _leftTrigger;
  9752. private _rightTrigger;
  9753. private _onlefttriggerchanged;
  9754. private _onrighttriggerchanged;
  9755. private _onbuttondown;
  9756. private _onbuttonup;
  9757. private _ondpaddown;
  9758. private _ondpadup;
  9759. /** Observable raised when a button is pressed */
  9760. onButtonDownObservable: Observable<Xbox360Button>;
  9761. /** Observable raised when a button is released */
  9762. onButtonUpObservable: Observable<Xbox360Button>;
  9763. /** Observable raised when a pad is pressed */
  9764. onPadDownObservable: Observable<Xbox360Dpad>;
  9765. /** Observable raised when a pad is released */
  9766. onPadUpObservable: Observable<Xbox360Dpad>;
  9767. private _buttonA;
  9768. private _buttonB;
  9769. private _buttonX;
  9770. private _buttonY;
  9771. private _buttonBack;
  9772. private _buttonStart;
  9773. private _buttonLB;
  9774. private _buttonRB;
  9775. private _buttonLeftStick;
  9776. private _buttonRightStick;
  9777. private _dPadUp;
  9778. private _dPadDown;
  9779. private _dPadLeft;
  9780. private _dPadRight;
  9781. private _isXboxOnePad;
  9782. /**
  9783. * Creates a new XBox360 gamepad object
  9784. * @param id defines the id of this gamepad
  9785. * @param index defines its index
  9786. * @param gamepad defines the internal HTML gamepad object
  9787. * @param xboxOne defines if it is a XBox One gamepad
  9788. */
  9789. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9790. /**
  9791. * Defines the callback to call when left trigger is pressed
  9792. * @param callback defines the callback to use
  9793. */
  9794. onlefttriggerchanged(callback: (value: number) => void): void;
  9795. /**
  9796. * Defines the callback to call when right trigger is pressed
  9797. * @param callback defines the callback to use
  9798. */
  9799. onrighttriggerchanged(callback: (value: number) => void): void;
  9800. /**
  9801. * Gets or sets left trigger value
  9802. */
  9803. leftTrigger: number;
  9804. /**
  9805. * Gets or sets right trigger value
  9806. */
  9807. rightTrigger: number;
  9808. /**
  9809. * Defines the callback to call when a button is pressed
  9810. * @param callback defines the callback to use
  9811. */
  9812. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9813. /**
  9814. * Defines the callback to call when a button is released
  9815. * @param callback defines the callback to use
  9816. */
  9817. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9818. /**
  9819. * Defines the callback to call when a pad is pressed
  9820. * @param callback defines the callback to use
  9821. */
  9822. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9823. /**
  9824. * Defines the callback to call when a pad is released
  9825. * @param callback defines the callback to use
  9826. */
  9827. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9828. private _setButtonValue;
  9829. private _setDPadValue;
  9830. /** Gets or sets value of A button */
  9831. buttonA: number;
  9832. /** Gets or sets value of B button */
  9833. buttonB: number;
  9834. /** Gets or sets value of X button */
  9835. buttonX: number;
  9836. /** Gets or sets value of Y button */
  9837. buttonY: number;
  9838. /** Gets or sets value of Start button */
  9839. buttonStart: number;
  9840. /** Gets or sets value of Back button */
  9841. buttonBack: number;
  9842. /** Gets or sets value of Left button */
  9843. buttonLB: number;
  9844. /** Gets or sets value of Right button */
  9845. buttonRB: number;
  9846. /** Gets or sets value of left stick */
  9847. buttonLeftStick: number;
  9848. /** Gets or sets value of right stick */
  9849. buttonRightStick: number;
  9850. /** Gets or sets value of DPad up */
  9851. dPadUp: number;
  9852. /** Gets or sets value of DPad down */
  9853. dPadDown: number;
  9854. /** Gets or sets value of DPad left */
  9855. dPadLeft: number;
  9856. /** Gets or sets value of DPad right */
  9857. dPadRight: number;
  9858. /**
  9859. * Force the gamepad to synchronize with device values
  9860. */
  9861. update(): void;
  9862. dispose(): void;
  9863. }
  9864. }
  9865. declare module BABYLON {
  9866. /**
  9867. * Single axis drag gizmo
  9868. */
  9869. class AxisDragGizmo extends Gizmo {
  9870. /**
  9871. * Drag behavior responsible for the gizmos dragging interactions
  9872. */
  9873. dragBehavior: PointerDragBehavior;
  9874. private _pointerObserver;
  9875. /**
  9876. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9877. */
  9878. snapDistance: number;
  9879. /**
  9880. * Event that fires each time the gizmo snaps to a new location.
  9881. * * snapDistance is the the change in distance
  9882. */
  9883. onSnapObservable: Observable<{
  9884. snapDistance: number;
  9885. }>;
  9886. /**
  9887. * Creates an AxisDragGizmo
  9888. * @param gizmoLayer The utility layer the gizmo will be added to
  9889. * @param dragAxis The axis which the gizmo will be able to drag on
  9890. * @param color The color of the gizmo
  9891. */
  9892. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9893. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9894. /**
  9895. * Disposes of the gizmo
  9896. */
  9897. dispose(): void;
  9898. }
  9899. }
  9900. declare module BABYLON {
  9901. /**
  9902. * Single axis scale gizmo
  9903. */
  9904. class AxisScaleGizmo extends Gizmo {
  9905. private _coloredMaterial;
  9906. /**
  9907. * Drag behavior responsible for the gizmos dragging interactions
  9908. */
  9909. dragBehavior: PointerDragBehavior;
  9910. private _pointerObserver;
  9911. /**
  9912. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9913. */
  9914. snapDistance: number;
  9915. /**
  9916. * Event that fires each time the gizmo snaps to a new location.
  9917. * * snapDistance is the the change in distance
  9918. */
  9919. onSnapObservable: Observable<{
  9920. snapDistance: number;
  9921. }>;
  9922. /**
  9923. * If the scaling operation should be done on all axis (default: false)
  9924. */
  9925. uniformScaling: boolean;
  9926. /**
  9927. * Creates an AxisScaleGizmo
  9928. * @param gizmoLayer The utility layer the gizmo will be added to
  9929. * @param dragAxis The axis which the gizmo will be able to scale on
  9930. * @param color The color of the gizmo
  9931. */
  9932. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9933. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9934. /**
  9935. * Disposes of the gizmo
  9936. */
  9937. dispose(): void;
  9938. /**
  9939. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9940. * @param mesh The mesh to replace the default mesh of the gizmo
  9941. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9942. */
  9943. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9944. }
  9945. }
  9946. declare module BABYLON {
  9947. /**
  9948. * Bounding box gizmo
  9949. */
  9950. class BoundingBoxGizmo extends Gizmo {
  9951. private _lineBoundingBox;
  9952. private _rotateSpheresParent;
  9953. private _scaleBoxesParent;
  9954. private _boundingDimensions;
  9955. private _renderObserver;
  9956. private _pointerObserver;
  9957. private _scaleDragSpeed;
  9958. private _tmpQuaternion;
  9959. private _tmpVector;
  9960. private _tmpRotationMatrix;
  9961. /**
  9962. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  9963. */
  9964. ignoreChildren: boolean;
  9965. /**
  9966. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9967. */
  9968. rotationSphereSize: number;
  9969. /**
  9970. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9971. */
  9972. scaleBoxSize: number;
  9973. /**
  9974. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  9975. */
  9976. fixedDragMeshScreenSize: boolean;
  9977. /**
  9978. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9979. */
  9980. fixedDragMeshScreenSizeDistanceFactor: number;
  9981. /**
  9982. * Fired when a rotation sphere or scale box is dragged
  9983. */
  9984. onDragStartObservable: Observable<{}>;
  9985. /**
  9986. * Fired when a scale box is dragged
  9987. */
  9988. onScaleBoxDragObservable: Observable<{}>;
  9989. /**
  9990. * Fired when a scale box drag is ended
  9991. */
  9992. onScaleBoxDragEndObservable: Observable<{}>;
  9993. /**
  9994. * Fired when a rotation sphere is dragged
  9995. */
  9996. onRotationSphereDragObservable: Observable<{}>;
  9997. /**
  9998. * Fired when a rotation sphere drag is ended
  9999. */
  10000. onRotationSphereDragEndObservable: Observable<{}>;
  10001. /**
  10002. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  10003. */
  10004. scalePivot: Nullable<Vector3>;
  10005. private _anchorMesh;
  10006. private _existingMeshScale;
  10007. private static _PivotCached;
  10008. private static _OldPivotPoint;
  10009. private static _PivotTranslation;
  10010. private static _PivotTmpVector;
  10011. /** @hidden */
  10012. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  10013. /** @hidden */
  10014. static _RestorePivotPoint(mesh: AbstractMesh): void;
  10015. /**
  10016. * Creates an BoundingBoxGizmo
  10017. * @param gizmoLayer The utility layer the gizmo will be added to
  10018. * @param color The color of the gizmo
  10019. */
  10020. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10021. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10022. private _selectNode;
  10023. private _recurseComputeWorld;
  10024. /**
  10025. * Updates the bounding box information for the Gizmo
  10026. */
  10027. updateBoundingBox(): void;
  10028. /**
  10029. * Enables rotation on the specified axis and disables rotation on the others
  10030. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10031. */
  10032. setEnabledRotationAxis(axis: string): void;
  10033. /**
  10034. * Disposes of the gizmo
  10035. */
  10036. dispose(): void;
  10037. /**
  10038. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  10039. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10040. * @returns the bounding box mesh with the passed in mesh as a child
  10041. */
  10042. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10043. /**
  10044. * CustomMeshes are not supported by this gizmo
  10045. * @param mesh The mesh to replace the default mesh of the gizmo
  10046. */
  10047. setCustomMesh(mesh: Mesh): void;
  10048. }
  10049. }
  10050. declare module BABYLON {
  10051. /**
  10052. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10053. */
  10054. class Gizmo implements IDisposable {
  10055. /** The utility layer the gizmo will be added to */
  10056. gizmoLayer: UtilityLayerRenderer;
  10057. /**
  10058. * The root mesh of the gizmo
  10059. */
  10060. protected _rootMesh: Mesh;
  10061. private _attachedMesh;
  10062. /**
  10063. * Ratio for the scale of the gizmo (Default: 1)
  10064. */
  10065. scaleRatio: number;
  10066. private _tmpMatrix;
  10067. /**
  10068. * If a custom mesh has been set (Default: false)
  10069. */
  10070. protected _customMeshSet: boolean;
  10071. /**
  10072. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10073. * * When set, interactions will be enabled
  10074. */
  10075. attachedMesh: Nullable<AbstractMesh>;
  10076. /**
  10077. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10078. * @param mesh The mesh to replace the default mesh of the gizmo
  10079. */
  10080. setCustomMesh(mesh: Mesh): void;
  10081. /**
  10082. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10083. */
  10084. updateGizmoRotationToMatchAttachedMesh: boolean;
  10085. /**
  10086. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10087. */
  10088. updateGizmoPositionToMatchAttachedMesh: boolean;
  10089. /**
  10090. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10091. */
  10092. protected _updateScale: boolean;
  10093. protected _interactionsEnabled: boolean;
  10094. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10095. private _beforeRenderObserver;
  10096. /**
  10097. * Creates a gizmo
  10098. * @param gizmoLayer The utility layer the gizmo will be added to
  10099. */
  10100. constructor(
  10101. /** The utility layer the gizmo will be added to */
  10102. gizmoLayer?: UtilityLayerRenderer);
  10103. private _tempVector;
  10104. /**
  10105. * @hidden
  10106. * Updates the gizmo to match the attached mesh's position/rotation
  10107. */
  10108. protected _update(): void;
  10109. /**
  10110. * Disposes of the gizmo
  10111. */
  10112. dispose(): void;
  10113. }
  10114. }
  10115. declare module BABYLON {
  10116. /**
  10117. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10118. */
  10119. class GizmoManager implements IDisposable {
  10120. private scene;
  10121. /**
  10122. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10123. */
  10124. gizmos: {
  10125. positionGizmo: Nullable<PositionGizmo>;
  10126. rotationGizmo: Nullable<RotationGizmo>;
  10127. scaleGizmo: Nullable<ScaleGizmo>;
  10128. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10129. };
  10130. private _gizmosEnabled;
  10131. private _pointerObserver;
  10132. private _attachedMesh;
  10133. private _boundingBoxColor;
  10134. private _dragBehavior;
  10135. /**
  10136. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10137. */
  10138. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10139. /**
  10140. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10141. */
  10142. usePointerToAttachGizmos: boolean;
  10143. /**
  10144. * Instatiates a gizmo manager
  10145. * @param scene the scene to overlay the gizmos on top of
  10146. */
  10147. constructor(scene: Scene);
  10148. /**
  10149. * Attaches a set of gizmos to the specified mesh
  10150. * @param mesh The mesh the gizmo's should be attached to
  10151. */
  10152. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10153. /**
  10154. * If the position gizmo is enabled
  10155. */
  10156. positionGizmoEnabled: boolean;
  10157. /**
  10158. * If the rotation gizmo is enabled
  10159. */
  10160. rotationGizmoEnabled: boolean;
  10161. /**
  10162. * If the scale gizmo is enabled
  10163. */
  10164. scaleGizmoEnabled: boolean;
  10165. /**
  10166. * If the boundingBox gizmo is enabled
  10167. */
  10168. boundingBoxGizmoEnabled: boolean;
  10169. /**
  10170. * Disposes of the gizmo manager
  10171. */
  10172. dispose(): void;
  10173. }
  10174. }
  10175. declare module BABYLON {
  10176. /**
  10177. * Single plane rotation gizmo
  10178. */
  10179. class PlaneRotationGizmo extends Gizmo {
  10180. /**
  10181. * Drag behavior responsible for the gizmos dragging interactions
  10182. */
  10183. dragBehavior: PointerDragBehavior;
  10184. private _pointerObserver;
  10185. /**
  10186. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10187. */
  10188. snapDistance: number;
  10189. /**
  10190. * Event that fires each time the gizmo snaps to a new location.
  10191. * * snapDistance is the the change in distance
  10192. */
  10193. onSnapObservable: Observable<{
  10194. snapDistance: number;
  10195. }>;
  10196. /**
  10197. * Creates a PlaneRotationGizmo
  10198. * @param gizmoLayer The utility layer the gizmo will be added to
  10199. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10200. * @param color The color of the gizmo
  10201. */
  10202. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10203. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10204. /**
  10205. * Disposes of the gizmo
  10206. */
  10207. dispose(): void;
  10208. }
  10209. }
  10210. declare module BABYLON {
  10211. /**
  10212. * Gizmo that enables dragging a mesh along 3 axis
  10213. */
  10214. class PositionGizmo extends Gizmo {
  10215. /**
  10216. * Internal gizmo used for interactions on the x axis
  10217. */
  10218. xGizmo: AxisDragGizmo;
  10219. /**
  10220. * Internal gizmo used for interactions on the y axis
  10221. */
  10222. yGizmo: AxisDragGizmo;
  10223. /**
  10224. * Internal gizmo used for interactions on the z axis
  10225. */
  10226. zGizmo: AxisDragGizmo;
  10227. attachedMesh: Nullable<AbstractMesh>;
  10228. /**
  10229. * Creates a PositionGizmo
  10230. * @param gizmoLayer The utility layer the gizmo will be added to
  10231. */
  10232. constructor(gizmoLayer?: UtilityLayerRenderer);
  10233. updateGizmoRotationToMatchAttachedMesh: boolean;
  10234. /**
  10235. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10236. */
  10237. snapDistance: number;
  10238. /**
  10239. * Ratio for the scale of the gizmo (Default: 1)
  10240. */
  10241. scaleRatio: number;
  10242. /**
  10243. * Disposes of the gizmo
  10244. */
  10245. dispose(): void;
  10246. /**
  10247. * CustomMeshes are not supported by this gizmo
  10248. * @param mesh The mesh to replace the default mesh of the gizmo
  10249. */
  10250. setCustomMesh(mesh: Mesh): void;
  10251. }
  10252. }
  10253. declare module BABYLON {
  10254. /**
  10255. * Gizmo that enables rotating a mesh along 3 axis
  10256. */
  10257. class RotationGizmo extends Gizmo {
  10258. /**
  10259. * Internal gizmo used for interactions on the x axis
  10260. */
  10261. xGizmo: PlaneRotationGizmo;
  10262. /**
  10263. * Internal gizmo used for interactions on the y axis
  10264. */
  10265. yGizmo: PlaneRotationGizmo;
  10266. /**
  10267. * Internal gizmo used for interactions on the z axis
  10268. */
  10269. zGizmo: PlaneRotationGizmo;
  10270. attachedMesh: Nullable<AbstractMesh>;
  10271. /**
  10272. * Creates a RotationGizmo
  10273. * @param gizmoLayer The utility layer the gizmo will be added to
  10274. */
  10275. constructor(gizmoLayer?: UtilityLayerRenderer);
  10276. updateGizmoRotationToMatchAttachedMesh: boolean;
  10277. /**
  10278. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10279. */
  10280. snapDistance: number;
  10281. /**
  10282. * Ratio for the scale of the gizmo (Default: 1)
  10283. */
  10284. scaleRatio: number;
  10285. /**
  10286. * Disposes of the gizmo
  10287. */
  10288. dispose(): void;
  10289. /**
  10290. * CustomMeshes are not supported by this gizmo
  10291. * @param mesh The mesh to replace the default mesh of the gizmo
  10292. */
  10293. setCustomMesh(mesh: Mesh): void;
  10294. }
  10295. }
  10296. declare module BABYLON {
  10297. /**
  10298. * Gizmo that enables scaling a mesh along 3 axis
  10299. */
  10300. class ScaleGizmo extends Gizmo {
  10301. /**
  10302. * Internal gizmo used for interactions on the x axis
  10303. */
  10304. xGizmo: AxisScaleGizmo;
  10305. /**
  10306. * Internal gizmo used for interactions on the y axis
  10307. */
  10308. yGizmo: AxisScaleGizmo;
  10309. /**
  10310. * Internal gizmo used for interactions on the z axis
  10311. */
  10312. zGizmo: AxisScaleGizmo;
  10313. /**
  10314. * @hidden
  10315. * Internal gizmo used to scale all axis equally
  10316. */
  10317. private _uniformGizmo;
  10318. attachedMesh: Nullable<AbstractMesh>;
  10319. /**
  10320. * Creates a ScaleGizmo
  10321. * @param gizmoLayer The utility layer the gizmo will be added to
  10322. */
  10323. constructor(gizmoLayer?: UtilityLayerRenderer);
  10324. updateGizmoRotationToMatchAttachedMesh: boolean;
  10325. /**
  10326. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10327. */
  10328. snapDistance: number;
  10329. /**
  10330. * Ratio for the scale of the gizmo (Default: 1)
  10331. */
  10332. scaleRatio: number;
  10333. /**
  10334. * Disposes of the gizmo
  10335. */
  10336. dispose(): void;
  10337. }
  10338. }
  10339. declare module BABYLON {
  10340. /**
  10341. * Represents the different options available during the creation of
  10342. * a Environment helper.
  10343. *
  10344. * This can control the default ground, skybox and image processing setup of your scene.
  10345. */
  10346. interface IEnvironmentHelperOptions {
  10347. /**
  10348. * Specifies wether or not to create a ground.
  10349. * True by default.
  10350. */
  10351. createGround: boolean;
  10352. /**
  10353. * Specifies the ground size.
  10354. * 15 by default.
  10355. */
  10356. groundSize: number;
  10357. /**
  10358. * The texture used on the ground for the main color.
  10359. * Comes from the BabylonJS CDN by default.
  10360. *
  10361. * Remarks: Can be either a texture or a url.
  10362. */
  10363. groundTexture: string | BaseTexture;
  10364. /**
  10365. * The color mixed in the ground texture by default.
  10366. * BabylonJS clearColor by default.
  10367. */
  10368. groundColor: Color3;
  10369. /**
  10370. * Specifies the ground opacity.
  10371. * 1 by default.
  10372. */
  10373. groundOpacity: number;
  10374. /**
  10375. * Enables the ground to receive shadows.
  10376. * True by default.
  10377. */
  10378. enableGroundShadow: boolean;
  10379. /**
  10380. * Helps preventing the shadow to be fully black on the ground.
  10381. * 0.5 by default.
  10382. */
  10383. groundShadowLevel: number;
  10384. /**
  10385. * Creates a mirror texture attach to the ground.
  10386. * false by default.
  10387. */
  10388. enableGroundMirror: boolean;
  10389. /**
  10390. * Specifies the ground mirror size ratio.
  10391. * 0.3 by default as the default kernel is 64.
  10392. */
  10393. groundMirrorSizeRatio: number;
  10394. /**
  10395. * Specifies the ground mirror blur kernel size.
  10396. * 64 by default.
  10397. */
  10398. groundMirrorBlurKernel: number;
  10399. /**
  10400. * Specifies the ground mirror visibility amount.
  10401. * 1 by default
  10402. */
  10403. groundMirrorAmount: number;
  10404. /**
  10405. * Specifies the ground mirror reflectance weight.
  10406. * This uses the standard weight of the background material to setup the fresnel effect
  10407. * of the mirror.
  10408. * 1 by default.
  10409. */
  10410. groundMirrorFresnelWeight: number;
  10411. /**
  10412. * Specifies the ground mirror Falloff distance.
  10413. * This can helps reducing the size of the reflection.
  10414. * 0 by Default.
  10415. */
  10416. groundMirrorFallOffDistance: number;
  10417. /**
  10418. * Specifies the ground mirror texture type.
  10419. * Unsigned Int by Default.
  10420. */
  10421. groundMirrorTextureType: number;
  10422. /**
  10423. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10424. * the shown objects.
  10425. */
  10426. groundYBias: number;
  10427. /**
  10428. * Specifies wether or not to create a skybox.
  10429. * True by default.
  10430. */
  10431. createSkybox: boolean;
  10432. /**
  10433. * Specifies the skybox size.
  10434. * 20 by default.
  10435. */
  10436. skyboxSize: number;
  10437. /**
  10438. * The texture used on the skybox for the main color.
  10439. * Comes from the BabylonJS CDN by default.
  10440. *
  10441. * Remarks: Can be either a texture or a url.
  10442. */
  10443. skyboxTexture: string | BaseTexture;
  10444. /**
  10445. * The color mixed in the skybox texture by default.
  10446. * BabylonJS clearColor by default.
  10447. */
  10448. skyboxColor: Color3;
  10449. /**
  10450. * The background rotation around the Y axis of the scene.
  10451. * This helps aligning the key lights of your scene with the background.
  10452. * 0 by default.
  10453. */
  10454. backgroundYRotation: number;
  10455. /**
  10456. * Compute automatically the size of the elements to best fit with the scene.
  10457. */
  10458. sizeAuto: boolean;
  10459. /**
  10460. * Default position of the rootMesh if autoSize is not true.
  10461. */
  10462. rootPosition: Vector3;
  10463. /**
  10464. * Sets up the image processing in the scene.
  10465. * true by default.
  10466. */
  10467. setupImageProcessing: boolean;
  10468. /**
  10469. * The texture used as your environment texture in the scene.
  10470. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10471. *
  10472. * Remarks: Can be either a texture or a url.
  10473. */
  10474. environmentTexture: string | BaseTexture;
  10475. /**
  10476. * The value of the exposure to apply to the scene.
  10477. * 0.6 by default if setupImageProcessing is true.
  10478. */
  10479. cameraExposure: number;
  10480. /**
  10481. * The value of the contrast to apply to the scene.
  10482. * 1.6 by default if setupImageProcessing is true.
  10483. */
  10484. cameraContrast: number;
  10485. /**
  10486. * Specifies wether or not tonemapping should be enabled in the scene.
  10487. * true by default if setupImageProcessing is true.
  10488. */
  10489. toneMappingEnabled: boolean;
  10490. }
  10491. /**
  10492. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10493. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10494. * It also helps with the default setup of your imageProcessing configuration.
  10495. */
  10496. class EnvironmentHelper {
  10497. /**
  10498. * Default ground texture URL.
  10499. */
  10500. private static _groundTextureCDNUrl;
  10501. /**
  10502. * Default skybox texture URL.
  10503. */
  10504. private static _skyboxTextureCDNUrl;
  10505. /**
  10506. * Default environment texture URL.
  10507. */
  10508. private static _environmentTextureCDNUrl;
  10509. /**
  10510. * Creates the default options for the helper.
  10511. */
  10512. private static _getDefaultOptions;
  10513. private _rootMesh;
  10514. /**
  10515. * Gets the root mesh created by the helper.
  10516. */
  10517. readonly rootMesh: Mesh;
  10518. private _skybox;
  10519. /**
  10520. * Gets the skybox created by the helper.
  10521. */
  10522. readonly skybox: Nullable<Mesh>;
  10523. private _skyboxTexture;
  10524. /**
  10525. * Gets the skybox texture created by the helper.
  10526. */
  10527. readonly skyboxTexture: Nullable<BaseTexture>;
  10528. private _skyboxMaterial;
  10529. /**
  10530. * Gets the skybox material created by the helper.
  10531. */
  10532. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10533. private _ground;
  10534. /**
  10535. * Gets the ground mesh created by the helper.
  10536. */
  10537. readonly ground: Nullable<Mesh>;
  10538. private _groundTexture;
  10539. /**
  10540. * Gets the ground texture created by the helper.
  10541. */
  10542. readonly groundTexture: Nullable<BaseTexture>;
  10543. private _groundMirror;
  10544. /**
  10545. * Gets the ground mirror created by the helper.
  10546. */
  10547. readonly groundMirror: Nullable<MirrorTexture>;
  10548. /**
  10549. * Gets the ground mirror render list to helps pushing the meshes
  10550. * you wish in the ground reflection.
  10551. */
  10552. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10553. private _groundMaterial;
  10554. /**
  10555. * Gets the ground material created by the helper.
  10556. */
  10557. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10558. /**
  10559. * Stores the creation options.
  10560. */
  10561. private readonly _scene;
  10562. private _options;
  10563. /**
  10564. * This observable will be notified with any error during the creation of the environment,
  10565. * mainly texture creation errors.
  10566. */
  10567. onErrorObservable: Observable<{
  10568. message?: string;
  10569. exception?: any;
  10570. }>;
  10571. /**
  10572. * constructor
  10573. * @param options
  10574. * @param scene The scene to add the material to
  10575. */
  10576. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10577. /**
  10578. * Updates the background according to the new options
  10579. * @param options
  10580. */
  10581. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10582. /**
  10583. * Sets the primary color of all the available elements.
  10584. * @param color the main color to affect to the ground and the background
  10585. */
  10586. setMainColor(color: Color3): void;
  10587. /**
  10588. * Setup the image processing according to the specified options.
  10589. */
  10590. private _setupImageProcessing;
  10591. /**
  10592. * Setup the environment texture according to the specified options.
  10593. */
  10594. private _setupEnvironmentTexture;
  10595. /**
  10596. * Setup the background according to the specified options.
  10597. */
  10598. private _setupBackground;
  10599. /**
  10600. * Get the scene sizes according to the setup.
  10601. */
  10602. private _getSceneSize;
  10603. /**
  10604. * Setup the ground according to the specified options.
  10605. */
  10606. private _setupGround;
  10607. /**
  10608. * Setup the ground material according to the specified options.
  10609. */
  10610. private _setupGroundMaterial;
  10611. /**
  10612. * Setup the ground diffuse texture according to the specified options.
  10613. */
  10614. private _setupGroundDiffuseTexture;
  10615. /**
  10616. * Setup the ground mirror texture according to the specified options.
  10617. */
  10618. private _setupGroundMirrorTexture;
  10619. /**
  10620. * Setup the ground to receive the mirror texture.
  10621. */
  10622. private _setupMirrorInGroundMaterial;
  10623. /**
  10624. * Setup the skybox according to the specified options.
  10625. */
  10626. private _setupSkybox;
  10627. /**
  10628. * Setup the skybox material according to the specified options.
  10629. */
  10630. private _setupSkyboxMaterial;
  10631. /**
  10632. * Setup the skybox reflection texture according to the specified options.
  10633. */
  10634. private _setupSkyboxReflectionTexture;
  10635. private _errorHandler;
  10636. /**
  10637. * Dispose all the elements created by the Helper.
  10638. */
  10639. dispose(): void;
  10640. }
  10641. }
  10642. declare module BABYLON {
  10643. /**
  10644. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10645. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10646. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10647. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10648. */
  10649. class PhotoDome extends TransformNode {
  10650. private _useDirectMapping;
  10651. /**
  10652. * The texture being displayed on the sphere
  10653. */
  10654. protected _photoTexture: Texture;
  10655. /**
  10656. * Gets or sets the texture being displayed on the sphere
  10657. */
  10658. photoTexture: Texture;
  10659. /**
  10660. * Observable raised when an error occured while loading the 360 image
  10661. */
  10662. onLoadErrorObservable: Observable<string>;
  10663. /**
  10664. * The skybox material
  10665. */
  10666. protected _material: BackgroundMaterial;
  10667. /**
  10668. * The surface used for the skybox
  10669. */
  10670. protected _mesh: Mesh;
  10671. /**
  10672. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10673. * Also see the options.resolution property.
  10674. */
  10675. fovMultiplier: number;
  10676. /**
  10677. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10678. * @param name Element's name, child elements will append suffixes for their own names.
  10679. * @param urlsOfPhoto defines the url of the photo to display
  10680. * @param options defines an object containing optional or exposed sub element properties
  10681. * @param onError defines a callback called when an error occured while loading the texture
  10682. */
  10683. constructor(name: string, urlOfPhoto: string, options: {
  10684. resolution?: number;
  10685. size?: number;
  10686. useDirectMapping?: boolean;
  10687. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10688. /**
  10689. * Releases resources associated with this node.
  10690. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10691. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10692. */
  10693. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10694. }
  10695. }
  10696. declare module BABYLON {
  10697. /**
  10698. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10699. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10700. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10701. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10702. */
  10703. class VideoDome extends TransformNode {
  10704. private _useDirectMapping;
  10705. /**
  10706. * The video texture being displayed on the sphere
  10707. */
  10708. protected _videoTexture: VideoTexture;
  10709. /**
  10710. * Gets the video texture being displayed on the sphere
  10711. */
  10712. readonly videoTexture: VideoTexture;
  10713. /**
  10714. * The skybox material
  10715. */
  10716. protected _material: BackgroundMaterial;
  10717. /**
  10718. * The surface used for the skybox
  10719. */
  10720. protected _mesh: Mesh;
  10721. /**
  10722. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10723. * Also see the options.resolution property.
  10724. */
  10725. fovMultiplier: number;
  10726. /**
  10727. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10728. * @param name Element's name, child elements will append suffixes for their own names.
  10729. * @param urlsOrVideo defines the url(s) or the video element to use
  10730. * @param options An object containing optional or exposed sub element properties
  10731. */
  10732. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10733. resolution?: number;
  10734. clickToPlay?: boolean;
  10735. autoPlay?: boolean;
  10736. loop?: boolean;
  10737. size?: number;
  10738. poster?: string;
  10739. useDirectMapping?: boolean;
  10740. }, scene: Scene);
  10741. /**
  10742. * Releases resources associated with this node.
  10743. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10744. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10745. */
  10746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10747. }
  10748. }
  10749. declare module BABYLON {
  10750. /**
  10751. * This class can be used to get instrumentation data from a Babylon engine
  10752. */
  10753. class EngineInstrumentation implements IDisposable {
  10754. engine: Engine;
  10755. private _captureGPUFrameTime;
  10756. private _gpuFrameTimeToken;
  10757. private _gpuFrameTime;
  10758. private _captureShaderCompilationTime;
  10759. private _shaderCompilationTime;
  10760. private _onBeginFrameObserver;
  10761. private _onEndFrameObserver;
  10762. private _onBeforeShaderCompilationObserver;
  10763. private _onAfterShaderCompilationObserver;
  10764. /**
  10765. * Gets the perf counter used for GPU frame time
  10766. */
  10767. readonly gpuFrameTimeCounter: PerfCounter;
  10768. /**
  10769. * Gets the GPU frame time capture status
  10770. */
  10771. /**
  10772. * Enable or disable the GPU frame time capture
  10773. */
  10774. captureGPUFrameTime: boolean;
  10775. /**
  10776. * Gets the perf counter used for shader compilation time
  10777. */
  10778. readonly shaderCompilationTimeCounter: PerfCounter;
  10779. /**
  10780. * Gets the shader compilation time capture status
  10781. */
  10782. /**
  10783. * Enable or disable the shader compilation time capture
  10784. */
  10785. captureShaderCompilationTime: boolean;
  10786. constructor(engine: Engine);
  10787. dispose(): void;
  10788. }
  10789. }
  10790. declare module BABYLON {
  10791. /**
  10792. * This class can be used to get instrumentation data from a Babylon engine
  10793. */
  10794. class SceneInstrumentation implements IDisposable {
  10795. scene: Scene;
  10796. private _captureActiveMeshesEvaluationTime;
  10797. private _activeMeshesEvaluationTime;
  10798. private _captureRenderTargetsRenderTime;
  10799. private _renderTargetsRenderTime;
  10800. private _captureFrameTime;
  10801. private _frameTime;
  10802. private _captureRenderTime;
  10803. private _renderTime;
  10804. private _captureInterFrameTime;
  10805. private _interFrameTime;
  10806. private _captureParticlesRenderTime;
  10807. private _particlesRenderTime;
  10808. private _captureSpritesRenderTime;
  10809. private _spritesRenderTime;
  10810. private _capturePhysicsTime;
  10811. private _physicsTime;
  10812. private _captureAnimationsTime;
  10813. private _animationsTime;
  10814. private _captureCameraRenderTime;
  10815. private _cameraRenderTime;
  10816. private _onBeforeActiveMeshesEvaluationObserver;
  10817. private _onAfterActiveMeshesEvaluationObserver;
  10818. private _onBeforeRenderTargetsRenderObserver;
  10819. private _onAfterRenderTargetsRenderObserver;
  10820. private _onAfterRenderObserver;
  10821. private _onBeforeDrawPhaseObserver;
  10822. private _onAfterDrawPhaseObserver;
  10823. private _onBeforeAnimationsObserver;
  10824. private _onBeforeParticlesRenderingObserver;
  10825. private _onAfterParticlesRenderingObserver;
  10826. private _onBeforeSpritesRenderingObserver;
  10827. private _onAfterSpritesRenderingObserver;
  10828. private _onBeforePhysicsObserver;
  10829. private _onAfterPhysicsObserver;
  10830. private _onAfterAnimationsObserver;
  10831. private _onBeforeCameraRenderObserver;
  10832. private _onAfterCameraRenderObserver;
  10833. /**
  10834. * Gets the perf counter used for active meshes evaluation time
  10835. */
  10836. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10837. /**
  10838. * Gets the active meshes evaluation time capture status
  10839. */
  10840. /**
  10841. * Enable or disable the active meshes evaluation time capture
  10842. */
  10843. captureActiveMeshesEvaluationTime: boolean;
  10844. /**
  10845. * Gets the perf counter used for render targets render time
  10846. */
  10847. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10848. /**
  10849. * Gets the render targets render time capture status
  10850. */
  10851. /**
  10852. * Enable or disable the render targets render time capture
  10853. */
  10854. captureRenderTargetsRenderTime: boolean;
  10855. /**
  10856. * Gets the perf counter used for particles render time
  10857. */
  10858. readonly particlesRenderTimeCounter: PerfCounter;
  10859. /**
  10860. * Gets the particles render time capture status
  10861. */
  10862. /**
  10863. * Enable or disable the particles render time capture
  10864. */
  10865. captureParticlesRenderTime: boolean;
  10866. /**
  10867. * Gets the perf counter used for sprites render time
  10868. */
  10869. readonly spritesRenderTimeCounter: PerfCounter;
  10870. /**
  10871. * Gets the sprites render time capture status
  10872. */
  10873. /**
  10874. * Enable or disable the sprites render time capture
  10875. */
  10876. captureSpritesRenderTime: boolean;
  10877. /**
  10878. * Gets the perf counter used for physics time
  10879. */
  10880. readonly physicsTimeCounter: PerfCounter;
  10881. /**
  10882. * Gets the physics time capture status
  10883. */
  10884. /**
  10885. * Enable or disable the physics time capture
  10886. */
  10887. capturePhysicsTime: boolean;
  10888. /**
  10889. * Gets the perf counter used for animations time
  10890. */
  10891. readonly animationsTimeCounter: PerfCounter;
  10892. /**
  10893. * Gets the animations time capture status
  10894. */
  10895. /**
  10896. * Enable or disable the animations time capture
  10897. */
  10898. captureAnimationsTime: boolean;
  10899. /**
  10900. * Gets the perf counter used for frame time capture
  10901. */
  10902. readonly frameTimeCounter: PerfCounter;
  10903. /**
  10904. * Gets the frame time capture status
  10905. */
  10906. /**
  10907. * Enable or disable the frame time capture
  10908. */
  10909. captureFrameTime: boolean;
  10910. /**
  10911. * Gets the perf counter used for inter-frames time capture
  10912. */
  10913. readonly interFrameTimeCounter: PerfCounter;
  10914. /**
  10915. * Gets the inter-frames time capture status
  10916. */
  10917. /**
  10918. * Enable or disable the inter-frames time capture
  10919. */
  10920. captureInterFrameTime: boolean;
  10921. /**
  10922. * Gets the perf counter used for render time capture
  10923. */
  10924. readonly renderTimeCounter: PerfCounter;
  10925. /**
  10926. * Gets the render time capture status
  10927. */
  10928. /**
  10929. * Enable or disable the render time capture
  10930. */
  10931. captureRenderTime: boolean;
  10932. /**
  10933. * Gets the perf counter used for camera render time capture
  10934. */
  10935. readonly cameraRenderTimeCounter: PerfCounter;
  10936. /**
  10937. * Gets the camera render time capture status
  10938. */
  10939. /**
  10940. * Enable or disable the camera render time capture
  10941. */
  10942. captureCameraRenderTime: boolean;
  10943. /**
  10944. * Gets the perf counter used for draw calls
  10945. */
  10946. readonly drawCallsCounter: PerfCounter;
  10947. /**
  10948. * Gets the perf counter used for texture collisions
  10949. */
  10950. readonly textureCollisionsCounter: PerfCounter;
  10951. constructor(scene: Scene);
  10952. dispose(): void;
  10953. }
  10954. }
  10955. declare module BABYLON {
  10956. /**
  10957. * @hidden
  10958. **/
  10959. class _TimeToken {
  10960. _startTimeQuery: Nullable<WebGLQuery>;
  10961. _endTimeQuery: Nullable<WebGLQuery>;
  10962. _timeElapsedQuery: Nullable<WebGLQuery>;
  10963. _timeElapsedQueryEnded: boolean;
  10964. }
  10965. }
  10966. declare module BABYLON {
  10967. /**
  10968. * Effect layer options. This helps customizing the behaviour
  10969. * of the effect layer.
  10970. */
  10971. interface IEffectLayerOptions {
  10972. /**
  10973. * Multiplication factor apply to the canvas size to compute the render target size
  10974. * used to generated the objects (the smaller the faster).
  10975. */
  10976. mainTextureRatio: number;
  10977. /**
  10978. * Enforces a fixed size texture to ensure effect stability across devices.
  10979. */
  10980. mainTextureFixedSize?: number;
  10981. /**
  10982. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10983. */
  10984. alphaBlendingMode: number;
  10985. /**
  10986. * The camera attached to the layer.
  10987. */
  10988. camera: Nullable<Camera>;
  10989. /**
  10990. * The rendering group to draw the layer in.
  10991. */
  10992. renderingGroupId: number;
  10993. }
  10994. /**
  10995. * The effect layer Helps adding post process effect blended with the main pass.
  10996. *
  10997. * This can be for instance use to generate glow or higlight effects on the scene.
  10998. *
  10999. * The effect layer class can not be used directly and is intented to inherited from to be
  11000. * customized per effects.
  11001. */
  11002. abstract class EffectLayer {
  11003. private _vertexBuffers;
  11004. private _indexBuffer;
  11005. private _cachedDefines;
  11006. private _effectLayerMapGenerationEffect;
  11007. private _effectLayerOptions;
  11008. private _mergeEffect;
  11009. protected _scene: Scene;
  11010. protected _engine: Engine;
  11011. protected _maxSize: number;
  11012. protected _mainTextureDesiredSize: ISize;
  11013. protected _mainTexture: RenderTargetTexture;
  11014. protected _shouldRender: boolean;
  11015. protected _postProcesses: PostProcess[];
  11016. protected _textures: BaseTexture[];
  11017. protected _emissiveTextureAndColor: {
  11018. texture: Nullable<BaseTexture>;
  11019. color: Color4;
  11020. };
  11021. /**
  11022. * The name of the layer
  11023. */
  11024. name: string;
  11025. /**
  11026. * The clear color of the texture used to generate the glow map.
  11027. */
  11028. neutralColor: Color4;
  11029. /**
  11030. * Specifies wether the highlight layer is enabled or not.
  11031. */
  11032. isEnabled: boolean;
  11033. /**
  11034. * Gets the camera attached to the layer.
  11035. */
  11036. readonly camera: Nullable<Camera>;
  11037. /**
  11038. * Gets the rendering group id the layer should render in.
  11039. */
  11040. readonly renderingGroupId: number;
  11041. /**
  11042. * An event triggered when the effect layer has been disposed.
  11043. */
  11044. onDisposeObservable: Observable<EffectLayer>;
  11045. /**
  11046. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11047. */
  11048. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11049. /**
  11050. * An event triggered when the generated texture is being merged in the scene.
  11051. */
  11052. onBeforeComposeObservable: Observable<EffectLayer>;
  11053. /**
  11054. * An event triggered when the generated texture has been merged in the scene.
  11055. */
  11056. onAfterComposeObservable: Observable<EffectLayer>;
  11057. /**
  11058. * An event triggered when the efffect layer changes its size.
  11059. */
  11060. onSizeChangedObservable: Observable<EffectLayer>;
  11061. /**
  11062. * Instantiates a new effect Layer and references it in the scene.
  11063. * @param name The name of the layer
  11064. * @param scene The scene to use the layer in
  11065. */
  11066. constructor(
  11067. /** The Friendly of the effect in the scene */
  11068. name: string, scene: Scene);
  11069. /**
  11070. * Get the effect name of the layer.
  11071. * @return The effect name
  11072. */
  11073. abstract getEffectName(): string;
  11074. /**
  11075. * Checks for the readiness of the element composing the layer.
  11076. * @param subMesh the mesh to check for
  11077. * @param useInstances specify wether or not to use instances to render the mesh
  11078. * @return true if ready otherwise, false
  11079. */
  11080. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11081. /**
  11082. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11083. * @returns true if the effect requires stencil during the main canvas render pass.
  11084. */
  11085. abstract needStencil(): boolean;
  11086. /**
  11087. * Create the merge effect. This is the shader use to blit the information back
  11088. * to the main canvas at the end of the scene rendering.
  11089. * @returns The effect containing the shader used to merge the effect on the main canvas
  11090. */
  11091. protected abstract _createMergeEffect(): Effect;
  11092. /**
  11093. * Creates the render target textures and post processes used in the effect layer.
  11094. */
  11095. protected abstract _createTextureAndPostProcesses(): void;
  11096. /**
  11097. * Implementation specific of rendering the generating effect on the main canvas.
  11098. * @param effect The effect used to render through
  11099. */
  11100. protected abstract _internalRender(effect: Effect): void;
  11101. /**
  11102. * Sets the required values for both the emissive texture and and the main color.
  11103. */
  11104. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11105. /**
  11106. * Free any resources and references associated to a mesh.
  11107. * Internal use
  11108. * @param mesh The mesh to free.
  11109. */
  11110. abstract _disposeMesh(mesh: Mesh): void;
  11111. /**
  11112. * Serializes this layer (Glow or Highlight for example)
  11113. * @returns a serialized layer object
  11114. */
  11115. abstract serialize?(): any;
  11116. /**
  11117. * Initializes the effect layer with the required options.
  11118. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11119. */
  11120. protected _init(options: Partial<IEffectLayerOptions>): void;
  11121. /**
  11122. * Generates the index buffer of the full screen quad blending to the main canvas.
  11123. */
  11124. private _generateIndexBuffer;
  11125. /**
  11126. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11127. */
  11128. private _genrateVertexBuffer;
  11129. /**
  11130. * Sets the main texture desired size which is the closest power of two
  11131. * of the engine canvas size.
  11132. */
  11133. private _setMainTextureSize;
  11134. /**
  11135. * Creates the main texture for the effect layer.
  11136. */
  11137. protected _createMainTexture(): void;
  11138. /**
  11139. * Checks for the readiness of the element composing the layer.
  11140. * @param subMesh the mesh to check for
  11141. * @param useInstances specify wether or not to use instances to render the mesh
  11142. * @param emissiveTexture the associated emissive texture used to generate the glow
  11143. * @return true if ready otherwise, false
  11144. */
  11145. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11146. /**
  11147. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11148. */
  11149. render(): void;
  11150. /**
  11151. * Determine if a given mesh will be used in the current effect.
  11152. * @param mesh mesh to test
  11153. * @returns true if the mesh will be used
  11154. */
  11155. hasMesh(mesh: AbstractMesh): boolean;
  11156. /**
  11157. * Returns true if the layer contains information to display, otherwise false.
  11158. * @returns true if the glow layer should be rendered
  11159. */
  11160. shouldRender(): boolean;
  11161. /**
  11162. * Returns true if the mesh should render, otherwise false.
  11163. * @param mesh The mesh to render
  11164. * @returns true if it should render otherwise false
  11165. */
  11166. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11167. /**
  11168. * Returns true if the mesh should render, otherwise false.
  11169. * @param mesh The mesh to render
  11170. * @returns true if it should render otherwise false
  11171. */
  11172. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11173. /**
  11174. * Renders the submesh passed in parameter to the generation map.
  11175. */
  11176. protected _renderSubMesh(subMesh: SubMesh): void;
  11177. /**
  11178. * Rebuild the required buffers.
  11179. * @hidden Internal use only.
  11180. */
  11181. _rebuild(): void;
  11182. /**
  11183. * Dispose only the render target textures and post process.
  11184. */
  11185. private _disposeTextureAndPostProcesses;
  11186. /**
  11187. * Dispose the highlight layer and free resources.
  11188. */
  11189. dispose(): void;
  11190. /**
  11191. * Gets the class name of the effect layer
  11192. * @returns the string with the class name of the effect layer
  11193. */
  11194. getClassName(): string;
  11195. /**
  11196. * Creates an effect layer from parsed effect layer data
  11197. * @param parsedEffectLayer defines effect layer data
  11198. * @param scene defines the current scene
  11199. * @param rootUrl defines the root URL containing the effect layer information
  11200. * @returns a parsed effect Layer
  11201. */
  11202. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11203. }
  11204. }
  11205. declare module BABYLON {
  11206. interface AbstractScene {
  11207. /**
  11208. * The list of effect layers (highlights/glow) added to the scene
  11209. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11210. * @see http://doc.babylonjs.com/how_to/glow_layer
  11211. */
  11212. effectLayers: Array<EffectLayer>;
  11213. /**
  11214. * Removes the given effect layer from this scene.
  11215. * @param toRemove defines the effect layer to remove
  11216. * @returns the index of the removed effect layer
  11217. */
  11218. removeEffectLayer(toRemove: EffectLayer): number;
  11219. /**
  11220. * Adds the given effect layer to this scene
  11221. * @param newEffectLayer defines the effect layer to add
  11222. */
  11223. addEffectLayer(newEffectLayer: EffectLayer): void;
  11224. }
  11225. /**
  11226. * Defines the layer scene component responsible to manage any effect layers
  11227. * in a given scene.
  11228. */
  11229. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11230. /**
  11231. * The component name helpfull to identify the component in the list of scene components.
  11232. */
  11233. readonly name: string;
  11234. /**
  11235. * The scene the component belongs to.
  11236. */
  11237. scene: Scene;
  11238. private _engine;
  11239. private _renderEffects;
  11240. private _needStencil;
  11241. private _previousStencilState;
  11242. /**
  11243. * Creates a new instance of the component for the given scene
  11244. * @param scene Defines the scene to register the component in
  11245. */
  11246. constructor(scene: Scene);
  11247. /**
  11248. * Registers the component in a given scene
  11249. */
  11250. register(): void;
  11251. /**
  11252. * Rebuilds the elements related to this component in case of
  11253. * context lost for instance.
  11254. */
  11255. rebuild(): void;
  11256. /**
  11257. * Serializes the component data to the specified json object
  11258. * @param serializationObject The object to serialize to
  11259. */
  11260. serialize(serializationObject: any): void;
  11261. /**
  11262. * Adds all the element from the container to the scene
  11263. * @param container the container holding the elements
  11264. */
  11265. addFromContainer(container: AbstractScene): void;
  11266. /**
  11267. * Removes all the elements in the container from the scene
  11268. * @param container contains the elements to remove
  11269. */
  11270. removeFromContainer(container: AbstractScene): void;
  11271. /**
  11272. * Disposes the component and the associated ressources.
  11273. */
  11274. dispose(): void;
  11275. private _isReadyForMesh;
  11276. private _renderMainTexture;
  11277. private _setStencil;
  11278. private _setStencilBack;
  11279. private _draw;
  11280. private _drawCamera;
  11281. private _drawRenderingGroup;
  11282. }
  11283. }
  11284. declare module BABYLON {
  11285. interface AbstractScene {
  11286. /**
  11287. * Return a the first highlight layer of the scene with a given name.
  11288. * @param name The name of the highlight layer to look for.
  11289. * @return The highlight layer if found otherwise null.
  11290. */
  11291. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11292. }
  11293. /**
  11294. * Glow layer options. This helps customizing the behaviour
  11295. * of the glow layer.
  11296. */
  11297. interface IGlowLayerOptions {
  11298. /**
  11299. * Multiplication factor apply to the canvas size to compute the render target size
  11300. * used to generated the glowing objects (the smaller the faster).
  11301. */
  11302. mainTextureRatio: number;
  11303. /**
  11304. * Enforces a fixed size texture to ensure resize independant blur.
  11305. */
  11306. mainTextureFixedSize?: number;
  11307. /**
  11308. * How big is the kernel of the blur texture.
  11309. */
  11310. blurKernelSize: number;
  11311. /**
  11312. * The camera attached to the layer.
  11313. */
  11314. camera: Nullable<Camera>;
  11315. /**
  11316. * Enable MSAA by chosing the number of samples.
  11317. */
  11318. mainTextureSamples?: number;
  11319. /**
  11320. * The rendering group to draw the layer in.
  11321. */
  11322. renderingGroupId: number;
  11323. }
  11324. /**
  11325. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11326. *
  11327. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11328. * glowy meshes to your scene.
  11329. *
  11330. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11331. */
  11332. class GlowLayer extends EffectLayer {
  11333. /**
  11334. * Effect Name of the layer.
  11335. */
  11336. static readonly EffectName: string;
  11337. /**
  11338. * The default blur kernel size used for the glow.
  11339. */
  11340. static DefaultBlurKernelSize: number;
  11341. /**
  11342. * The default texture size ratio used for the glow.
  11343. */
  11344. static DefaultTextureRatio: number;
  11345. /**
  11346. * Sets the kernel size of the blur.
  11347. */
  11348. /**
  11349. * Gets the kernel size of the blur.
  11350. */
  11351. blurKernelSize: number;
  11352. /**
  11353. * Sets the glow intensity.
  11354. */
  11355. /**
  11356. * Gets the glow intensity.
  11357. */
  11358. intensity: number;
  11359. private _options;
  11360. private _intensity;
  11361. private _horizontalBlurPostprocess1;
  11362. private _verticalBlurPostprocess1;
  11363. private _horizontalBlurPostprocess2;
  11364. private _verticalBlurPostprocess2;
  11365. private _blurTexture1;
  11366. private _blurTexture2;
  11367. private _postProcesses1;
  11368. private _postProcesses2;
  11369. private _includedOnlyMeshes;
  11370. private _excludedMeshes;
  11371. /**
  11372. * Callback used to let the user override the color selection on a per mesh basis
  11373. */
  11374. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11375. /**
  11376. * Callback used to let the user override the texture selection on a per mesh basis
  11377. */
  11378. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11379. /**
  11380. * Instantiates a new glow Layer and references it to the scene.
  11381. * @param name The name of the layer
  11382. * @param scene The scene to use the layer in
  11383. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11384. */
  11385. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11386. /**
  11387. * Get the effect name of the layer.
  11388. * @return The effect name
  11389. */
  11390. getEffectName(): string;
  11391. /**
  11392. * Create the merge effect. This is the shader use to blit the information back
  11393. * to the main canvas at the end of the scene rendering.
  11394. */
  11395. protected _createMergeEffect(): Effect;
  11396. /**
  11397. * Creates the render target textures and post processes used in the glow layer.
  11398. */
  11399. protected _createTextureAndPostProcesses(): void;
  11400. /**
  11401. * Checks for the readiness of the element composing the layer.
  11402. * @param subMesh the mesh to check for
  11403. * @param useInstances specify wether or not to use instances to render the mesh
  11404. * @param emissiveTexture the associated emissive texture used to generate the glow
  11405. * @return true if ready otherwise, false
  11406. */
  11407. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11408. /**
  11409. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11410. */
  11411. needStencil(): boolean;
  11412. /**
  11413. * Implementation specific of rendering the generating effect on the main canvas.
  11414. * @param effect The effect used to render through
  11415. */
  11416. protected _internalRender(effect: Effect): void;
  11417. /**
  11418. * Sets the required values for both the emissive texture and and the main color.
  11419. */
  11420. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11421. /**
  11422. * Returns true if the mesh should render, otherwise false.
  11423. * @param mesh The mesh to render
  11424. * @returns true if it should render otherwise false
  11425. */
  11426. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11427. /**
  11428. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11429. * @param mesh The mesh to exclude from the glow layer
  11430. */
  11431. addExcludedMesh(mesh: Mesh): void;
  11432. /**
  11433. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11434. * @param mesh The mesh to remove
  11435. */
  11436. removeExcludedMesh(mesh: Mesh): void;
  11437. /**
  11438. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11439. * @param mesh The mesh to include in the glow layer
  11440. */
  11441. addIncludedOnlyMesh(mesh: Mesh): void;
  11442. /**
  11443. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11444. * @param mesh The mesh to remove
  11445. */
  11446. removeIncludedOnlyMesh(mesh: Mesh): void;
  11447. /**
  11448. * Determine if a given mesh will be used in the glow layer
  11449. * @param mesh The mesh to test
  11450. * @returns true if the mesh will be highlighted by the current glow layer
  11451. */
  11452. hasMesh(mesh: AbstractMesh): boolean;
  11453. /**
  11454. * Free any resources and references associated to a mesh.
  11455. * Internal use
  11456. * @param mesh The mesh to free.
  11457. * @hidden
  11458. */
  11459. _disposeMesh(mesh: Mesh): void;
  11460. /**
  11461. * Gets the class name of the effect layer
  11462. * @returns the string with the class name of the effect layer
  11463. */
  11464. getClassName(): string;
  11465. /**
  11466. * Serializes this glow layer
  11467. * @returns a serialized glow layer object
  11468. */
  11469. serialize(): any;
  11470. /**
  11471. * Creates a Glow Layer from parsed glow layer data
  11472. * @param parsedGlowLayer defines glow layer data
  11473. * @param scene defines the current scene
  11474. * @param rootUrl defines the root URL containing the glow layer information
  11475. * @returns a parsed Glow Layer
  11476. */
  11477. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11478. }
  11479. }
  11480. declare module BABYLON {
  11481. interface AbstractScene {
  11482. /**
  11483. * Return a the first highlight layer of the scene with a given name.
  11484. * @param name The name of the highlight layer to look for.
  11485. * @return The highlight layer if found otherwise null.
  11486. */
  11487. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11488. }
  11489. /**
  11490. * Highlight layer options. This helps customizing the behaviour
  11491. * of the highlight layer.
  11492. */
  11493. interface IHighlightLayerOptions {
  11494. /**
  11495. * Multiplication factor apply to the canvas size to compute the render target size
  11496. * used to generated the glowing objects (the smaller the faster).
  11497. */
  11498. mainTextureRatio: number;
  11499. /**
  11500. * Enforces a fixed size texture to ensure resize independant blur.
  11501. */
  11502. mainTextureFixedSize?: number;
  11503. /**
  11504. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11505. * of the picture to blur (the smaller the faster).
  11506. */
  11507. blurTextureSizeRatio: number;
  11508. /**
  11509. * How big in texel of the blur texture is the vertical blur.
  11510. */
  11511. blurVerticalSize: number;
  11512. /**
  11513. * How big in texel of the blur texture is the horizontal blur.
  11514. */
  11515. blurHorizontalSize: number;
  11516. /**
  11517. * Alpha blending mode used to apply the blur. Default is combine.
  11518. */
  11519. alphaBlendingMode: number;
  11520. /**
  11521. * The camera attached to the layer.
  11522. */
  11523. camera: Nullable<Camera>;
  11524. /**
  11525. * Should we display highlight as a solid stroke?
  11526. */
  11527. isStroke?: boolean;
  11528. /**
  11529. * The rendering group to draw the layer in.
  11530. */
  11531. renderingGroupId: number;
  11532. }
  11533. /**
  11534. * The highlight layer Helps adding a glow effect around a mesh.
  11535. *
  11536. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11537. * glowy meshes to your scene.
  11538. *
  11539. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11540. */
  11541. class HighlightLayer extends EffectLayer {
  11542. name: string;
  11543. /**
  11544. * Effect Name of the highlight layer.
  11545. */
  11546. static readonly EffectName: string;
  11547. /**
  11548. * The neutral color used during the preparation of the glow effect.
  11549. * This is black by default as the blend operation is a blend operation.
  11550. */
  11551. static NeutralColor: Color4;
  11552. /**
  11553. * Stencil value used for glowing meshes.
  11554. */
  11555. static GlowingMeshStencilReference: number;
  11556. /**
  11557. * Stencil value used for the other meshes in the scene.
  11558. */
  11559. static NormalMeshStencilReference: number;
  11560. /**
  11561. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11562. */
  11563. innerGlow: boolean;
  11564. /**
  11565. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11566. */
  11567. outerGlow: boolean;
  11568. /**
  11569. * Specifies the horizontal size of the blur.
  11570. */
  11571. /**
  11572. * Gets the horizontal size of the blur.
  11573. */
  11574. blurHorizontalSize: number;
  11575. /**
  11576. * Specifies the vertical size of the blur.
  11577. */
  11578. /**
  11579. * Gets the vertical size of the blur.
  11580. */
  11581. blurVerticalSize: number;
  11582. /**
  11583. * An event triggered when the highlight layer is being blurred.
  11584. */
  11585. onBeforeBlurObservable: Observable<HighlightLayer>;
  11586. /**
  11587. * An event triggered when the highlight layer has been blurred.
  11588. */
  11589. onAfterBlurObservable: Observable<HighlightLayer>;
  11590. private _instanceGlowingMeshStencilReference;
  11591. private _options;
  11592. private _downSamplePostprocess;
  11593. private _horizontalBlurPostprocess;
  11594. private _verticalBlurPostprocess;
  11595. private _blurTexture;
  11596. private _meshes;
  11597. private _excludedMeshes;
  11598. /**
  11599. * Instantiates a new highlight Layer and references it to the scene..
  11600. * @param name The name of the layer
  11601. * @param scene The scene to use the layer in
  11602. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11603. */
  11604. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11605. /**
  11606. * Get the effect name of the layer.
  11607. * @return The effect name
  11608. */
  11609. getEffectName(): string;
  11610. /**
  11611. * Create the merge effect. This is the shader use to blit the information back
  11612. * to the main canvas at the end of the scene rendering.
  11613. */
  11614. protected _createMergeEffect(): Effect;
  11615. /**
  11616. * Creates the render target textures and post processes used in the highlight layer.
  11617. */
  11618. protected _createTextureAndPostProcesses(): void;
  11619. /**
  11620. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11621. */
  11622. needStencil(): boolean;
  11623. /**
  11624. * Checks for the readiness of the element composing the layer.
  11625. * @param subMesh the mesh to check for
  11626. * @param useInstances specify wether or not to use instances to render the mesh
  11627. * @param emissiveTexture the associated emissive texture used to generate the glow
  11628. * @return true if ready otherwise, false
  11629. */
  11630. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11631. /**
  11632. * Implementation specific of rendering the generating effect on the main canvas.
  11633. * @param effect The effect used to render through
  11634. */
  11635. protected _internalRender(effect: Effect): void;
  11636. /**
  11637. * Returns true if the layer contains information to display, otherwise false.
  11638. */
  11639. shouldRender(): boolean;
  11640. /**
  11641. * Returns true if the mesh should render, otherwise false.
  11642. * @param mesh The mesh to render
  11643. * @returns true if it should render otherwise false
  11644. */
  11645. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11646. /**
  11647. * Sets the required values for both the emissive texture and and the main color.
  11648. */
  11649. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11650. /**
  11651. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11652. * @param mesh The mesh to exclude from the highlight layer
  11653. */
  11654. addExcludedMesh(mesh: Mesh): void;
  11655. /**
  11656. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11657. * @param mesh The mesh to highlight
  11658. */
  11659. removeExcludedMesh(mesh: Mesh): void;
  11660. /**
  11661. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11662. * @param mesh mesh to test
  11663. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11664. */
  11665. hasMesh(mesh: AbstractMesh): boolean;
  11666. /**
  11667. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11668. * @param mesh The mesh to highlight
  11669. * @param color The color of the highlight
  11670. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11671. */
  11672. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11673. /**
  11674. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11675. * @param mesh The mesh to highlight
  11676. */
  11677. removeMesh(mesh: Mesh): void;
  11678. /**
  11679. * Force the stencil to the normal expected value for none glowing parts
  11680. */
  11681. private _defaultStencilReference;
  11682. /**
  11683. * Free any resources and references associated to a mesh.
  11684. * Internal use
  11685. * @param mesh The mesh to free.
  11686. * @hidden
  11687. */
  11688. _disposeMesh(mesh: Mesh): void;
  11689. /**
  11690. * Dispose the highlight layer and free resources.
  11691. */
  11692. dispose(): void;
  11693. /**
  11694. * Gets the class name of the effect layer
  11695. * @returns the string with the class name of the effect layer
  11696. */
  11697. getClassName(): string;
  11698. /**
  11699. * Serializes this Highlight layer
  11700. * @returns a serialized Highlight layer object
  11701. */
  11702. serialize(): any;
  11703. /**
  11704. * Creates a Highlight layer from parsed Highlight layer data
  11705. * @param parsedHightlightLayer defines the Highlight layer data
  11706. * @param scene defines the current scene
  11707. * @param rootUrl defines the root URL containing the Highlight layer information
  11708. * @returns a parsed Highlight layer
  11709. */
  11710. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11711. }
  11712. }
  11713. declare module BABYLON {
  11714. class Layer {
  11715. name: string;
  11716. texture: Nullable<Texture>;
  11717. isBackground: boolean;
  11718. color: Color4;
  11719. scale: Vector2;
  11720. offset: Vector2;
  11721. alphaBlendingMode: number;
  11722. alphaTest: boolean;
  11723. layerMask: number;
  11724. private _scene;
  11725. private _vertexBuffers;
  11726. private _indexBuffer;
  11727. private _effect;
  11728. private _alphaTestEffect;
  11729. /**
  11730. * An event triggered when the layer is disposed.
  11731. */
  11732. onDisposeObservable: Observable<Layer>;
  11733. private _onDisposeObserver;
  11734. onDispose: () => void;
  11735. /**
  11736. * An event triggered before rendering the scene
  11737. */
  11738. onBeforeRenderObservable: Observable<Layer>;
  11739. private _onBeforeRenderObserver;
  11740. onBeforeRender: () => void;
  11741. /**
  11742. * An event triggered after rendering the scene
  11743. */
  11744. onAfterRenderObservable: Observable<Layer>;
  11745. private _onAfterRenderObserver;
  11746. onAfterRender: () => void;
  11747. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11748. private _createIndexBuffer;
  11749. /** @hidden */
  11750. _rebuild(): void;
  11751. render(): void;
  11752. dispose(): void;
  11753. }
  11754. }
  11755. declare module BABYLON {
  11756. interface AbstractScene {
  11757. /**
  11758. * The list of layers (background and foreground) of the scene
  11759. */
  11760. layers: Array<Layer>;
  11761. }
  11762. /**
  11763. * Defines the layer scene component responsible to manage any layers
  11764. * in a given scene.
  11765. */
  11766. class LayerSceneComponent implements ISceneComponent {
  11767. /**
  11768. * The component name helpfull to identify the component in the list of scene components.
  11769. */
  11770. readonly name: string;
  11771. /**
  11772. * The scene the component belongs to.
  11773. */
  11774. scene: Scene;
  11775. private _engine;
  11776. /**
  11777. * Creates a new instance of the component for the given scene
  11778. * @param scene Defines the scene to register the component in
  11779. */
  11780. constructor(scene: Scene);
  11781. /**
  11782. * Registers the component in a given scene
  11783. */
  11784. register(): void;
  11785. /**
  11786. * Rebuilds the elements related to this component in case of
  11787. * context lost for instance.
  11788. */
  11789. rebuild(): void;
  11790. /**
  11791. * Disposes the component and the associated ressources.
  11792. */
  11793. dispose(): void;
  11794. private _draw;
  11795. private _drawBackground;
  11796. private _drawForeground;
  11797. }
  11798. }
  11799. declare module BABYLON {
  11800. class LensFlare {
  11801. size: number;
  11802. position: number;
  11803. color: Color3;
  11804. texture: Nullable<Texture>;
  11805. alphaMode: number;
  11806. private _system;
  11807. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11808. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11809. dispose(): void;
  11810. }
  11811. }
  11812. declare module BABYLON {
  11813. class LensFlareSystem {
  11814. name: string;
  11815. lensFlares: LensFlare[];
  11816. borderLimit: number;
  11817. viewportBorder: number;
  11818. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11819. layerMask: number;
  11820. id: string;
  11821. private _scene;
  11822. private _emitter;
  11823. private _vertexBuffers;
  11824. private _indexBuffer;
  11825. private _effect;
  11826. private _positionX;
  11827. private _positionY;
  11828. private _isEnabled;
  11829. constructor(name: string, emitter: any, scene: Scene);
  11830. isEnabled: boolean;
  11831. getScene(): Scene;
  11832. getEmitter(): any;
  11833. setEmitter(newEmitter: any): void;
  11834. getEmitterPosition(): Vector3;
  11835. computeEffectivePosition(globalViewport: Viewport): boolean;
  11836. /** @hidden */
  11837. _isVisible(): boolean;
  11838. render(): boolean;
  11839. dispose(): void;
  11840. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11841. serialize(): any;
  11842. }
  11843. }
  11844. declare module BABYLON {
  11845. interface AbstractScene {
  11846. /**
  11847. * The list of lens flare system added to the scene
  11848. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11849. */
  11850. lensFlareSystems: Array<LensFlareSystem>;
  11851. /**
  11852. * Removes the given lens flare system from this scene.
  11853. * @param toRemove The lens flare system to remove
  11854. * @returns The index of the removed lens flare system
  11855. */
  11856. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11857. /**
  11858. * Adds the given lens flare system to this scene
  11859. * @param newLensFlareSystem The lens flare system to add
  11860. */
  11861. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11862. /**
  11863. * Gets a lens flare system using its name
  11864. * @param name defines the name to look for
  11865. * @returns the lens flare system or null if not found
  11866. */
  11867. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11868. /**
  11869. * Gets a lens flare system using its id
  11870. * @param id defines the id to look for
  11871. * @returns the lens flare system or null if not found
  11872. */
  11873. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11874. }
  11875. /**
  11876. * Defines the lens flare scene component responsible to manage any lens flares
  11877. * in a given scene.
  11878. */
  11879. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11880. /**
  11881. * The component name helpfull to identify the component in the list of scene components.
  11882. */
  11883. readonly name: string;
  11884. /**
  11885. * The scene the component belongs to.
  11886. */
  11887. scene: Scene;
  11888. /**
  11889. * Creates a new instance of the component for the given scene
  11890. * @param scene Defines the scene to register the component in
  11891. */
  11892. constructor(scene: Scene);
  11893. /**
  11894. * Registers the component in a given scene
  11895. */
  11896. register(): void;
  11897. /**
  11898. * Rebuilds the elements related to this component in case of
  11899. * context lost for instance.
  11900. */
  11901. rebuild(): void;
  11902. /**
  11903. * Adds all the element from the container to the scene
  11904. * @param container the container holding the elements
  11905. */
  11906. addFromContainer(container: AbstractScene): void;
  11907. /**
  11908. * Removes all the elements in the container from the scene
  11909. * @param container contains the elements to remove
  11910. */
  11911. removeFromContainer(container: AbstractScene): void;
  11912. /**
  11913. * Serializes the component data to the specified json object
  11914. * @param serializationObject The object to serialize to
  11915. */
  11916. serialize(serializationObject: any): void;
  11917. /**
  11918. * Disposes the component and the associated ressources.
  11919. */
  11920. dispose(): void;
  11921. private _draw;
  11922. }
  11923. }
  11924. declare module BABYLON {
  11925. /**
  11926. * A directional light is defined by a direction (what a surprise!).
  11927. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11928. * 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.
  11929. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11930. */
  11931. class DirectionalLight extends ShadowLight {
  11932. private _shadowFrustumSize;
  11933. /**
  11934. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11935. */
  11936. /**
  11937. * Specifies a fix frustum size for the shadow generation.
  11938. */
  11939. shadowFrustumSize: number;
  11940. private _shadowOrthoScale;
  11941. /**
  11942. * Gets the shadow projection scale against the optimal computed one.
  11943. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11944. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11945. */
  11946. /**
  11947. * Sets the shadow projection scale against the optimal computed one.
  11948. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11949. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11950. */
  11951. shadowOrthoScale: number;
  11952. /**
  11953. * Automatically compute the projection matrix to best fit (including all the casters)
  11954. * on each frame.
  11955. */
  11956. autoUpdateExtends: boolean;
  11957. private _orthoLeft;
  11958. private _orthoRight;
  11959. private _orthoTop;
  11960. private _orthoBottom;
  11961. /**
  11962. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11963. * The directional light is emitted from everywhere in the given direction.
  11964. * It can cast shawdows.
  11965. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11966. * @param name The friendly name of the light
  11967. * @param direction The direction of the light
  11968. * @param scene The scene the light belongs to
  11969. */
  11970. constructor(name: string, direction: Vector3, scene: Scene);
  11971. /**
  11972. * Returns the string "DirectionalLight".
  11973. * @return The class name
  11974. */
  11975. getClassName(): string;
  11976. /**
  11977. * Returns the integer 1.
  11978. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11979. */
  11980. getTypeID(): number;
  11981. /**
  11982. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11983. * Returns the DirectionalLight Shadow projection matrix.
  11984. */
  11985. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11986. /**
  11987. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11988. * Returns the DirectionalLight Shadow projection matrix.
  11989. */
  11990. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11991. /**
  11992. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11993. * Returns the DirectionalLight Shadow projection matrix.
  11994. */
  11995. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11996. protected _buildUniformLayout(): void;
  11997. /**
  11998. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11999. * @param effect The effect to update
  12000. * @param lightIndex The index of the light in the effect to update
  12001. * @returns The directional light
  12002. */
  12003. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  12004. /**
  12005. * Gets the minZ used for shadow according to both the scene and the light.
  12006. *
  12007. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12008. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12009. * @param activeCamera The camera we are returning the min for
  12010. * @returns the depth min z
  12011. */
  12012. getDepthMinZ(activeCamera: Camera): number;
  12013. /**
  12014. * Gets the maxZ used for shadow according to both the scene and the light.
  12015. *
  12016. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12017. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12018. * @param activeCamera The camera we are returning the max for
  12019. * @returns the depth max z
  12020. */
  12021. getDepthMaxZ(activeCamera: Camera): number;
  12022. /**
  12023. * Prepares the list of defines specific to the light type.
  12024. * @param defines the list of defines
  12025. * @param lightIndex defines the index of the light for the effect
  12026. */
  12027. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12028. }
  12029. }
  12030. declare module BABYLON {
  12031. /**
  12032. * The HemisphericLight simulates the ambient environment light,
  12033. * so the passed direction is the light reflection direction, not the incoming direction.
  12034. */
  12035. class HemisphericLight extends Light {
  12036. /**
  12037. * The groundColor is the light in the opposite direction to the one specified during creation.
  12038. * 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.
  12039. */
  12040. groundColor: Color3;
  12041. /**
  12042. * The light reflection direction, not the incoming direction.
  12043. */
  12044. direction: Vector3;
  12045. private _worldMatrix;
  12046. /**
  12047. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12048. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12049. * The HemisphericLight can't cast shadows.
  12050. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12051. * @param name The friendly name of the light
  12052. * @param direction The direction of the light reflection
  12053. * @param scene The scene the light belongs to
  12054. */
  12055. constructor(name: string, direction: Vector3, scene: Scene);
  12056. protected _buildUniformLayout(): void;
  12057. /**
  12058. * Returns the string "HemisphericLight".
  12059. * @return The class name
  12060. */
  12061. getClassName(): string;
  12062. /**
  12063. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12064. * Returns the updated direction.
  12065. * @param target The target the direction should point to
  12066. * @return The computed direction
  12067. */
  12068. setDirectionToTarget(target: Vector3): Vector3;
  12069. /**
  12070. * Returns the shadow generator associated to the light.
  12071. * @returns Always null for hemispheric lights because it does not support shadows.
  12072. */
  12073. getShadowGenerator(): Nullable<ShadowGenerator>;
  12074. /**
  12075. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12076. * @param effect The effect to update
  12077. * @param lightIndex The index of the light in the effect to update
  12078. * @returns The hemispheric light
  12079. */
  12080. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12081. /**
  12082. * @hidden internal use only.
  12083. */
  12084. _getWorldMatrix(): Matrix;
  12085. /**
  12086. * Returns the integer 3.
  12087. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12088. */
  12089. getTypeID(): number;
  12090. /**
  12091. * Prepares the list of defines specific to the light type.
  12092. * @param defines the list of defines
  12093. * @param lightIndex defines the index of the light for the effect
  12094. */
  12095. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12096. }
  12097. }
  12098. declare module BABYLON {
  12099. /**
  12100. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12101. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12102. * 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.
  12103. */
  12104. abstract class Light extends Node {
  12105. /**
  12106. * Falloff Default: light is falling off following the material specification:
  12107. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12108. */
  12109. static readonly FALLOFF_DEFAULT: number;
  12110. /**
  12111. * Falloff Physical: light is falling off following the inverse squared distance law.
  12112. */
  12113. static readonly FALLOFF_PHYSICAL: number;
  12114. /**
  12115. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12116. * to enhance interoperability with other engines.
  12117. */
  12118. static readonly FALLOFF_GLTF: number;
  12119. /**
  12120. * Falloff Standard: light is falling off like in the standard material
  12121. * to enhance interoperability with other materials.
  12122. */
  12123. static readonly FALLOFF_STANDARD: number;
  12124. /**
  12125. * If every light affecting the material is in this lightmapMode,
  12126. * material.lightmapTexture adds or multiplies
  12127. * (depends on material.useLightmapAsShadowmap)
  12128. * after every other light calculations.
  12129. */
  12130. static readonly LIGHTMAP_DEFAULT: number;
  12131. /**
  12132. * material.lightmapTexture as only diffuse lighting from this light
  12133. * adds only specular lighting from this light
  12134. * adds dynamic shadows
  12135. */
  12136. static readonly LIGHTMAP_SPECULAR: number;
  12137. /**
  12138. * material.lightmapTexture as only lighting
  12139. * no light calculation from this light
  12140. * only adds dynamic shadows from this light
  12141. */
  12142. static readonly LIGHTMAP_SHADOWSONLY: number;
  12143. /**
  12144. * Each light type uses the default quantity according to its type:
  12145. * point/spot lights use luminous intensity
  12146. * directional lights use illuminance
  12147. */
  12148. static readonly INTENSITYMODE_AUTOMATIC: number;
  12149. /**
  12150. * lumen (lm)
  12151. */
  12152. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12153. /**
  12154. * candela (lm/sr)
  12155. */
  12156. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12157. /**
  12158. * lux (lm/m^2)
  12159. */
  12160. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12161. /**
  12162. * nit (cd/m^2)
  12163. */
  12164. static readonly INTENSITYMODE_LUMINANCE: number;
  12165. /**
  12166. * Light type const id of the point light.
  12167. */
  12168. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12169. /**
  12170. * Light type const id of the directional light.
  12171. */
  12172. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12173. /**
  12174. * Light type const id of the spot light.
  12175. */
  12176. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12177. /**
  12178. * Light type const id of the hemispheric light.
  12179. */
  12180. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12181. /**
  12182. * Diffuse gives the basic color to an object.
  12183. */
  12184. diffuse: Color3;
  12185. /**
  12186. * Specular produces a highlight color on an object.
  12187. * Note: This is note affecting PBR materials.
  12188. */
  12189. specular: Color3;
  12190. /**
  12191. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12192. * falling off base on range or angle.
  12193. * This can be set to any values in Light.FALLOFF_x.
  12194. *
  12195. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12196. * other types of materials.
  12197. */
  12198. falloffType: number;
  12199. /**
  12200. * Strength of the light.
  12201. * Note: By default it is define in the framework own unit.
  12202. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12203. */
  12204. intensity: number;
  12205. private _range;
  12206. protected _inverseSquaredRange: number;
  12207. /**
  12208. * Defines how far from the source the light is impacting in scene units.
  12209. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12210. */
  12211. /**
  12212. * Defines how far from the source the light is impacting in scene units.
  12213. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12214. */
  12215. range: number;
  12216. /**
  12217. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12218. * of light.
  12219. */
  12220. private _photometricScale;
  12221. private _intensityMode;
  12222. /**
  12223. * Gets the photometric scale used to interpret the intensity.
  12224. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12225. */
  12226. /**
  12227. * Sets the photometric scale used to interpret the intensity.
  12228. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12229. */
  12230. intensityMode: number;
  12231. private _radius;
  12232. /**
  12233. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12234. */
  12235. /**
  12236. * sets the light radius used by PBR Materials to simulate soft area lights.
  12237. */
  12238. radius: number;
  12239. private _renderPriority;
  12240. /**
  12241. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12242. * exceeding the number allowed of the materials.
  12243. */
  12244. renderPriority: number;
  12245. private _shadowEnabled;
  12246. /**
  12247. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12248. * the current shadow generator.
  12249. */
  12250. /**
  12251. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12252. * the current shadow generator.
  12253. */
  12254. shadowEnabled: boolean;
  12255. private _includedOnlyMeshes;
  12256. /**
  12257. * Gets the only meshes impacted by this light.
  12258. */
  12259. /**
  12260. * Sets the only meshes impacted by this light.
  12261. */
  12262. includedOnlyMeshes: AbstractMesh[];
  12263. private _excludedMeshes;
  12264. /**
  12265. * Gets the meshes not impacted by this light.
  12266. */
  12267. /**
  12268. * Sets the meshes not impacted by this light.
  12269. */
  12270. excludedMeshes: AbstractMesh[];
  12271. private _excludeWithLayerMask;
  12272. /**
  12273. * Gets the layer id use to find what meshes are not impacted by the light.
  12274. * Inactive if 0
  12275. */
  12276. /**
  12277. * Sets the layer id use to find what meshes are not impacted by the light.
  12278. * Inactive if 0
  12279. */
  12280. excludeWithLayerMask: number;
  12281. private _includeOnlyWithLayerMask;
  12282. /**
  12283. * Gets the layer id use to find what meshes are impacted by the light.
  12284. * Inactive if 0
  12285. */
  12286. /**
  12287. * Sets the layer id use to find what meshes are impacted by the light.
  12288. * Inactive if 0
  12289. */
  12290. includeOnlyWithLayerMask: number;
  12291. private _lightmapMode;
  12292. /**
  12293. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12294. */
  12295. /**
  12296. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12297. */
  12298. lightmapMode: number;
  12299. private _parentedWorldMatrix;
  12300. /**
  12301. * Shadow generator associted to the light.
  12302. * @hidden Internal use only.
  12303. */
  12304. _shadowGenerator: Nullable<IShadowGenerator>;
  12305. /**
  12306. * @hidden Internal use only.
  12307. */
  12308. _excludedMeshesIds: string[];
  12309. /**
  12310. * @hidden Internal use only.
  12311. */
  12312. _includedOnlyMeshesIds: string[];
  12313. /**
  12314. * The current light unifom buffer.
  12315. * @hidden Internal use only.
  12316. */
  12317. _uniformBuffer: UniformBuffer;
  12318. /**
  12319. * Creates a Light object in the scene.
  12320. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12321. * @param name The firendly name of the light
  12322. * @param scene The scene the light belongs too
  12323. */
  12324. constructor(name: string, scene: Scene);
  12325. protected abstract _buildUniformLayout(): void;
  12326. /**
  12327. * Sets the passed Effect "effect" with the Light information.
  12328. * @param effect The effect to update
  12329. * @param lightIndex The index of the light in the effect to update
  12330. * @returns The light
  12331. */
  12332. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12333. /**
  12334. * @hidden internal use only.
  12335. */
  12336. abstract _getWorldMatrix(): Matrix;
  12337. /**
  12338. * Returns the string "Light".
  12339. * @returns the class name
  12340. */
  12341. getClassName(): string;
  12342. /**
  12343. * Converts the light information to a readable string for debug purpose.
  12344. * @param fullDetails Supports for multiple levels of logging within scene loading
  12345. * @returns the human readable light info
  12346. */
  12347. toString(fullDetails?: boolean): string;
  12348. /**
  12349. * Set the enabled state of this node.
  12350. * @param value - the new enabled state
  12351. */
  12352. setEnabled(value: boolean): void;
  12353. /**
  12354. * Returns the Light associated shadow generator if any.
  12355. * @return the associated shadow generator.
  12356. */
  12357. getShadowGenerator(): Nullable<IShadowGenerator>;
  12358. /**
  12359. * Returns a Vector3, the absolute light position in the World.
  12360. * @returns the world space position of the light
  12361. */
  12362. getAbsolutePosition(): Vector3;
  12363. /**
  12364. * Specifies if the light will affect the passed mesh.
  12365. * @param mesh The mesh to test against the light
  12366. * @return true the mesh is affected otherwise, false.
  12367. */
  12368. canAffectMesh(mesh: AbstractMesh): boolean;
  12369. /**
  12370. * Computes and Returns the light World matrix.
  12371. * @returns the world matrix
  12372. */
  12373. getWorldMatrix(): Matrix;
  12374. /**
  12375. * Sort function to order lights for rendering.
  12376. * @param a First Light object to compare to second.
  12377. * @param b Second Light object to compare first.
  12378. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12379. */
  12380. static CompareLightsPriority(a: Light, b: Light): number;
  12381. /**
  12382. * Releases resources associated with this node.
  12383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12385. */
  12386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12387. /**
  12388. * Returns the light type ID (integer).
  12389. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12390. */
  12391. getTypeID(): number;
  12392. /**
  12393. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12394. * @returns the scaled intensity in intensity mode unit
  12395. */
  12396. getScaledIntensity(): number;
  12397. /**
  12398. * Returns a new Light object, named "name", from the current one.
  12399. * @param name The name of the cloned light
  12400. * @returns the new created light
  12401. */
  12402. clone(name: string): Nullable<Light>;
  12403. /**
  12404. * Serializes the current light into a Serialization object.
  12405. * @returns the serialized object.
  12406. */
  12407. serialize(): any;
  12408. /**
  12409. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12410. * This new light is named "name" and added to the passed scene.
  12411. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12412. * @param name The friendly name of the light
  12413. * @param scene The scene the new light will belong to
  12414. * @returns the constructor function
  12415. */
  12416. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12417. /**
  12418. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12419. * @param parsedLight The JSON representation of the light
  12420. * @param scene The scene to create the parsed light in
  12421. * @returns the created light after parsing
  12422. */
  12423. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12424. private _hookArrayForExcluded;
  12425. private _hookArrayForIncludedOnly;
  12426. private _resyncMeshes;
  12427. /**
  12428. * Forces the meshes to update their light related information in their rendering used effects
  12429. * @hidden Internal Use Only
  12430. */
  12431. _markMeshesAsLightDirty(): void;
  12432. /**
  12433. * Recomputes the cached photometric scale if needed.
  12434. */
  12435. private _computePhotometricScale;
  12436. /**
  12437. * Returns the Photometric Scale according to the light type and intensity mode.
  12438. */
  12439. private _getPhotometricScale;
  12440. /**
  12441. * Reorder the light in the scene according to their defined priority.
  12442. * @hidden Internal Use Only
  12443. */
  12444. _reorderLightsInScene(): void;
  12445. /**
  12446. * Prepares the list of defines specific to the light type.
  12447. * @param defines the list of defines
  12448. * @param lightIndex defines the index of the light for the effect
  12449. */
  12450. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12451. }
  12452. }
  12453. declare module BABYLON {
  12454. /**
  12455. * A point light is a light defined by an unique point in world space.
  12456. * The light is emitted in every direction from this point.
  12457. * A good example of a point light is a standard light bulb.
  12458. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12459. */
  12460. class PointLight extends ShadowLight {
  12461. private _shadowAngle;
  12462. /**
  12463. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12464. * This specifies what angle the shadow will use to be created.
  12465. *
  12466. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12467. */
  12468. /**
  12469. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12470. * This specifies what angle the shadow will use to be created.
  12471. *
  12472. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12473. */
  12474. shadowAngle: number;
  12475. /**
  12476. * Gets the direction if it has been set.
  12477. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12478. */
  12479. /**
  12480. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12481. */
  12482. direction: Vector3;
  12483. /**
  12484. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12485. * A PointLight emits the light in every direction.
  12486. * It can cast shadows.
  12487. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12488. * ```javascript
  12489. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12490. * ```
  12491. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12492. * @param name The light friendly name
  12493. * @param position The position of the point light in the scene
  12494. * @param scene The scene the lights belongs to
  12495. */
  12496. constructor(name: string, position: Vector3, scene: Scene);
  12497. /**
  12498. * Returns the string "PointLight"
  12499. * @returns the class name
  12500. */
  12501. getClassName(): string;
  12502. /**
  12503. * Returns the integer 0.
  12504. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12505. */
  12506. getTypeID(): number;
  12507. /**
  12508. * Specifies wether or not the shadowmap should be a cube texture.
  12509. * @returns true if the shadowmap needs to be a cube texture.
  12510. */
  12511. needCube(): boolean;
  12512. /**
  12513. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12514. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12515. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12516. */
  12517. getShadowDirection(faceIndex?: number): Vector3;
  12518. /**
  12519. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12520. * - fov = PI / 2
  12521. * - aspect ratio : 1.0
  12522. * - z-near and far equal to the active camera minZ and maxZ.
  12523. * Returns the PointLight.
  12524. */
  12525. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12526. protected _buildUniformLayout(): void;
  12527. /**
  12528. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12529. * @param effect The effect to update
  12530. * @param lightIndex The index of the light in the effect to update
  12531. * @returns The point light
  12532. */
  12533. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12534. /**
  12535. * Prepares the list of defines specific to the light type.
  12536. * @param defines the list of defines
  12537. * @param lightIndex defines the index of the light for the effect
  12538. */
  12539. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12540. }
  12541. }
  12542. declare module BABYLON {
  12543. /**
  12544. * Interface describing all the common properties and methods a shadow light needs to implement.
  12545. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12546. * as well as binding the different shadow properties to the effects.
  12547. */
  12548. interface IShadowLight extends Light {
  12549. /**
  12550. * The light id in the scene (used in scene.findLighById for instance)
  12551. */
  12552. id: string;
  12553. /**
  12554. * The position the shdow will be casted from.
  12555. */
  12556. position: Vector3;
  12557. /**
  12558. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12559. */
  12560. direction: Vector3;
  12561. /**
  12562. * The transformed position. Position of the light in world space taking parenting in account.
  12563. */
  12564. transformedPosition: Vector3;
  12565. /**
  12566. * The transformed direction. Direction of the light in world space taking parenting in account.
  12567. */
  12568. transformedDirection: Vector3;
  12569. /**
  12570. * The friendly name of the light in the scene.
  12571. */
  12572. name: string;
  12573. /**
  12574. * Defines the shadow projection clipping minimum z value.
  12575. */
  12576. shadowMinZ: number;
  12577. /**
  12578. * Defines the shadow projection clipping maximum z value.
  12579. */
  12580. shadowMaxZ: number;
  12581. /**
  12582. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12583. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12584. */
  12585. computeTransformedInformation(): boolean;
  12586. /**
  12587. * Gets the scene the light belongs to.
  12588. * @returns The scene
  12589. */
  12590. getScene(): Scene;
  12591. /**
  12592. * Callback defining a custom Projection Matrix Builder.
  12593. * This can be used to override the default projection matrix computation.
  12594. */
  12595. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12596. /**
  12597. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12598. * @param matrix The materix to updated with the projection information
  12599. * @param viewMatrix The transform matrix of the light
  12600. * @param renderList The list of mesh to render in the map
  12601. * @returns The current light
  12602. */
  12603. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12604. /**
  12605. * Gets the current depth scale used in ESM.
  12606. * @returns The scale
  12607. */
  12608. getDepthScale(): number;
  12609. /**
  12610. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12611. * @returns true if a cube texture needs to be use
  12612. */
  12613. needCube(): boolean;
  12614. /**
  12615. * Detects if the projection matrix requires to be recomputed this frame.
  12616. * @returns true if it requires to be recomputed otherwise, false.
  12617. */
  12618. needProjectionMatrixCompute(): boolean;
  12619. /**
  12620. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12621. */
  12622. forceProjectionMatrixCompute(): void;
  12623. /**
  12624. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12625. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12626. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12627. */
  12628. getShadowDirection(faceIndex?: number): Vector3;
  12629. /**
  12630. * Gets the minZ used for shadow according to both the scene and the light.
  12631. * @param activeCamera The camera we are returning the min for
  12632. * @returns the depth min z
  12633. */
  12634. getDepthMinZ(activeCamera: Camera): number;
  12635. /**
  12636. * Gets the maxZ used for shadow according to both the scene and the light.
  12637. * @param activeCamera The camera we are returning the max for
  12638. * @returns the depth max z
  12639. */
  12640. getDepthMaxZ(activeCamera: Camera): number;
  12641. }
  12642. /**
  12643. * Base implementation IShadowLight
  12644. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12645. */
  12646. abstract class ShadowLight extends Light implements IShadowLight {
  12647. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12648. protected _position: Vector3;
  12649. protected _setPosition(value: Vector3): void;
  12650. /**
  12651. * Sets the position the shadow will be casted from. Also use as the light position for both
  12652. * point and spot lights.
  12653. */
  12654. /**
  12655. * Sets the position the shadow will be casted from. Also use as the light position for both
  12656. * point and spot lights.
  12657. */
  12658. position: Vector3;
  12659. protected _direction: Vector3;
  12660. protected _setDirection(value: Vector3): void;
  12661. /**
  12662. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12663. * Also use as the light direction on spot and directional lights.
  12664. */
  12665. /**
  12666. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12667. * Also use as the light direction on spot and directional lights.
  12668. */
  12669. direction: Vector3;
  12670. private _shadowMinZ;
  12671. /**
  12672. * Gets the shadow projection clipping minimum z value.
  12673. */
  12674. /**
  12675. * Sets the shadow projection clipping minimum z value.
  12676. */
  12677. shadowMinZ: number;
  12678. private _shadowMaxZ;
  12679. /**
  12680. * Sets the shadow projection clipping maximum z value.
  12681. */
  12682. /**
  12683. * Gets the shadow projection clipping maximum z value.
  12684. */
  12685. shadowMaxZ: number;
  12686. /**
  12687. * Callback defining a custom Projection Matrix Builder.
  12688. * This can be used to override the default projection matrix computation.
  12689. */
  12690. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12691. /**
  12692. * The transformed position. Position of the light in world space taking parenting in account.
  12693. */
  12694. transformedPosition: Vector3;
  12695. /**
  12696. * The transformed direction. Direction of the light in world space taking parenting in account.
  12697. */
  12698. transformedDirection: Vector3;
  12699. private _worldMatrix;
  12700. private _needProjectionMatrixCompute;
  12701. /**
  12702. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12703. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12704. */
  12705. computeTransformedInformation(): boolean;
  12706. /**
  12707. * Return the depth scale used for the shadow map.
  12708. * @returns the depth scale.
  12709. */
  12710. getDepthScale(): number;
  12711. /**
  12712. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12713. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12714. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12715. */
  12716. getShadowDirection(faceIndex?: number): Vector3;
  12717. /**
  12718. * Returns the ShadowLight absolute position in the World.
  12719. * @returns the position vector in world space
  12720. */
  12721. getAbsolutePosition(): Vector3;
  12722. /**
  12723. * Sets the ShadowLight direction toward the passed target.
  12724. * @param target The point tot target in local space
  12725. * @returns the updated ShadowLight direction
  12726. */
  12727. setDirectionToTarget(target: Vector3): Vector3;
  12728. /**
  12729. * Returns the light rotation in euler definition.
  12730. * @returns the x y z rotation in local space.
  12731. */
  12732. getRotation(): Vector3;
  12733. /**
  12734. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12735. * @returns true if a cube texture needs to be use
  12736. */
  12737. needCube(): boolean;
  12738. /**
  12739. * Detects if the projection matrix requires to be recomputed this frame.
  12740. * @returns true if it requires to be recomputed otherwise, false.
  12741. */
  12742. needProjectionMatrixCompute(): boolean;
  12743. /**
  12744. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12745. */
  12746. forceProjectionMatrixCompute(): void;
  12747. /**
  12748. * Get the world matrix of the sahdow lights.
  12749. * @hidden Internal Use Only
  12750. */
  12751. _getWorldMatrix(): Matrix;
  12752. /**
  12753. * Gets the minZ used for shadow according to both the scene and the light.
  12754. * @param activeCamera The camera we are returning the min for
  12755. * @returns the depth min z
  12756. */
  12757. getDepthMinZ(activeCamera: Camera): number;
  12758. /**
  12759. * Gets the maxZ used for shadow according to both the scene and the light.
  12760. * @param activeCamera The camera we are returning the max for
  12761. * @returns the depth max z
  12762. */
  12763. getDepthMaxZ(activeCamera: Camera): number;
  12764. /**
  12765. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12766. * @param matrix The materix to updated with the projection information
  12767. * @param viewMatrix The transform matrix of the light
  12768. * @param renderList The list of mesh to render in the map
  12769. * @returns The current light
  12770. */
  12771. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12772. }
  12773. }
  12774. declare module BABYLON {
  12775. /**
  12776. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12777. * These values define a cone of light starting from the position, emitting toward the direction.
  12778. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12779. * and the exponent defines the speed of the decay of the light with distance (reach).
  12780. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12781. */
  12782. class SpotLight extends ShadowLight {
  12783. private _angle;
  12784. private _innerAngle;
  12785. private _cosHalfAngle;
  12786. private _lightAngleScale;
  12787. private _lightAngleOffset;
  12788. /**
  12789. * Gets the cone angle of the spot light in Radians.
  12790. */
  12791. /**
  12792. * Sets the cone angle of the spot light in Radians.
  12793. */
  12794. angle: number;
  12795. /**
  12796. * Only used in gltf falloff mode, this defines the angle where
  12797. * the directional falloff will start before cutting at angle which could be seen
  12798. * as outer angle.
  12799. */
  12800. /**
  12801. * Only used in gltf falloff mode, this defines the angle where
  12802. * the directional falloff will start before cutting at angle which could be seen
  12803. * as outer angle.
  12804. */
  12805. innerAngle: number;
  12806. private _shadowAngleScale;
  12807. /**
  12808. * Allows scaling the angle of the light for shadow generation only.
  12809. */
  12810. /**
  12811. * Allows scaling the angle of the light for shadow generation only.
  12812. */
  12813. shadowAngleScale: number;
  12814. /**
  12815. * The light decay speed with the distance from the emission spot.
  12816. */
  12817. exponent: number;
  12818. private _projectionTextureMatrix;
  12819. /**
  12820. * Allows reading the projecton texture
  12821. */
  12822. readonly projectionTextureMatrix: Matrix;
  12823. protected _projectionTextureLightNear: number;
  12824. /**
  12825. * Gets the near clip of the Spotlight for texture projection.
  12826. */
  12827. /**
  12828. * Sets the near clip of the Spotlight for texture projection.
  12829. */
  12830. projectionTextureLightNear: number;
  12831. protected _projectionTextureLightFar: number;
  12832. /**
  12833. * Gets the far clip of the Spotlight for texture projection.
  12834. */
  12835. /**
  12836. * Sets the far clip of the Spotlight for texture projection.
  12837. */
  12838. projectionTextureLightFar: number;
  12839. protected _projectionTextureUpDirection: Vector3;
  12840. /**
  12841. * Gets the Up vector of the Spotlight for texture projection.
  12842. */
  12843. /**
  12844. * Sets the Up vector of the Spotlight for texture projection.
  12845. */
  12846. projectionTextureUpDirection: Vector3;
  12847. private _projectionTexture;
  12848. /**
  12849. * Gets the projection texture of the light.
  12850. */
  12851. /**
  12852. * Sets the projection texture of the light.
  12853. */
  12854. projectionTexture: Nullable<BaseTexture>;
  12855. private _projectionTextureViewLightDirty;
  12856. private _projectionTextureProjectionLightDirty;
  12857. private _projectionTextureDirty;
  12858. private _projectionTextureViewTargetVector;
  12859. private _projectionTextureViewLightMatrix;
  12860. private _projectionTextureProjectionLightMatrix;
  12861. private _projectionTextureScalingMatrix;
  12862. /**
  12863. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12864. * It can cast shadows.
  12865. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12866. * @param name The light friendly name
  12867. * @param position The position of the spot light in the scene
  12868. * @param direction The direction of the light in the scene
  12869. * @param angle The cone angle of the light in Radians
  12870. * @param exponent The light decay speed with the distance from the emission spot
  12871. * @param scene The scene the lights belongs to
  12872. */
  12873. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12874. /**
  12875. * Returns the string "SpotLight".
  12876. * @returns the class name
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * Returns the integer 2.
  12881. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12882. */
  12883. getTypeID(): number;
  12884. /**
  12885. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12886. */
  12887. protected _setDirection(value: Vector3): void;
  12888. /**
  12889. * Overrides the position setter to recompute the projection texture view light Matrix.
  12890. */
  12891. protected _setPosition(value: Vector3): void;
  12892. /**
  12893. * 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.
  12894. * Returns the SpotLight.
  12895. */
  12896. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12897. protected _computeProjectionTextureViewLightMatrix(): void;
  12898. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12899. /**
  12900. * Main function for light texture projection matrix computing.
  12901. */
  12902. protected _computeProjectionTextureMatrix(): void;
  12903. protected _buildUniformLayout(): void;
  12904. private _computeAngleValues;
  12905. /**
  12906. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12907. * @param effect The effect to update
  12908. * @param lightIndex The index of the light in the effect to update
  12909. * @returns The spot light
  12910. */
  12911. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12912. /**
  12913. * Disposes the light and the associated resources.
  12914. */
  12915. dispose(): void;
  12916. /**
  12917. * Prepares the list of defines specific to the light type.
  12918. * @param defines the list of defines
  12919. * @param lightIndex defines the index of the light for the effect
  12920. */
  12921. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. interface ILoadingScreen {
  12926. displayLoadingUI: () => void;
  12927. hideLoadingUI: () => void;
  12928. loadingUIBackgroundColor: string;
  12929. loadingUIText: string;
  12930. }
  12931. class DefaultLoadingScreen implements ILoadingScreen {
  12932. private _renderingCanvas;
  12933. private _loadingText;
  12934. private _loadingDivBackgroundColor;
  12935. private _loadingDiv;
  12936. private _loadingTextDiv;
  12937. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12938. displayLoadingUI(): void;
  12939. hideLoadingUI(): void;
  12940. loadingUIText: string;
  12941. loadingUIBackgroundColor: string;
  12942. private _resizeLoadingUI;
  12943. }
  12944. }
  12945. declare module BABYLON {
  12946. class SceneLoaderProgressEvent {
  12947. readonly lengthComputable: boolean;
  12948. readonly loaded: number;
  12949. readonly total: number;
  12950. constructor(lengthComputable: boolean, loaded: number, total: number);
  12951. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12952. }
  12953. interface ISceneLoaderPluginExtensions {
  12954. [extension: string]: {
  12955. isBinary: boolean;
  12956. };
  12957. }
  12958. interface ISceneLoaderPluginFactory {
  12959. name: string;
  12960. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12961. canDirectLoad?: (data: string) => boolean;
  12962. }
  12963. interface ISceneLoaderPlugin {
  12964. /**
  12965. * The friendly name of this plugin.
  12966. */
  12967. name: string;
  12968. /**
  12969. * The file extensions supported by this plugin.
  12970. */
  12971. extensions: string | ISceneLoaderPluginExtensions;
  12972. /**
  12973. * Import meshes into a scene.
  12974. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12975. * @param scene The scene to import into
  12976. * @param data The data to import
  12977. * @param rootUrl The root url for scene and resources
  12978. * @param meshes The meshes array to import into
  12979. * @param particleSystems The particle systems array to import into
  12980. * @param skeletons The skeletons array to import into
  12981. * @param onError The callback when import fails
  12982. * @returns True if successful or false otherwise
  12983. */
  12984. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12985. /**
  12986. * Load into a scene.
  12987. * @param scene The scene to load into
  12988. * @param data The data to import
  12989. * @param rootUrl The root url for scene and resources
  12990. * @param onError The callback when import fails
  12991. * @returns true if successful or false otherwise
  12992. */
  12993. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12994. /**
  12995. * The callback that returns true if the data can be directly loaded.
  12996. */
  12997. canDirectLoad?: (data: string) => boolean;
  12998. /**
  12999. * The callback that allows custom handling of the root url based on the response url.
  13000. */
  13001. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13002. /**
  13003. * Load into an asset container.
  13004. * @param scene The scene to load into
  13005. * @param data The data to import
  13006. * @param rootUrl The root url for scene and resources
  13007. * @param onError The callback when import fails
  13008. * @returns The loaded asset container
  13009. */
  13010. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  13011. }
  13012. interface ISceneLoaderPluginAsync {
  13013. /**
  13014. * The friendly name of this plugin.
  13015. */
  13016. name: string;
  13017. /**
  13018. * The file extensions supported by this plugin.
  13019. */
  13020. extensions: string | ISceneLoaderPluginExtensions;
  13021. /**
  13022. * Import meshes into a scene.
  13023. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13024. * @param scene The scene to import into
  13025. * @param data The data to import
  13026. * @param rootUrl The root url for scene and resources
  13027. * @param onProgress The callback when the load progresses
  13028. * @param fullName Defines the FQDN of the file to load
  13029. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  13030. */
  13031. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<{
  13032. meshes: AbstractMesh[];
  13033. particleSystems: IParticleSystem[];
  13034. skeletons: Skeleton[];
  13035. animationGroups: AnimationGroup[];
  13036. }>;
  13037. /**
  13038. * Load into a scene.
  13039. * @param scene The scene to load into
  13040. * @param data The data to import
  13041. * @param rootUrl The root url for scene and resources
  13042. * @param onProgress The callback when the load progresses
  13043. * @param fullName Defines the FQDN of the file to load
  13044. * @returns Nothing
  13045. */
  13046. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<void>;
  13047. /**
  13048. * The callback that returns true if the data can be directly loaded.
  13049. */
  13050. canDirectLoad?: (data: string) => boolean;
  13051. /**
  13052. * The callback that allows custom handling of the root url based on the response url.
  13053. */
  13054. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13055. /**
  13056. * Load into an asset container.
  13057. * @param scene The scene to load into
  13058. * @param data The data to import
  13059. * @param rootUrl The root url for scene and resources
  13060. * @param onProgress The callback when the load progresses
  13061. * @param fullName Defines the FQDN of the file to load
  13062. * @returns The loaded asset container
  13063. */
  13064. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<AssetContainer>;
  13065. }
  13066. class SceneLoader {
  13067. private static _ForceFullSceneLoadingForIncremental;
  13068. private static _ShowLoadingScreen;
  13069. private static _CleanBoneMatrixWeights;
  13070. static readonly NO_LOGGING: number;
  13071. static readonly MINIMAL_LOGGING: number;
  13072. static readonly SUMMARY_LOGGING: number;
  13073. static readonly DETAILED_LOGGING: number;
  13074. private static _loggingLevel;
  13075. static ForceFullSceneLoadingForIncremental: boolean;
  13076. static ShowLoadingScreen: boolean;
  13077. static loggingLevel: number;
  13078. static CleanBoneMatrixWeights: boolean;
  13079. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13080. private static _registeredPlugins;
  13081. private static _getDefaultPlugin;
  13082. private static _getPluginForExtension;
  13083. private static _getPluginForDirectLoad;
  13084. private static _getPluginForFilename;
  13085. private static _getDirectLoad;
  13086. private static _loadData;
  13087. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  13088. static IsPluginForExtensionAvailable(extension: string): boolean;
  13089. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  13090. /**
  13091. * Import meshes into a scene
  13092. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13093. * @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)
  13094. * @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)
  13095. * @param scene the instance of BABYLON.Scene to append to
  13096. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  13097. * @param onProgress a callback with a progress event for each file being loaded
  13098. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13099. * @param pluginExtension the extension used to determine the plugin
  13100. * @returns The loaded plugin
  13101. */
  13102. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13103. /**
  13104. * Import meshes into a scene
  13105. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13106. * @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)
  13107. * @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)
  13108. * @param scene the instance of BABYLON.Scene to append to
  13109. * @param onProgress a callback with a progress event for each file being loaded
  13110. * @param pluginExtension the extension used to determine the plugin
  13111. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  13112. */
  13113. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  13114. meshes: AbstractMesh[];
  13115. particleSystems: IParticleSystem[];
  13116. skeletons: Skeleton[];
  13117. animationGroups: AnimationGroup[];
  13118. }>;
  13119. /**
  13120. * Load a scene
  13121. * @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)
  13122. * @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)
  13123. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13124. * @param onSuccess a callback with the scene when import succeeds
  13125. * @param onProgress a callback with a progress event for each file being loaded
  13126. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13127. * @param pluginExtension the extension used to determine the plugin
  13128. * @returns The loaded plugin
  13129. */
  13130. 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>;
  13131. /**
  13132. * Load a scene
  13133. * @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)
  13134. * @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)
  13135. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13136. * @param onProgress a callback with a progress event for each file being loaded
  13137. * @param pluginExtension the extension used to determine the plugin
  13138. * @returns The loaded scene
  13139. */
  13140. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13141. /**
  13142. * Append a scene
  13143. * @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)
  13144. * @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)
  13145. * @param scene is the instance of BABYLON.Scene to append to
  13146. * @param onSuccess a callback with the scene when import succeeds
  13147. * @param onProgress a callback with a progress event for each file being loaded
  13148. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13149. * @param pluginExtension the extension used to determine the plugin
  13150. * @returns The loaded plugin
  13151. */
  13152. 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>;
  13153. /**
  13154. * Append a scene
  13155. * @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)
  13156. * @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)
  13157. * @param scene is the instance of BABYLON.Scene to append to
  13158. * @param onProgress a callback with a progress event for each file being loaded
  13159. * @param pluginExtension the extension used to determine the plugin
  13160. * @returns The given scene
  13161. */
  13162. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13163. /**
  13164. * Load a scene into an asset container
  13165. * @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)
  13166. * @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)
  13167. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13168. * @param onSuccess a callback with the scene when import succeeds
  13169. * @param onProgress a callback with a progress event for each file being loaded
  13170. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13171. * @param pluginExtension the extension used to determine the plugin
  13172. * @returns The loaded plugin
  13173. */
  13174. 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>;
  13175. /**
  13176. * Load a scene into an asset container
  13177. * @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)
  13178. * @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)
  13179. * @param scene is the instance of BABYLON.Scene to append to
  13180. * @param onProgress a callback with a progress event for each file being loaded
  13181. * @param pluginExtension the extension used to determine the plugin
  13182. * @returns The loaded asset container
  13183. */
  13184. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13185. }
  13186. }
  13187. declare module BABYLON {
  13188. /**
  13189. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13190. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13191. * 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;
  13192. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13193. */
  13194. class ColorCurves {
  13195. private _dirty;
  13196. private _tempColor;
  13197. private _globalCurve;
  13198. private _highlightsCurve;
  13199. private _midtonesCurve;
  13200. private _shadowsCurve;
  13201. private _positiveCurve;
  13202. private _negativeCurve;
  13203. private _globalHue;
  13204. private _globalDensity;
  13205. private _globalSaturation;
  13206. private _globalExposure;
  13207. /**
  13208. * Gets the global Hue value.
  13209. * 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).
  13210. */
  13211. /**
  13212. * Sets the global Hue value.
  13213. * 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).
  13214. */
  13215. globalHue: number;
  13216. /**
  13217. * Gets the global Density value.
  13218. * 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.
  13219. * Values less than zero provide a filter of opposite hue.
  13220. */
  13221. /**
  13222. * Sets the global Density value.
  13223. * 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.
  13224. * Values less than zero provide a filter of opposite hue.
  13225. */
  13226. globalDensity: number;
  13227. /**
  13228. * Gets the global Saturation value.
  13229. * 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.
  13230. */
  13231. /**
  13232. * Sets the global Saturation value.
  13233. * 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.
  13234. */
  13235. globalSaturation: number;
  13236. /**
  13237. * Gets the global Exposure value.
  13238. * 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.
  13239. */
  13240. /**
  13241. * Sets the global Exposure value.
  13242. * 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.
  13243. */
  13244. globalExposure: number;
  13245. private _highlightsHue;
  13246. private _highlightsDensity;
  13247. private _highlightsSaturation;
  13248. private _highlightsExposure;
  13249. /**
  13250. * Gets the highlights Hue value.
  13251. * 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).
  13252. */
  13253. /**
  13254. * Sets the highlights Hue value.
  13255. * 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).
  13256. */
  13257. highlightsHue: number;
  13258. /**
  13259. * Gets the highlights Density value.
  13260. * 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.
  13261. * Values less than zero provide a filter of opposite hue.
  13262. */
  13263. /**
  13264. * Sets the highlights Density value.
  13265. * 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.
  13266. * Values less than zero provide a filter of opposite hue.
  13267. */
  13268. highlightsDensity: number;
  13269. /**
  13270. * Gets the highlights Saturation value.
  13271. * 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.
  13272. */
  13273. /**
  13274. * Sets the highlights Saturation value.
  13275. * 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.
  13276. */
  13277. highlightsSaturation: number;
  13278. /**
  13279. * Gets the highlights Exposure value.
  13280. * 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.
  13281. */
  13282. /**
  13283. * Sets the highlights Exposure value.
  13284. * 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.
  13285. */
  13286. highlightsExposure: number;
  13287. private _midtonesHue;
  13288. private _midtonesDensity;
  13289. private _midtonesSaturation;
  13290. private _midtonesExposure;
  13291. /**
  13292. * Gets the midtones Hue value.
  13293. * 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).
  13294. */
  13295. /**
  13296. * Sets the midtones Hue value.
  13297. * 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).
  13298. */
  13299. midtonesHue: number;
  13300. /**
  13301. * Gets the midtones Density value.
  13302. * 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.
  13303. * Values less than zero provide a filter of opposite hue.
  13304. */
  13305. /**
  13306. * Sets the midtones Density value.
  13307. * 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.
  13308. * Values less than zero provide a filter of opposite hue.
  13309. */
  13310. midtonesDensity: number;
  13311. /**
  13312. * Gets the midtones Saturation value.
  13313. * 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.
  13314. */
  13315. /**
  13316. * Sets the midtones Saturation value.
  13317. * 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.
  13318. */
  13319. midtonesSaturation: number;
  13320. /**
  13321. * Gets the midtones Exposure value.
  13322. * 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.
  13323. */
  13324. /**
  13325. * Sets the midtones Exposure value.
  13326. * 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.
  13327. */
  13328. midtonesExposure: number;
  13329. private _shadowsHue;
  13330. private _shadowsDensity;
  13331. private _shadowsSaturation;
  13332. private _shadowsExposure;
  13333. /**
  13334. * Gets the shadows Hue value.
  13335. * 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).
  13336. */
  13337. /**
  13338. * Sets the shadows Hue value.
  13339. * 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).
  13340. */
  13341. shadowsHue: number;
  13342. /**
  13343. * Gets the shadows Density value.
  13344. * 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.
  13345. * Values less than zero provide a filter of opposite hue.
  13346. */
  13347. /**
  13348. * Sets the shadows Density value.
  13349. * 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.
  13350. * Values less than zero provide a filter of opposite hue.
  13351. */
  13352. shadowsDensity: number;
  13353. /**
  13354. * Gets the shadows Saturation value.
  13355. * 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.
  13356. */
  13357. /**
  13358. * Sets the shadows Saturation value.
  13359. * 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.
  13360. */
  13361. shadowsSaturation: number;
  13362. /**
  13363. * Gets the shadows Exposure value.
  13364. * 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.
  13365. */
  13366. /**
  13367. * Sets the shadows Exposure value.
  13368. * 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.
  13369. */
  13370. shadowsExposure: number;
  13371. getClassName(): string;
  13372. /**
  13373. * Binds the color curves to the shader.
  13374. * @param colorCurves The color curve to bind
  13375. * @param effect The effect to bind to
  13376. */
  13377. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13378. /**
  13379. * Prepare the list of uniforms associated with the ColorCurves effects.
  13380. * @param uniformsList The list of uniforms used in the effect
  13381. */
  13382. static PrepareUniforms(uniformsList: string[]): void;
  13383. /**
  13384. * Returns color grading data based on a hue, density, saturation and exposure value.
  13385. * @param filterHue The hue of the color filter.
  13386. * @param filterDensity The density of the color filter.
  13387. * @param saturation The saturation.
  13388. * @param exposure The exposure.
  13389. * @param result The result data container.
  13390. */
  13391. private getColorGradingDataToRef;
  13392. /**
  13393. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13394. * @param value The input slider value in range [-100,100].
  13395. * @returns Adjusted value.
  13396. */
  13397. private static applyColorGradingSliderNonlinear;
  13398. /**
  13399. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13400. * @param hue The hue (H) input.
  13401. * @param saturation The saturation (S) input.
  13402. * @param brightness The brightness (B) input.
  13403. * @result An RGBA color represented as Vector4.
  13404. */
  13405. private static fromHSBToRef;
  13406. /**
  13407. * Returns a value clamped between min and max
  13408. * @param value The value to clamp
  13409. * @param min The minimum of value
  13410. * @param max The maximum of value
  13411. * @returns The clamped value.
  13412. */
  13413. private static clamp;
  13414. /**
  13415. * Clones the current color curve instance.
  13416. * @return The cloned curves
  13417. */
  13418. clone(): ColorCurves;
  13419. /**
  13420. * Serializes the current color curve instance to a json representation.
  13421. * @return a JSON representation
  13422. */
  13423. serialize(): any;
  13424. /**
  13425. * Parses the color curve from a json representation.
  13426. * @param source the JSON source to parse
  13427. * @return The parsed curves
  13428. */
  13429. static Parse(source: any): ColorCurves;
  13430. }
  13431. }
  13432. declare module BABYLON {
  13433. /**
  13434. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13435. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13436. */
  13437. class EffectFallbacks {
  13438. private _defines;
  13439. private _currentRank;
  13440. private _maxRank;
  13441. private _mesh;
  13442. /**
  13443. * Removes the fallback from the bound mesh.
  13444. */
  13445. unBindMesh(): void;
  13446. /**
  13447. * Adds a fallback on the specified property.
  13448. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13449. * @param define The name of the define in the shader
  13450. */
  13451. addFallback(rank: number, define: string): void;
  13452. /**
  13453. * Sets the mesh to use CPU skinning when needing to fallback.
  13454. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13455. * @param mesh The mesh to use the fallbacks.
  13456. */
  13457. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13458. /**
  13459. * Checks to see if more fallbacks are still availible.
  13460. */
  13461. readonly isMoreFallbacks: boolean;
  13462. /**
  13463. * Removes the defines that shoould be removed when falling back.
  13464. * @param currentDefines defines the current define statements for the shader.
  13465. * @param effect defines the current effect we try to compile
  13466. * @returns The resulting defines with defines of the current rank removed.
  13467. */
  13468. reduce(currentDefines: string, effect: Effect): string;
  13469. }
  13470. /**
  13471. * Options to be used when creating an effect.
  13472. */
  13473. class EffectCreationOptions {
  13474. /**
  13475. * Atrributes that will be used in the shader.
  13476. */
  13477. attributes: string[];
  13478. /**
  13479. * Uniform varible names that will be set in the shader.
  13480. */
  13481. uniformsNames: string[];
  13482. /**
  13483. * Uniform buffer varible names that will be set in the shader.
  13484. */
  13485. uniformBuffersNames: string[];
  13486. /**
  13487. * Sampler texture variable names that will be set in the shader.
  13488. */
  13489. samplers: string[];
  13490. /**
  13491. * Define statements that will be set in the shader.
  13492. */
  13493. defines: any;
  13494. /**
  13495. * Possible fallbacks for this effect to improve performance when needed.
  13496. */
  13497. fallbacks: Nullable<EffectFallbacks>;
  13498. /**
  13499. * Callback that will be called when the shader is compiled.
  13500. */
  13501. onCompiled: Nullable<(effect: Effect) => void>;
  13502. /**
  13503. * Callback that will be called if an error occurs during shader compilation.
  13504. */
  13505. onError: Nullable<(effect: Effect, errors: string) => void>;
  13506. /**
  13507. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13508. */
  13509. indexParameters: any;
  13510. /**
  13511. * Max number of lights that can be used in the shader.
  13512. */
  13513. maxSimultaneousLights: number;
  13514. /**
  13515. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13516. */
  13517. transformFeedbackVaryings: Nullable<string[]>;
  13518. }
  13519. /**
  13520. * Effect containing vertex and fragment shader that can be executed on an object.
  13521. */
  13522. class Effect {
  13523. /**
  13524. * Name of the effect.
  13525. */
  13526. name: any;
  13527. /**
  13528. * String container all the define statements that should be set on the shader.
  13529. */
  13530. defines: string;
  13531. /**
  13532. * Callback that will be called when the shader is compiled.
  13533. */
  13534. onCompiled: Nullable<(effect: Effect) => void>;
  13535. /**
  13536. * Callback that will be called if an error occurs during shader compilation.
  13537. */
  13538. onError: Nullable<(effect: Effect, errors: string) => void>;
  13539. /**
  13540. * Callback that will be called when effect is bound.
  13541. */
  13542. onBind: Nullable<(effect: Effect) => void>;
  13543. /**
  13544. * Unique ID of the effect.
  13545. */
  13546. uniqueId: number;
  13547. /**
  13548. * Observable that will be called when the shader is compiled.
  13549. */
  13550. onCompileObservable: Observable<Effect>;
  13551. /**
  13552. * Observable that will be called if an error occurs during shader compilation.
  13553. */
  13554. onErrorObservable: Observable<Effect>;
  13555. /** @hidden */
  13556. _onBindObservable: Nullable<Observable<Effect>>;
  13557. /**
  13558. * Observable that will be called when effect is bound.
  13559. */
  13560. readonly onBindObservable: Observable<Effect>;
  13561. /** @hidden */
  13562. _bonesComputationForcedToCPU: boolean;
  13563. private static _uniqueIdSeed;
  13564. private _engine;
  13565. private _uniformBuffersNames;
  13566. private _uniformsNames;
  13567. private _samplers;
  13568. private _isReady;
  13569. private _compilationError;
  13570. private _attributesNames;
  13571. private _attributes;
  13572. private _uniforms;
  13573. /**
  13574. * Key for the effect.
  13575. * @hidden
  13576. */
  13577. _key: string;
  13578. private _indexParameters;
  13579. private _fallbacks;
  13580. private _vertexSourceCode;
  13581. private _fragmentSourceCode;
  13582. private _vertexSourceCodeOverride;
  13583. private _fragmentSourceCodeOverride;
  13584. private _transformFeedbackVaryings;
  13585. /**
  13586. * Compiled shader to webGL program.
  13587. * @hidden
  13588. */
  13589. _program: WebGLProgram;
  13590. private _valueCache;
  13591. private static _baseCache;
  13592. /**
  13593. * Instantiates an effect.
  13594. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13595. * @param baseName Name of the effect.
  13596. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13597. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13598. * @param samplers List of sampler variables that will be passed to the shader.
  13599. * @param engine Engine to be used to render the effect
  13600. * @param defines Define statements to be added to the shader.
  13601. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13602. * @param onCompiled Callback that will be called when the shader is compiled.
  13603. * @param onError Callback that will be called if an error occurs during shader compilation.
  13604. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13605. */
  13606. 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);
  13607. /**
  13608. * Unique key for this effect
  13609. */
  13610. readonly key: string;
  13611. /**
  13612. * If the effect has been compiled and prepared.
  13613. * @returns if the effect is compiled and prepared.
  13614. */
  13615. isReady(): boolean;
  13616. /**
  13617. * The engine the effect was initialized with.
  13618. * @returns the engine.
  13619. */
  13620. getEngine(): Engine;
  13621. /**
  13622. * The compiled webGL program for the effect
  13623. * @returns the webGL program.
  13624. */
  13625. getProgram(): WebGLProgram;
  13626. /**
  13627. * The set of names of attribute variables for the shader.
  13628. * @returns An array of attribute names.
  13629. */
  13630. getAttributesNames(): string[];
  13631. /**
  13632. * Returns the attribute at the given index.
  13633. * @param index The index of the attribute.
  13634. * @returns The location of the attribute.
  13635. */
  13636. getAttributeLocation(index: number): number;
  13637. /**
  13638. * Returns the attribute based on the name of the variable.
  13639. * @param name of the attribute to look up.
  13640. * @returns the attribute location.
  13641. */
  13642. getAttributeLocationByName(name: string): number;
  13643. /**
  13644. * The number of attributes.
  13645. * @returns the numnber of attributes.
  13646. */
  13647. getAttributesCount(): number;
  13648. /**
  13649. * Gets the index of a uniform variable.
  13650. * @param uniformName of the uniform to look up.
  13651. * @returns the index.
  13652. */
  13653. getUniformIndex(uniformName: string): number;
  13654. /**
  13655. * Returns the attribute based on the name of the variable.
  13656. * @param uniformName of the uniform to look up.
  13657. * @returns the location of the uniform.
  13658. */
  13659. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13660. /**
  13661. * Returns an array of sampler variable names
  13662. * @returns The array of sampler variable neames.
  13663. */
  13664. getSamplers(): string[];
  13665. /**
  13666. * The error from the last compilation.
  13667. * @returns the error string.
  13668. */
  13669. getCompilationError(): string;
  13670. /**
  13671. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13672. * @param func The callback to be used.
  13673. */
  13674. executeWhenCompiled(func: (effect: Effect) => void): void;
  13675. /** @hidden */
  13676. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13677. /** @hidden */
  13678. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13679. /** @hidden */
  13680. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13681. private _processShaderConversion;
  13682. private _processIncludes;
  13683. private _processPrecision;
  13684. /**
  13685. * Recompiles the webGL program
  13686. * @param vertexSourceCode The source code for the vertex shader.
  13687. * @param fragmentSourceCode The source code for the fragment shader.
  13688. * @param onCompiled Callback called when completed.
  13689. * @param onError Callback called on error.
  13690. * @hidden
  13691. */
  13692. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13693. /**
  13694. * Gets the uniform locations of the the specified variable names
  13695. * @param names THe names of the variables to lookup.
  13696. * @returns Array of locations in the same order as variable names.
  13697. */
  13698. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13699. /**
  13700. * Prepares the effect
  13701. * @hidden
  13702. */
  13703. _prepareEffect(): void;
  13704. /**
  13705. * Checks if the effect is supported. (Must be called after compilation)
  13706. */
  13707. readonly isSupported: boolean;
  13708. /**
  13709. * Binds a texture to the engine to be used as output of the shader.
  13710. * @param channel Name of the output variable.
  13711. * @param texture Texture to bind.
  13712. * @hidden
  13713. */
  13714. _bindTexture(channel: string, texture: InternalTexture): void;
  13715. /**
  13716. * Sets a texture on the engine to be used in the shader.
  13717. * @param channel Name of the sampler variable.
  13718. * @param texture Texture to set.
  13719. */
  13720. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13721. /**
  13722. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13723. * @param channel Name of the sampler variable.
  13724. * @param texture Texture to set.
  13725. */
  13726. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13727. /**
  13728. * Sets an array of textures on the engine to be used in the shader.
  13729. * @param channel Name of the variable.
  13730. * @param textures Textures to set.
  13731. */
  13732. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13733. /**
  13734. * 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)
  13735. * @param channel Name of the sampler variable.
  13736. * @param postProcess Post process to get the input texture from.
  13737. */
  13738. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13739. /**
  13740. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13741. * 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)
  13742. * @param channel Name of the sampler variable.
  13743. * @param postProcess Post process to get the output texture from.
  13744. */
  13745. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13746. /** @hidden */
  13747. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13748. /** @hidden */
  13749. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13750. /** @hidden */
  13751. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13752. /** @hidden */
  13753. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13754. /**
  13755. * Binds a buffer to a uniform.
  13756. * @param buffer Buffer to bind.
  13757. * @param name Name of the uniform variable to bind to.
  13758. */
  13759. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13760. /**
  13761. * Binds block to a uniform.
  13762. * @param blockName Name of the block to bind.
  13763. * @param index Index to bind.
  13764. */
  13765. bindUniformBlock(blockName: string, index: number): void;
  13766. /**
  13767. * Sets an interger value on a uniform variable.
  13768. * @param uniformName Name of the variable.
  13769. * @param value Value to be set.
  13770. * @returns this effect.
  13771. */
  13772. setInt(uniformName: string, value: number): Effect;
  13773. /**
  13774. * Sets an int array on a uniform variable.
  13775. * @param uniformName Name of the variable.
  13776. * @param array array to be set.
  13777. * @returns this effect.
  13778. */
  13779. setIntArray(uniformName: string, array: Int32Array): Effect;
  13780. /**
  13781. * 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)
  13782. * @param uniformName Name of the variable.
  13783. * @param array array to be set.
  13784. * @returns this effect.
  13785. */
  13786. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13787. /**
  13788. * 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)
  13789. * @param uniformName Name of the variable.
  13790. * @param array array to be set.
  13791. * @returns this effect.
  13792. */
  13793. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13794. /**
  13795. * 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)
  13796. * @param uniformName Name of the variable.
  13797. * @param array array to be set.
  13798. * @returns this effect.
  13799. */
  13800. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13801. /**
  13802. * Sets an float array on a uniform variable.
  13803. * @param uniformName Name of the variable.
  13804. * @param array array to be set.
  13805. * @returns this effect.
  13806. */
  13807. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13808. /**
  13809. * 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)
  13810. * @param uniformName Name of the variable.
  13811. * @param array array to be set.
  13812. * @returns this effect.
  13813. */
  13814. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13815. /**
  13816. * 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)
  13817. * @param uniformName Name of the variable.
  13818. * @param array array to be set.
  13819. * @returns this effect.
  13820. */
  13821. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13822. /**
  13823. * 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)
  13824. * @param uniformName Name of the variable.
  13825. * @param array array to be set.
  13826. * @returns this effect.
  13827. */
  13828. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13829. /**
  13830. * Sets an array on a uniform variable.
  13831. * @param uniformName Name of the variable.
  13832. * @param array array to be set.
  13833. * @returns this effect.
  13834. */
  13835. setArray(uniformName: string, array: number[]): Effect;
  13836. /**
  13837. * 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)
  13838. * @param uniformName Name of the variable.
  13839. * @param array array to be set.
  13840. * @returns this effect.
  13841. */
  13842. setArray2(uniformName: string, array: number[]): Effect;
  13843. /**
  13844. * 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)
  13845. * @param uniformName Name of the variable.
  13846. * @param array array to be set.
  13847. * @returns this effect.
  13848. */
  13849. setArray3(uniformName: string, array: number[]): Effect;
  13850. /**
  13851. * 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)
  13852. * @param uniformName Name of the variable.
  13853. * @param array array to be set.
  13854. * @returns this effect.
  13855. */
  13856. setArray4(uniformName: string, array: number[]): Effect;
  13857. /**
  13858. * Sets matrices on a uniform variable.
  13859. * @param uniformName Name of the variable.
  13860. * @param matrices matrices to be set.
  13861. * @returns this effect.
  13862. */
  13863. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13864. /**
  13865. * Sets matrix on a uniform variable.
  13866. * @param uniformName Name of the variable.
  13867. * @param matrix matrix to be set.
  13868. * @returns this effect.
  13869. */
  13870. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13871. /**
  13872. * 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)
  13873. * @param uniformName Name of the variable.
  13874. * @param matrix matrix to be set.
  13875. * @returns this effect.
  13876. */
  13877. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13878. /**
  13879. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13880. * @param uniformName Name of the variable.
  13881. * @param matrix matrix to be set.
  13882. * @returns this effect.
  13883. */
  13884. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13885. /**
  13886. * Sets a float on a uniform variable.
  13887. * @param uniformName Name of the variable.
  13888. * @param value value to be set.
  13889. * @returns this effect.
  13890. */
  13891. setFloat(uniformName: string, value: number): Effect;
  13892. /**
  13893. * Sets a boolean on a uniform variable.
  13894. * @param uniformName Name of the variable.
  13895. * @param bool value to be set.
  13896. * @returns this effect.
  13897. */
  13898. setBool(uniformName: string, bool: boolean): Effect;
  13899. /**
  13900. * Sets a Vector2 on a uniform variable.
  13901. * @param uniformName Name of the variable.
  13902. * @param vector2 vector2 to be set.
  13903. * @returns this effect.
  13904. */
  13905. setVector2(uniformName: string, vector2: Vector2): Effect;
  13906. /**
  13907. * Sets a float2 on a uniform variable.
  13908. * @param uniformName Name of the variable.
  13909. * @param x First float in float2.
  13910. * @param y Second float in float2.
  13911. * @returns this effect.
  13912. */
  13913. setFloat2(uniformName: string, x: number, y: number): Effect;
  13914. /**
  13915. * Sets a Vector3 on a uniform variable.
  13916. * @param uniformName Name of the variable.
  13917. * @param vector3 Value to be set.
  13918. * @returns this effect.
  13919. */
  13920. setVector3(uniformName: string, vector3: Vector3): Effect;
  13921. /**
  13922. * Sets a float3 on a uniform variable.
  13923. * @param uniformName Name of the variable.
  13924. * @param x First float in float3.
  13925. * @param y Second float in float3.
  13926. * @param z Third float in float3.
  13927. * @returns this effect.
  13928. */
  13929. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13930. /**
  13931. * Sets a Vector4 on a uniform variable.
  13932. * @param uniformName Name of the variable.
  13933. * @param vector4 Value to be set.
  13934. * @returns this effect.
  13935. */
  13936. setVector4(uniformName: string, vector4: Vector4): Effect;
  13937. /**
  13938. * Sets a float4 on a uniform variable.
  13939. * @param uniformName Name of the variable.
  13940. * @param x First float in float4.
  13941. * @param y Second float in float4.
  13942. * @param z Third float in float4.
  13943. * @param w Fourth float in float4.
  13944. * @returns this effect.
  13945. */
  13946. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13947. /**
  13948. * Sets a Color3 on a uniform variable.
  13949. * @param uniformName Name of the variable.
  13950. * @param color3 Value to be set.
  13951. * @returns this effect.
  13952. */
  13953. setColor3(uniformName: string, color3: Color3): Effect;
  13954. /**
  13955. * Sets a Color4 on a uniform variable.
  13956. * @param uniformName Name of the variable.
  13957. * @param color3 Value to be set.
  13958. * @param alpha Alpha value to be set.
  13959. * @returns this effect.
  13960. */
  13961. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13962. /**
  13963. * Sets a Color4 on a uniform variable
  13964. * @param uniformName defines the name of the variable
  13965. * @param color4 defines the value to be set
  13966. * @returns this effect.
  13967. */
  13968. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13969. /**
  13970. * This function will add a new shader to the shader store
  13971. * @param name the name of the shader
  13972. * @param pixelShader optional pixel shader content
  13973. * @param vertexShader optional vertex shader content
  13974. */
  13975. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13976. /**
  13977. * Store of each shader (The can be looked up using effect.key)
  13978. */
  13979. static ShadersStore: {
  13980. [key: string]: string;
  13981. };
  13982. /**
  13983. * Store of each included file for a shader (The can be looked up using effect.key)
  13984. */
  13985. static IncludesShadersStore: {
  13986. [key: string]: string;
  13987. };
  13988. /**
  13989. * Resets the cache of effects.
  13990. */
  13991. static ResetCache(): void;
  13992. }
  13993. }
  13994. declare module BABYLON {
  13995. class FresnelParameters {
  13996. private _isEnabled;
  13997. isEnabled: boolean;
  13998. leftColor: Color3;
  13999. rightColor: Color3;
  14000. bias: number;
  14001. power: number;
  14002. clone(): FresnelParameters;
  14003. serialize(): any;
  14004. static Parse(parsedFresnelParameters: any): FresnelParameters;
  14005. }
  14006. }
  14007. declare module BABYLON {
  14008. /**
  14009. * Interface to follow in your material defines to integrate easily the
  14010. * Image proccessing functions.
  14011. * @hidden
  14012. */
  14013. interface IImageProcessingConfigurationDefines {
  14014. IMAGEPROCESSING: boolean;
  14015. VIGNETTE: boolean;
  14016. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14017. VIGNETTEBLENDMODEOPAQUE: boolean;
  14018. TONEMAPPING: boolean;
  14019. TONEMAPPING_ACES: boolean;
  14020. CONTRAST: boolean;
  14021. EXPOSURE: boolean;
  14022. COLORCURVES: boolean;
  14023. COLORGRADING: boolean;
  14024. COLORGRADING3D: boolean;
  14025. SAMPLER3DGREENDEPTH: boolean;
  14026. SAMPLER3DBGRMAP: boolean;
  14027. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14028. }
  14029. /**
  14030. * @hidden
  14031. */
  14032. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14033. IMAGEPROCESSING: boolean;
  14034. VIGNETTE: boolean;
  14035. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14036. VIGNETTEBLENDMODEOPAQUE: boolean;
  14037. TONEMAPPING: boolean;
  14038. TONEMAPPING_ACES: boolean;
  14039. CONTRAST: boolean;
  14040. COLORCURVES: boolean;
  14041. COLORGRADING: boolean;
  14042. COLORGRADING3D: boolean;
  14043. SAMPLER3DGREENDEPTH: boolean;
  14044. SAMPLER3DBGRMAP: boolean;
  14045. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14046. EXPOSURE: boolean;
  14047. constructor();
  14048. }
  14049. /**
  14050. * This groups together the common properties used for image processing either in direct forward pass
  14051. * or through post processing effect depending on the use of the image processing pipeline in your scene
  14052. * or not.
  14053. */
  14054. class ImageProcessingConfiguration {
  14055. /**
  14056. * Default tone mapping applied in BabylonJS.
  14057. */
  14058. static readonly TONEMAPPING_STANDARD: number;
  14059. /**
  14060. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  14061. * to other engines rendering to increase portability.
  14062. */
  14063. static readonly TONEMAPPING_ACES: number;
  14064. /**
  14065. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  14066. */
  14067. colorCurves: Nullable<ColorCurves>;
  14068. private _colorCurvesEnabled;
  14069. /**
  14070. * Gets wether the color curves effect is enabled.
  14071. */
  14072. /**
  14073. * Sets wether the color curves effect is enabled.
  14074. */
  14075. colorCurvesEnabled: boolean;
  14076. /**
  14077. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  14078. */
  14079. colorGradingTexture: Nullable<BaseTexture>;
  14080. private _colorGradingEnabled;
  14081. /**
  14082. * Gets wether the color grading effect is enabled.
  14083. */
  14084. /**
  14085. * Sets wether the color grading effect is enabled.
  14086. */
  14087. colorGradingEnabled: boolean;
  14088. private _colorGradingWithGreenDepth;
  14089. /**
  14090. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  14091. */
  14092. /**
  14093. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  14094. */
  14095. colorGradingWithGreenDepth: boolean;
  14096. private _colorGradingBGR;
  14097. /**
  14098. * Gets wether the color grading texture contains BGR values.
  14099. */
  14100. /**
  14101. * Sets wether the color grading texture contains BGR values.
  14102. */
  14103. colorGradingBGR: boolean;
  14104. /** @hidden */
  14105. _exposure: number;
  14106. /**
  14107. * Gets the Exposure used in the effect.
  14108. */
  14109. /**
  14110. * Sets the Exposure used in the effect.
  14111. */
  14112. exposure: number;
  14113. private _toneMappingEnabled;
  14114. /**
  14115. * Gets wether the tone mapping effect is enabled.
  14116. */
  14117. /**
  14118. * Sets wether the tone mapping effect is enabled.
  14119. */
  14120. toneMappingEnabled: boolean;
  14121. private _toneMappingType;
  14122. /**
  14123. * Gets the type of tone mapping effect.
  14124. */
  14125. /**
  14126. * Sets the type of tone mapping effect used in BabylonJS.
  14127. */
  14128. toneMappingType: number;
  14129. protected _contrast: number;
  14130. /**
  14131. * Gets the contrast used in the effect.
  14132. */
  14133. /**
  14134. * Sets the contrast used in the effect.
  14135. */
  14136. contrast: number;
  14137. /**
  14138. * Vignette stretch size.
  14139. */
  14140. vignetteStretch: number;
  14141. /**
  14142. * Vignette centre X Offset.
  14143. */
  14144. vignetteCentreX: number;
  14145. /**
  14146. * Vignette centre Y Offset.
  14147. */
  14148. vignetteCentreY: number;
  14149. /**
  14150. * Vignette weight or intensity of the vignette effect.
  14151. */
  14152. vignetteWeight: number;
  14153. /**
  14154. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  14155. * if vignetteEnabled is set to true.
  14156. */
  14157. vignetteColor: Color4;
  14158. /**
  14159. * Camera field of view used by the Vignette effect.
  14160. */
  14161. vignetteCameraFov: number;
  14162. private _vignetteBlendMode;
  14163. /**
  14164. * Gets the vignette blend mode allowing different kind of effect.
  14165. */
  14166. /**
  14167. * Sets the vignette blend mode allowing different kind of effect.
  14168. */
  14169. vignetteBlendMode: number;
  14170. private _vignetteEnabled;
  14171. /**
  14172. * Gets wether the vignette effect is enabled.
  14173. */
  14174. /**
  14175. * Sets wether the vignette effect is enabled.
  14176. */
  14177. vignetteEnabled: boolean;
  14178. private _applyByPostProcess;
  14179. /**
  14180. * Gets wether the image processing is applied through a post process or not.
  14181. */
  14182. /**
  14183. * Sets wether the image processing is applied through a post process or not.
  14184. */
  14185. applyByPostProcess: boolean;
  14186. private _isEnabled;
  14187. /**
  14188. * Gets wether the image processing is enabled or not.
  14189. */
  14190. /**
  14191. * Sets wether the image processing is enabled or not.
  14192. */
  14193. isEnabled: boolean;
  14194. /**
  14195. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  14196. */
  14197. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  14198. /**
  14199. * Method called each time the image processing information changes requires to recompile the effect.
  14200. */
  14201. protected _updateParameters(): void;
  14202. getClassName(): string;
  14203. /**
  14204. * Prepare the list of uniforms associated with the Image Processing effects.
  14205. * @param uniformsList The list of uniforms used in the effect
  14206. * @param defines the list of defines currently in use
  14207. */
  14208. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  14209. /**
  14210. * Prepare the list of samplers associated with the Image Processing effects.
  14211. * @param uniformsList The list of uniforms used in the effect
  14212. * @param defines the list of defines currently in use
  14213. */
  14214. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  14215. /**
  14216. * Prepare the list of defines associated to the shader.
  14217. * @param defines the list of defines to complete
  14218. */
  14219. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  14220. /**
  14221. * Returns true if all the image processing information are ready.
  14222. */
  14223. isReady(): boolean;
  14224. /**
  14225. * Binds the image processing to the shader.
  14226. * @param effect The effect to bind to
  14227. */
  14228. bind(effect: Effect, aspectRatio?: number): void;
  14229. /**
  14230. * Clones the current image processing instance.
  14231. * @return The cloned image processing
  14232. */
  14233. clone(): ImageProcessingConfiguration;
  14234. /**
  14235. * Serializes the current image processing instance to a json representation.
  14236. * @return a JSON representation
  14237. */
  14238. serialize(): any;
  14239. /**
  14240. * Parses the image processing from a json representation.
  14241. * @param source the JSON source to parse
  14242. * @return The parsed image processing
  14243. */
  14244. static Parse(source: any): ImageProcessingConfiguration;
  14245. private static _VIGNETTEMODE_MULTIPLY;
  14246. private static _VIGNETTEMODE_OPAQUE;
  14247. /**
  14248. * Used to apply the vignette as a mix with the pixel color.
  14249. */
  14250. static readonly VIGNETTEMODE_MULTIPLY: number;
  14251. /**
  14252. * Used to apply the vignette as a replacement of the pixel color.
  14253. */
  14254. static readonly VIGNETTEMODE_OPAQUE: number;
  14255. }
  14256. }
  14257. declare module BABYLON {
  14258. /**
  14259. * Manages the defines for the Material
  14260. */
  14261. class MaterialDefines {
  14262. private _keys;
  14263. private _isDirty;
  14264. /** @hidden */
  14265. _renderId: number;
  14266. /** @hidden */
  14267. _areLightsDirty: boolean;
  14268. /** @hidden */
  14269. _areAttributesDirty: boolean;
  14270. /** @hidden */
  14271. _areTexturesDirty: boolean;
  14272. /** @hidden */
  14273. _areFresnelDirty: boolean;
  14274. /** @hidden */
  14275. _areMiscDirty: boolean;
  14276. /** @hidden */
  14277. _areImageProcessingDirty: boolean;
  14278. /** @hidden */
  14279. _normals: boolean;
  14280. /** @hidden */
  14281. _uvs: boolean;
  14282. /** @hidden */
  14283. _needNormals: boolean;
  14284. /** @hidden */
  14285. _needUVs: boolean;
  14286. /**
  14287. * Specifies if the material needs to be re-calculated
  14288. */
  14289. readonly isDirty: boolean;
  14290. /**
  14291. * Marks the material to indicate that it has been re-calculated
  14292. */
  14293. markAsProcessed(): void;
  14294. /**
  14295. * Marks the material to indicate that it needs to be re-calculated
  14296. */
  14297. markAsUnprocessed(): void;
  14298. /**
  14299. * Marks the material to indicate all of its defines need to be re-calculated
  14300. */
  14301. markAllAsDirty(): void;
  14302. /**
  14303. * Marks the material to indicate that image processing needs to be re-calculated
  14304. */
  14305. markAsImageProcessingDirty(): void;
  14306. /**
  14307. * Marks the material to indicate the lights need to be re-calculated
  14308. */
  14309. markAsLightDirty(): void;
  14310. /**
  14311. * Marks the attribute state as changed
  14312. */
  14313. markAsAttributesDirty(): void;
  14314. /**
  14315. * Marks the texture state as changed
  14316. */
  14317. markAsTexturesDirty(): void;
  14318. /**
  14319. * Marks the fresnel state as changed
  14320. */
  14321. markAsFresnelDirty(): void;
  14322. /**
  14323. * Marks the misc state as changed
  14324. */
  14325. markAsMiscDirty(): void;
  14326. /**
  14327. * Rebuilds the material defines
  14328. */
  14329. rebuild(): void;
  14330. /**
  14331. * Specifies if two material defines are equal
  14332. * @param other - A material define instance to compare to
  14333. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14334. */
  14335. isEqual(other: MaterialDefines): boolean;
  14336. /**
  14337. * Clones this instance's defines to another instance
  14338. * @param other - material defines to clone values to
  14339. */
  14340. cloneTo(other: MaterialDefines): void;
  14341. /**
  14342. * Resets the material define values
  14343. */
  14344. reset(): void;
  14345. /**
  14346. * Converts the material define values to a string
  14347. * @returns - String of material define information
  14348. */
  14349. toString(): string;
  14350. }
  14351. /**
  14352. * Base class for the main features of a material in Babylon.js
  14353. */
  14354. class Material implements IAnimatable {
  14355. private static _TriangleFillMode;
  14356. private static _WireFrameFillMode;
  14357. private static _PointFillMode;
  14358. private static _PointListDrawMode;
  14359. private static _LineListDrawMode;
  14360. private static _LineLoopDrawMode;
  14361. private static _LineStripDrawMode;
  14362. private static _TriangleStripDrawMode;
  14363. private static _TriangleFanDrawMode;
  14364. /**
  14365. * Returns the triangle fill mode
  14366. */
  14367. static readonly TriangleFillMode: number;
  14368. /**
  14369. * Returns the wireframe mode
  14370. */
  14371. static readonly WireFrameFillMode: number;
  14372. /**
  14373. * Returns the point fill mode
  14374. */
  14375. static readonly PointFillMode: number;
  14376. /**
  14377. * Returns the point list draw mode
  14378. */
  14379. static readonly PointListDrawMode: number;
  14380. /**
  14381. * Returns the line list draw mode
  14382. */
  14383. static readonly LineListDrawMode: number;
  14384. /**
  14385. * Returns the line loop draw mode
  14386. */
  14387. static readonly LineLoopDrawMode: number;
  14388. /**
  14389. * Returns the line strip draw mode
  14390. */
  14391. static readonly LineStripDrawMode: number;
  14392. /**
  14393. * Returns the triangle strip draw mode
  14394. */
  14395. static readonly TriangleStripDrawMode: number;
  14396. /**
  14397. * Returns the triangle fan draw mode
  14398. */
  14399. static readonly TriangleFanDrawMode: number;
  14400. /**
  14401. * Stores the clock-wise side orientation
  14402. */
  14403. private static _ClockWiseSideOrientation;
  14404. /**
  14405. * Stores the counter clock-wise side orientation
  14406. */
  14407. private static _CounterClockWiseSideOrientation;
  14408. /**
  14409. * Returns the clock-wise side orientation
  14410. */
  14411. static readonly ClockWiseSideOrientation: number;
  14412. /**
  14413. * Returns the counter clock-wise side orientation
  14414. */
  14415. static readonly CounterClockWiseSideOrientation: number;
  14416. /**
  14417. * The dirty texture flag value
  14418. */
  14419. private static _TextureDirtyFlag;
  14420. /**
  14421. * The dirty light flag value
  14422. */
  14423. private static _LightDirtyFlag;
  14424. /**
  14425. * The dirty fresnel flag value
  14426. */
  14427. private static _FresnelDirtyFlag;
  14428. /**
  14429. * The dirty attribute flag value
  14430. */
  14431. private static _AttributesDirtyFlag;
  14432. /**
  14433. * The dirty misc flag value
  14434. */
  14435. private static _MiscDirtyFlag;
  14436. /**
  14437. * Returns the dirty texture flag value
  14438. */
  14439. static readonly TextureDirtyFlag: number;
  14440. /**
  14441. * Returns the dirty light flag value
  14442. */
  14443. static readonly LightDirtyFlag: number;
  14444. /**
  14445. * Returns the dirty fresnel flag value
  14446. */
  14447. static readonly FresnelDirtyFlag: number;
  14448. /**
  14449. * Returns the dirty attributes flag value
  14450. */
  14451. static readonly AttributesDirtyFlag: number;
  14452. /**
  14453. * Returns the dirty misc flag value
  14454. */
  14455. static readonly MiscDirtyFlag: number;
  14456. /**
  14457. * The ID of the material
  14458. */
  14459. id: string;
  14460. /**
  14461. * Gets or sets the unique id of the material
  14462. */
  14463. uniqueId: number;
  14464. /**
  14465. * The name of the material
  14466. */
  14467. name: string;
  14468. /**
  14469. * Specifies if the ready state should be checked on each call
  14470. */
  14471. checkReadyOnEveryCall: boolean;
  14472. /**
  14473. * Specifies if the ready state should be checked once
  14474. */
  14475. checkReadyOnlyOnce: boolean;
  14476. /**
  14477. * The state of the material
  14478. */
  14479. state: string;
  14480. /**
  14481. * The alpha value of the material
  14482. */
  14483. protected _alpha: number;
  14484. /**
  14485. * Sets the alpha value of the material
  14486. */
  14487. /**
  14488. * Gets the alpha value of the material
  14489. */
  14490. alpha: number;
  14491. /**
  14492. * Specifies if back face culling is enabled
  14493. */
  14494. protected _backFaceCulling: boolean;
  14495. /**
  14496. * Sets the back-face culling state
  14497. */
  14498. /**
  14499. * Gets the back-face culling state
  14500. */
  14501. backFaceCulling: boolean;
  14502. /**
  14503. * Stores the value for side orientation
  14504. */
  14505. sideOrientation: number;
  14506. /**
  14507. * Callback triggered when the material is compiled
  14508. */
  14509. onCompiled: (effect: Effect) => void;
  14510. /**
  14511. * Callback triggered when an error occurs
  14512. */
  14513. onError: (effect: Effect, errors: string) => void;
  14514. /**
  14515. * Callback triggered to get the render target textures
  14516. */
  14517. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14518. /**
  14519. * Specifies if the material should be serialized
  14520. */
  14521. doNotSerialize: boolean;
  14522. /**
  14523. * Specifies if the effect should be stored on sub meshes
  14524. */
  14525. storeEffectOnSubMeshes: boolean;
  14526. /**
  14527. * Stores the animations for the material
  14528. */
  14529. animations: Array<Animation>;
  14530. /**
  14531. * An event triggered when the material is disposed
  14532. */
  14533. onDisposeObservable: Observable<Material>;
  14534. /**
  14535. * An observer which watches for dispose events
  14536. */
  14537. private _onDisposeObserver;
  14538. private _onUnBindObservable;
  14539. /**
  14540. * Called during a dispose event
  14541. */
  14542. onDispose: () => void;
  14543. private _onBindObservable;
  14544. /**
  14545. * An event triggered when the material is bound
  14546. */
  14547. readonly onBindObservable: Observable<AbstractMesh>;
  14548. /**
  14549. * An observer which watches for bind events
  14550. */
  14551. private _onBindObserver;
  14552. /**
  14553. * Called during a bind event
  14554. */
  14555. onBind: (Mesh: AbstractMesh) => void;
  14556. /**
  14557. * An event triggered when the material is unbound
  14558. */
  14559. readonly onUnBindObservable: Observable<Material>;
  14560. /**
  14561. * Stores the value of the alpha mode
  14562. */
  14563. private _alphaMode;
  14564. /**
  14565. * Sets the value of the alpha mode.
  14566. *
  14567. * | Value | Type | Description |
  14568. * | --- | --- | --- |
  14569. * | 0 | ALPHA_DISABLE | |
  14570. * | 1 | ALPHA_ADD | |
  14571. * | 2 | ALPHA_COMBINE | |
  14572. * | 3 | ALPHA_SUBTRACT | |
  14573. * | 4 | ALPHA_MULTIPLY | |
  14574. * | 5 | ALPHA_MAXIMIZED | |
  14575. * | 6 | ALPHA_ONEONE | |
  14576. * | 7 | ALPHA_PREMULTIPLIED | |
  14577. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14578. * | 9 | ALPHA_INTERPOLATE | |
  14579. * | 10 | ALPHA_SCREENMODE | |
  14580. *
  14581. */
  14582. /**
  14583. * Gets the value of the alpha mode
  14584. */
  14585. alphaMode: number;
  14586. /**
  14587. * Stores the state of the need depth pre-pass value
  14588. */
  14589. private _needDepthPrePass;
  14590. /**
  14591. * Sets the need depth pre-pass value
  14592. */
  14593. /**
  14594. * Gets the depth pre-pass value
  14595. */
  14596. needDepthPrePass: boolean;
  14597. /**
  14598. * Specifies if depth writing should be disabled
  14599. */
  14600. disableDepthWrite: boolean;
  14601. /**
  14602. * Specifies if depth writing should be forced
  14603. */
  14604. forceDepthWrite: boolean;
  14605. /**
  14606. * Specifies if there should be a separate pass for culling
  14607. */
  14608. separateCullingPass: boolean;
  14609. /**
  14610. * Stores the state specifing if fog should be enabled
  14611. */
  14612. private _fogEnabled;
  14613. /**
  14614. * Sets the state for enabling fog
  14615. */
  14616. /**
  14617. * Gets the value of the fog enabled state
  14618. */
  14619. fogEnabled: boolean;
  14620. /**
  14621. * Stores the size of points
  14622. */
  14623. pointSize: number;
  14624. /**
  14625. * Stores the z offset value
  14626. */
  14627. zOffset: number;
  14628. /**
  14629. * Gets a value specifying if wireframe mode is enabled
  14630. */
  14631. /**
  14632. * Sets the state of wireframe mode
  14633. */
  14634. wireframe: boolean;
  14635. /**
  14636. * Gets the value specifying if point clouds are enabled
  14637. */
  14638. /**
  14639. * Sets the state of point cloud mode
  14640. */
  14641. pointsCloud: boolean;
  14642. /**
  14643. * Gets the material fill mode
  14644. */
  14645. /**
  14646. * Sets the material fill mode
  14647. */
  14648. fillMode: number;
  14649. /**
  14650. * @hidden
  14651. * Stores the effects for the material
  14652. */
  14653. _effect: Nullable<Effect>;
  14654. /**
  14655. * @hidden
  14656. * Specifies if the material was previously ready
  14657. */
  14658. _wasPreviouslyReady: boolean;
  14659. /**
  14660. * Specifies if uniform buffers should be used
  14661. */
  14662. private _useUBO;
  14663. /**
  14664. * Stores a reference to the scene
  14665. */
  14666. private _scene;
  14667. /**
  14668. * Stores the fill mode state
  14669. */
  14670. private _fillMode;
  14671. /**
  14672. * Specifies if the depth write state should be cached
  14673. */
  14674. private _cachedDepthWriteState;
  14675. /**
  14676. * Stores the uniform buffer
  14677. */
  14678. protected _uniformBuffer: UniformBuffer;
  14679. /**
  14680. * Creates a material instance
  14681. * @param name defines the name of the material
  14682. * @param scene defines the scene to reference
  14683. * @param doNotAdd specifies if the material should be added to the scene
  14684. */
  14685. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14686. /**
  14687. * Returns a string representation of the current material
  14688. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14689. * @returns a string with material information
  14690. */
  14691. toString(fullDetails?: boolean): string;
  14692. /**
  14693. * Gets the class name of the material
  14694. * @returns a string with the class name of the material
  14695. */
  14696. getClassName(): string;
  14697. /**
  14698. * Specifies if updates for the material been locked
  14699. */
  14700. readonly isFrozen: boolean;
  14701. /**
  14702. * Locks updates for the material
  14703. */
  14704. freeze(): void;
  14705. /**
  14706. * Unlocks updates for the material
  14707. */
  14708. unfreeze(): void;
  14709. /**
  14710. * Specifies if the material is ready to be used
  14711. * @param mesh defines the mesh to check
  14712. * @param useInstances specifies if instances should be used
  14713. * @returns a boolean indicating if the material is ready to be used
  14714. */
  14715. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14716. /**
  14717. * Specifies that the submesh is ready to be used
  14718. * @param mesh defines the mesh to check
  14719. * @param subMesh defines which submesh to check
  14720. * @param useInstances specifies that instances should be used
  14721. * @returns a boolean indicating that the submesh is ready or not
  14722. */
  14723. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14724. /**
  14725. * Returns the material effect
  14726. * @returns the effect associated with the material
  14727. */
  14728. getEffect(): Nullable<Effect>;
  14729. /**
  14730. * Returns the current scene
  14731. * @returns a Scene
  14732. */
  14733. getScene(): Scene;
  14734. /**
  14735. * Specifies if the material will require alpha blending
  14736. * @returns a boolean specifying if alpha blending is needed
  14737. */
  14738. needAlphaBlending(): boolean;
  14739. /**
  14740. * Specifies if the mesh will require alpha blending
  14741. * @param mesh defines the mesh to check
  14742. * @returns a boolean specifying if alpha blending is needed for the mesh
  14743. */
  14744. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14745. /**
  14746. * Specifies if this material should be rendered in alpha test mode
  14747. * @returns a boolean specifying if an alpha test is needed.
  14748. */
  14749. needAlphaTesting(): boolean;
  14750. /**
  14751. * Gets the texture used for the alpha test
  14752. * @returns the texture to use for alpha testing
  14753. */
  14754. getAlphaTestTexture(): Nullable<BaseTexture>;
  14755. /**
  14756. * Marks the material to indicate that it needs to be re-calculated
  14757. */
  14758. markDirty(): void;
  14759. /** @hidden */
  14760. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14761. /**
  14762. * Binds the material to the mesh
  14763. * @param world defines the world transformation matrix
  14764. * @param mesh defines the mesh to bind the material to
  14765. */
  14766. bind(world: Matrix, mesh?: Mesh): void;
  14767. /**
  14768. * Binds the submesh to the material
  14769. * @param world defines the world transformation matrix
  14770. * @param mesh defines the mesh containing the submesh
  14771. * @param subMesh defines the submesh to bind the material to
  14772. */
  14773. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14774. /**
  14775. * Binds the world matrix to the material
  14776. * @param world defines the world transformation matrix
  14777. */
  14778. bindOnlyWorldMatrix(world: Matrix): void;
  14779. /**
  14780. * Binds the scene's uniform buffer to the effect.
  14781. * @param effect defines the effect to bind to the scene uniform buffer
  14782. * @param sceneUbo defines the uniform buffer storing scene data
  14783. */
  14784. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14785. /**
  14786. * Binds the view matrix to the effect
  14787. * @param effect defines the effect to bind the view matrix to
  14788. */
  14789. bindView(effect: Effect): void;
  14790. /**
  14791. * Binds the view projection matrix to the effect
  14792. * @param effect defines the effect to bind the view projection matrix to
  14793. */
  14794. bindViewProjection(effect: Effect): void;
  14795. /**
  14796. * Specifies if material alpha testing should be turned on for the mesh
  14797. * @param mesh defines the mesh to check
  14798. */
  14799. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14800. /**
  14801. * Processes to execute after binding the material to a mesh
  14802. * @param mesh defines the rendered mesh
  14803. */
  14804. protected _afterBind(mesh?: Mesh): void;
  14805. /**
  14806. * Unbinds the material from the mesh
  14807. */
  14808. unbind(): void;
  14809. /**
  14810. * Gets the active textures from the material
  14811. * @returns an array of textures
  14812. */
  14813. getActiveTextures(): BaseTexture[];
  14814. /**
  14815. * Specifies if the material uses a texture
  14816. * @param texture defines the texture to check against the material
  14817. * @returns a boolean specifying if the material uses the texture
  14818. */
  14819. hasTexture(texture: BaseTexture): boolean;
  14820. /**
  14821. * Makes a duplicate of the material, and gives it a new name
  14822. * @param name defines the new name for the duplicated material
  14823. * @returns the cloned material
  14824. */
  14825. clone(name: string): Nullable<Material>;
  14826. /**
  14827. * Gets the meshes bound to the material
  14828. * @returns an array of meshes bound to the material
  14829. */
  14830. getBindedMeshes(): AbstractMesh[];
  14831. /**
  14832. * Force shader compilation
  14833. * @param mesh defines the mesh associated with this material
  14834. * @param onCompiled defines a function to execute once the material is compiled
  14835. * @param options defines the options to configure the compilation
  14836. */
  14837. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14838. clipPlane: boolean;
  14839. }>): void;
  14840. /**
  14841. * Force shader compilation
  14842. * @param mesh defines the mesh that will use this material
  14843. * @param options defines additional options for compiling the shaders
  14844. * @returns a promise that resolves when the compilation completes
  14845. */
  14846. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14847. clipPlane: boolean;
  14848. }>): Promise<void>;
  14849. /**
  14850. * Marks a define in the material to indicate that it needs to be re-computed
  14851. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14852. */
  14853. markAsDirty(flag: number): void;
  14854. /**
  14855. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14856. * @param func defines a function which checks material defines against the submeshes
  14857. */
  14858. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14859. /**
  14860. * Indicates that image processing needs to be re-calculated for all submeshes
  14861. */
  14862. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14863. /**
  14864. * Indicates that textures need to be re-calculated for all submeshes
  14865. */
  14866. protected _markAllSubMeshesAsTexturesDirty(): void;
  14867. /**
  14868. * Indicates that fresnel needs to be re-calculated for all submeshes
  14869. */
  14870. protected _markAllSubMeshesAsFresnelDirty(): void;
  14871. /**
  14872. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14873. */
  14874. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14875. /**
  14876. * Indicates that lights need to be re-calculated for all submeshes
  14877. */
  14878. protected _markAllSubMeshesAsLightsDirty(): void;
  14879. /**
  14880. * Indicates that attributes need to be re-calculated for all submeshes
  14881. */
  14882. protected _markAllSubMeshesAsAttributesDirty(): void;
  14883. /**
  14884. * Indicates that misc needs to be re-calculated for all submeshes
  14885. */
  14886. protected _markAllSubMeshesAsMiscDirty(): void;
  14887. /**
  14888. * Indicates that textures and misc need to be re-calculated for all submeshes
  14889. */
  14890. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14891. /**
  14892. * Disposes the material
  14893. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14894. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14895. */
  14896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14897. /**
  14898. * Serializes this material
  14899. * @returns the serialized material object
  14900. */
  14901. serialize(): any;
  14902. /**
  14903. * Creates a MultiMaterial from parsed MultiMaterial data.
  14904. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14905. * @param scene defines the hosting scene
  14906. * @returns a new MultiMaterial
  14907. */
  14908. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14909. /**
  14910. * Creates a material from parsed material data
  14911. * @param parsedMaterial defines parsed material data
  14912. * @param scene defines the hosting scene
  14913. * @param rootUrl defines the root URL to use to load textures
  14914. * @returns a new material
  14915. */
  14916. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14917. }
  14918. }
  14919. declare module BABYLON {
  14920. /**
  14921. * "Static Class" containing the most commonly used helper while dealing with material for
  14922. * rendering purpose.
  14923. *
  14924. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14925. *
  14926. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14927. */
  14928. class MaterialHelper {
  14929. /**
  14930. * Bind the current view position to an effect.
  14931. * @param effect The effect to be bound
  14932. * @param scene The scene the eyes position is used from
  14933. */
  14934. static BindEyePosition(effect: Effect, scene: Scene): void;
  14935. /**
  14936. * Helps preparing the defines values about the UVs in used in the effect.
  14937. * UVs are shared as much as we can accross chanels in the shaders.
  14938. * @param texture The texture we are preparing the UVs for
  14939. * @param defines The defines to update
  14940. * @param key The chanel key "diffuse", "specular"... used in the shader
  14941. */
  14942. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14943. /**
  14944. * Binds a texture matrix value to its corrsponding uniform
  14945. * @param texture The texture to bind the matrix for
  14946. * @param uniformBuffer The uniform buffer receivin the data
  14947. * @param key The chanel key "diffuse", "specular"... used in the shader
  14948. */
  14949. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14950. /**
  14951. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14952. * @param mesh defines the current mesh
  14953. * @param scene defines the current scene
  14954. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14955. * @param pointsCloud defines if point cloud rendering has to be turned on
  14956. * @param fogEnabled defines if fog has to be turned on
  14957. * @param alphaTest defines if alpha testing has to be turned on
  14958. * @param defines defines the current list of defines
  14959. */
  14960. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14961. /**
  14962. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14963. * @param scene defines the current scene
  14964. * @param engine defines the current engine
  14965. * @param defines specifies the list of active defines
  14966. * @param useInstances defines if instances have to be turned on
  14967. * @param useClipPlane defines if clip plane have to be turned on
  14968. */
  14969. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14970. /**
  14971. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14972. * @param mesh The mesh containing the geometry data we will draw
  14973. * @param defines The defines to update
  14974. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14975. * @param useBones Precise whether bones should be used or not (override mesh info)
  14976. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14977. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14978. * @returns false if defines are considered not dirty and have not been checked
  14979. */
  14980. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14981. /**
  14982. * Prepares the defines related to the light information passed in parameter
  14983. * @param scene The scene we are intending to draw
  14984. * @param mesh The mesh the effect is compiling for
  14985. * @param defines The defines to update
  14986. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14987. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14988. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14989. * @returns true if normals will be required for the rest of the effect
  14990. */
  14991. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14992. /**
  14993. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14994. * that won t be acctive due to defines being turned off.
  14995. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14996. * @param samplersList The samplers list
  14997. * @param defines The defines helping in the list generation
  14998. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14999. */
  15000. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  15001. /**
  15002. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  15003. * @param defines The defines to update while falling back
  15004. * @param fallbacks The authorized effect fallbacks
  15005. * @param maxSimultaneousLights The maximum number of lights allowed
  15006. * @param rank the current rank of the Effect
  15007. * @returns The newly affected rank
  15008. */
  15009. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  15010. /**
  15011. * Prepares the list of attributes required for morph targets according to the effect defines.
  15012. * @param attribs The current list of supported attribs
  15013. * @param mesh The mesh to prepare the morph targets attributes for
  15014. * @param defines The current Defines of the effect
  15015. */
  15016. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  15017. /**
  15018. * Prepares the list of attributes required for bones according to the effect defines.
  15019. * @param attribs The current list of supported attribs
  15020. * @param mesh The mesh to prepare the bones attributes for
  15021. * @param defines The current Defines of the effect
  15022. * @param fallbacks The current efffect fallback strategy
  15023. */
  15024. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  15025. /**
  15026. * Prepares the list of attributes required for instances according to the effect defines.
  15027. * @param attribs The current list of supported attribs
  15028. * @param defines The current Defines of the effect
  15029. */
  15030. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  15031. /**
  15032. * Binds the light shadow information to the effect for the given mesh.
  15033. * @param light The light containing the generator
  15034. * @param scene The scene the lights belongs to
  15035. * @param mesh The mesh we are binding the information to render
  15036. * @param lightIndex The light index in the effect used to render the mesh
  15037. * @param effect The effect we are binding the data to
  15038. */
  15039. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  15040. /**
  15041. * Binds the light information to the effect.
  15042. * @param light The light containing the generator
  15043. * @param effect The effect we are binding the data to
  15044. * @param lightIndex The light index in the effect used to render
  15045. */
  15046. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  15047. /**
  15048. * Binds the lights information from the scene to the effect for the given mesh.
  15049. * @param scene The scene the lights belongs to
  15050. * @param mesh The mesh we are binding the information to render
  15051. * @param effect The effect we are binding the data to
  15052. * @param defines The generated defines for the effect
  15053. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  15054. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  15055. */
  15056. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  15057. /**
  15058. * Binds the fog information from the scene to the effect for the given mesh.
  15059. * @param scene The scene the lights belongs to
  15060. * @param mesh The mesh we are binding the information to render
  15061. * @param effect The effect we are binding the data to
  15062. */
  15063. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  15064. /**
  15065. * Binds the bones information from the mesh to the effect.
  15066. * @param mesh The mesh we are binding the information to render
  15067. * @param effect The effect we are binding the data to
  15068. */
  15069. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  15070. /**
  15071. * Binds the morph targets information from the mesh to the effect.
  15072. * @param abstractMesh The mesh we are binding the information to render
  15073. * @param effect The effect we are binding the data to
  15074. */
  15075. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  15076. /**
  15077. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  15078. * @param defines The generated defines used in the effect
  15079. * @param effect The effect we are binding the data to
  15080. * @param scene The scene we are willing to render with logarithmic scale for
  15081. */
  15082. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  15083. /**
  15084. * Binds the clip plane information from the scene to the effect.
  15085. * @param scene The scene the clip plane information are extracted from
  15086. * @param effect The effect we are binding the data to
  15087. */
  15088. static BindClipPlane(effect: Effect, scene: Scene): void;
  15089. }
  15090. }
  15091. declare module BABYLON {
  15092. class MultiMaterial extends Material {
  15093. private _subMaterials;
  15094. subMaterials: Nullable<Material>[];
  15095. constructor(name: string, scene: Scene);
  15096. private _hookArray;
  15097. getSubMaterial(index: number): Nullable<Material>;
  15098. getActiveTextures(): BaseTexture[];
  15099. getClassName(): string;
  15100. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15101. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  15102. serialize(): any;
  15103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15104. }
  15105. }
  15106. declare module BABYLON {
  15107. class PushMaterial extends Material {
  15108. protected _activeEffect: Effect;
  15109. protected _normalMatrix: Matrix;
  15110. constructor(name: string, scene: Scene);
  15111. getEffect(): Effect;
  15112. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15113. /**
  15114. * Binds the given world matrix to the active effect
  15115. *
  15116. * @param world the matrix to bind
  15117. */
  15118. bindOnlyWorldMatrix(world: Matrix): void;
  15119. /**
  15120. * Binds the given normal matrix to the active effect
  15121. *
  15122. * @param normalMatrix the matrix to bind
  15123. */
  15124. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  15125. bind(world: Matrix, mesh?: Mesh): void;
  15126. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  15127. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  15128. }
  15129. }
  15130. declare module BABYLON {
  15131. class ShaderMaterial extends Material {
  15132. private _shaderPath;
  15133. private _options;
  15134. private _textures;
  15135. private _textureArrays;
  15136. private _floats;
  15137. private _ints;
  15138. private _floatsArrays;
  15139. private _colors3;
  15140. private _colors3Arrays;
  15141. private _colors4;
  15142. private _vectors2;
  15143. private _vectors3;
  15144. private _vectors4;
  15145. private _matrices;
  15146. private _matrices3x3;
  15147. private _matrices2x2;
  15148. private _vectors2Arrays;
  15149. private _vectors3Arrays;
  15150. private _cachedWorldViewMatrix;
  15151. private _renderId;
  15152. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  15153. getClassName(): string;
  15154. needAlphaBlending(): boolean;
  15155. needAlphaTesting(): boolean;
  15156. private _checkUniform;
  15157. setTexture(name: string, texture: Texture): ShaderMaterial;
  15158. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15159. setFloat(name: string, value: number): ShaderMaterial;
  15160. setInt(name: string, value: number): ShaderMaterial;
  15161. setFloats(name: string, value: number[]): ShaderMaterial;
  15162. setColor3(name: string, value: Color3): ShaderMaterial;
  15163. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15164. setColor4(name: string, value: Color4): ShaderMaterial;
  15165. setVector2(name: string, value: Vector2): ShaderMaterial;
  15166. setVector3(name: string, value: Vector3): ShaderMaterial;
  15167. setVector4(name: string, value: Vector4): ShaderMaterial;
  15168. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15169. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15170. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15171. setArray2(name: string, value: number[]): ShaderMaterial;
  15172. setArray3(name: string, value: number[]): ShaderMaterial;
  15173. private _checkCache;
  15174. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15175. bindOnlyWorldMatrix(world: Matrix): void;
  15176. bind(world: Matrix, mesh?: Mesh): void;
  15177. getActiveTextures(): BaseTexture[];
  15178. hasTexture(texture: BaseTexture): boolean;
  15179. clone(name: string): ShaderMaterial;
  15180. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15181. serialize(): any;
  15182. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15183. }
  15184. }
  15185. declare module BABYLON {
  15186. /** @hidden */
  15187. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  15188. MAINUV1: boolean;
  15189. MAINUV2: boolean;
  15190. DIFFUSE: boolean;
  15191. DIFFUSEDIRECTUV: number;
  15192. AMBIENT: boolean;
  15193. AMBIENTDIRECTUV: number;
  15194. OPACITY: boolean;
  15195. OPACITYDIRECTUV: number;
  15196. OPACITYRGB: boolean;
  15197. REFLECTION: boolean;
  15198. EMISSIVE: boolean;
  15199. EMISSIVEDIRECTUV: number;
  15200. SPECULAR: boolean;
  15201. SPECULARDIRECTUV: number;
  15202. BUMP: boolean;
  15203. BUMPDIRECTUV: number;
  15204. PARALLAX: boolean;
  15205. PARALLAXOCCLUSION: boolean;
  15206. SPECULAROVERALPHA: boolean;
  15207. CLIPPLANE: boolean;
  15208. CLIPPLANE2: boolean;
  15209. CLIPPLANE3: boolean;
  15210. CLIPPLANE4: boolean;
  15211. ALPHATEST: boolean;
  15212. DEPTHPREPASS: boolean;
  15213. ALPHAFROMDIFFUSE: boolean;
  15214. POINTSIZE: boolean;
  15215. FOG: boolean;
  15216. SPECULARTERM: boolean;
  15217. DIFFUSEFRESNEL: boolean;
  15218. OPACITYFRESNEL: boolean;
  15219. REFLECTIONFRESNEL: boolean;
  15220. REFRACTIONFRESNEL: boolean;
  15221. EMISSIVEFRESNEL: boolean;
  15222. FRESNEL: boolean;
  15223. NORMAL: boolean;
  15224. UV1: boolean;
  15225. UV2: boolean;
  15226. VERTEXCOLOR: boolean;
  15227. VERTEXALPHA: boolean;
  15228. NUM_BONE_INFLUENCERS: number;
  15229. BonesPerMesh: number;
  15230. INSTANCES: boolean;
  15231. GLOSSINESS: boolean;
  15232. ROUGHNESS: boolean;
  15233. EMISSIVEASILLUMINATION: boolean;
  15234. LINKEMISSIVEWITHDIFFUSE: boolean;
  15235. REFLECTIONFRESNELFROMSPECULAR: boolean;
  15236. LIGHTMAP: boolean;
  15237. LIGHTMAPDIRECTUV: number;
  15238. OBJECTSPACE_NORMALMAP: boolean;
  15239. USELIGHTMAPASSHADOWMAP: boolean;
  15240. REFLECTIONMAP_3D: boolean;
  15241. REFLECTIONMAP_SPHERICAL: boolean;
  15242. REFLECTIONMAP_PLANAR: boolean;
  15243. REFLECTIONMAP_CUBIC: boolean;
  15244. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  15245. REFLECTIONMAP_PROJECTION: boolean;
  15246. REFLECTIONMAP_SKYBOX: boolean;
  15247. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  15248. REFLECTIONMAP_EXPLICIT: boolean;
  15249. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  15250. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  15251. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  15252. INVERTCUBICMAP: boolean;
  15253. LOGARITHMICDEPTH: boolean;
  15254. REFRACTION: boolean;
  15255. REFRACTIONMAP_3D: boolean;
  15256. REFLECTIONOVERALPHA: boolean;
  15257. TWOSIDEDLIGHTING: boolean;
  15258. SHADOWFLOAT: boolean;
  15259. MORPHTARGETS: boolean;
  15260. MORPHTARGETS_NORMAL: boolean;
  15261. MORPHTARGETS_TANGENT: boolean;
  15262. NUM_MORPH_INFLUENCERS: number;
  15263. NONUNIFORMSCALING: boolean;
  15264. PREMULTIPLYALPHA: boolean;
  15265. IMAGEPROCESSING: boolean;
  15266. VIGNETTE: boolean;
  15267. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15268. VIGNETTEBLENDMODEOPAQUE: boolean;
  15269. TONEMAPPING: boolean;
  15270. TONEMAPPING_ACES: boolean;
  15271. CONTRAST: boolean;
  15272. COLORCURVES: boolean;
  15273. COLORGRADING: boolean;
  15274. COLORGRADING3D: boolean;
  15275. SAMPLER3DGREENDEPTH: boolean;
  15276. SAMPLER3DBGRMAP: boolean;
  15277. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15278. /**
  15279. * If the reflection texture on this material is in linear color space
  15280. * @hidden
  15281. */
  15282. IS_REFLECTION_LINEAR: boolean;
  15283. /**
  15284. * If the refraction texture on this material is in linear color space
  15285. * @hidden
  15286. */
  15287. IS_REFRACTION_LINEAR: boolean;
  15288. EXPOSURE: boolean;
  15289. constructor();
  15290. setReflectionMode(modeToEnable: string): void;
  15291. }
  15292. class StandardMaterial extends PushMaterial {
  15293. private _diffuseTexture;
  15294. diffuseTexture: Nullable<BaseTexture>;
  15295. private _ambientTexture;
  15296. ambientTexture: Nullable<BaseTexture>;
  15297. private _opacityTexture;
  15298. opacityTexture: Nullable<BaseTexture>;
  15299. private _reflectionTexture;
  15300. reflectionTexture: Nullable<BaseTexture>;
  15301. private _emissiveTexture;
  15302. emissiveTexture: Nullable<BaseTexture>;
  15303. private _specularTexture;
  15304. specularTexture: Nullable<BaseTexture>;
  15305. private _bumpTexture;
  15306. bumpTexture: Nullable<BaseTexture>;
  15307. private _lightmapTexture;
  15308. lightmapTexture: Nullable<BaseTexture>;
  15309. private _refractionTexture;
  15310. refractionTexture: Nullable<BaseTexture>;
  15311. ambientColor: Color3;
  15312. diffuseColor: Color3;
  15313. specularColor: Color3;
  15314. emissiveColor: Color3;
  15315. specularPower: number;
  15316. private _useAlphaFromDiffuseTexture;
  15317. useAlphaFromDiffuseTexture: boolean;
  15318. private _useEmissiveAsIllumination;
  15319. useEmissiveAsIllumination: boolean;
  15320. private _linkEmissiveWithDiffuse;
  15321. linkEmissiveWithDiffuse: boolean;
  15322. private _useSpecularOverAlpha;
  15323. useSpecularOverAlpha: boolean;
  15324. private _useReflectionOverAlpha;
  15325. useReflectionOverAlpha: boolean;
  15326. private _disableLighting;
  15327. disableLighting: boolean;
  15328. private _useObjectSpaceNormalMap;
  15329. /**
  15330. * Allows using an object space normal map (instead of tangent space).
  15331. */
  15332. useObjectSpaceNormalMap: boolean;
  15333. private _useParallax;
  15334. useParallax: boolean;
  15335. private _useParallaxOcclusion;
  15336. useParallaxOcclusion: boolean;
  15337. parallaxScaleBias: number;
  15338. private _roughness;
  15339. roughness: number;
  15340. indexOfRefraction: number;
  15341. invertRefractionY: boolean;
  15342. /**
  15343. * Defines the alpha limits in alpha test mode
  15344. */
  15345. alphaCutOff: number;
  15346. private _useLightmapAsShadowmap;
  15347. useLightmapAsShadowmap: boolean;
  15348. private _diffuseFresnelParameters;
  15349. diffuseFresnelParameters: FresnelParameters;
  15350. private _opacityFresnelParameters;
  15351. opacityFresnelParameters: FresnelParameters;
  15352. private _reflectionFresnelParameters;
  15353. reflectionFresnelParameters: FresnelParameters;
  15354. private _refractionFresnelParameters;
  15355. refractionFresnelParameters: FresnelParameters;
  15356. private _emissiveFresnelParameters;
  15357. emissiveFresnelParameters: FresnelParameters;
  15358. private _useReflectionFresnelFromSpecular;
  15359. useReflectionFresnelFromSpecular: boolean;
  15360. private _useGlossinessFromSpecularMapAlpha;
  15361. useGlossinessFromSpecularMapAlpha: boolean;
  15362. private _maxSimultaneousLights;
  15363. maxSimultaneousLights: number;
  15364. /**
  15365. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15366. */
  15367. private _invertNormalMapX;
  15368. invertNormalMapX: boolean;
  15369. /**
  15370. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15371. */
  15372. private _invertNormalMapY;
  15373. invertNormalMapY: boolean;
  15374. /**
  15375. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15376. */
  15377. private _twoSidedLighting;
  15378. twoSidedLighting: boolean;
  15379. /**
  15380. * Default configuration related to image processing available in the standard Material.
  15381. */
  15382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15383. /**
  15384. * Gets the image processing configuration used either in this material.
  15385. */
  15386. /**
  15387. * Sets the Default image processing configuration used either in the this material.
  15388. *
  15389. * If sets to null, the scene one is in use.
  15390. */
  15391. imageProcessingConfiguration: ImageProcessingConfiguration;
  15392. /**
  15393. * Keep track of the image processing observer to allow dispose and replace.
  15394. */
  15395. private _imageProcessingObserver;
  15396. /**
  15397. * Attaches a new image processing configuration to the Standard Material.
  15398. * @param configuration
  15399. */
  15400. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15401. /**
  15402. * Gets wether the color curves effect is enabled.
  15403. */
  15404. /**
  15405. * Sets wether the color curves effect is enabled.
  15406. */
  15407. cameraColorCurvesEnabled: boolean;
  15408. /**
  15409. * Gets wether the color grading effect is enabled.
  15410. */
  15411. /**
  15412. * Gets wether the color grading effect is enabled.
  15413. */
  15414. cameraColorGradingEnabled: boolean;
  15415. /**
  15416. * Gets wether tonemapping is enabled or not.
  15417. */
  15418. /**
  15419. * Sets wether tonemapping is enabled or not
  15420. */
  15421. cameraToneMappingEnabled: boolean;
  15422. /**
  15423. * The camera exposure used on this material.
  15424. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15425. * This corresponds to a photographic exposure.
  15426. */
  15427. /**
  15428. * The camera exposure used on this material.
  15429. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15430. * This corresponds to a photographic exposure.
  15431. */
  15432. cameraExposure: number;
  15433. /**
  15434. * Gets The camera contrast used on this material.
  15435. */
  15436. /**
  15437. * Sets The camera contrast used on this material.
  15438. */
  15439. cameraContrast: number;
  15440. /**
  15441. * Gets the Color Grading 2D Lookup Texture.
  15442. */
  15443. /**
  15444. * Sets the Color Grading 2D Lookup Texture.
  15445. */
  15446. cameraColorGradingTexture: Nullable<BaseTexture>;
  15447. /**
  15448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15450. * 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;
  15451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15452. */
  15453. /**
  15454. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15455. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15456. * 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;
  15457. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15458. */
  15459. cameraColorCurves: Nullable<ColorCurves>;
  15460. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15461. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15462. protected _worldViewProjectionMatrix: Matrix;
  15463. protected _globalAmbientColor: Color3;
  15464. protected _useLogarithmicDepth: boolean;
  15465. constructor(name: string, scene: Scene);
  15466. getClassName(): string;
  15467. useLogarithmicDepth: boolean;
  15468. needAlphaBlending(): boolean;
  15469. needAlphaTesting(): boolean;
  15470. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15471. getAlphaTestTexture(): Nullable<BaseTexture>;
  15472. /**
  15473. * Child classes can use it to update shaders
  15474. */
  15475. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15476. buildUniformLayout(): void;
  15477. unbind(): void;
  15478. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15479. getAnimatables(): IAnimatable[];
  15480. getActiveTextures(): BaseTexture[];
  15481. hasTexture(texture: BaseTexture): boolean;
  15482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15483. clone(name: string): StandardMaterial;
  15484. serialize(): any;
  15485. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15486. static _DiffuseTextureEnabled: boolean;
  15487. static DiffuseTextureEnabled: boolean;
  15488. static _AmbientTextureEnabled: boolean;
  15489. static AmbientTextureEnabled: boolean;
  15490. static _OpacityTextureEnabled: boolean;
  15491. static OpacityTextureEnabled: boolean;
  15492. static _ReflectionTextureEnabled: boolean;
  15493. static ReflectionTextureEnabled: boolean;
  15494. static _EmissiveTextureEnabled: boolean;
  15495. static EmissiveTextureEnabled: boolean;
  15496. static _SpecularTextureEnabled: boolean;
  15497. static SpecularTextureEnabled: boolean;
  15498. static _BumpTextureEnabled: boolean;
  15499. static BumpTextureEnabled: boolean;
  15500. static _LightmapTextureEnabled: boolean;
  15501. static LightmapTextureEnabled: boolean;
  15502. static _RefractionTextureEnabled: boolean;
  15503. static RefractionTextureEnabled: boolean;
  15504. static _ColorGradingTextureEnabled: boolean;
  15505. static ColorGradingTextureEnabled: boolean;
  15506. static _FresnelEnabled: boolean;
  15507. static FresnelEnabled: boolean;
  15508. }
  15509. }
  15510. declare module BABYLON {
  15511. class UniformBuffer {
  15512. private _engine;
  15513. private _buffer;
  15514. private _data;
  15515. private _bufferData;
  15516. private _dynamic?;
  15517. private _uniformLocations;
  15518. private _uniformSizes;
  15519. private _uniformLocationPointer;
  15520. private _needSync;
  15521. private _noUBO;
  15522. private _currentEffect;
  15523. private static _MAX_UNIFORM_SIZE;
  15524. private static _tempBuffer;
  15525. /**
  15526. * Wrapper for updateUniform.
  15527. * @method updateMatrix3x3
  15528. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15529. * @param {Float32Array} matrix
  15530. */
  15531. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15532. /**
  15533. * Wrapper for updateUniform.
  15534. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15535. * @param {Float32Array} matrix
  15536. */
  15537. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15538. /**
  15539. * Wrapper for updateUniform.
  15540. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15541. * @param {number} x
  15542. */
  15543. updateFloat: (name: string, x: number) => void;
  15544. /**
  15545. * Wrapper for updateUniform.
  15546. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15547. * @param {number} x
  15548. * @param {number} y
  15549. * @param {string} [suffix] Suffix to add to the uniform name.
  15550. */
  15551. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15552. /**
  15553. * Wrapper for updateUniform.
  15554. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15555. * @param {number} x
  15556. * @param {number} y
  15557. * @param {number} z
  15558. * @param {string} [suffix] Suffix to add to the uniform name.
  15559. */
  15560. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15561. /**
  15562. * Wrapper for updateUniform.
  15563. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15564. * @param {number} x
  15565. * @param {number} y
  15566. * @param {number} z
  15567. * @param {number} w
  15568. * @param {string} [suffix] Suffix to add to the uniform name.
  15569. */
  15570. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15571. /**
  15572. * Wrapper for updateUniform.
  15573. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15574. * @param {Matrix} A 4x4 matrix.
  15575. */
  15576. updateMatrix: (name: string, mat: Matrix) => void;
  15577. /**
  15578. * Wrapper for updateUniform.
  15579. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15580. * @param {Vector3} vector
  15581. */
  15582. updateVector3: (name: string, vector: Vector3) => void;
  15583. /**
  15584. * Wrapper for updateUniform.
  15585. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15586. * @param {Vector4} vector
  15587. */
  15588. updateVector4: (name: string, vector: Vector4) => void;
  15589. /**
  15590. * Wrapper for updateUniform.
  15591. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15592. * @param {Color3} color
  15593. * @param {string} [suffix] Suffix to add to the uniform name.
  15594. */
  15595. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15596. /**
  15597. * Wrapper for updateUniform.
  15598. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15599. * @param {Color3} color
  15600. * @param {number} alpha
  15601. * @param {string} [suffix] Suffix to add to the uniform name.
  15602. */
  15603. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15604. /**
  15605. * Uniform buffer objects.
  15606. *
  15607. * Handles blocks of uniform on the GPU.
  15608. *
  15609. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15610. *
  15611. * For more information, please refer to :
  15612. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15613. */
  15614. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15615. /**
  15616. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15617. * or just falling back on setUniformXXX calls.
  15618. */
  15619. readonly useUbo: boolean;
  15620. /**
  15621. * Indicates if the WebGL underlying uniform buffer is in sync
  15622. * with the javascript cache data.
  15623. */
  15624. readonly isSync: boolean;
  15625. /**
  15626. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15627. * Also, a dynamic UniformBuffer will disable cache verification and always
  15628. * update the underlying WebGL uniform buffer to the GPU.
  15629. */
  15630. isDynamic(): boolean;
  15631. /**
  15632. * The data cache on JS side.
  15633. */
  15634. getData(): Float32Array;
  15635. /**
  15636. * The underlying WebGL Uniform buffer.
  15637. */
  15638. getBuffer(): Nullable<WebGLBuffer>;
  15639. /**
  15640. * std140 layout specifies how to align data within an UBO structure.
  15641. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15642. * for specs.
  15643. */
  15644. private _fillAlignment;
  15645. /**
  15646. * Adds an uniform in the buffer.
  15647. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15648. * for the layout to be correct !
  15649. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15650. * @param {number|number[]} size Data size, or data directly.
  15651. */
  15652. addUniform(name: string, size: number | number[]): void;
  15653. /**
  15654. * Wrapper for addUniform.
  15655. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15656. * @param {Matrix} mat A 4x4 matrix.
  15657. */
  15658. addMatrix(name: string, mat: Matrix): void;
  15659. /**
  15660. * Wrapper for addUniform.
  15661. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15662. * @param {number} x
  15663. * @param {number} y
  15664. */
  15665. addFloat2(name: string, x: number, y: number): void;
  15666. /**
  15667. * Wrapper for addUniform.
  15668. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15669. * @param {number} x
  15670. * @param {number} y
  15671. * @param {number} z
  15672. */
  15673. addFloat3(name: string, x: number, y: number, z: number): void;
  15674. /**
  15675. * Wrapper for addUniform.
  15676. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15677. * @param {Color3} color
  15678. */
  15679. addColor3(name: string, color: Color3): void;
  15680. /**
  15681. * Wrapper for addUniform.
  15682. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15683. * @param {Color3} color
  15684. * @param {number} alpha
  15685. */
  15686. addColor4(name: string, color: Color3, alpha: number): void;
  15687. /**
  15688. * Wrapper for addUniform.
  15689. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15690. * @param {Vector3} vector
  15691. */
  15692. addVector3(name: string, vector: Vector3): void;
  15693. /**
  15694. * Wrapper for addUniform.
  15695. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15696. */
  15697. addMatrix3x3(name: string): void;
  15698. /**
  15699. * Wrapper for addUniform.
  15700. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15701. */
  15702. addMatrix2x2(name: string): void;
  15703. /**
  15704. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15705. */
  15706. create(): void;
  15707. /** @hidden */
  15708. _rebuild(): void;
  15709. /**
  15710. * Updates the WebGL Uniform Buffer on the GPU.
  15711. * If the `dynamic` flag is set to true, no cache comparison is done.
  15712. * Otherwise, the buffer will be updated only if the cache differs.
  15713. */
  15714. update(): void;
  15715. /**
  15716. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15717. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15718. * @param {number[]|Float32Array} data Flattened data
  15719. * @param {number} size Size of the data.
  15720. */
  15721. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15722. private _updateMatrix3x3ForUniform;
  15723. private _updateMatrix3x3ForEffect;
  15724. private _updateMatrix2x2ForEffect;
  15725. private _updateMatrix2x2ForUniform;
  15726. private _updateFloatForEffect;
  15727. private _updateFloatForUniform;
  15728. private _updateFloat2ForEffect;
  15729. private _updateFloat2ForUniform;
  15730. private _updateFloat3ForEffect;
  15731. private _updateFloat3ForUniform;
  15732. private _updateFloat4ForEffect;
  15733. private _updateFloat4ForUniform;
  15734. private _updateMatrixForEffect;
  15735. private _updateMatrixForUniform;
  15736. private _updateVector3ForEffect;
  15737. private _updateVector3ForUniform;
  15738. private _updateVector4ForEffect;
  15739. private _updateVector4ForUniform;
  15740. private _updateColor3ForEffect;
  15741. private _updateColor3ForUniform;
  15742. private _updateColor4ForEffect;
  15743. private _updateColor4ForUniform;
  15744. /**
  15745. * Sets a sampler uniform on the effect.
  15746. * @param {string} name Name of the sampler.
  15747. * @param {Texture} texture
  15748. */
  15749. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15750. /**
  15751. * Directly updates the value of the uniform in the cache AND on the GPU.
  15752. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15753. * @param {number[]|Float32Array} data Flattened data
  15754. */
  15755. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15756. /**
  15757. * Binds this uniform buffer to an effect.
  15758. * @param {Effect} effect
  15759. * @param {string} name Name of the uniform block in the shader.
  15760. */
  15761. bindToEffect(effect: Effect, name: string): void;
  15762. /**
  15763. * Disposes the uniform buffer.
  15764. */
  15765. dispose(): void;
  15766. }
  15767. }
  15768. declare module BABYLON {
  15769. class Scalar {
  15770. /**
  15771. * Two pi constants convenient for computation.
  15772. */
  15773. static TwoPi: number;
  15774. /**
  15775. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15776. */
  15777. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15778. /**
  15779. * Returns a string : the upper case translation of the number i to hexadecimal.
  15780. */
  15781. static ToHex(i: number): string;
  15782. /**
  15783. * Returns -1 if value is negative and +1 is value is positive.
  15784. * Returns the value itself if it's equal to zero.
  15785. */
  15786. static Sign(value: number): number;
  15787. /**
  15788. * Returns the value itself if it's between min and max.
  15789. * Returns min if the value is lower than min.
  15790. * Returns max if the value is greater than max.
  15791. */
  15792. static Clamp(value: number, min?: number, max?: number): number;
  15793. /**
  15794. * Returns the log2 of value.
  15795. */
  15796. static Log2(value: number): number;
  15797. /**
  15798. * Loops the value, so that it is never larger than length and never smaller than 0.
  15799. *
  15800. * This is similar to the modulo operator but it works with floating point numbers.
  15801. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15802. * With t = 5 and length = 2.5, the result would be 0.0.
  15803. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15804. */
  15805. static Repeat(value: number, length: number): number;
  15806. /**
  15807. * Normalize the value between 0.0 and 1.0 using min and max values
  15808. */
  15809. static Normalize(value: number, min: number, max: number): number;
  15810. /**
  15811. * Denormalize the value from 0.0 and 1.0 using min and max values
  15812. */
  15813. static Denormalize(normalized: number, min: number, max: number): number;
  15814. /**
  15815. * Calculates the shortest difference between two given angles given in degrees.
  15816. */
  15817. static DeltaAngle(current: number, target: number): number;
  15818. /**
  15819. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15820. *
  15821. * The returned value will move back and forth between 0 and length
  15822. */
  15823. static PingPong(tx: number, length: number): number;
  15824. /**
  15825. * Interpolates between min and max with smoothing at the limits.
  15826. *
  15827. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15828. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15829. */
  15830. static SmoothStep(from: number, to: number, tx: number): number;
  15831. /**
  15832. * Moves a value current towards target.
  15833. *
  15834. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15835. * Negative values of maxDelta pushes the value away from target.
  15836. */
  15837. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15838. /**
  15839. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15840. *
  15841. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15842. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15843. */
  15844. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15845. /**
  15846. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15847. */
  15848. static Lerp(start: number, end: number, amount: number): number;
  15849. /**
  15850. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15851. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15852. */
  15853. static LerpAngle(start: number, end: number, amount: number): number;
  15854. /**
  15855. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15856. */
  15857. static InverseLerp(a: number, b: number, value: number): number;
  15858. /**
  15859. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15860. */
  15861. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15862. /**
  15863. * Returns a random float number between and min and max values
  15864. */
  15865. static RandomRange(min: number, max: number): number;
  15866. /**
  15867. * This function returns percentage of a number in a given range.
  15868. *
  15869. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15870. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15871. */
  15872. static RangeToPercent(number: number, min: number, max: number): number;
  15873. /**
  15874. * This function returns number that corresponds to the percentage in a given range.
  15875. *
  15876. * PercentToRange(0.34,0,100) will return 34.
  15877. */
  15878. static PercentToRange(percent: number, min: number, max: number): number;
  15879. /**
  15880. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15881. * @param angle The angle to normalize in radian.
  15882. * @return The converted angle.
  15883. */
  15884. static NormalizeRadians(angle: number): number;
  15885. }
  15886. }
  15887. declare module BABYLON {
  15888. const ToGammaSpace: number;
  15889. const ToLinearSpace = 2.2;
  15890. const Epsilon = 0.001;
  15891. /**
  15892. * Class used to hold a RBG color
  15893. */
  15894. class Color3 {
  15895. /**
  15896. * Defines the red component (between 0 and 1, default is 0)
  15897. */
  15898. r: number;
  15899. /**
  15900. * Defines the green component (between 0 and 1, default is 0)
  15901. */
  15902. g: number;
  15903. /**
  15904. * Defines the blue component (between 0 and 1, default is 0)
  15905. */
  15906. b: number;
  15907. /**
  15908. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15909. * @param r defines the red component (between 0 and 1, default is 0)
  15910. * @param g defines the green component (between 0 and 1, default is 0)
  15911. * @param b defines the blue component (between 0 and 1, default is 0)
  15912. */
  15913. constructor(
  15914. /**
  15915. * Defines the red component (between 0 and 1, default is 0)
  15916. */
  15917. r?: number,
  15918. /**
  15919. * Defines the green component (between 0 and 1, default is 0)
  15920. */
  15921. g?: number,
  15922. /**
  15923. * Defines the blue component (between 0 and 1, default is 0)
  15924. */
  15925. b?: number);
  15926. /**
  15927. * Creates a string with the Color3 current values
  15928. * @returns the string representation of the Color3 object
  15929. */
  15930. toString(): string;
  15931. /**
  15932. * Returns the string "Color3"
  15933. * @returns "Color3"
  15934. */
  15935. getClassName(): string;
  15936. /**
  15937. * Compute the Color3 hash code
  15938. * @returns an unique number that can be used to hash Color3 objects
  15939. */
  15940. getHashCode(): number;
  15941. /**
  15942. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15943. * @param array defines the array where to store the r,g,b components
  15944. * @param index defines an optional index in the target array to define where to start storing values
  15945. * @returns the current Color3 object
  15946. */
  15947. toArray(array: FloatArray, index?: number): Color3;
  15948. /**
  15949. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15950. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15951. * @returns a new {BABYLON.Color4} object
  15952. */
  15953. toColor4(alpha?: number): Color4;
  15954. /**
  15955. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15956. * @returns the new array
  15957. */
  15958. asArray(): number[];
  15959. /**
  15960. * Returns the luminance value
  15961. * @returns a float value
  15962. */
  15963. toLuminance(): number;
  15964. /**
  15965. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15966. * @param otherColor defines the second operand
  15967. * @returns the new Color3 object
  15968. */
  15969. multiply(otherColor: Color3): Color3;
  15970. /**
  15971. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15972. * @param otherColor defines the second operand
  15973. * @param result defines the Color3 object where to store the result
  15974. * @returns the current Color3
  15975. */
  15976. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15977. /**
  15978. * Determines equality between Color3 objects
  15979. * @param otherColor defines the second operand
  15980. * @returns true if the rgb values are equal to the given ones
  15981. */
  15982. equals(otherColor: Color3): boolean;
  15983. /**
  15984. * Determines equality between the current Color3 object and a set of r,b,g values
  15985. * @param r defines the red component to check
  15986. * @param g defines the green component to check
  15987. * @param b defines the blue component to check
  15988. * @returns true if the rgb values are equal to the given ones
  15989. */
  15990. equalsFloats(r: number, g: number, b: number): boolean;
  15991. /**
  15992. * Multiplies in place each rgb value by scale
  15993. * @param scale defines the scaling factor
  15994. * @returns the updated Color3
  15995. */
  15996. scale(scale: number): Color3;
  15997. /**
  15998. * Multiplies the rgb values by scale and stores the result into "result"
  15999. * @param scale defines the scaling factor
  16000. * @param result defines the Color3 object where to store the result
  16001. * @returns the unmodified current Color3
  16002. */
  16003. scaleToRef(scale: number, result: Color3): Color3;
  16004. /**
  16005. * Scale the current Color3 values by a factor and add the result to a given Color3
  16006. * @param scale defines the scale factor
  16007. * @param result defines color to store the result into
  16008. * @returns the unmodified current Color3
  16009. */
  16010. scaleAndAddToRef(scale: number, result: Color3): Color3;
  16011. /**
  16012. * Clamps the rgb values by the min and max values and stores the result into "result"
  16013. * @param min defines minimum clamping value (default is 0)
  16014. * @param max defines maximum clamping value (default is 1)
  16015. * @param result defines color to store the result into
  16016. * @returns the original Color3
  16017. */
  16018. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  16019. /**
  16020. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  16021. * @param otherColor defines the second operand
  16022. * @returns the new Color3
  16023. */
  16024. add(otherColor: Color3): Color3;
  16025. /**
  16026. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  16027. * @param otherColor defines the second operand
  16028. * @param result defines Color3 object to store the result into
  16029. * @returns the unmodified current Color3
  16030. */
  16031. addToRef(otherColor: Color3, result: Color3): Color3;
  16032. /**
  16033. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  16034. * @param otherColor defines the second operand
  16035. * @returns the new Color3
  16036. */
  16037. subtract(otherColor: Color3): Color3;
  16038. /**
  16039. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  16040. * @param otherColor defines the second operand
  16041. * @param result defines Color3 object to store the result into
  16042. * @returns the unmodified current Color3
  16043. */
  16044. subtractToRef(otherColor: Color3, result: Color3): Color3;
  16045. /**
  16046. * Copy the current object
  16047. * @returns a new Color3 copied the current one
  16048. */
  16049. clone(): Color3;
  16050. /**
  16051. * Copies the rgb values from the source in the current Color3
  16052. * @param source defines the source Color3 object
  16053. * @returns the updated Color3 object
  16054. */
  16055. copyFrom(source: Color3): Color3;
  16056. /**
  16057. * Updates the Color3 rgb values from the given floats
  16058. * @param r defines the red component to read from
  16059. * @param g defines the green component to read from
  16060. * @param b defines the blue component to read from
  16061. * @returns the current Color3 object
  16062. */
  16063. copyFromFloats(r: number, g: number, b: number): Color3;
  16064. /**
  16065. * Updates the Color3 rgb values from the given floats
  16066. * @param r defines the red component to read from
  16067. * @param g defines the green component to read from
  16068. * @param b defines the blue component to read from
  16069. * @returns the current Color3 object
  16070. */
  16071. set(r: number, g: number, b: number): Color3;
  16072. /**
  16073. * Compute the Color3 hexadecimal code as a string
  16074. * @returns a string containing the hexadecimal representation of the Color3 object
  16075. */
  16076. toHexString(): string;
  16077. /**
  16078. * Computes a new Color3 converted from the current one to linear space
  16079. * @returns a new Color3 object
  16080. */
  16081. toLinearSpace(): Color3;
  16082. /**
  16083. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  16084. * @param convertedColor defines the Color3 object where to store the linear space version
  16085. * @returns the unmodified Color3
  16086. */
  16087. toLinearSpaceToRef(convertedColor: Color3): Color3;
  16088. /**
  16089. * Computes a new Color3 converted from the current one to gamma space
  16090. * @returns a new Color3 object
  16091. */
  16092. toGammaSpace(): Color3;
  16093. /**
  16094. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  16095. * @param convertedColor defines the Color3 object where to store the gamma space version
  16096. * @returns the unmodified Color3
  16097. */
  16098. toGammaSpaceToRef(convertedColor: Color3): Color3;
  16099. /**
  16100. * Creates a new Color3 from the string containing valid hexadecimal values
  16101. * @param hex defines a string containing valid hexadecimal values
  16102. * @returns a new Color3 object
  16103. */
  16104. static FromHexString(hex: string): Color3;
  16105. /**
  16106. * Creates a new Vector3 from the starting index of the given array
  16107. * @param array defines the source array
  16108. * @param offset defines an offset in the source array
  16109. * @returns a new Color3 object
  16110. */
  16111. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  16112. /**
  16113. * Creates a new Color3 from integer values (< 256)
  16114. * @param r defines the red component to read from (value between 0 and 255)
  16115. * @param g defines the green component to read from (value between 0 and 255)
  16116. * @param b defines the blue component to read from (value between 0 and 255)
  16117. * @returns a new Color3 object
  16118. */
  16119. static FromInts(r: number, g: number, b: number): Color3;
  16120. /**
  16121. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  16122. * @param start defines the start Color3 value
  16123. * @param end defines the end Color3 value
  16124. * @param amount defines the gradient value between start and end
  16125. * @returns a new Color3 object
  16126. */
  16127. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  16128. /**
  16129. * Returns a Color3 value containing a red color
  16130. * @returns a new Color3 object
  16131. */
  16132. static Red(): Color3;
  16133. /**
  16134. * Returns a Color3 value containing a green color
  16135. * @returns a new Color3 object
  16136. */
  16137. static Green(): Color3;
  16138. /**
  16139. * Returns a Color3 value containing a blue color
  16140. * @returns a new Color3 object
  16141. */
  16142. static Blue(): Color3;
  16143. /**
  16144. * Returns a Color3 value containing a black color
  16145. * @returns a new Color3 object
  16146. */
  16147. static Black(): Color3;
  16148. /**
  16149. * Returns a Color3 value containing a white color
  16150. * @returns a new Color3 object
  16151. */
  16152. static White(): Color3;
  16153. /**
  16154. * Returns a Color3 value containing a purple color
  16155. * @returns a new Color3 object
  16156. */
  16157. static Purple(): Color3;
  16158. /**
  16159. * Returns a Color3 value containing a magenta color
  16160. * @returns a new Color3 object
  16161. */
  16162. static Magenta(): Color3;
  16163. /**
  16164. * Returns a Color3 value containing a yellow color
  16165. * @returns a new Color3 object
  16166. */
  16167. static Yellow(): Color3;
  16168. /**
  16169. * Returns a Color3 value containing a gray color
  16170. * @returns a new Color3 object
  16171. */
  16172. static Gray(): Color3;
  16173. /**
  16174. * Returns a Color3 value containing a teal color
  16175. * @returns a new Color3 object
  16176. */
  16177. static Teal(): Color3;
  16178. /**
  16179. * Returns a Color3 value containing a random color
  16180. * @returns a new Color3 object
  16181. */
  16182. static Random(): Color3;
  16183. }
  16184. /**
  16185. * Class used to hold a RBGA color
  16186. */
  16187. class Color4 {
  16188. /**
  16189. * Defines the red component (between 0 and 1, default is 0)
  16190. */
  16191. r: number;
  16192. /**
  16193. * Defines the green component (between 0 and 1, default is 0)
  16194. */
  16195. g: number;
  16196. /**
  16197. * Defines the blue component (between 0 and 1, default is 0)
  16198. */
  16199. b: number;
  16200. /**
  16201. * Defines the alpha component (between 0 and 1, default is 1)
  16202. */
  16203. a: number;
  16204. /**
  16205. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  16206. * @param r defines the red component (between 0 and 1, default is 0)
  16207. * @param g defines the green component (between 0 and 1, default is 0)
  16208. * @param b defines the blue component (between 0 and 1, default is 0)
  16209. * @param a defines the alpha component (between 0 and 1, default is 1)
  16210. */
  16211. constructor(
  16212. /**
  16213. * Defines the red component (between 0 and 1, default is 0)
  16214. */
  16215. r?: number,
  16216. /**
  16217. * Defines the green component (between 0 and 1, default is 0)
  16218. */
  16219. g?: number,
  16220. /**
  16221. * Defines the blue component (between 0 and 1, default is 0)
  16222. */
  16223. b?: number,
  16224. /**
  16225. * Defines the alpha component (between 0 and 1, default is 1)
  16226. */
  16227. a?: number);
  16228. /**
  16229. * Adds in place the given Color4 values to the current Color4 object
  16230. * @param right defines the second operand
  16231. * @returns the current updated Color4 object
  16232. */
  16233. addInPlace(right: Color4): Color4;
  16234. /**
  16235. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  16236. * @returns the new array
  16237. */
  16238. asArray(): number[];
  16239. /**
  16240. * Stores from the starting index in the given array the Color4 successive values
  16241. * @param array defines the array where to store the r,g,b components
  16242. * @param index defines an optional index in the target array to define where to start storing values
  16243. * @returns the current Color4 object
  16244. */
  16245. toArray(array: number[], index?: number): Color4;
  16246. /**
  16247. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  16248. * @param right defines the second operand
  16249. * @returns a new Color4 object
  16250. */
  16251. add(right: Color4): Color4;
  16252. /**
  16253. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  16254. * @param right defines the second operand
  16255. * @returns a new Color4 object
  16256. */
  16257. subtract(right: Color4): Color4;
  16258. /**
  16259. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  16260. * @param right defines the second operand
  16261. * @param result defines the Color4 object where to store the result
  16262. * @returns the current Color4 object
  16263. */
  16264. subtractToRef(right: Color4, result: Color4): Color4;
  16265. /**
  16266. * Creates a new Color4 with the current Color4 values multiplied by scale
  16267. * @param scale defines the scaling factor to apply
  16268. * @returns a new Color4 object
  16269. */
  16270. scale(scale: number): Color4;
  16271. /**
  16272. * Multiplies the current Color4 values by scale and stores the result in "result"
  16273. * @param scale defines the scaling factor to apply
  16274. * @param result defines the Color4 object where to store the result
  16275. * @returns the current unmodified Color4
  16276. */
  16277. scaleToRef(scale: number, result: Color4): Color4;
  16278. /**
  16279. * Scale the current Color4 values by a factor and add the result to a given Color4
  16280. * @param scale defines the scale factor
  16281. * @param result defines the Color4 object where to store the result
  16282. * @returns the unmodified current Color4
  16283. */
  16284. scaleAndAddToRef(scale: number, result: Color4): Color4;
  16285. /**
  16286. * Clamps the rgb values by the min and max values and stores the result into "result"
  16287. * @param min defines minimum clamping value (default is 0)
  16288. * @param max defines maximum clamping value (default is 1)
  16289. * @param result defines color to store the result into.
  16290. * @returns the cuurent Color4
  16291. */
  16292. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  16293. /**
  16294. * Multipy an Color4 value by another and return a new Color4 object
  16295. * @param color defines the Color4 value to multiply by
  16296. * @returns a new Color4 object
  16297. */
  16298. multiply(color: Color4): Color4;
  16299. /**
  16300. * Multipy a Color4 value by another and push the result in a reference value
  16301. * @param color defines the Color4 value to multiply by
  16302. * @param result defines the Color4 to fill the result in
  16303. * @returns the result Color4
  16304. */
  16305. multiplyToRef(color: Color4, result: Color4): Color4;
  16306. /**
  16307. * Creates a string with the Color4 current values
  16308. * @returns the string representation of the Color4 object
  16309. */
  16310. toString(): string;
  16311. /**
  16312. * Returns the string "Color4"
  16313. * @returns "Color4"
  16314. */
  16315. getClassName(): string;
  16316. /**
  16317. * Compute the Color4 hash code
  16318. * @returns an unique number that can be used to hash Color4 objects
  16319. */
  16320. getHashCode(): number;
  16321. /**
  16322. * Creates a new Color4 copied from the current one
  16323. * @returns a new Color4 object
  16324. */
  16325. clone(): Color4;
  16326. /**
  16327. * Copies the given Color4 values into the current one
  16328. * @param source defines the source Color4 object
  16329. * @returns the current updated Color4 object
  16330. */
  16331. copyFrom(source: Color4): Color4;
  16332. /**
  16333. * Copies the given float values into the current one
  16334. * @param r defines the red component to read from
  16335. * @param g defines the green component to read from
  16336. * @param b defines the blue component to read from
  16337. * @param a defines the alpha component to read from
  16338. * @returns the current updated Color4 object
  16339. */
  16340. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  16341. /**
  16342. * Copies the given float values into the current one
  16343. * @param r defines the red component to read from
  16344. * @param g defines the green component to read from
  16345. * @param b defines the blue component to read from
  16346. * @param a defines the alpha component to read from
  16347. * @returns the current updated Color4 object
  16348. */
  16349. set(r: number, g: number, b: number, a: number): Color4;
  16350. /**
  16351. * Compute the Color4 hexadecimal code as a string
  16352. * @returns a string containing the hexadecimal representation of the Color4 object
  16353. */
  16354. toHexString(): string;
  16355. /**
  16356. * Computes a new Color4 converted from the current one to linear space
  16357. * @returns a new Color4 object
  16358. */
  16359. toLinearSpace(): Color4;
  16360. /**
  16361. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  16362. * @param convertedColor defines the Color4 object where to store the linear space version
  16363. * @returns the unmodified Color4
  16364. */
  16365. toLinearSpaceToRef(convertedColor: Color4): Color4;
  16366. /**
  16367. * Computes a new Color4 converted from the current one to gamma space
  16368. * @returns a new Color4 object
  16369. */
  16370. toGammaSpace(): Color4;
  16371. /**
  16372. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  16373. * @param convertedColor defines the Color4 object where to store the gamma space version
  16374. * @returns the unmodified Color4
  16375. */
  16376. toGammaSpaceToRef(convertedColor: Color4): Color4;
  16377. /**
  16378. * Creates a new Color4 from the string containing valid hexadecimal values
  16379. * @param hex defines a string containing valid hexadecimal values
  16380. * @returns a new Color4 object
  16381. */
  16382. static FromHexString(hex: string): Color4;
  16383. /**
  16384. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16385. * @param left defines the start value
  16386. * @param right defines the end value
  16387. * @param amount defines the gradient factor
  16388. * @returns a new Color4 object
  16389. */
  16390. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  16391. /**
  16392. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16393. * @param left defines the start value
  16394. * @param right defines the end value
  16395. * @param amount defines the gradient factor
  16396. * @param result defines the Color4 object where to store data
  16397. */
  16398. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  16399. /**
  16400. * Creates a new Color4 from the starting index element of the given array
  16401. * @param array defines the source array to read from
  16402. * @param offset defines the offset in the source array
  16403. * @returns a new Color4 object
  16404. */
  16405. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  16406. /**
  16407. * Creates a new Color3 from integer values (< 256)
  16408. * @param r defines the red component to read from (value between 0 and 255)
  16409. * @param g defines the green component to read from (value between 0 and 255)
  16410. * @param b defines the blue component to read from (value between 0 and 255)
  16411. * @param a defines the alpha component to read from (value between 0 and 255)
  16412. * @returns a new Color3 object
  16413. */
  16414. static FromInts(r: number, g: number, b: number, a: number): Color4;
  16415. /**
  16416. * Check the content of a given array and convert it to an array containing RGBA data
  16417. * If the original array was already containing count * 4 values then it is returned directly
  16418. * @param colors defines the array to check
  16419. * @param count defines the number of RGBA data to expect
  16420. * @returns an array containing count * 4 values (RGBA)
  16421. */
  16422. static CheckColors4(colors: number[], count: number): number[];
  16423. }
  16424. /**
  16425. * Class representing a vector containing 2 coordinates
  16426. */
  16427. class Vector2 {
  16428. /** defines the first coordinate */
  16429. x: number;
  16430. /** defines the second coordinate */
  16431. y: number;
  16432. /**
  16433. * Creates a new Vector2 from the given x and y coordinates
  16434. * @param x defines the first coordinate
  16435. * @param y defines the second coordinate
  16436. */
  16437. constructor(
  16438. /** defines the first coordinate */
  16439. x?: number,
  16440. /** defines the second coordinate */
  16441. y?: number);
  16442. /**
  16443. * Gets a string with the Vector2 coordinates
  16444. * @returns a string with the Vector2 coordinates
  16445. */
  16446. toString(): string;
  16447. /**
  16448. * Gets class name
  16449. * @returns the string "Vector2"
  16450. */
  16451. getClassName(): string;
  16452. /**
  16453. * Gets current vector hash code
  16454. * @returns the Vector2 hash code as a number
  16455. */
  16456. getHashCode(): number;
  16457. /**
  16458. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  16459. * @param array defines the source array
  16460. * @param index defines the offset in source array
  16461. * @returns the current Vector2
  16462. */
  16463. toArray(array: FloatArray, index?: number): Vector2;
  16464. /**
  16465. * Copy the current vector to an array
  16466. * @returns a new array with 2 elements: the Vector2 coordinates.
  16467. */
  16468. asArray(): number[];
  16469. /**
  16470. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16471. * @param source defines the source Vector2
  16472. * @returns the current updated Vector2
  16473. */
  16474. copyFrom(source: Vector2): Vector2;
  16475. /**
  16476. * Sets the Vector2 coordinates with the given floats
  16477. * @param x defines the first coordinate
  16478. * @param y defines the second coordinate
  16479. * @returns the current updated Vector2
  16480. */
  16481. copyFromFloats(x: number, y: number): Vector2;
  16482. /**
  16483. * Sets the Vector2 coordinates with the given floats
  16484. * @param x defines the first coordinate
  16485. * @param y defines the second coordinate
  16486. * @returns the current updated Vector2
  16487. */
  16488. set(x: number, y: number): Vector2;
  16489. /**
  16490. * Add another vector with the current one
  16491. * @param otherVector defines the other vector
  16492. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16493. */
  16494. add(otherVector: Vector2): Vector2;
  16495. /**
  16496. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16497. * @param otherVector defines the other vector
  16498. * @param result defines the target vector
  16499. * @returns the unmodified current Vector2
  16500. */
  16501. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16502. /**
  16503. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16504. * @param otherVector defines the other vector
  16505. * @returns the current updated Vector2
  16506. */
  16507. addInPlace(otherVector: Vector2): Vector2;
  16508. /**
  16509. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16510. * @param otherVector defines the other vector
  16511. * @returns a new Vector2
  16512. */
  16513. addVector3(otherVector: Vector3): Vector2;
  16514. /**
  16515. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16516. * @param otherVector defines the other vector
  16517. * @returns a new Vector2
  16518. */
  16519. subtract(otherVector: Vector2): Vector2;
  16520. /**
  16521. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16522. * @param otherVector defines the other vector
  16523. * @param result defines the target vector
  16524. * @returns the unmodified current Vector2
  16525. */
  16526. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16527. /**
  16528. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16529. * @param otherVector defines the other vector
  16530. * @returns the current updated Vector2
  16531. */
  16532. subtractInPlace(otherVector: Vector2): Vector2;
  16533. /**
  16534. * Multiplies in place the current Vector2 coordinates by the given ones
  16535. * @param otherVector defines the other vector
  16536. * @returns the current updated Vector2
  16537. */
  16538. multiplyInPlace(otherVector: Vector2): Vector2;
  16539. /**
  16540. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16541. * @param otherVector defines the other vector
  16542. * @returns a new Vector2
  16543. */
  16544. multiply(otherVector: Vector2): Vector2;
  16545. /**
  16546. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16547. * @param otherVector defines the other vector
  16548. * @param result defines the target vector
  16549. * @returns the unmodified current Vector2
  16550. */
  16551. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16552. /**
  16553. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16554. * @param x defines the first coordinate
  16555. * @param y defines the second coordinate
  16556. * @returns a new Vector2
  16557. */
  16558. multiplyByFloats(x: number, y: number): Vector2;
  16559. /**
  16560. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16561. * @param otherVector defines the other vector
  16562. * @returns a new Vector2
  16563. */
  16564. divide(otherVector: Vector2): Vector2;
  16565. /**
  16566. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16567. * @param otherVector defines the other vector
  16568. * @param result defines the target vector
  16569. * @returns the unmodified current Vector2
  16570. */
  16571. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16572. /**
  16573. * Divides the current Vector2 coordinates by the given ones
  16574. * @param otherVector defines the other vector
  16575. * @returns the current updated Vector2
  16576. */
  16577. divideInPlace(otherVector: Vector2): Vector2;
  16578. /**
  16579. * Gets a new Vector2 with current Vector2 negated coordinates
  16580. * @returns a new Vector2
  16581. */
  16582. negate(): Vector2;
  16583. /**
  16584. * Multiply the Vector2 coordinates by scale
  16585. * @param scale defines the scaling factor
  16586. * @returns the current updated Vector2
  16587. */
  16588. scaleInPlace(scale: number): Vector2;
  16589. /**
  16590. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16591. * @param scale defines the scaling factor
  16592. * @returns a new Vector2
  16593. */
  16594. scale(scale: number): Vector2;
  16595. /**
  16596. * Scale the current Vector2 values by a factor to a given Vector2
  16597. * @param scale defines the scale factor
  16598. * @param result defines the Vector2 object where to store the result
  16599. * @returns the unmodified current Vector2
  16600. */
  16601. scaleToRef(scale: number, result: Vector2): Vector2;
  16602. /**
  16603. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16604. * @param scale defines the scale factor
  16605. * @param result defines the Vector2 object where to store the result
  16606. * @returns the unmodified current Vector2
  16607. */
  16608. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16609. /**
  16610. * Gets a boolean if two vectors are equals
  16611. * @param otherVector defines the other vector
  16612. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16613. */
  16614. equals(otherVector: Vector2): boolean;
  16615. /**
  16616. * Gets a boolean if two vectors are equals (using an epsilon value)
  16617. * @param otherVector defines the other vector
  16618. * @param epsilon defines the minimal distance to consider equality
  16619. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16620. */
  16621. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16622. /**
  16623. * Gets a new Vector2 from current Vector2 floored values
  16624. * @returns a new Vector2
  16625. */
  16626. floor(): Vector2;
  16627. /**
  16628. * Gets a new Vector2 from current Vector2 floored values
  16629. * @returns a new Vector2
  16630. */
  16631. fract(): Vector2;
  16632. /**
  16633. * Gets the length of the vector
  16634. * @returns the vector length (float)
  16635. */
  16636. length(): number;
  16637. /**
  16638. * Gets the vector squared length
  16639. * @returns the vector squared length (float)
  16640. */
  16641. lengthSquared(): number;
  16642. /**
  16643. * Normalize the vector
  16644. * @returns the current updated Vector2
  16645. */
  16646. normalize(): Vector2;
  16647. /**
  16648. * Gets a new Vector2 copied from the Vector2
  16649. * @returns a new Vector2
  16650. */
  16651. clone(): Vector2;
  16652. /**
  16653. * Gets a new Vector2(0, 0)
  16654. * @returns a new Vector2
  16655. */
  16656. static Zero(): Vector2;
  16657. /**
  16658. * Gets a new Vector2(1, 1)
  16659. * @returns a new Vector2
  16660. */
  16661. static One(): Vector2;
  16662. /**
  16663. * Gets a new Vector2 set from the given index element of the given array
  16664. * @param array defines the data source
  16665. * @param offset defines the offset in the data source
  16666. * @returns a new Vector2
  16667. */
  16668. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16669. /**
  16670. * Sets "result" from the given index element of the given array
  16671. * @param array defines the data source
  16672. * @param offset defines the offset in the data source
  16673. * @param result defines the target vector
  16674. */
  16675. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16676. /**
  16677. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16678. * @param value1 defines 1st point of control
  16679. * @param value2 defines 2nd point of control
  16680. * @param value3 defines 3rd point of control
  16681. * @param value4 defines 4th point of control
  16682. * @param amount defines the interpolation factor
  16683. * @returns a new Vector2
  16684. */
  16685. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16686. /**
  16687. * 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".
  16688. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16689. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16690. * @param value defines the value to clamp
  16691. * @param min defines the lower limit
  16692. * @param max defines the upper limit
  16693. * @returns a new Vector2
  16694. */
  16695. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16696. /**
  16697. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16698. * @param value1 defines the 1st control point
  16699. * @param tangent1 defines the outgoing tangent
  16700. * @param value2 defines the 2nd control point
  16701. * @param tangent2 defines the incoming tangent
  16702. * @param amount defines the interpolation factor
  16703. * @returns a new Vector2
  16704. */
  16705. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16706. /**
  16707. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16708. * @param start defines the start vector
  16709. * @param end defines the end vector
  16710. * @param amount defines the interpolation factor
  16711. * @returns a new Vector2
  16712. */
  16713. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16714. /**
  16715. * Gets the dot product of the vector "left" and the vector "right"
  16716. * @param left defines first vector
  16717. * @param right defines second vector
  16718. * @returns the dot product (float)
  16719. */
  16720. static Dot(left: Vector2, right: Vector2): number;
  16721. /**
  16722. * Returns a new Vector2 equal to the normalized given vector
  16723. * @param vector defines the vector to normalize
  16724. * @returns a new Vector2
  16725. */
  16726. static Normalize(vector: Vector2): Vector2;
  16727. /**
  16728. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16729. * @param left defines 1st vector
  16730. * @param right defines 2nd vector
  16731. * @returns a new Vector2
  16732. */
  16733. static Minimize(left: Vector2, right: Vector2): Vector2;
  16734. /**
  16735. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16736. * @param left defines 1st vector
  16737. * @param right defines 2nd vector
  16738. * @returns a new Vector2
  16739. */
  16740. static Maximize(left: Vector2, right: Vector2): Vector2;
  16741. /**
  16742. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16743. * @param vector defines the vector to transform
  16744. * @param transformation defines the matrix to apply
  16745. * @returns a new Vector2
  16746. */
  16747. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16748. /**
  16749. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16750. * @param vector defines the vector to transform
  16751. * @param transformation defines the matrix to apply
  16752. * @param result defines the target vector
  16753. */
  16754. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16755. /**
  16756. * Determines if a given vector is included in a triangle
  16757. * @param p defines the vector to test
  16758. * @param p0 defines 1st triangle point
  16759. * @param p1 defines 2nd triangle point
  16760. * @param p2 defines 3rd triangle point
  16761. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16762. */
  16763. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16764. /**
  16765. * Gets the distance between the vectors "value1" and "value2"
  16766. * @param value1 defines first vector
  16767. * @param value2 defines second vector
  16768. * @returns the distance between vectors
  16769. */
  16770. static Distance(value1: Vector2, value2: Vector2): number;
  16771. /**
  16772. * Returns the squared distance between the vectors "value1" and "value2"
  16773. * @param value1 defines first vector
  16774. * @param value2 defines second vector
  16775. * @returns the squared distance between vectors
  16776. */
  16777. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16778. /**
  16779. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16780. * @param value1 defines first vector
  16781. * @param value2 defines second vector
  16782. * @returns a new Vector2
  16783. */
  16784. static Center(value1: Vector2, value2: Vector2): Vector2;
  16785. /**
  16786. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16787. * @param p defines the middle point
  16788. * @param segA defines one point of the segment
  16789. * @param segB defines the other point of the segment
  16790. * @returns the shortest distance
  16791. */
  16792. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16793. }
  16794. /**
  16795. * Classed used to store (x,y,z) vector representation
  16796. * A Vector3 is the main object used in 3D geometry
  16797. * It can represent etiher the coordinates of a point the space, either a direction
  16798. * Reminder: Babylon.js uses a left handed forward facing system
  16799. */
  16800. class Vector3 {
  16801. /**
  16802. * Defines the first coordinates (on X axis)
  16803. */
  16804. x: number;
  16805. /**
  16806. * Defines the second coordinates (on Y axis)
  16807. */
  16808. y: number;
  16809. /**
  16810. * Defines the third coordinates (on Z axis)
  16811. */
  16812. z: number;
  16813. /**
  16814. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16815. * @param x defines the first coordinates (on X axis)
  16816. * @param y defines the second coordinates (on Y axis)
  16817. * @param z defines the third coordinates (on Z axis)
  16818. */
  16819. constructor(
  16820. /**
  16821. * Defines the first coordinates (on X axis)
  16822. */
  16823. x?: number,
  16824. /**
  16825. * Defines the second coordinates (on Y axis)
  16826. */
  16827. y?: number,
  16828. /**
  16829. * Defines the third coordinates (on Z axis)
  16830. */
  16831. z?: number);
  16832. /**
  16833. * Creates a string representation of the Vector3
  16834. * @returns a string with the Vector3 coordinates.
  16835. */
  16836. toString(): string;
  16837. /**
  16838. * Gets the class name
  16839. * @returns the string "Vector3"
  16840. */
  16841. getClassName(): string;
  16842. /**
  16843. * Creates the Vector3 hash code
  16844. * @returns a number which tends to be unique between Vector3 instances
  16845. */
  16846. getHashCode(): number;
  16847. /**
  16848. * Creates an array containing three elements : the coordinates of the Vector3
  16849. * @returns a new array of numbers
  16850. */
  16851. asArray(): number[];
  16852. /**
  16853. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16854. * @param array defines the destination array
  16855. * @param index defines the offset in the destination array
  16856. * @returns the current Vector3
  16857. */
  16858. toArray(array: FloatArray, index?: number): Vector3;
  16859. /**
  16860. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16861. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16862. */
  16863. toQuaternion(): Quaternion;
  16864. /**
  16865. * Adds the given vector to the current Vector3
  16866. * @param otherVector defines the second operand
  16867. * @returns the current updated Vector3
  16868. */
  16869. addInPlace(otherVector: Vector3): Vector3;
  16870. /**
  16871. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16872. * @param otherVector defines the second operand
  16873. * @returns the resulting Vector3
  16874. */
  16875. add(otherVector: Vector3): Vector3;
  16876. /**
  16877. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16878. * @param otherVector defines the second operand
  16879. * @param result defines the Vector3 object where to store the result
  16880. * @returns the current Vector3
  16881. */
  16882. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16883. /**
  16884. * Subtract the given vector from the current Vector3
  16885. * @param otherVector defines the second operand
  16886. * @returns the current updated Vector3
  16887. */
  16888. subtractInPlace(otherVector: Vector3): Vector3;
  16889. /**
  16890. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16891. * @param otherVector defines the second operand
  16892. * @returns the resulting Vector3
  16893. */
  16894. subtract(otherVector: Vector3): Vector3;
  16895. /**
  16896. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16897. * @param otherVector defines the second operand
  16898. * @param result defines the Vector3 object where to store the result
  16899. * @returns the current Vector3
  16900. */
  16901. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16902. /**
  16903. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16904. * @param x defines the x coordinate of the operand
  16905. * @param y defines the y coordinate of the operand
  16906. * @param z defines the z coordinate of the operand
  16907. * @returns the resulting Vector3
  16908. */
  16909. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16910. /**
  16911. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16912. * @param x defines the x coordinate of the operand
  16913. * @param y defines the y coordinate of the operand
  16914. * @param z defines the z coordinate of the operand
  16915. * @param result defines the Vector3 object where to store the result
  16916. * @returns the current Vector3
  16917. */
  16918. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16919. /**
  16920. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16921. * @returns a new Vector3
  16922. */
  16923. negate(): Vector3;
  16924. /**
  16925. * Multiplies the Vector3 coordinates by the float "scale"
  16926. * @param scale defines the multiplier factor
  16927. * @returns the current updated Vector3
  16928. */
  16929. scaleInPlace(scale: number): Vector3;
  16930. /**
  16931. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16932. * @param scale defines the multiplier factor
  16933. * @returns a new Vector3
  16934. */
  16935. scale(scale: number): Vector3;
  16936. /**
  16937. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16938. * @param scale defines the multiplier factor
  16939. * @param result defines the Vector3 object where to store the result
  16940. * @returns the current Vector3
  16941. */
  16942. scaleToRef(scale: number, result: Vector3): Vector3;
  16943. /**
  16944. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16945. * @param scale defines the scale factor
  16946. * @param result defines the Vector3 object where to store the result
  16947. * @returns the unmodified current Vector3
  16948. */
  16949. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16950. /**
  16951. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16952. * @param otherVector defines the second operand
  16953. * @returns true if both vectors are equals
  16954. */
  16955. equals(otherVector: Vector3): boolean;
  16956. /**
  16957. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16958. * @param otherVector defines the second operand
  16959. * @param epsilon defines the minimal distance to define values as equals
  16960. * @returns true if both vectors are distant less than epsilon
  16961. */
  16962. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16963. /**
  16964. * Returns true if the current Vector3 coordinates equals the given floats
  16965. * @param x defines the x coordinate of the operand
  16966. * @param y defines the y coordinate of the operand
  16967. * @param z defines the z coordinate of the operand
  16968. * @returns true if both vectors are equals
  16969. */
  16970. equalsToFloats(x: number, y: number, z: number): boolean;
  16971. /**
  16972. * Multiplies the current Vector3 coordinates by the given ones
  16973. * @param otherVector defines the second operand
  16974. * @returns the current updated Vector3
  16975. */
  16976. multiplyInPlace(otherVector: Vector3): Vector3;
  16977. /**
  16978. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16979. * @param otherVector defines the second operand
  16980. * @returns the new Vector3
  16981. */
  16982. multiply(otherVector: Vector3): Vector3;
  16983. /**
  16984. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16985. * @param otherVector defines the second operand
  16986. * @param result defines the Vector3 object where to store the result
  16987. * @returns the current Vector3
  16988. */
  16989. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16990. /**
  16991. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16992. * @param x defines the x coordinate of the operand
  16993. * @param y defines the y coordinate of the operand
  16994. * @param z defines the z coordinate of the operand
  16995. * @returns the new Vector3
  16996. */
  16997. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16998. /**
  16999. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  17000. * @param otherVector defines the second operand
  17001. * @returns the new Vector3
  17002. */
  17003. divide(otherVector: Vector3): Vector3;
  17004. /**
  17005. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  17006. * @param otherVector defines the second operand
  17007. * @param result defines the Vector3 object where to store the result
  17008. * @returns the current Vector3
  17009. */
  17010. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  17011. /**
  17012. * Divides the current Vector3 coordinates by the given ones.
  17013. * @param otherVector defines the second operand
  17014. * @returns the current updated Vector3
  17015. */
  17016. divideInPlace(otherVector: Vector3): Vector3;
  17017. /**
  17018. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  17019. * @param other defines the second operand
  17020. * @returns the current updated Vector3
  17021. */
  17022. minimizeInPlace(other: Vector3): Vector3;
  17023. /**
  17024. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  17025. * @param other defines the second operand
  17026. * @returns the current updated Vector3
  17027. */
  17028. maximizeInPlace(other: Vector3): Vector3;
  17029. /**
  17030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  17031. */
  17032. readonly isNonUniform: boolean;
  17033. /**
  17034. * Gets a new Vector3 from current Vector3 floored values
  17035. * @returns a new Vector3
  17036. */
  17037. floor(): Vector3;
  17038. /**
  17039. * Gets a new Vector3 from current Vector3 floored values
  17040. * @returns a new Vector3
  17041. */
  17042. fract(): Vector3;
  17043. /**
  17044. * Gets the length of the Vector3
  17045. * @returns the length of the Vecto3
  17046. */
  17047. length(): number;
  17048. /**
  17049. * Gets the squared length of the Vector3
  17050. * @returns squared length of the Vector3
  17051. */
  17052. lengthSquared(): number;
  17053. /**
  17054. * Normalize the current Vector3.
  17055. * Please note that this is an in place operation.
  17056. * @returns the current updated Vector3
  17057. */
  17058. normalize(): Vector3;
  17059. /**
  17060. * Normalize the current Vector3 to a new vector
  17061. * @returns the new Vector3
  17062. */
  17063. normalizeToNew(): Vector3;
  17064. /**
  17065. * Normalize the current Vector3 to the reference
  17066. * @param reference define the Vector3 to update
  17067. * @returns the updated Vector3
  17068. */
  17069. normalizeToRef(reference: Vector3): Vector3;
  17070. /**
  17071. * Creates a new Vector3 copied from the current Vector3
  17072. * @returns the new Vector3
  17073. */
  17074. clone(): Vector3;
  17075. /**
  17076. * Copies the given vector coordinates to the current Vector3 ones
  17077. * @param source defines the source Vector3
  17078. * @returns the current updated Vector3
  17079. */
  17080. copyFrom(source: Vector3): Vector3;
  17081. /**
  17082. * Copies the given floats to the current Vector3 coordinates
  17083. * @param x defines the x coordinate of the operand
  17084. * @param y defines the y coordinate of the operand
  17085. * @param z defines the z coordinate of the operand
  17086. * @returns the current updated Vector3
  17087. */
  17088. copyFromFloats(x: number, y: number, z: number): Vector3;
  17089. /**
  17090. * Copies the given floats to the current Vector3 coordinates
  17091. * @param x defines the x coordinate of the operand
  17092. * @param y defines the y coordinate of the operand
  17093. * @param z defines the z coordinate of the operand
  17094. * @returns the current updated Vector3
  17095. */
  17096. set(x: number, y: number, z: number): Vector3;
  17097. /**
  17098. * Get the clip factor between two vectors
  17099. * @param vector0 defines the first operand
  17100. * @param vector1 defines the second operand
  17101. * @param axis defines the axis to use
  17102. * @param size defines the size along the axis
  17103. * @returns the clip factor
  17104. */
  17105. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  17106. /**
  17107. * Get angle between two vectors
  17108. * @param vector0 angle between vector0 and vector1
  17109. * @param vector1 angle between vector0 and vector1
  17110. * @param normal direction of the normal
  17111. * @return the angle between vector0 and vector1
  17112. */
  17113. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  17114. /**
  17115. * Returns a new Vector3 set from the index "offset" of the given array
  17116. * @param array defines the source array
  17117. * @param offset defines the offset in the source array
  17118. * @returns the new Vector3
  17119. */
  17120. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  17121. /**
  17122. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  17123. * This function is deprecated. Use FromArray instead
  17124. * @param array defines the source array
  17125. * @param offset defines the offset in the source array
  17126. * @returns the new Vector3
  17127. */
  17128. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  17129. /**
  17130. * Sets the given vector "result" with the element values from the index "offset" of the given array
  17131. * @param array defines the source array
  17132. * @param offset defines the offset in the source array
  17133. * @param result defines the Vector3 where to store the result
  17134. */
  17135. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  17136. /**
  17137. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  17138. * This function is deprecated. Use FromArrayToRef instead.
  17139. * @param array defines the source array
  17140. * @param offset defines the offset in the source array
  17141. * @param result defines the Vector3 where to store the result
  17142. */
  17143. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  17144. /**
  17145. * Sets the given vector "result" with the given floats.
  17146. * @param x defines the x coordinate of the source
  17147. * @param y defines the y coordinate of the source
  17148. * @param z defines the z coordinate of the source
  17149. * @param result defines the Vector3 where to store the result
  17150. */
  17151. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  17152. /**
  17153. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  17154. * @returns a new empty Vector3
  17155. */
  17156. static Zero(): Vector3;
  17157. /**
  17158. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  17159. * @returns a new unit Vector3
  17160. */
  17161. static One(): Vector3;
  17162. /**
  17163. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  17164. * @returns a new up Vector3
  17165. */
  17166. static Up(): Vector3;
  17167. /**
  17168. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  17169. * @returns a new down Vector3
  17170. */
  17171. static Down(): Vector3;
  17172. /**
  17173. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  17174. * @returns a new forward Vector3
  17175. */
  17176. static Forward(): Vector3;
  17177. /**
  17178. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  17179. * @returns a new right Vector3
  17180. */
  17181. static Right(): Vector3;
  17182. /**
  17183. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  17184. * @returns a new left Vector3
  17185. */
  17186. static Left(): Vector3;
  17187. /**
  17188. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  17189. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17190. * @param vector defines the Vector3 to transform
  17191. * @param transformation defines the transformation matrix
  17192. * @returns the transformed Vector3
  17193. */
  17194. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  17195. /**
  17196. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  17197. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17198. * @param vector defines the Vector3 to transform
  17199. * @param transformation defines the transformation matrix
  17200. * @param result defines the Vector3 where to store the result
  17201. */
  17202. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17203. /**
  17204. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  17205. * This method computes tranformed coordinates only, not transformed direction vectors
  17206. * @param x define the x coordinate of the source vector
  17207. * @param y define the y coordinate of the source vector
  17208. * @param z define the z coordinate of the source vector
  17209. * @param transformation defines the transformation matrix
  17210. * @param result defines the Vector3 where to store the result
  17211. */
  17212. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17213. /**
  17214. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  17215. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17216. * @param vector defines the Vector3 to transform
  17217. * @param transformation defines the transformation matrix
  17218. * @returns the new Vector3
  17219. */
  17220. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  17221. /**
  17222. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  17223. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17224. * @param vector defines the Vector3 to transform
  17225. * @param transformation defines the transformation matrix
  17226. * @param result defines the Vector3 where to store the result
  17227. */
  17228. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17229. /**
  17230. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  17231. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17232. * @param x define the x coordinate of the source vector
  17233. * @param y define the y coordinate of the source vector
  17234. * @param z define the z coordinate of the source vector
  17235. * @param transformation defines the transformation matrix
  17236. * @param result defines the Vector3 where to store the result
  17237. */
  17238. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17239. /**
  17240. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  17241. * @param value1 defines the first control point
  17242. * @param value2 defines the second control point
  17243. * @param value3 defines the third control point
  17244. * @param value4 defines the fourth control point
  17245. * @param amount defines the amount on the spline to use
  17246. * @returns the new Vector3
  17247. */
  17248. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  17249. /**
  17250. * 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"
  17251. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  17252. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  17253. * @param value defines the current value
  17254. * @param min defines the lower range value
  17255. * @param max defines the upper range value
  17256. * @returns the new Vector3
  17257. */
  17258. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  17259. /**
  17260. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  17261. * @param value1 defines the first control point
  17262. * @param tangent1 defines the first tangent vector
  17263. * @param value2 defines the second control point
  17264. * @param tangent2 defines the second tangent vector
  17265. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  17266. * @returns the new Vector3
  17267. */
  17268. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  17269. /**
  17270. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  17271. * @param start defines the start value
  17272. * @param end defines the end value
  17273. * @param amount max defines amount between both (between 0 and 1)
  17274. * @returns the new Vector3
  17275. */
  17276. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  17277. /**
  17278. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  17279. * @param start defines the start value
  17280. * @param end defines the end value
  17281. * @param amount max defines amount between both (between 0 and 1)
  17282. * @param result defines the Vector3 where to store the result
  17283. */
  17284. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  17285. /**
  17286. * Returns the dot product (float) between the vectors "left" and "right"
  17287. * @param left defines the left operand
  17288. * @param right defines the right operand
  17289. * @returns the dot product
  17290. */
  17291. static Dot(left: Vector3, right: Vector3): number;
  17292. /**
  17293. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  17294. * The cross product is then orthogonal to both "left" and "right"
  17295. * @param left defines the left operand
  17296. * @param right defines the right operand
  17297. * @returns the cross product
  17298. */
  17299. static Cross(left: Vector3, right: Vector3): Vector3;
  17300. /**
  17301. * Sets the given vector "result" with the cross product of "left" and "right"
  17302. * The cross product is then orthogonal to both "left" and "right"
  17303. * @param left defines the left operand
  17304. * @param right defines the right operand
  17305. * @param result defines the Vector3 where to store the result
  17306. */
  17307. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  17308. /**
  17309. * Returns a new Vector3 as the normalization of the given vector
  17310. * @param vector defines the Vector3 to normalize
  17311. * @returns the new Vector3
  17312. */
  17313. static Normalize(vector: Vector3): Vector3;
  17314. /**
  17315. * Sets the given vector "result" with the normalization of the given first vector
  17316. * @param vector defines the Vector3 to normalize
  17317. * @param result defines the Vector3 where to store the result
  17318. */
  17319. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  17320. private static _viewportMatrixCache;
  17321. /**
  17322. * Project a Vector3 onto screen space
  17323. * @param vector defines the Vector3 to project
  17324. * @param world defines the world matrix to use
  17325. * @param transform defines the transform (view x projection) matrix to use
  17326. * @param viewport defines the screen viewport to use
  17327. * @returns the new Vector3
  17328. */
  17329. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  17330. /**
  17331. * Unproject from screen space to object space
  17332. * @param source defines the screen space Vector3 to use
  17333. * @param viewportWidth defines the current width of the viewport
  17334. * @param viewportHeight defines the current height of the viewport
  17335. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17336. * @param transform defines the transform (view x projection) matrix to use
  17337. * @returns the new Vector3
  17338. */
  17339. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  17340. /**
  17341. * Unproject from screen space to object space
  17342. * @param source defines the screen space Vector3 to use
  17343. * @param viewportWidth defines the current width of the viewport
  17344. * @param viewportHeight defines the current height of the viewport
  17345. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17346. * @param view defines the view matrix to use
  17347. * @param projection defines the projection matrix to use
  17348. * @returns the new Vector3
  17349. */
  17350. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  17351. /**
  17352. * Unproject from screen space to object space
  17353. * @param source defines the screen space Vector3 to use
  17354. * @param viewportWidth defines the current width of the viewport
  17355. * @param viewportHeight defines the current height of the viewport
  17356. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17357. * @param view defines the view matrix to use
  17358. * @param projection defines the projection matrix to use
  17359. * @param result defines the Vector3 where to store the result
  17360. */
  17361. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17362. /**
  17363. * Unproject from screen space to object space
  17364. * @param sourceX defines the screen space x coordinate to use
  17365. * @param sourceY defines the screen space y coordinate to use
  17366. * @param sourceZ defines the screen space z coordinate to use
  17367. * @param viewportWidth defines the current width of the viewport
  17368. * @param viewportHeight defines the current height of the viewport
  17369. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17370. * @param view defines the view matrix to use
  17371. * @param projection defines the projection matrix to use
  17372. * @param result defines the Vector3 where to store the result
  17373. */
  17374. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17375. /**
  17376. * Gets the minimal coordinate values between two Vector3
  17377. * @param left defines the first operand
  17378. * @param right defines the second operand
  17379. * @returns the new Vector3
  17380. */
  17381. static Minimize(left: Vector3, right: Vector3): Vector3;
  17382. /**
  17383. * Gets the maximal coordinate values between two Vector3
  17384. * @param left defines the first operand
  17385. * @param right defines the second operand
  17386. * @returns the new Vector3
  17387. */
  17388. static Maximize(left: Vector3, right: Vector3): Vector3;
  17389. /**
  17390. * Returns the distance between the vectors "value1" and "value2"
  17391. * @param value1 defines the first operand
  17392. * @param value2 defines the second operand
  17393. * @returns the distance
  17394. */
  17395. static Distance(value1: Vector3, value2: Vector3): number;
  17396. /**
  17397. * Returns the squared distance between the vectors "value1" and "value2"
  17398. * @param value1 defines the first operand
  17399. * @param value2 defines the second operand
  17400. * @returns the squared distance
  17401. */
  17402. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  17403. /**
  17404. * Returns a new Vector3 located at the center between "value1" and "value2"
  17405. * @param value1 defines the first operand
  17406. * @param value2 defines the second operand
  17407. * @returns the new Vector3
  17408. */
  17409. static Center(value1: Vector3, value2: Vector3): Vector3;
  17410. /**
  17411. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  17412. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  17413. * to something in order to rotate it from its local system to the given target system
  17414. * Note: axis1, axis2 and axis3 are normalized during this operation
  17415. * @param axis1 defines the first axis
  17416. * @param axis2 defines the second axis
  17417. * @param axis3 defines the third axis
  17418. * @returns a new Vector3
  17419. */
  17420. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  17421. /**
  17422. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  17423. * @param axis1 defines the first axis
  17424. * @param axis2 defines the second axis
  17425. * @param axis3 defines the third axis
  17426. * @param ref defines the Vector3 where to store the result
  17427. */
  17428. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  17429. }
  17430. class Vector4 {
  17431. x: number;
  17432. y: number;
  17433. z: number;
  17434. w: number;
  17435. /**
  17436. * Creates a Vector4 object from the given floats.
  17437. */
  17438. constructor(x: number, y: number, z: number, w: number);
  17439. /**
  17440. * Returns the string with the Vector4 coordinates.
  17441. */
  17442. toString(): string;
  17443. /**
  17444. * Returns the string "Vector4".
  17445. */
  17446. getClassName(): string;
  17447. /**
  17448. * Returns the Vector4 hash code.
  17449. */
  17450. getHashCode(): number;
  17451. /**
  17452. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  17453. */
  17454. asArray(): number[];
  17455. /**
  17456. * Populates the given array from the given index with the Vector4 coordinates.
  17457. * Returns the Vector4.
  17458. */
  17459. toArray(array: FloatArray, index?: number): Vector4;
  17460. /**
  17461. * Adds the given vector to the current Vector4.
  17462. * Returns the updated Vector4.
  17463. */
  17464. addInPlace(otherVector: Vector4): Vector4;
  17465. /**
  17466. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  17467. */
  17468. add(otherVector: Vector4): Vector4;
  17469. /**
  17470. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17471. * Returns the current Vector4.
  17472. */
  17473. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17474. /**
  17475. * Subtract in place the given vector from the current Vector4.
  17476. * Returns the updated Vector4.
  17477. */
  17478. subtractInPlace(otherVector: Vector4): Vector4;
  17479. /**
  17480. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17481. */
  17482. subtract(otherVector: Vector4): Vector4;
  17483. /**
  17484. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17485. * Returns the current Vector4.
  17486. */
  17487. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17488. /**
  17489. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17490. */
  17491. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17492. /**
  17493. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17494. * Returns the current Vector4.
  17495. */
  17496. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17497. /**
  17498. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17499. */
  17500. negate(): Vector4;
  17501. /**
  17502. * Multiplies the current Vector4 coordinates by scale (float).
  17503. * Returns the updated Vector4.
  17504. */
  17505. scaleInPlace(scale: number): Vector4;
  17506. /**
  17507. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17508. */
  17509. scale(scale: number): Vector4;
  17510. /**
  17511. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17512. * Returns the current Vector4.
  17513. */
  17514. scaleToRef(scale: number, result: Vector4): Vector4;
  17515. /**
  17516. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17517. * @param scale defines the scale factor
  17518. * @param result defines the Vector4 object where to store the result
  17519. * @returns the unmodified current Vector4
  17520. */
  17521. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17522. /**
  17523. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17524. */
  17525. equals(otherVector: Vector4): boolean;
  17526. /**
  17527. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17528. */
  17529. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17530. /**
  17531. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17532. */
  17533. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17534. /**
  17535. * Multiplies in place the current Vector4 by the given one.
  17536. * Returns the updated Vector4.
  17537. */
  17538. multiplyInPlace(otherVector: Vector4): Vector4;
  17539. /**
  17540. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17541. */
  17542. multiply(otherVector: Vector4): Vector4;
  17543. /**
  17544. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17545. * Returns the current Vector4.
  17546. */
  17547. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17548. /**
  17549. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17550. */
  17551. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17552. /**
  17553. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17554. */
  17555. divide(otherVector: Vector4): Vector4;
  17556. /**
  17557. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17558. * Returns the current Vector4.
  17559. */
  17560. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17561. /**
  17562. * Divides the current Vector3 coordinates by the given ones.
  17563. * @returns the updated Vector3.
  17564. */
  17565. divideInPlace(otherVector: Vector4): Vector4;
  17566. /**
  17567. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17568. * @param other defines the second operand
  17569. * @returns the current updated Vector4
  17570. */
  17571. minimizeInPlace(other: Vector4): Vector4;
  17572. /**
  17573. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17574. * @param other defines the second operand
  17575. * @returns the current updated Vector4
  17576. */
  17577. maximizeInPlace(other: Vector4): Vector4;
  17578. /**
  17579. * Gets a new Vector4 from current Vector4 floored values
  17580. * @returns a new Vector4
  17581. */
  17582. floor(): Vector4;
  17583. /**
  17584. * Gets a new Vector4 from current Vector3 floored values
  17585. * @returns a new Vector4
  17586. */
  17587. fract(): Vector4;
  17588. /**
  17589. * Returns the Vector4 length (float).
  17590. */
  17591. length(): number;
  17592. /**
  17593. * Returns the Vector4 squared length (float).
  17594. */
  17595. lengthSquared(): number;
  17596. /**
  17597. * Normalizes in place the Vector4.
  17598. * Returns the updated Vector4.
  17599. */
  17600. normalize(): Vector4;
  17601. /**
  17602. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17603. */
  17604. toVector3(): Vector3;
  17605. /**
  17606. * Returns a new Vector4 copied from the current one.
  17607. */
  17608. clone(): Vector4;
  17609. /**
  17610. * Updates the current Vector4 with the given one coordinates.
  17611. * Returns the updated Vector4.
  17612. */
  17613. copyFrom(source: Vector4): Vector4;
  17614. /**
  17615. * Updates the current Vector4 coordinates with the given floats.
  17616. * Returns the updated Vector4.
  17617. */
  17618. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17619. /**
  17620. * Updates the current Vector4 coordinates with the given floats.
  17621. * Returns the updated Vector4.
  17622. */
  17623. set(x: number, y: number, z: number, w: number): Vector4;
  17624. /**
  17625. * Returns a new Vector4 set from the starting index of the given array.
  17626. */
  17627. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17628. /**
  17629. * Updates the given vector "result" from the starting index of the given array.
  17630. */
  17631. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17632. /**
  17633. * Updates the given vector "result" from the starting index of the given Float32Array.
  17634. */
  17635. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17636. /**
  17637. * Updates the given vector "result" coordinates from the given floats.
  17638. */
  17639. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17640. /**
  17641. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17642. */
  17643. static Zero(): Vector4;
  17644. /**
  17645. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17646. */
  17647. static One(): Vector4;
  17648. /**
  17649. * Returns a new normalized Vector4 from the given one.
  17650. */
  17651. static Normalize(vector: Vector4): Vector4;
  17652. /**
  17653. * Updates the given vector "result" from the normalization of the given one.
  17654. */
  17655. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17656. static Minimize(left: Vector4, right: Vector4): Vector4;
  17657. static Maximize(left: Vector4, right: Vector4): Vector4;
  17658. /**
  17659. * Returns the distance (float) between the vectors "value1" and "value2".
  17660. */
  17661. static Distance(value1: Vector4, value2: Vector4): number;
  17662. /**
  17663. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17664. */
  17665. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17666. /**
  17667. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17668. */
  17669. static Center(value1: Vector4, value2: Vector4): Vector4;
  17670. /**
  17671. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17672. * This methods computes transformed normalized direction vectors only.
  17673. */
  17674. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17675. /**
  17676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17677. * This methods computes transformed normalized direction vectors only.
  17678. */
  17679. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17680. /**
  17681. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17682. * This methods computes transformed normalized direction vectors only.
  17683. */
  17684. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17685. }
  17686. interface ISize {
  17687. width: number;
  17688. height: number;
  17689. }
  17690. class Size implements ISize {
  17691. width: number;
  17692. height: number;
  17693. /**
  17694. * Creates a Size object from the given width and height (floats).
  17695. */
  17696. constructor(width: number, height: number);
  17697. toString(): string;
  17698. /**
  17699. * Returns the string "Size"
  17700. */
  17701. getClassName(): string;
  17702. /**
  17703. * Returns the Size hash code.
  17704. */
  17705. getHashCode(): number;
  17706. /**
  17707. * Updates the current size from the given one.
  17708. * Returns the updated Size.
  17709. */
  17710. copyFrom(src: Size): void;
  17711. /**
  17712. * Updates in place the current Size from the given floats.
  17713. * Returns the updated Size.
  17714. */
  17715. copyFromFloats(width: number, height: number): Size;
  17716. /**
  17717. * Updates in place the current Size from the given floats.
  17718. * Returns the updated Size.
  17719. */
  17720. set(width: number, height: number): Size;
  17721. /**
  17722. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17723. */
  17724. multiplyByFloats(w: number, h: number): Size;
  17725. /**
  17726. * Returns a new Size copied from the given one.
  17727. */
  17728. clone(): Size;
  17729. /**
  17730. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17731. */
  17732. equals(other: Size): boolean;
  17733. /**
  17734. * Returns the surface of the Size : width * height (float).
  17735. */
  17736. readonly surface: number;
  17737. /**
  17738. * Returns a new Size set to (0.0, 0.0)
  17739. */
  17740. static Zero(): Size;
  17741. /**
  17742. * Returns a new Size set as the addition result of the current Size and the given one.
  17743. */
  17744. add(otherSize: Size): Size;
  17745. /**
  17746. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17747. */
  17748. subtract(otherSize: Size): Size;
  17749. /**
  17750. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17751. */
  17752. static Lerp(start: Size, end: Size, amount: number): Size;
  17753. }
  17754. /**
  17755. * Class used to store quaternion data
  17756. * @see https://en.wikipedia.org/wiki/Quaternion
  17757. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17758. */
  17759. class Quaternion {
  17760. /** defines the first component (0 by default) */
  17761. x: number;
  17762. /** defines the second component (0 by default) */
  17763. y: number;
  17764. /** defines the third component (0 by default) */
  17765. z: number;
  17766. /** defines the fourth component (1.0 by default) */
  17767. w: number;
  17768. /**
  17769. * Creates a new Quaternion from the given floats
  17770. * @param x defines the first component (0 by default)
  17771. * @param y defines the second component (0 by default)
  17772. * @param z defines the third component (0 by default)
  17773. * @param w defines the fourth component (1.0 by default)
  17774. */
  17775. constructor(
  17776. /** defines the first component (0 by default) */
  17777. x?: number,
  17778. /** defines the second component (0 by default) */
  17779. y?: number,
  17780. /** defines the third component (0 by default) */
  17781. z?: number,
  17782. /** defines the fourth component (1.0 by default) */
  17783. w?: number);
  17784. /**
  17785. * Gets a string representation for the current quaternion
  17786. * @returns a string with the Quaternion coordinates
  17787. */
  17788. toString(): string;
  17789. /**
  17790. * Gets the class name of the quaternion
  17791. * @returns the string "Quaternion"
  17792. */
  17793. getClassName(): string;
  17794. /**
  17795. * Gets a hash code for this quaternion
  17796. * @returns the quaternion hash code
  17797. */
  17798. getHashCode(): number;
  17799. /**
  17800. * Copy the quaternion to an array
  17801. * @returns a new array populated with 4 elements from the quaternion coordinates
  17802. */
  17803. asArray(): number[];
  17804. /**
  17805. * Check if two quaternions are equals
  17806. * @param otherQuaternion defines the second operand
  17807. * @return true if the current quaternion and the given one coordinates are strictly equals
  17808. */
  17809. equals(otherQuaternion: Quaternion): boolean;
  17810. /**
  17811. * Clone the current quaternion
  17812. * @returns a new quaternion copied from the current one
  17813. */
  17814. clone(): Quaternion;
  17815. /**
  17816. * Copy a quaternion to the current one
  17817. * @param other defines the other quaternion
  17818. * @returns the updated current quaternion
  17819. */
  17820. copyFrom(other: Quaternion): Quaternion;
  17821. /**
  17822. * Updates the current quaternion with the given float coordinates
  17823. * @param x defines the x coordinate
  17824. * @param y defines the y coordinate
  17825. * @param z defines the z coordinate
  17826. * @param w defines the w coordinate
  17827. * @returns the updated current quaternion
  17828. */
  17829. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17830. /**
  17831. * Updates the current quaternion from the given float coordinates
  17832. * @param x defines the x coordinate
  17833. * @param y defines the y coordinate
  17834. * @param z defines the z coordinate
  17835. * @param w defines the w coordinate
  17836. * @returns the updated current quaternion
  17837. */
  17838. set(x: number, y: number, z: number, w: number): Quaternion;
  17839. /**
  17840. * Adds two quaternions
  17841. * @param other defines the second operand
  17842. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17843. */
  17844. add(other: Quaternion): Quaternion;
  17845. /**
  17846. * Add a quaternion to the current one
  17847. * @param other defines the quaternion to add
  17848. * @returns the current quaternion
  17849. */
  17850. addInPlace(other: Quaternion): Quaternion;
  17851. /**
  17852. * Subtract two quaternions
  17853. * @param other defines the second operand
  17854. * @returns a new quaternion as the subtraction result of the given one from the current one
  17855. */
  17856. subtract(other: Quaternion): Quaternion;
  17857. /**
  17858. * Multiplies the current quaternion by a scale factor
  17859. * @param value defines the scale factor
  17860. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17861. */
  17862. scale(value: number): Quaternion;
  17863. /**
  17864. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17865. * @param scale defines the scale factor
  17866. * @param result defines the Quaternion object where to store the result
  17867. * @returns the unmodified current quaternion
  17868. */
  17869. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17870. /**
  17871. * Multiplies in place the current quaternion by a scale factor
  17872. * @param value defines the scale factor
  17873. * @returns the current modified quaternion
  17874. */
  17875. scaleInPlace(value: number): Quaternion;
  17876. /**
  17877. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17878. * @param scale defines the scale factor
  17879. * @param result defines the Quaternion object where to store the result
  17880. * @returns the unmodified current quaternion
  17881. */
  17882. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17883. /**
  17884. * Multiplies two quaternions
  17885. * @param q1 defines the second operand
  17886. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17887. */
  17888. multiply(q1: Quaternion): Quaternion;
  17889. /**
  17890. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17891. * @param q1 defines the second operand
  17892. * @param result defines the target quaternion
  17893. * @returns the current quaternion
  17894. */
  17895. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17896. /**
  17897. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17898. * @param q1 defines the second operand
  17899. * @returns the currentupdated quaternion
  17900. */
  17901. multiplyInPlace(q1: Quaternion): Quaternion;
  17902. /**
  17903. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17904. * @param ref defines the target quaternion
  17905. * @returns the current quaternion
  17906. */
  17907. conjugateToRef(ref: Quaternion): Quaternion;
  17908. /**
  17909. * Conjugates in place (1-q) the current quaternion
  17910. * @returns the current updated quaternion
  17911. */
  17912. conjugateInPlace(): Quaternion;
  17913. /**
  17914. * Conjugates in place (1-q) the current quaternion
  17915. * @returns a new quaternion
  17916. */
  17917. conjugate(): Quaternion;
  17918. /**
  17919. * Gets length of current quaternion
  17920. * @returns the quaternion length (float)
  17921. */
  17922. length(): number;
  17923. /**
  17924. * Normalize in place the current quaternion
  17925. * @returns the current updated quaternion
  17926. */
  17927. normalize(): Quaternion;
  17928. /**
  17929. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17930. * @param order is a reserved parameter and is ignore for now
  17931. * @returns a new Vector3 containing the Euler angles
  17932. */
  17933. toEulerAngles(order?: string): Vector3;
  17934. /**
  17935. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17936. * @param result defines the vector which will be filled with the Euler angles
  17937. * @param order is a reserved parameter and is ignore for now
  17938. * @returns the current unchanged quaternion
  17939. */
  17940. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17941. /**
  17942. * Updates the given rotation matrix with the current quaternion values
  17943. * @param result defines the target matrix
  17944. * @returns the current unchanged quaternion
  17945. */
  17946. toRotationMatrix(result: Matrix): Quaternion;
  17947. /**
  17948. * Updates the current quaternion from the given rotation matrix values
  17949. * @param matrix defines the source matrix
  17950. * @returns the current updated quaternion
  17951. */
  17952. fromRotationMatrix(matrix: Matrix): Quaternion;
  17953. /**
  17954. * Creates a new quaternion from a rotation matrix
  17955. * @param matrix defines the source matrix
  17956. * @returns a new quaternion created from the given rotation matrix values
  17957. */
  17958. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17959. /**
  17960. * Updates the given quaternion with the given rotation matrix values
  17961. * @param matrix defines the source matrix
  17962. * @param result defines the target quaternion
  17963. */
  17964. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17965. /**
  17966. * Returns the dot product (float) between the quaternions "left" and "right"
  17967. * @param left defines the left operand
  17968. * @param right defines the right operand
  17969. * @returns the dot product
  17970. */
  17971. static Dot(left: Quaternion, right: Quaternion): number;
  17972. /**
  17973. * Checks if the two quaternions are close to each other
  17974. * @param quat0 defines the first quaternion to check
  17975. * @param quat1 defines the second quaternion to check
  17976. * @returns true if the two quaternions are close to each other
  17977. */
  17978. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17979. /**
  17980. * Creates an empty quaternion
  17981. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17982. */
  17983. static Zero(): Quaternion;
  17984. /**
  17985. * Inverse a given quaternion
  17986. * @param q defines the source quaternion
  17987. * @returns a new quaternion as the inverted current quaternion
  17988. */
  17989. static Inverse(q: Quaternion): Quaternion;
  17990. /**
  17991. * Creates an identity quaternion
  17992. * @returns the identity quaternion
  17993. */
  17994. static Identity(): Quaternion;
  17995. /**
  17996. * Gets a boolean indicating if the given quaternion is identity
  17997. * @param quaternion defines the quaternion to check
  17998. * @returns true if the quaternion is identity
  17999. */
  18000. static IsIdentity(quaternion: Quaternion): boolean;
  18001. /**
  18002. * Creates a quaternion from a rotation around an axis
  18003. * @param axis defines the axis to use
  18004. * @param angle defines the angle to use
  18005. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  18006. */
  18007. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  18008. /**
  18009. * Creates a rotation around an axis and stores it into the given quaternion
  18010. * @param axis defines the axis to use
  18011. * @param angle defines the angle to use
  18012. * @param result defines the target quaternion
  18013. * @returns the target quaternion
  18014. */
  18015. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  18016. /**
  18017. * Creates a new quaternion from data stored into an array
  18018. * @param array defines the data source
  18019. * @param offset defines the offset in the source array where the data starts
  18020. * @returns a new quaternion
  18021. */
  18022. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  18023. /**
  18024. * Creates a new quaternion from the given Euler float angles (y, x, z)
  18025. * @param yaw defines the rotation around Y axis
  18026. * @param pitch defines the rotation around X axis
  18027. * @param roll defines the rotation around Z axis
  18028. * @returns the new quaternion
  18029. */
  18030. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  18031. /**
  18032. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  18033. * @param yaw defines the rotation around Y axis
  18034. * @param pitch defines the rotation around X axis
  18035. * @param roll defines the rotation around Z axis
  18036. * @param result defines the target quaternion
  18037. */
  18038. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  18039. /**
  18040. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  18041. * @param alpha defines the rotation around first axis
  18042. * @param beta defines the rotation around second axis
  18043. * @param gamma defines the rotation around third axis
  18044. * @returns the new quaternion
  18045. */
  18046. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  18047. /**
  18048. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  18049. * @param alpha defines the rotation around first axis
  18050. * @param beta defines the rotation around second axis
  18051. * @param gamma defines the rotation around third axis
  18052. * @param result defines the target quaternion
  18053. */
  18054. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  18055. /**
  18056. * 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)
  18057. * @param axis1 defines the first axis
  18058. * @param axis2 defines the second axis
  18059. * @param axis3 defines the third axis
  18060. * @returns the new quaternion
  18061. */
  18062. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  18063. /**
  18064. * 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
  18065. * @param axis1 defines the first axis
  18066. * @param axis2 defines the second axis
  18067. * @param axis3 defines the third axis
  18068. * @param ref defines the target quaternion
  18069. */
  18070. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  18071. /**
  18072. * Interpolates between two quaternions
  18073. * @param left defines first quaternion
  18074. * @param right defines second quaternion
  18075. * @param amount defines the gradient to use
  18076. * @returns the new interpolated quaternion
  18077. */
  18078. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  18079. /**
  18080. * Interpolates between two quaternions and stores it into a target quaternion
  18081. * @param left defines first quaternion
  18082. * @param right defines second quaternion
  18083. * @param amount defines the gradient to use
  18084. * @param result defines the target quaternion
  18085. */
  18086. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  18087. /**
  18088. * Interpolate between two quaternions using Hermite interpolation
  18089. * @param value1 defines first quaternion
  18090. * @param tangent1 defines the incoming tangent
  18091. * @param value2 defines second quaternion
  18092. * @param tangent2 defines the outgoing tangent
  18093. * @param amount defines the target quaternion
  18094. * @returns the new interpolated quaternion
  18095. */
  18096. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  18097. }
  18098. /**
  18099. * Class used to store matrix data (4x4)
  18100. */
  18101. class Matrix {
  18102. private static _tempQuaternion;
  18103. private static _xAxis;
  18104. private static _yAxis;
  18105. private static _zAxis;
  18106. private static _updateFlagSeed;
  18107. private static _identityReadOnly;
  18108. private _isIdentity;
  18109. private _isIdentityDirty;
  18110. /**
  18111. * Gets the update flag of the matrix which is an unique number for the matrix.
  18112. * It will be incremented every time the matrix data change.
  18113. * You can use it to speed the comparison between two versions of the same matrix.
  18114. */
  18115. updateFlag: number;
  18116. /**
  18117. * Gets or sets the internal data of the matrix
  18118. */
  18119. m: Float32Array;
  18120. /** @hidden */
  18121. _markAsUpdated(): void;
  18122. /**
  18123. * Creates an empty matrix (filled with zeros)
  18124. */
  18125. constructor();
  18126. /**
  18127. * Check if the current matrix is indentity
  18128. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  18129. * @returns true is the matrix is the identity matrix
  18130. */
  18131. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  18132. /**
  18133. * Gets the determinant of the matrix
  18134. * @returns the matrix determinant
  18135. */
  18136. determinant(): number;
  18137. /**
  18138. * Returns the matrix as a Float32Array
  18139. * @returns the matrix underlying array
  18140. */
  18141. toArray(): Float32Array;
  18142. /**
  18143. * Returns the matrix as a Float32Array
  18144. * @returns the matrix underlying array.
  18145. */
  18146. asArray(): Float32Array;
  18147. /**
  18148. * Inverts the current matrix in place
  18149. * @returns the current inverted matrix
  18150. */
  18151. invert(): Matrix;
  18152. /**
  18153. * Sets all the matrix elements to zero
  18154. * @returns the current matrix
  18155. */
  18156. reset(): Matrix;
  18157. /**
  18158. * Adds the current matrix with a second one
  18159. * @param other defines the matrix to add
  18160. * @returns a new matrix as the addition of the current matrix and the given one
  18161. */
  18162. add(other: Matrix): Matrix;
  18163. /**
  18164. * Sets the given matrix "result" to the addition of the current matrix and the given one
  18165. * @param other defines the matrix to add
  18166. * @param result defines the target matrix
  18167. * @returns the current matrix
  18168. */
  18169. addToRef(other: Matrix, result: Matrix): Matrix;
  18170. /**
  18171. * Adds in place the given matrix to the current matrix
  18172. * @param other defines the second operand
  18173. * @returns the current updated matrix
  18174. */
  18175. addToSelf(other: Matrix): Matrix;
  18176. /**
  18177. * Sets the given matrix to the current inverted Matrix
  18178. * @param other defines the target matrix
  18179. * @returns the unmodified current matrix
  18180. */
  18181. invertToRef(other: Matrix): Matrix;
  18182. /**
  18183. * Inserts the translation vector (using 3 floats) in the current matrix
  18184. * @param x defines the 1st component of the translation
  18185. * @param y defines the 2nd component of the translation
  18186. * @param z defines the 3rd component of the translation
  18187. * @returns the current updated matrix
  18188. */
  18189. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  18190. /**
  18191. * Inserts the translation vector in the current matrix
  18192. * @param vector3 defines the translation to insert
  18193. * @returns the current updated matrix
  18194. */
  18195. setTranslation(vector3: Vector3): Matrix;
  18196. /**
  18197. * Gets the translation value of the current matrix
  18198. * @returns a new Vector3 as the extracted translation from the matrix
  18199. */
  18200. getTranslation(): Vector3;
  18201. /**
  18202. * Fill a Vector3 with the extracted translation from the matrix
  18203. * @param result defines the Vector3 where to store the translation
  18204. * @returns the current matrix
  18205. */
  18206. getTranslationToRef(result: Vector3): Matrix;
  18207. /**
  18208. * Remove rotation and scaling part from the matrix
  18209. * @returns the updated matrix
  18210. */
  18211. removeRotationAndScaling(): Matrix;
  18212. /**
  18213. * Multiply two matrices
  18214. * @param other defines the second operand
  18215. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  18216. */
  18217. multiply(other: Matrix): Matrix;
  18218. /**
  18219. * Copy the current matrix from the given one
  18220. * @param other defines the source matrix
  18221. * @returns the current updated matrix
  18222. */
  18223. copyFrom(other: Matrix): Matrix;
  18224. /**
  18225. * Populates the given array from the starting index with the current matrix values
  18226. * @param array defines the target array
  18227. * @param offset defines the offset in the target array where to start storing values
  18228. * @returns the current matrix
  18229. */
  18230. copyToArray(array: Float32Array, offset?: number): Matrix;
  18231. /**
  18232. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  18233. * @param other defines the second operand
  18234. * @param result defines the matrix where to store the multiplication
  18235. * @returns the current matrix
  18236. */
  18237. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  18238. /**
  18239. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  18240. * @param other defines the second operand
  18241. * @param result defines the array where to store the multiplication
  18242. * @param offset defines the offset in the target array where to start storing values
  18243. * @returns the current matrix
  18244. */
  18245. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  18246. /**
  18247. * Check equality between this matrix and a second one
  18248. * @param value defines the second matrix to compare
  18249. * @returns true is the current matrix and the given one values are strictly equal
  18250. */
  18251. equals(value: Matrix): boolean;
  18252. /**
  18253. * Clone the current matrix
  18254. * @returns a new matrix from the current matrix
  18255. */
  18256. clone(): Matrix;
  18257. /**
  18258. * Returns the name of the current matrix class
  18259. * @returns the string "Matrix"
  18260. */
  18261. getClassName(): string;
  18262. /**
  18263. * Gets the hash code of the current matrix
  18264. * @returns the hash code
  18265. */
  18266. getHashCode(): number;
  18267. /**
  18268. * Decomposes the current Matrix into a translation, rotation and scaling components
  18269. * @param scale defines the scale vector3 given as a reference to update
  18270. * @param rotation defines the rotation quaternion given as a reference to update
  18271. * @param translation defines the translation vector3 given as a reference to update
  18272. * @returns true if operation was successful
  18273. */
  18274. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  18275. /**
  18276. * Gets specific row of the matrix
  18277. * @param index defines the number of the row to get
  18278. * @returns the index-th row of the current matrix as a new Vector4
  18279. */
  18280. getRow(index: number): Nullable<Vector4>;
  18281. /**
  18282. * Sets the index-th row of the current matrix to the vector4 values
  18283. * @param index defines the number of the row to set
  18284. * @param row defines the target vector4
  18285. * @returns the updated current matrix
  18286. */
  18287. setRow(index: number, row: Vector4): Matrix;
  18288. /**
  18289. * Compute the transpose of the matrix
  18290. * @returns the new transposed matrix
  18291. */
  18292. transpose(): Matrix;
  18293. /**
  18294. * Compute the transpose of the matrix and store it in a given matrix
  18295. * @param result defines the target matrix
  18296. * @returns the current matrix
  18297. */
  18298. transposeToRef(result: Matrix): Matrix;
  18299. /**
  18300. * Sets the index-th row of the current matrix with the given 4 x float values
  18301. * @param index defines the row index
  18302. * @param x defines the x component to set
  18303. * @param y defines the y component to set
  18304. * @param z defines the z component to set
  18305. * @param w defines the w component to set
  18306. * @returns the updated current matrix
  18307. */
  18308. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  18309. /**
  18310. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  18311. * @param scale defines the scale factor
  18312. * @returns a new matrix
  18313. */
  18314. scale(scale: number): Matrix;
  18315. /**
  18316. * Scale the current matrix values by a factor to a given result matrix
  18317. * @param scale defines the scale factor
  18318. * @param result defines the matrix to store the result
  18319. * @returns the current matrix
  18320. */
  18321. scaleToRef(scale: number, result: Matrix): Matrix;
  18322. /**
  18323. * Scale the current matrix values by a factor and add the result to a given matrix
  18324. * @param scale defines the scale factor
  18325. * @param result defines the Matrix to store the result
  18326. * @returns the current matrix
  18327. */
  18328. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  18329. /**
  18330. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  18331. * @param ref matrix to store the result
  18332. */
  18333. toNormalMatrix(ref: Matrix): void;
  18334. /**
  18335. * Gets only rotation part of the current matrix
  18336. * @returns a new matrix sets to the extracted rotation matrix from the current one
  18337. */
  18338. getRotationMatrix(): Matrix;
  18339. /**
  18340. * Extracts the rotation matrix from the current one and sets it as the given "result"
  18341. * @param result defines the target matrix to store data to
  18342. * @returns the current matrix
  18343. */
  18344. getRotationMatrixToRef(result: Matrix): Matrix;
  18345. /**
  18346. * Creates a matrix from an array
  18347. * @param array defines the source array
  18348. * @param offset defines an offset in the source array
  18349. * @returns a new Matrix set from the starting index of the given array
  18350. */
  18351. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  18352. /**
  18353. * Copy the content of an array into a given matrix
  18354. * @param array defines the source array
  18355. * @param offset defines an offset in the source array
  18356. * @param result defines the target matrix
  18357. */
  18358. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  18359. /**
  18360. * Stores an array into a matrix after having multiplied each component by a given factor
  18361. * @param array defines the source array
  18362. * @param offset defines the offset in the source array
  18363. * @param scale defines the scaling factor
  18364. * @param result defines the target matrix
  18365. */
  18366. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  18367. /**
  18368. * Stores a list of values (16) inside a given matrix
  18369. * @param initialM11 defines 1st value of 1st row
  18370. * @param initialM12 defines 2nd value of 1st row
  18371. * @param initialM13 defines 3rd value of 1st row
  18372. * @param initialM14 defines 4th value of 1st row
  18373. * @param initialM21 defines 1st value of 2nd row
  18374. * @param initialM22 defines 2nd value of 2nd row
  18375. * @param initialM23 defines 3rd value of 2nd row
  18376. * @param initialM24 defines 4th value of 2nd row
  18377. * @param initialM31 defines 1st value of 3rd row
  18378. * @param initialM32 defines 2nd value of 3rd row
  18379. * @param initialM33 defines 3rd value of 3rd row
  18380. * @param initialM34 defines 4th value of 3rd row
  18381. * @param initialM41 defines 1st value of 4th row
  18382. * @param initialM42 defines 2nd value of 4th row
  18383. * @param initialM43 defines 3rd value of 4th row
  18384. * @param initialM44 defines 4th value of 4th row
  18385. * @param result defines the target matrix
  18386. */
  18387. 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;
  18388. /**
  18389. * Gets an identity matrix that must not be updated
  18390. */
  18391. static readonly IdentityReadOnly: Matrix;
  18392. /**
  18393. * Creates new matrix from a list of values (16)
  18394. * @param initialM11 defines 1st value of 1st row
  18395. * @param initialM12 defines 2nd value of 1st row
  18396. * @param initialM13 defines 3rd value of 1st row
  18397. * @param initialM14 defines 4th value of 1st row
  18398. * @param initialM21 defines 1st value of 2nd row
  18399. * @param initialM22 defines 2nd value of 2nd row
  18400. * @param initialM23 defines 3rd value of 2nd row
  18401. * @param initialM24 defines 4th value of 2nd row
  18402. * @param initialM31 defines 1st value of 3rd row
  18403. * @param initialM32 defines 2nd value of 3rd row
  18404. * @param initialM33 defines 3rd value of 3rd row
  18405. * @param initialM34 defines 4th value of 3rd row
  18406. * @param initialM41 defines 1st value of 4th row
  18407. * @param initialM42 defines 2nd value of 4th row
  18408. * @param initialM43 defines 3rd value of 4th row
  18409. * @param initialM44 defines 4th value of 4th row
  18410. * @returns the new matrix
  18411. */
  18412. 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;
  18413. /**
  18414. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18415. * @param scale defines the scale vector3
  18416. * @param rotation defines the rotation quaternion
  18417. * @param translation defines the translation vector3
  18418. * @returns a new matrix
  18419. */
  18420. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  18421. /**
  18422. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18423. * @param scale defines the scale vector3
  18424. * @param rotation defines the rotation quaternion
  18425. * @param translation defines the translation vector3
  18426. * @param result defines the target matrix
  18427. */
  18428. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  18429. /**
  18430. * Creates a new identity matrix
  18431. * @returns a new identity matrix
  18432. */
  18433. static Identity(): Matrix;
  18434. /**
  18435. * Creates a new identity matrix and stores the result in a given matrix
  18436. * @param result defines the target matrix
  18437. */
  18438. static IdentityToRef(result: Matrix): void;
  18439. /**
  18440. * Creates a new zero matrix
  18441. * @returns a new zero matrix
  18442. */
  18443. static Zero(): Matrix;
  18444. /**
  18445. * Creates a new rotation matrix for "angle" radians around the X axis
  18446. * @param angle defines the angle (in radians) to use
  18447. * @return the new matrix
  18448. */
  18449. static RotationX(angle: number): Matrix;
  18450. /**
  18451. * Creates a new matrix as the invert of a given matrix
  18452. * @param source defines the source matrix
  18453. * @returns the new matrix
  18454. */
  18455. static Invert(source: Matrix): Matrix;
  18456. /**
  18457. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  18458. * @param angle defines the angle (in radians) to use
  18459. * @param result defines the target matrix
  18460. */
  18461. static RotationXToRef(angle: number, result: Matrix): void;
  18462. /**
  18463. * Creates a new rotation matrix for "angle" radians around the Y axis
  18464. * @param angle defines the angle (in radians) to use
  18465. * @return the new matrix
  18466. */
  18467. static RotationY(angle: number): Matrix;
  18468. /**
  18469. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18470. * @param angle defines the angle (in radians) to use
  18471. * @param result defines the target matrix
  18472. */
  18473. static RotationYToRef(angle: number, result: Matrix): void;
  18474. /**
  18475. * Creates a new rotation matrix for "angle" radians around the Z axis
  18476. * @param angle defines the angle (in radians) to use
  18477. * @return the new matrix
  18478. */
  18479. static RotationZ(angle: number): Matrix;
  18480. /**
  18481. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18482. * @param angle defines the angle (in radians) to use
  18483. * @param result defines the target matrix
  18484. */
  18485. static RotationZToRef(angle: number, result: Matrix): void;
  18486. /**
  18487. * Creates a new rotation matrix for "angle" radians around the given axis
  18488. * @param axis defines the axis to use
  18489. * @param angle defines the angle (in radians) to use
  18490. * @return the new matrix
  18491. */
  18492. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18493. /**
  18494. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18495. * @param axis defines the axis to use
  18496. * @param angle defines the angle (in radians) to use
  18497. * @param result defines the target matrix
  18498. */
  18499. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18500. /**
  18501. * Creates a rotation matrix
  18502. * @param yaw defines the yaw angle in radians (Y axis)
  18503. * @param pitch defines the pitch angle in radians (X axis)
  18504. * @param roll defines the roll angle in radians (X axis)
  18505. * @returns the new rotation matrix
  18506. */
  18507. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18508. /**
  18509. * Creates a rotation matrix and stores it in a given matrix
  18510. * @param yaw defines the yaw angle in radians (Y axis)
  18511. * @param pitch defines the pitch angle in radians (X axis)
  18512. * @param roll defines the roll angle in radians (X axis)
  18513. * @param result defines the target matrix
  18514. */
  18515. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18516. /**
  18517. * Creates a scaling matrix
  18518. * @param x defines the scale factor on X axis
  18519. * @param y defines the scale factor on Y axis
  18520. * @param z defines the scale factor on Z axis
  18521. * @returns the new matrix
  18522. */
  18523. static Scaling(x: number, y: number, z: number): Matrix;
  18524. /**
  18525. * Creates a scaling matrix and stores it in a given matrix
  18526. * @param x defines the scale factor on X axis
  18527. * @param y defines the scale factor on Y axis
  18528. * @param z defines the scale factor on Z axis
  18529. * @param result defines the target matrix
  18530. */
  18531. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18532. /**
  18533. * Creates a translation matrix
  18534. * @param x defines the translation on X axis
  18535. * @param y defines the translation on Y axis
  18536. * @param z defines the translationon Z axis
  18537. * @returns the new matrix
  18538. */
  18539. static Translation(x: number, y: number, z: number): Matrix;
  18540. /**
  18541. * Creates a translation matrix and stores it in a given matrix
  18542. * @param x defines the translation on X axis
  18543. * @param y defines the translation on Y axis
  18544. * @param z defines the translationon Z axis
  18545. * @param result defines the target matrix
  18546. */
  18547. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18548. /**
  18549. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18550. * @param startValue defines the start value
  18551. * @param endValue defines the end value
  18552. * @param gradient defines the gradient factor
  18553. * @returns the new matrix
  18554. */
  18555. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18556. /**
  18557. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18558. * @param startValue defines the start value
  18559. * @param endValue defines the end value
  18560. * @param gradient defines the gradient factor
  18561. * @param result defines the Matrix object where to store data
  18562. */
  18563. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18564. /**
  18565. * Builds a new matrix whose values are computed by:
  18566. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18567. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18568. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18569. * @param startValue defines the first matrix
  18570. * @param endValue defines the second matrix
  18571. * @param gradient defines the gradient between the two matrices
  18572. * @returns the new matrix
  18573. */
  18574. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18575. /**
  18576. * Update a matrix to values which are computed by:
  18577. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18578. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18579. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18580. * @param startValue defines the first matrix
  18581. * @param endValue defines the second matrix
  18582. * @param gradient defines the gradient between the two matrices
  18583. * @param result defines the target matrix
  18584. */
  18585. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18586. /**
  18587. * 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"
  18588. * This function works in left handed mode
  18589. * @param eye defines the final position of the entity
  18590. * @param target defines where the entity should look at
  18591. * @param up defines the up vector for the entity
  18592. * @returns the new matrix
  18593. */
  18594. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18595. /**
  18596. * 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".
  18597. * This function works in left handed mode
  18598. * @param eye defines the final position of the entity
  18599. * @param target defines where the entity should look at
  18600. * @param up defines the up vector for the entity
  18601. * @param result defines the target matrix
  18602. */
  18603. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18604. /**
  18605. * 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"
  18606. * This function works in right handed mode
  18607. * @param eye defines the final position of the entity
  18608. * @param target defines where the entity should look at
  18609. * @param up defines the up vector for the entity
  18610. * @returns the new matrix
  18611. */
  18612. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18613. /**
  18614. * 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".
  18615. * This function works in right handed mode
  18616. * @param eye defines the final position of the entity
  18617. * @param target defines where the entity should look at
  18618. * @param up defines the up vector for the entity
  18619. * @param result defines the target matrix
  18620. */
  18621. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18622. /**
  18623. * Create a left-handed orthographic projection matrix
  18624. * @param width defines the viewport width
  18625. * @param height defines the viewport height
  18626. * @param znear defines the near clip plane
  18627. * @param zfar defines the far clip plane
  18628. * @returns a new matrix as a left-handed orthographic projection matrix
  18629. */
  18630. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18631. /**
  18632. * Store a left-handed orthographic projection to a given matrix
  18633. * @param width defines the viewport width
  18634. * @param height defines the viewport height
  18635. * @param znear defines the near clip plane
  18636. * @param zfar defines the far clip plane
  18637. * @param result defines the target matrix
  18638. */
  18639. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18640. /**
  18641. * Create a left-handed orthographic projection matrix
  18642. * @param left defines the viewport left coordinate
  18643. * @param right defines the viewport right coordinate
  18644. * @param bottom defines the viewport bottom coordinate
  18645. * @param top defines the viewport top coordinate
  18646. * @param znear defines the near clip plane
  18647. * @param zfar defines the far clip plane
  18648. * @returns a new matrix as a left-handed orthographic projection matrix
  18649. */
  18650. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18651. /**
  18652. * Stores a left-handed orthographic projection into a given matrix
  18653. * @param left defines the viewport left coordinate
  18654. * @param right defines the viewport right coordinate
  18655. * @param bottom defines the viewport bottom coordinate
  18656. * @param top defines the viewport top coordinate
  18657. * @param znear defines the near clip plane
  18658. * @param zfar defines the far clip plane
  18659. * @param result defines the target matrix
  18660. */
  18661. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18662. /**
  18663. * Creates a right-handed orthographic projection matrix
  18664. * @param left defines the viewport left coordinate
  18665. * @param right defines the viewport right coordinate
  18666. * @param bottom defines the viewport bottom coordinate
  18667. * @param top defines the viewport top coordinate
  18668. * @param znear defines the near clip plane
  18669. * @param zfar defines the far clip plane
  18670. * @returns a new matrix as a right-handed orthographic projection matrix
  18671. */
  18672. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18673. /**
  18674. * Stores a right-handed orthographic projection into a given matrix
  18675. * @param left defines the viewport left coordinate
  18676. * @param right defines the viewport right coordinate
  18677. * @param bottom defines the viewport bottom coordinate
  18678. * @param top defines the viewport top coordinate
  18679. * @param znear defines the near clip plane
  18680. * @param zfar defines the far clip plane
  18681. * @param result defines the target matrix
  18682. */
  18683. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18684. /**
  18685. * Creates a left-handed perspective projection matrix
  18686. * @param width defines the viewport width
  18687. * @param height defines the viewport height
  18688. * @param znear defines the near clip plane
  18689. * @param zfar defines the far clip plane
  18690. * @returns a new matrix as a left-handed perspective projection matrix
  18691. */
  18692. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18693. /**
  18694. * Creates a left-handed perspective projection matrix
  18695. * @param fov defines the horizontal field of view
  18696. * @param aspect defines the aspect ratio
  18697. * @param znear defines the near clip plane
  18698. * @param zfar defines the far clip plane
  18699. * @returns a new matrix as a left-handed perspective projection matrix
  18700. */
  18701. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18702. /**
  18703. * Stores a left-handed perspective projection into a given matrix
  18704. * @param fov defines the horizontal field of view
  18705. * @param aspect defines the aspect ratio
  18706. * @param znear defines the near clip plane
  18707. * @param zfar defines the far clip plane
  18708. * @param result defines the target matrix
  18709. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18710. */
  18711. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18712. /**
  18713. * Creates a right-handed perspective projection matrix
  18714. * @param fov defines the horizontal field of view
  18715. * @param aspect defines the aspect ratio
  18716. * @param znear defines the near clip plane
  18717. * @param zfar defines the far clip plane
  18718. * @returns a new matrix as a right-handed perspective projection matrix
  18719. */
  18720. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18721. /**
  18722. * Stores a right-handed perspective projection into a given matrix
  18723. * @param fov defines the horizontal field of view
  18724. * @param aspect defines the aspect ratio
  18725. * @param znear defines the near clip plane
  18726. * @param zfar defines the far clip plane
  18727. * @param result defines the target matrix
  18728. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18729. */
  18730. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18731. /**
  18732. * Stores a perspective projection for WebVR info a given matrix
  18733. * @param fov defines the field of view
  18734. * @param znear defines the near clip plane
  18735. * @param zfar defines the far clip plane
  18736. * @param result defines the target matrix
  18737. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18738. */
  18739. static PerspectiveFovWebVRToRef(fov: {
  18740. upDegrees: number;
  18741. downDegrees: number;
  18742. leftDegrees: number;
  18743. rightDegrees: number;
  18744. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18745. /**
  18746. * Computes a complete transformation matrix
  18747. * @param viewport defines the viewport to use
  18748. * @param world defines the world matrix
  18749. * @param view defines the view matrix
  18750. * @param projection defines the projection matrix
  18751. * @param zmin defines the near clip plane
  18752. * @param zmax defines the far clip plane
  18753. * @returns the transformation matrix
  18754. */
  18755. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18756. /**
  18757. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18758. * @param matrix defines the matrix to use
  18759. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18760. */
  18761. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18762. /**
  18763. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18764. * @param matrix defines the matrix to use
  18765. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18766. */
  18767. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18768. /**
  18769. * Compute the transpose of a given matrix
  18770. * @param matrix defines the matrix to transpose
  18771. * @returns the new matrix
  18772. */
  18773. static Transpose(matrix: Matrix): Matrix;
  18774. /**
  18775. * Compute the transpose of a matrix and store it in a target matrix
  18776. * @param matrix defines the matrix to transpose
  18777. * @param result defines the target matrix
  18778. */
  18779. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18780. /**
  18781. * Computes a reflection matrix from a plane
  18782. * @param plane defines the reflection plane
  18783. * @returns a new matrix
  18784. */
  18785. static Reflection(plane: Plane): Matrix;
  18786. /**
  18787. * Computes a reflection matrix from a plane
  18788. * @param plane defines the reflection plane
  18789. * @param result defines the target matrix
  18790. */
  18791. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18792. /**
  18793. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18794. * @param xaxis defines the value of the 1st axis
  18795. * @param yaxis defines the value of the 2nd axis
  18796. * @param zaxis defines the value of the 3rd axis
  18797. * @param result defines the target matrix
  18798. */
  18799. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18800. /**
  18801. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18802. * @param quat defines the quaternion to use
  18803. * @param result defines the target matrix
  18804. */
  18805. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18806. }
  18807. class Plane {
  18808. normal: Vector3;
  18809. d: number;
  18810. /**
  18811. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18812. */
  18813. constructor(a: number, b: number, c: number, d: number);
  18814. /**
  18815. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18816. */
  18817. asArray(): number[];
  18818. /**
  18819. * Returns a new plane copied from the current Plane.
  18820. */
  18821. clone(): Plane;
  18822. /**
  18823. * Returns the string "Plane".
  18824. */
  18825. getClassName(): string;
  18826. /**
  18827. * Returns the Plane hash code.
  18828. */
  18829. getHashCode(): number;
  18830. /**
  18831. * Normalize the current Plane in place.
  18832. * Returns the updated Plane.
  18833. */
  18834. normalize(): Plane;
  18835. /**
  18836. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18837. */
  18838. transform(transformation: Matrix): Plane;
  18839. /**
  18840. * Returns the dot product (float) of the point coordinates and the plane normal.
  18841. */
  18842. dotCoordinate(point: Vector3): number;
  18843. /**
  18844. * Updates the current Plane from the plane defined by the three given points.
  18845. * Returns the updated Plane.
  18846. */
  18847. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18848. /**
  18849. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18850. */
  18851. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18852. /**
  18853. * Returns the signed distance (float) from the given point to the Plane.
  18854. */
  18855. signedDistanceTo(point: Vector3): number;
  18856. /**
  18857. * Returns a new Plane from the given array.
  18858. */
  18859. static FromArray(array: ArrayLike<number>): Plane;
  18860. /**
  18861. * Returns a new Plane defined by the three given points.
  18862. */
  18863. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18864. /**
  18865. * Returns a new Plane the normal vector to this plane at the given origin point.
  18866. * Note : the vector "normal" is updated because normalized.
  18867. */
  18868. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18869. /**
  18870. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18871. */
  18872. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18873. }
  18874. class Viewport {
  18875. x: number;
  18876. y: number;
  18877. width: number;
  18878. height: number;
  18879. /**
  18880. * Creates a Viewport object located at (x, y) and sized (width, height).
  18881. */
  18882. constructor(x: number, y: number, width: number, height: number);
  18883. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18884. /**
  18885. * Returns a new Viewport copied from the current one.
  18886. */
  18887. clone(): Viewport;
  18888. }
  18889. class Frustum {
  18890. /**
  18891. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18892. */
  18893. static GetPlanes(transform: Matrix): Plane[];
  18894. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18895. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18896. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18897. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18898. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18899. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18900. /**
  18901. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18902. */
  18903. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18904. }
  18905. /** Defines supported spaces */
  18906. enum Space {
  18907. /** Local (object) space */
  18908. LOCAL = 0,
  18909. /** World space */
  18910. WORLD = 1,
  18911. /** Bone space */
  18912. BONE = 2
  18913. }
  18914. /** Defines the 3 main axes */
  18915. class Axis {
  18916. /** X axis */
  18917. static X: Vector3;
  18918. /** Y axis */
  18919. static Y: Vector3;
  18920. /** Z axis */
  18921. static Z: Vector3;
  18922. }
  18923. class BezierCurve {
  18924. /**
  18925. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18926. */
  18927. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18928. }
  18929. /**
  18930. * Defines potential orientation for back face culling
  18931. */
  18932. enum Orientation {
  18933. /**
  18934. * Clockwise
  18935. */
  18936. CW = 0,
  18937. /** Counter clockwise */
  18938. CCW = 1
  18939. }
  18940. /**
  18941. * Defines angle representation
  18942. */
  18943. class Angle {
  18944. private _radians;
  18945. /**
  18946. * Creates an Angle object of "radians" radians (float).
  18947. */
  18948. constructor(radians: number);
  18949. /**
  18950. * Get value in degrees
  18951. * @returns the Angle value in degrees (float)
  18952. */
  18953. degrees(): number;
  18954. /**
  18955. * Get value in radians
  18956. * @returns the Angle value in radians (float)
  18957. */
  18958. radians(): number;
  18959. /**
  18960. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18961. * @param a defines first vector
  18962. * @param b defines second vector
  18963. * @returns a new Angle
  18964. */
  18965. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18966. /**
  18967. * Gets a new Angle object from the given float in radians
  18968. * @param radians defines the angle value in radians
  18969. * @returns a new Angle
  18970. */
  18971. static FromRadians(radians: number): Angle;
  18972. /**
  18973. * Gets a new Angle object from the given float in degrees
  18974. * @param degrees defines the angle value in degrees
  18975. * @returns a new Angle
  18976. */
  18977. static FromDegrees(degrees: number): Angle;
  18978. }
  18979. class Arc2 {
  18980. startPoint: Vector2;
  18981. midPoint: Vector2;
  18982. endPoint: Vector2;
  18983. centerPoint: Vector2;
  18984. radius: number;
  18985. angle: Angle;
  18986. startAngle: Angle;
  18987. orientation: Orientation;
  18988. /**
  18989. * Creates an Arc object from the three given points : start, middle and end.
  18990. */
  18991. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18992. }
  18993. class Path2 {
  18994. private _points;
  18995. private _length;
  18996. closed: boolean;
  18997. /**
  18998. * Creates a Path2 object from the starting 2D coordinates x and y.
  18999. */
  19000. constructor(x: number, y: number);
  19001. /**
  19002. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  19003. * Returns the updated Path2.
  19004. */
  19005. addLineTo(x: number, y: number): Path2;
  19006. /**
  19007. * 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.
  19008. * Returns the updated Path2.
  19009. */
  19010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  19011. /**
  19012. * Closes the Path2.
  19013. * Returns the Path2.
  19014. */
  19015. close(): Path2;
  19016. /**
  19017. * Returns the Path2 total length (float).
  19018. */
  19019. length(): number;
  19020. /**
  19021. * Returns the Path2 internal array of points.
  19022. */
  19023. getPoints(): Vector2[];
  19024. /**
  19025. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  19026. */
  19027. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  19028. /**
  19029. * Returns a new Path2 starting at the coordinates (x, y).
  19030. */
  19031. static StartingAt(x: number, y: number): Path2;
  19032. }
  19033. class Path3D {
  19034. path: Vector3[];
  19035. private _curve;
  19036. private _distances;
  19037. private _tangents;
  19038. private _normals;
  19039. private _binormals;
  19040. private _raw;
  19041. /**
  19042. * new Path3D(path, normal, raw)
  19043. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  19044. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  19045. * path : an array of Vector3, the curve axis of the Path3D
  19046. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  19047. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  19048. */
  19049. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  19050. /**
  19051. * Returns the Path3D array of successive Vector3 designing its curve.
  19052. */
  19053. getCurve(): Vector3[];
  19054. /**
  19055. * Returns an array populated with tangent vectors on each Path3D curve point.
  19056. */
  19057. getTangents(): Vector3[];
  19058. /**
  19059. * Returns an array populated with normal vectors on each Path3D curve point.
  19060. */
  19061. getNormals(): Vector3[];
  19062. /**
  19063. * Returns an array populated with binormal vectors on each Path3D curve point.
  19064. */
  19065. getBinormals(): Vector3[];
  19066. /**
  19067. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  19068. */
  19069. getDistances(): number[];
  19070. /**
  19071. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  19072. * Returns the same object updated.
  19073. */
  19074. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  19075. private _compute;
  19076. private _getFirstNonNullVector;
  19077. private _getLastNonNullVector;
  19078. private _normalVector;
  19079. }
  19080. class Curve3 {
  19081. private _points;
  19082. private _length;
  19083. /**
  19084. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  19085. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  19086. * @param v1 (Vector3) the control point
  19087. * @param v2 (Vector3) the end point of the Quadratic Bezier
  19088. * @param nbPoints (integer) the wanted number of points in the curve
  19089. */
  19090. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  19091. /**
  19092. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  19093. * @param v0 (Vector3) the origin point of the Cubic Bezier
  19094. * @param v1 (Vector3) the first control point
  19095. * @param v2 (Vector3) the second control point
  19096. * @param v3 (Vector3) the end point of the Cubic Bezier
  19097. * @param nbPoints (integer) the wanted number of points in the curve
  19098. */
  19099. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  19100. /**
  19101. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  19102. * @param p1 (Vector3) the origin point of the Hermite Spline
  19103. * @param t1 (Vector3) the tangent vector at the origin point
  19104. * @param p2 (Vector3) the end point of the Hermite Spline
  19105. * @param t2 (Vector3) the tangent vector at the end point
  19106. * @param nbPoints (integer) the wanted number of points in the curve
  19107. */
  19108. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  19109. /**
  19110. * Returns a Curve3 object along a CatmullRom Spline curve :
  19111. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  19112. * @param nbPoints (integer) the wanted number of points between each curve control points
  19113. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  19114. */
  19115. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  19116. /**
  19117. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  19118. * A Curve3 is designed from a series of successive Vector3.
  19119. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  19120. */
  19121. constructor(points: Vector3[]);
  19122. /**
  19123. * Returns the Curve3 stored array of successive Vector3
  19124. */
  19125. getPoints(): Vector3[];
  19126. /**
  19127. * Returns the computed length (float) of the curve.
  19128. */
  19129. length(): number;
  19130. /**
  19131. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  19132. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  19133. * curveA and curveB keep unchanged.
  19134. */
  19135. continue(curve: Curve3): Curve3;
  19136. private _computeLength;
  19137. }
  19138. class PositionNormalVertex {
  19139. position: Vector3;
  19140. normal: Vector3;
  19141. constructor(position?: Vector3, normal?: Vector3);
  19142. clone(): PositionNormalVertex;
  19143. }
  19144. class PositionNormalTextureVertex {
  19145. position: Vector3;
  19146. normal: Vector3;
  19147. uv: Vector2;
  19148. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  19149. clone(): PositionNormalTextureVertex;
  19150. }
  19151. class Tmp {
  19152. static Color3: Color3[];
  19153. static Color4: Color4[];
  19154. static Vector2: Vector2[];
  19155. static Vector3: Vector3[];
  19156. static Vector4: Vector4[];
  19157. static Quaternion: Quaternion[];
  19158. static Matrix: Matrix[];
  19159. }
  19160. }
  19161. declare module BABYLON {
  19162. /**
  19163. * Class representing spherical polynomial coefficients to the 3rd degree
  19164. */
  19165. class SphericalPolynomial {
  19166. /**
  19167. * The x coefficients of the spherical polynomial
  19168. */
  19169. x: Vector3;
  19170. /**
  19171. * The y coefficients of the spherical polynomial
  19172. */
  19173. y: Vector3;
  19174. /**
  19175. * The z coefficients of the spherical polynomial
  19176. */
  19177. z: Vector3;
  19178. /**
  19179. * The xx coefficients of the spherical polynomial
  19180. */
  19181. xx: Vector3;
  19182. /**
  19183. * The yy coefficients of the spherical polynomial
  19184. */
  19185. yy: Vector3;
  19186. /**
  19187. * The zz coefficients of the spherical polynomial
  19188. */
  19189. zz: Vector3;
  19190. /**
  19191. * The xy coefficients of the spherical polynomial
  19192. */
  19193. xy: Vector3;
  19194. /**
  19195. * The yz coefficients of the spherical polynomial
  19196. */
  19197. yz: Vector3;
  19198. /**
  19199. * The zx coefficients of the spherical polynomial
  19200. */
  19201. zx: Vector3;
  19202. /**
  19203. * Adds an ambient color to the spherical polynomial
  19204. * @param color the color to add
  19205. */
  19206. addAmbient(color: Color3): void;
  19207. /**
  19208. * Scales the spherical polynomial by the given amount
  19209. * @param scale the amount to scale
  19210. */
  19211. scale(scale: number): void;
  19212. /**
  19213. * Gets the spherical polynomial from harmonics
  19214. * @param harmonics the spherical harmonics
  19215. * @returns the spherical polynomial
  19216. */
  19217. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  19218. /**
  19219. * Constructs a spherical polynomial from an array.
  19220. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  19221. * @returns the spherical polynomial
  19222. */
  19223. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  19224. }
  19225. /**
  19226. * Class representing spherical harmonics coefficients to the 3rd degree
  19227. */
  19228. class SphericalHarmonics {
  19229. /**
  19230. * The l0,0 coefficients of the spherical harmonics
  19231. */
  19232. l00: Vector3;
  19233. /**
  19234. * The l1,-1 coefficients of the spherical harmonics
  19235. */
  19236. l1_1: Vector3;
  19237. /**
  19238. * The l1,0 coefficients of the spherical harmonics
  19239. */
  19240. l10: Vector3;
  19241. /**
  19242. * The l1,1 coefficients of the spherical harmonics
  19243. */
  19244. l11: Vector3;
  19245. /**
  19246. * The l2,-2 coefficients of the spherical harmonics
  19247. */
  19248. l2_2: Vector3;
  19249. /**
  19250. * The l2,-1 coefficients of the spherical harmonics
  19251. */
  19252. l2_1: Vector3;
  19253. /**
  19254. * The l2,0 coefficients of the spherical harmonics
  19255. */
  19256. l20: Vector3;
  19257. /**
  19258. * The l2,1 coefficients of the spherical harmonics
  19259. */
  19260. l21: Vector3;
  19261. /**
  19262. * The l2,2 coefficients of the spherical harmonics
  19263. */
  19264. lL22: Vector3;
  19265. /**
  19266. * Adds a light to the spherical harmonics
  19267. * @param direction the direction of the light
  19268. * @param color the color of the light
  19269. * @param deltaSolidAngle the delta solid angle of the light
  19270. */
  19271. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  19272. /**
  19273. * Scales the spherical harmonics by the given amount
  19274. * @param scale the amount to scale
  19275. */
  19276. scale(scale: number): void;
  19277. /**
  19278. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  19279. *
  19280. * ```
  19281. * E_lm = A_l * L_lm
  19282. * ```
  19283. *
  19284. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  19285. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  19286. * the scaling factors are given in equation 9.
  19287. */
  19288. convertIncidentRadianceToIrradiance(): void;
  19289. /**
  19290. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  19291. *
  19292. * ```
  19293. * L = (1/pi) * E * rho
  19294. * ```
  19295. *
  19296. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  19297. */
  19298. convertIrradianceToLambertianRadiance(): void;
  19299. /**
  19300. * Gets the spherical harmonics from polynomial
  19301. * @param polynomial the spherical polynomial
  19302. * @returns the spherical harmonics
  19303. */
  19304. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  19305. /**
  19306. * Constructs a spherical harmonics from an array.
  19307. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  19308. * @returns the spherical harmonics
  19309. */
  19310. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  19311. }
  19312. }
  19313. declare module BABYLON {
  19314. /**
  19315. * Class used to store all common mesh properties
  19316. */
  19317. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19318. /** No occlusion */
  19319. static OCCLUSION_TYPE_NONE: number;
  19320. /** Occlusion set to optimisitic */
  19321. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19322. /** Occlusion set to strict */
  19323. static OCCLUSION_TYPE_STRICT: number;
  19324. /** Use an accurante occlusion algorithm */
  19325. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19326. /** Use a conservative occlusion algorithm */
  19327. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19328. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19329. static readonly CULLINGSTRATEGY_STANDARD: number;
  19330. /** Culling strategy with bounding sphere only and then frustum culling */
  19331. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19332. /**
  19333. * No billboard
  19334. */
  19335. static readonly BILLBOARDMODE_NONE: number;
  19336. /** Billboard on X axis */
  19337. static readonly BILLBOARDMODE_X: number;
  19338. /** Billboard on Y axis */
  19339. static readonly BILLBOARDMODE_Y: number;
  19340. /** Billboard on Z axis */
  19341. static readonly BILLBOARDMODE_Z: number;
  19342. /** Billboard on all axes */
  19343. static readonly BILLBOARDMODE_ALL: number;
  19344. private _facetPositions;
  19345. private _facetNormals;
  19346. private _facetPartitioning;
  19347. private _facetNb;
  19348. private _partitioningSubdivisions;
  19349. private _partitioningBBoxRatio;
  19350. private _facetDataEnabled;
  19351. private _facetParameters;
  19352. private _bbSize;
  19353. private _subDiv;
  19354. private _facetDepthSort;
  19355. private _facetDepthSortEnabled;
  19356. private _depthSortedIndices;
  19357. private _depthSortedFacets;
  19358. private _facetDepthSortFunction;
  19359. private _facetDepthSortFrom;
  19360. private _facetDepthSortOrigin;
  19361. private _invertedMatrix;
  19362. /** Gets ot sets the culling strategy to use to find visible meshes */
  19363. cullingStrategy: number;
  19364. /**
  19365. * Gets the number of facets in the mesh
  19366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19367. */
  19368. readonly facetNb: number;
  19369. /**
  19370. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19372. */
  19373. partitioningSubdivisions: number;
  19374. /**
  19375. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19376. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19378. */
  19379. partitioningBBoxRatio: number;
  19380. /**
  19381. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19382. * Works only for updatable meshes.
  19383. * Doesn't work with multi-materials
  19384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19385. */
  19386. mustDepthSortFacets: boolean;
  19387. /**
  19388. * The location (Vector3) where the facet depth sort must be computed from.
  19389. * By default, the active camera position.
  19390. * Used only when facet depth sort is enabled
  19391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19392. */
  19393. facetDepthSortFrom: Vector3;
  19394. /**
  19395. * gets a boolean indicating if facetData is enabled
  19396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19397. */
  19398. readonly isFacetDataEnabled: boolean;
  19399. /** @hidden */
  19400. _updateNonUniformScalingState(value: boolean): boolean;
  19401. /**
  19402. * An event triggered when this mesh collides with another one
  19403. */
  19404. onCollideObservable: Observable<AbstractMesh>;
  19405. private _onCollideObserver;
  19406. /** Set a function to call when this mesh collides with another one */
  19407. onCollide: () => void;
  19408. /**
  19409. * An event triggered when the collision's position changes
  19410. */
  19411. onCollisionPositionChangeObservable: Observable<Vector3>;
  19412. private _onCollisionPositionChangeObserver;
  19413. /** Set a function to call when the collision's position changes */
  19414. onCollisionPositionChange: () => void;
  19415. /**
  19416. * An event triggered when material is changed
  19417. */
  19418. onMaterialChangedObservable: Observable<AbstractMesh>;
  19419. /**
  19420. * Gets or sets the orientation for POV movement & rotation
  19421. */
  19422. definedFacingForward: boolean;
  19423. /**
  19424. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19425. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19426. * * 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.
  19427. * @see http://doc.babylonjs.com/features/occlusionquery
  19428. */
  19429. occlusionQueryAlgorithmType: number;
  19430. /**
  19431. * 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:
  19432. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19433. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19434. * * 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.
  19435. * @see http://doc.babylonjs.com/features/occlusionquery
  19436. */
  19437. occlusionType: number;
  19438. /**
  19439. * 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.
  19440. * The default value is -1 which means don't break the query and wait till the result
  19441. * @see http://doc.babylonjs.com/features/occlusionquery
  19442. */
  19443. occlusionRetryCount: number;
  19444. /** @hidden */
  19445. _occlusionInternalRetryCounter: number;
  19446. /** @hidden */
  19447. _isOccluded: boolean;
  19448. /**
  19449. * 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
  19450. * @see http://doc.babylonjs.com/features/occlusionquery
  19451. */
  19452. isOccluded: boolean;
  19453. /** @hidden */
  19454. _isOcclusionQueryInProgress: boolean;
  19455. /**
  19456. * Flag to check the progress status of the query
  19457. * @see http://doc.babylonjs.com/features/occlusionquery
  19458. */
  19459. readonly isOcclusionQueryInProgress: boolean;
  19460. /** @hidden */
  19461. _occlusionQuery: Nullable<WebGLQuery>;
  19462. private _visibility;
  19463. /**
  19464. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19465. */
  19466. /**
  19467. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19468. */
  19469. visibility: number;
  19470. /** Gets or sets the alpha index used to sort transparent meshes
  19471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19472. */
  19473. alphaIndex: number;
  19474. /**
  19475. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19476. */
  19477. isVisible: boolean;
  19478. /**
  19479. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19480. */
  19481. isPickable: boolean;
  19482. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19483. showSubMeshesBoundingBox: boolean;
  19484. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19485. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19486. */
  19487. isBlocker: boolean;
  19488. /**
  19489. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19490. */
  19491. enablePointerMoveEvents: boolean;
  19492. /**
  19493. * Specifies the rendering group id for this mesh (0 by default)
  19494. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19495. */
  19496. renderingGroupId: number;
  19497. private _material;
  19498. /** Gets or sets current material */
  19499. material: Nullable<Material>;
  19500. private _receiveShadows;
  19501. /**
  19502. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19503. * @see http://doc.babylonjs.com/babylon101/shadows
  19504. */
  19505. receiveShadows: boolean;
  19506. /** Defines color to use when rendering outline */
  19507. outlineColor: Color3;
  19508. /** Define width to use when rendering outline */
  19509. outlineWidth: number;
  19510. /** Defines color to use when rendering overlay */
  19511. overlayColor: Color3;
  19512. /** Defines alpha to use when rendering overlay */
  19513. overlayAlpha: number;
  19514. private _hasVertexAlpha;
  19515. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19516. hasVertexAlpha: boolean;
  19517. private _useVertexColors;
  19518. /** 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) */
  19519. useVertexColors: boolean;
  19520. private _computeBonesUsingShaders;
  19521. /**
  19522. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19523. */
  19524. computeBonesUsingShaders: boolean;
  19525. private _numBoneInfluencers;
  19526. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19527. numBoneInfluencers: number;
  19528. private _applyFog;
  19529. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19530. applyFog: boolean;
  19531. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19532. useOctreeForRenderingSelection: boolean;
  19533. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19534. useOctreeForPicking: boolean;
  19535. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19536. useOctreeForCollisions: boolean;
  19537. private _layerMask;
  19538. /**
  19539. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19540. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19541. */
  19542. layerMask: number;
  19543. /**
  19544. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19545. */
  19546. alwaysSelectAsActiveMesh: boolean;
  19547. /**
  19548. * Gets or sets the current action manager
  19549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19550. */
  19551. actionManager: Nullable<ActionManager>;
  19552. /**
  19553. * Gets or sets impostor used for physic simulation
  19554. * @see http://doc.babylonjs.com/features/physics_engine
  19555. */
  19556. physicsImpostor: Nullable<PhysicsImpostor>;
  19557. private _checkCollisions;
  19558. private _collisionMask;
  19559. private _collisionGroup;
  19560. /**
  19561. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19562. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19563. */
  19564. ellipsoid: Vector3;
  19565. /**
  19566. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19568. */
  19569. ellipsoidOffset: Vector3;
  19570. private _collider;
  19571. private _oldPositionForCollisions;
  19572. private _diffPositionForCollisions;
  19573. /**
  19574. * Gets or sets a collision mask used to mask collisions (default is -1).
  19575. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19576. */
  19577. collisionMask: number;
  19578. /**
  19579. * Gets or sets the current collision group mask (-1 by default).
  19580. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19581. */
  19582. collisionGroup: number;
  19583. /**
  19584. * Defines edge width used when edgesRenderer is enabled
  19585. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19586. */
  19587. edgesWidth: number;
  19588. /**
  19589. * Defines edge color used when edgesRenderer is enabled
  19590. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19591. */
  19592. edgesColor: Color4;
  19593. /** @hidden */
  19594. _edgesRenderer: Nullable<IEdgesRenderer>;
  19595. private _collisionsTransformMatrix;
  19596. private _collisionsScalingMatrix;
  19597. /** @hidden */
  19598. _masterMesh: Nullable<AbstractMesh>;
  19599. /** @hidden */
  19600. _boundingInfo: Nullable<BoundingInfo>;
  19601. /** @hidden */
  19602. _renderId: number;
  19603. /**
  19604. * Gets or sets the list of subMeshes
  19605. * @see http://doc.babylonjs.com/how_to/multi_materials
  19606. */
  19607. subMeshes: SubMesh[];
  19608. /** @hidden */
  19609. _submeshesOctree: Octree<SubMesh>;
  19610. /** @hidden */
  19611. _intersectionsInProgress: AbstractMesh[];
  19612. /** @hidden */
  19613. _unIndexed: boolean;
  19614. /** @hidden */
  19615. _lightSources: Light[];
  19616. /** @hidden */
  19617. readonly _positions: Nullable<Vector3[]>;
  19618. /** @hidden */
  19619. _waitingActions: any;
  19620. /** @hidden */
  19621. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19622. private _skeleton;
  19623. /** @hidden */
  19624. _bonesTransformMatrices: Nullable<Float32Array>;
  19625. /**
  19626. * Gets or sets a skeleton to apply skining transformations
  19627. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19628. */
  19629. skeleton: Nullable<Skeleton>;
  19630. /**
  19631. * An event triggered when the mesh is rebuilt.
  19632. */
  19633. onRebuildObservable: Observable<AbstractMesh>;
  19634. /**
  19635. * Creates a new AbstractMesh
  19636. * @param name defines the name of the mesh
  19637. * @param scene defines the hosting scene
  19638. */
  19639. constructor(name: string, scene?: Nullable<Scene>);
  19640. /**
  19641. * Returns the string "AbstractMesh"
  19642. * @returns "AbstractMesh"
  19643. */
  19644. getClassName(): string;
  19645. /**
  19646. * Gets a string representation of the current mesh
  19647. * @param fullDetails defines a boolean indicating if full details must be included
  19648. * @returns a string representation of the current mesh
  19649. */
  19650. toString(fullDetails?: boolean): string;
  19651. /** @hidden */
  19652. _rebuild(): void;
  19653. /** @hidden */
  19654. _resyncLightSources(): void;
  19655. /** @hidden */
  19656. _resyncLighSource(light: Light): void;
  19657. /** @hidden */
  19658. _unBindEffect(): void;
  19659. /** @hidden */
  19660. _removeLightSource(light: Light): void;
  19661. private _markSubMeshesAsDirty;
  19662. /** @hidden */
  19663. _markSubMeshesAsLightDirty(): void;
  19664. /** @hidden */
  19665. _markSubMeshesAsAttributesDirty(): void;
  19666. /** @hidden */
  19667. _markSubMeshesAsMiscDirty(): void;
  19668. /**
  19669. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19670. */
  19671. scaling: Vector3;
  19672. /**
  19673. * Returns true if the mesh is blocked. Implemented by child classes
  19674. */
  19675. readonly isBlocked: boolean;
  19676. /**
  19677. * Returns the mesh itself by default. Implemented by child classes
  19678. * @param camera defines the camera to use to pick the right LOD level
  19679. * @returns the currentAbstractMesh
  19680. */
  19681. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19682. /**
  19683. * Returns 0 by default. Implemented by child classes
  19684. * @returns an integer
  19685. */
  19686. getTotalVertices(): number;
  19687. /**
  19688. * Returns null by default. Implemented by child classes
  19689. * @returns null
  19690. */
  19691. getIndices(): Nullable<IndicesArray>;
  19692. /**
  19693. * Returns the array of the requested vertex data kind. Implemented by child classes
  19694. * @param kind defines the vertex data kind to use
  19695. * @returns null
  19696. */
  19697. getVerticesData(kind: string): Nullable<FloatArray>;
  19698. /**
  19699. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19700. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19701. * Note that a new underlying VertexBuffer object is created each call.
  19702. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19703. * @param kind defines vertex data kind:
  19704. * * BABYLON.VertexBuffer.PositionKind
  19705. * * BABYLON.VertexBuffer.UVKind
  19706. * * BABYLON.VertexBuffer.UV2Kind
  19707. * * BABYLON.VertexBuffer.UV3Kind
  19708. * * BABYLON.VertexBuffer.UV4Kind
  19709. * * BABYLON.VertexBuffer.UV5Kind
  19710. * * BABYLON.VertexBuffer.UV6Kind
  19711. * * BABYLON.VertexBuffer.ColorKind
  19712. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19713. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19714. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19715. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19716. * @param data defines the data source
  19717. * @param updatable defines if the data must be flagged as updatable (or static)
  19718. * @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
  19719. * @returns the current mesh
  19720. */
  19721. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19722. /**
  19723. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19724. * If the mesh has no geometry, it is simply returned as it is.
  19725. * @param kind defines vertex data kind:
  19726. * * BABYLON.VertexBuffer.PositionKind
  19727. * * BABYLON.VertexBuffer.UVKind
  19728. * * BABYLON.VertexBuffer.UV2Kind
  19729. * * BABYLON.VertexBuffer.UV3Kind
  19730. * * BABYLON.VertexBuffer.UV4Kind
  19731. * * BABYLON.VertexBuffer.UV5Kind
  19732. * * BABYLON.VertexBuffer.UV6Kind
  19733. * * BABYLON.VertexBuffer.ColorKind
  19734. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19735. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19736. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19737. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19738. * @param data defines the data source
  19739. * @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
  19740. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19741. * @returns the current mesh
  19742. */
  19743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19744. /**
  19745. * Sets the mesh indices,
  19746. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19747. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19748. * @param totalVertices Defines the total number of vertices
  19749. * @returns the current mesh
  19750. */
  19751. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19752. /**
  19753. * Gets a boolean indicating if specific vertex data is present
  19754. * @param kind defines the vertex data kind to use
  19755. * @returns true is data kind is present
  19756. */
  19757. isVerticesDataPresent(kind: string): boolean;
  19758. /**
  19759. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19760. * @returns a BoundingInfo
  19761. */
  19762. getBoundingInfo(): BoundingInfo;
  19763. /**
  19764. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19765. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19766. * @returns the current mesh
  19767. */
  19768. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19769. /**
  19770. * Overwrite the current bounding info
  19771. * @param boundingInfo defines the new bounding info
  19772. * @returns the current mesh
  19773. */
  19774. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19775. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19776. readonly useBones: boolean;
  19777. /** @hidden */
  19778. _preActivate(): void;
  19779. /** @hidden */
  19780. _preActivateForIntermediateRendering(renderId: number): void;
  19781. /** @hidden */
  19782. _activate(renderId: number): void;
  19783. /**
  19784. * Gets the current world matrix
  19785. * @returns a Matrix
  19786. */
  19787. getWorldMatrix(): Matrix;
  19788. /** @hidden */
  19789. _getWorldMatrixDeterminant(): number;
  19790. /**
  19791. * Perform relative position change from the point of view of behind the front of the mesh.
  19792. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19793. * Supports definition of mesh facing forward or backward
  19794. * @param amountRight defines the distance on the right axis
  19795. * @param amountUp defines the distance on the up axis
  19796. * @param amountForward defines the distance on the forward axis
  19797. * @returns the current mesh
  19798. */
  19799. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19800. /**
  19801. * Calculate relative position change from the point of view of behind the front of the mesh.
  19802. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19803. * Supports definition of mesh facing forward or backward
  19804. * @param amountRight defines the distance on the right axis
  19805. * @param amountUp defines the distance on the up axis
  19806. * @param amountForward defines the distance on the forward axis
  19807. * @returns the new displacement vector
  19808. */
  19809. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19810. /**
  19811. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19812. * Supports definition of mesh facing forward or backward
  19813. * @param flipBack defines the flip
  19814. * @param twirlClockwise defines the twirl
  19815. * @param tiltRight defines the tilt
  19816. * @returns the current mesh
  19817. */
  19818. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19819. /**
  19820. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19821. * Supports definition of mesh facing forward or backward.
  19822. * @param flipBack defines the flip
  19823. * @param twirlClockwise defines the twirl
  19824. * @param tiltRight defines the tilt
  19825. * @returns the new rotation vector
  19826. */
  19827. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19828. /**
  19829. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19830. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19831. * @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
  19832. * @returns the new bounding vectors
  19833. */
  19834. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19835. min: Vector3;
  19836. max: Vector3;
  19837. };
  19838. /** @hidden */
  19839. _updateBoundingInfo(): AbstractMesh;
  19840. /** @hidden */
  19841. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19842. /** @hidden */
  19843. protected _afterComputeWorldMatrix(): void;
  19844. /**
  19845. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19846. * A mesh is in the frustum if its bounding box intersects the frustum
  19847. * @param frustumPlanes defines the frustum to test
  19848. * @returns true if the mesh is in the frustum planes
  19849. */
  19850. isInFrustum(frustumPlanes: Plane[]): boolean;
  19851. /**
  19852. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19853. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19854. * @param frustumPlanes defines the frustum to test
  19855. * @returns true if the mesh is completely in the frustum planes
  19856. */
  19857. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19858. /**
  19859. * True if the mesh intersects another mesh or a SolidParticle object
  19860. * @param mesh defines a target mesh or SolidParticle to test
  19861. * @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)
  19862. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19863. * @returns true if there is an intersection
  19864. */
  19865. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19866. /**
  19867. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19868. * @param point defines the point to test
  19869. * @returns true if there is an intersection
  19870. */
  19871. intersectsPoint(point: Vector3): boolean;
  19872. /**
  19873. * Gets the current physics impostor
  19874. * @see http://doc.babylonjs.com/features/physics_engine
  19875. * @returns a physics impostor or null
  19876. */
  19877. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19878. /**
  19879. * Gets the position of the current mesh in camera space
  19880. * @param camera defines the camera to use
  19881. * @returns a position
  19882. */
  19883. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19884. /**
  19885. * Returns the distance from the mesh to the active camera
  19886. * @param camera defines the camera to use
  19887. * @returns the distance
  19888. */
  19889. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19890. /**
  19891. * Apply a physic impulse to the mesh
  19892. * @param force defines the force to apply
  19893. * @param contactPoint defines where to apply the force
  19894. * @returns the current mesh
  19895. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19896. */
  19897. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19898. /**
  19899. * Creates a physic joint between two meshes
  19900. * @param otherMesh defines the other mesh to use
  19901. * @param pivot1 defines the pivot to use on this mesh
  19902. * @param pivot2 defines the pivot to use on the other mesh
  19903. * @param options defines additional options (can be plugin dependent)
  19904. * @returns the current mesh
  19905. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19906. */
  19907. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19908. /**
  19909. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19910. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19911. */
  19912. checkCollisions: boolean;
  19913. /**
  19914. * Gets Collider object used to compute collisions (not physics)
  19915. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19916. */
  19917. readonly collider: Collider;
  19918. /**
  19919. * Move the mesh using collision engine
  19920. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19921. * @param displacement defines the requested displacement vector
  19922. * @returns the current mesh
  19923. */
  19924. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19925. private _onCollisionPositionChange;
  19926. /**
  19927. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19928. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19929. * @param maxCapacity defines the maximum size of each block (64 by default)
  19930. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19931. * @returns the new octree
  19932. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19934. */
  19935. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19936. /** @hidden */
  19937. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19938. /** @hidden */
  19939. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19940. /** @hidden */
  19941. _checkCollision(collider: Collider): AbstractMesh;
  19942. /** @hidden */
  19943. _generatePointsArray(): boolean;
  19944. /**
  19945. * Checks if the passed Ray intersects with the mesh
  19946. * @param ray defines the ray to use
  19947. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19948. * @returns the picking info
  19949. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19950. */
  19951. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19952. /**
  19953. * Clones the current mesh
  19954. * @param name defines the mesh name
  19955. * @param newParent defines the new mesh parent
  19956. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19957. * @returns the new mesh
  19958. */
  19959. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19960. /**
  19961. * Disposes all the submeshes of the current meshnp
  19962. * @returns the current mesh
  19963. */
  19964. releaseSubMeshes(): AbstractMesh;
  19965. /**
  19966. * Releases resources associated with this abstract mesh.
  19967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19969. */
  19970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19971. /**
  19972. * Adds the passed mesh as a child to the current mesh
  19973. * @param mesh defines the child mesh
  19974. * @returns the current mesh
  19975. */
  19976. addChild(mesh: AbstractMesh): AbstractMesh;
  19977. /**
  19978. * Removes the passed mesh from the current mesh children list
  19979. * @param mesh defines the child mesh
  19980. * @returns the current mesh
  19981. */
  19982. removeChild(mesh: AbstractMesh): AbstractMesh;
  19983. /** @hidden */
  19984. private _initFacetData;
  19985. /**
  19986. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19987. * This method can be called within the render loop.
  19988. * 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
  19989. * @returns the current mesh
  19990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19991. */
  19992. updateFacetData(): AbstractMesh;
  19993. /**
  19994. * Returns the facetLocalNormals array.
  19995. * The normals are expressed in the mesh local spac
  19996. * @returns an array of Vector3
  19997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19998. */
  19999. getFacetLocalNormals(): Vector3[];
  20000. /**
  20001. * Returns the facetLocalPositions array.
  20002. * The facet positions are expressed in the mesh local space
  20003. * @returns an array of Vector3
  20004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20005. */
  20006. getFacetLocalPositions(): Vector3[];
  20007. /**
  20008. * Returns the facetLocalPartioning array
  20009. * @returns an array of array of numbers
  20010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20011. */
  20012. getFacetLocalPartitioning(): number[][];
  20013. /**
  20014. * Returns the i-th facet position in the world system.
  20015. * This method allocates a new Vector3 per call
  20016. * @param i defines the facet index
  20017. * @returns a new Vector3
  20018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20019. */
  20020. getFacetPosition(i: number): Vector3;
  20021. /**
  20022. * Sets the reference Vector3 with the i-th facet position in the world system
  20023. * @param i defines the facet index
  20024. * @param ref defines the target vector
  20025. * @returns the current mesh
  20026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20027. */
  20028. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20029. /**
  20030. * Returns the i-th facet normal in the world system.
  20031. * This method allocates a new Vector3 per call
  20032. * @param i defines the facet index
  20033. * @returns a new Vector3
  20034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20035. */
  20036. getFacetNormal(i: number): Vector3;
  20037. /**
  20038. * Sets the reference Vector3 with the i-th facet normal in the world system
  20039. * @param i defines the facet index
  20040. * @param ref defines the target vector
  20041. * @returns the current mesh
  20042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20043. */
  20044. getFacetNormalToRef(i: number, ref: Vector3): this;
  20045. /**
  20046. * 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)
  20047. * @param x defines x coordinate
  20048. * @param y defines y coordinate
  20049. * @param z defines z coordinate
  20050. * @returns the array of facet indexes
  20051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20052. */
  20053. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20054. /**
  20055. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20056. * @param projected sets as the (x,y,z) world projection on the facet
  20057. * @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
  20058. * @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
  20059. * @param x defines x coordinate
  20060. * @param y defines y coordinate
  20061. * @param z defines z coordinate
  20062. * @returns the face index if found (or null instead)
  20063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20064. */
  20065. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20066. /**
  20067. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20068. * @param projected sets as the (x,y,z) local projection on the facet
  20069. * @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
  20070. * @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
  20071. * @param x defines x coordinate
  20072. * @param y defines y coordinate
  20073. * @param z defines z coordinate
  20074. * @returns the face index if found (or null instead)
  20075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20076. */
  20077. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20078. /**
  20079. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20080. * @returns the parameters
  20081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20082. */
  20083. getFacetDataParameters(): any;
  20084. /**
  20085. * Disables the feature FacetData and frees the related memory
  20086. * @returns the current mesh
  20087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20088. */
  20089. disableFacetData(): AbstractMesh;
  20090. /**
  20091. * Updates the AbstractMesh indices array
  20092. * @param indices defines the data source
  20093. * @returns the current mesh
  20094. */
  20095. updateIndices(indices: IndicesArray): AbstractMesh;
  20096. /**
  20097. * Creates new normals data for the mesh
  20098. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20099. * @returns the current mesh
  20100. */
  20101. createNormals(updatable: boolean): AbstractMesh;
  20102. /**
  20103. * Align the mesh with a normal
  20104. * @param normal defines the normal to use
  20105. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20106. * @returns the current mesh
  20107. */
  20108. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20109. /** @hidden */
  20110. _checkOcclusionQuery(): void;
  20111. }
  20112. }
  20113. declare module BABYLON {
  20114. class Buffer {
  20115. private _engine;
  20116. private _buffer;
  20117. /** @hidden */
  20118. _data: Nullable<DataArray>;
  20119. private _updatable;
  20120. private _instanced;
  20121. /**
  20122. * Gets the byte stride.
  20123. */
  20124. readonly byteStride: number;
  20125. /**
  20126. * Constructor
  20127. * @param engine the engine
  20128. * @param data the data to use for this buffer
  20129. * @param updatable whether the data is updatable
  20130. * @param stride the stride (optional)
  20131. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20132. * @param instanced whether the buffer is instanced (optional)
  20133. * @param useBytes set to true if the stride in in bytes (optional)
  20134. */
  20135. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20136. /**
  20137. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20138. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20139. * @param offset defines offset in the buffer (0 by default)
  20140. * @param size defines the size in floats of attributes (position is 3 for instance)
  20141. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20142. * @param instanced defines if the vertex buffer contains indexed data
  20143. * @param useBytes defines if the offset and stride are in bytes
  20144. * @returns the new vertex buffer
  20145. */
  20146. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20147. isUpdatable(): boolean;
  20148. getData(): Nullable<DataArray>;
  20149. getBuffer(): Nullable<WebGLBuffer>;
  20150. /**
  20151. * Gets the stride in float32 units (i.e. byte stride / 4).
  20152. * May not be an integer if the byte stride is not divisible by 4.
  20153. * DEPRECATED. Use byteStride instead.
  20154. * @returns the stride in float32 units
  20155. */
  20156. getStrideSize(): number;
  20157. create(data?: Nullable<DataArray>): void;
  20158. /** @hidden */
  20159. _rebuild(): void;
  20160. update(data: DataArray): void;
  20161. /**
  20162. * Updates the data directly.
  20163. * @param data the new data
  20164. * @param offset the new offset
  20165. * @param vertexCount the vertex count (optional)
  20166. * @param useBytes set to true if the offset is in bytes
  20167. */
  20168. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20169. dispose(): void;
  20170. }
  20171. }
  20172. declare module BABYLON {
  20173. class CSG {
  20174. private polygons;
  20175. matrix: Matrix;
  20176. position: Vector3;
  20177. rotation: Vector3;
  20178. rotationQuaternion: Nullable<Quaternion>;
  20179. scaling: Vector3;
  20180. static FromMesh(mesh: Mesh): CSG;
  20181. private static FromPolygons;
  20182. clone(): CSG;
  20183. union(csg: CSG): CSG;
  20184. unionInPlace(csg: CSG): void;
  20185. subtract(csg: CSG): CSG;
  20186. subtractInPlace(csg: CSG): void;
  20187. intersect(csg: CSG): CSG;
  20188. intersectInPlace(csg: CSG): void;
  20189. inverse(): CSG;
  20190. inverseInPlace(): void;
  20191. copyTransformAttributes(csg: CSG): CSG;
  20192. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20193. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20194. }
  20195. }
  20196. declare module BABYLON {
  20197. /**
  20198. * Class used to store geometry data (vertex buffers + index buffer)
  20199. */
  20200. class Geometry implements IGetSetVerticesData {
  20201. /**
  20202. * Gets or sets the unique ID of the geometry
  20203. */
  20204. id: string;
  20205. /**
  20206. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20207. */
  20208. delayLoadState: number;
  20209. /**
  20210. * Gets the file containing the data to load when running in delay load state
  20211. */
  20212. delayLoadingFile: Nullable<string>;
  20213. /**
  20214. * Callback called when the geometry is updated
  20215. */
  20216. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20217. private _scene;
  20218. private _engine;
  20219. private _meshes;
  20220. private _totalVertices;
  20221. /** @hidden */
  20222. _indices: IndicesArray;
  20223. /** @hidden */
  20224. _vertexBuffers: {
  20225. [key: string]: VertexBuffer;
  20226. };
  20227. private _isDisposed;
  20228. private _extend;
  20229. private _boundingBias;
  20230. /** @hidden */
  20231. _delayInfo: Array<string>;
  20232. private _indexBuffer;
  20233. private _indexBufferIsUpdatable;
  20234. /** @hidden */
  20235. _boundingInfo: Nullable<BoundingInfo>;
  20236. /** @hidden */
  20237. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20238. /** @hidden */
  20239. _softwareSkinningRenderId: number;
  20240. private _vertexArrayObjects;
  20241. private _updatable;
  20242. /** @hidden */
  20243. _positions: Nullable<Vector3[]>;
  20244. /**
  20245. * 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
  20246. */
  20247. /**
  20248. * 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
  20249. */
  20250. boundingBias: Vector2;
  20251. /**
  20252. * Static function used to attach a new empty geometry to a mesh
  20253. * @param mesh defines the mesh to attach the geometry to
  20254. * @returns the new {BABYLON.Geometry}
  20255. */
  20256. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20257. /**
  20258. * Creates a new geometry
  20259. * @param id defines the unique ID
  20260. * @param scene defines the hosting scene
  20261. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20262. * @param updatable defines if geometry must be updatable (false by default)
  20263. * @param mesh defines the mesh that will be associated with the geometry
  20264. */
  20265. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20266. /**
  20267. * Gets the current extend of the geometry
  20268. */
  20269. readonly extend: {
  20270. minimum: Vector3;
  20271. maximum: Vector3;
  20272. };
  20273. /**
  20274. * Gets the hosting scene
  20275. * @returns the hosting {BABYLON.Scene}
  20276. */
  20277. getScene(): Scene;
  20278. /**
  20279. * Gets the hosting engine
  20280. * @returns the hosting {BABYLON.Engine}
  20281. */
  20282. getEngine(): Engine;
  20283. /**
  20284. * Defines if the geometry is ready to use
  20285. * @returns true if the geometry is ready to be used
  20286. */
  20287. isReady(): boolean;
  20288. /**
  20289. * Gets a value indicating that the geometry should not be serialized
  20290. */
  20291. readonly doNotSerialize: boolean;
  20292. /** @hidden */
  20293. _rebuild(): void;
  20294. /**
  20295. * Affects all geometry data in one call
  20296. * @param vertexData defines the geometry data
  20297. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20298. */
  20299. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20300. /**
  20301. * Set specific vertex data
  20302. * @param kind defines the data kind (Position, normal, etc...)
  20303. * @param data defines the vertex data to use
  20304. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20305. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20306. */
  20307. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20308. /**
  20309. * Removes a specific vertex data
  20310. * @param kind defines the data kind (Position, normal, etc...)
  20311. */
  20312. removeVerticesData(kind: string): void;
  20313. /**
  20314. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20315. * @param buffer defines the vertex buffer to use
  20316. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20317. */
  20318. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20319. /**
  20320. * Update a specific vertex buffer
  20321. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20322. * It will do nothing if the buffer is not updatable
  20323. * @param kind defines the data kind (Position, normal, etc...)
  20324. * @param data defines the data to use
  20325. * @param offset defines the offset in the target buffer where to store the data
  20326. * @param useBytes set to true if the offset is in bytes
  20327. */
  20328. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20329. /**
  20330. * Update a specific vertex buffer
  20331. * This function will create a new buffer if the current one is not updatable
  20332. * @param kind defines the data kind (Position, normal, etc...)
  20333. * @param data defines the data to use
  20334. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20335. */
  20336. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20337. private _updateBoundingInfo;
  20338. /** @hidden */
  20339. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20340. /**
  20341. * Gets total number of vertices
  20342. * @returns the total number of vertices
  20343. */
  20344. getTotalVertices(): number;
  20345. /**
  20346. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20347. * @param kind defines the data kind (Position, normal, etc...)
  20348. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20349. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20350. * @returns a float array containing vertex data
  20351. */
  20352. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20353. /**
  20354. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20355. * @param kind defines the data kind (Position, normal, etc...)
  20356. * @returns true if the vertex buffer with the specified kind is updatable
  20357. */
  20358. isVertexBufferUpdatable(kind: string): boolean;
  20359. /**
  20360. * Gets a specific vertex buffer
  20361. * @param kind defines the data kind (Position, normal, etc...)
  20362. * @returns a {BABYLON.VertexBuffer}
  20363. */
  20364. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20365. /**
  20366. * Returns all vertex buffers
  20367. * @return an object holding all vertex buffers indexed by kind
  20368. */
  20369. getVertexBuffers(): Nullable<{
  20370. [key: string]: VertexBuffer;
  20371. }>;
  20372. /**
  20373. * Gets a boolean indicating if specific vertex buffer is present
  20374. * @param kind defines the data kind (Position, normal, etc...)
  20375. * @returns true if data is present
  20376. */
  20377. isVerticesDataPresent(kind: string): boolean;
  20378. /**
  20379. * Gets a list of all attached data kinds (Position, normal, etc...)
  20380. * @returns a list of string containing all kinds
  20381. */
  20382. getVerticesDataKinds(): string[];
  20383. /**
  20384. * Update index buffer
  20385. * @param indices defines the indices to store in the index buffer
  20386. * @param offset defines the offset in the target buffer where to store the data
  20387. */
  20388. updateIndices(indices: IndicesArray, offset?: number): void;
  20389. /**
  20390. * Creates a new index buffer
  20391. * @param indices defines the indices to store in the index buffer
  20392. * @param totalVertices defines the total number of vertices (could be null)
  20393. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20394. */
  20395. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20396. /**
  20397. * Return the total number of indices
  20398. * @returns the total number of indices
  20399. */
  20400. getTotalIndices(): number;
  20401. /**
  20402. * Gets the index buffer array
  20403. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20404. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20405. * @returns the index buffer array
  20406. */
  20407. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20408. /**
  20409. * Gets the index buffer
  20410. * @return the index buffer
  20411. */
  20412. getIndexBuffer(): Nullable<WebGLBuffer>;
  20413. /** @hidden */
  20414. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20415. /**
  20416. * Release the associated resources for a specific mesh
  20417. * @param mesh defines the source mesh
  20418. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20419. */
  20420. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20421. /**
  20422. * Apply current geometry to a given mesh
  20423. * @param mesh defines the mesh to apply geometry to
  20424. */
  20425. applyToMesh(mesh: Mesh): void;
  20426. private _updateExtend;
  20427. private _applyToMesh;
  20428. private notifyUpdate;
  20429. /**
  20430. * Load the geometry if it was flagged as delay loaded
  20431. * @param scene defines the hosting scene
  20432. * @param onLoaded defines a callback called when the geometry is loaded
  20433. */
  20434. load(scene: Scene, onLoaded?: () => void): void;
  20435. private _queueLoad;
  20436. /**
  20437. * Invert the geometry to move from a right handed system to a left handed one.
  20438. */
  20439. toLeftHanded(): void;
  20440. /** @hidden */
  20441. _resetPointsArrayCache(): void;
  20442. /** @hidden */
  20443. _generatePointsArray(): boolean;
  20444. /**
  20445. * Gets a value indicating if the geometry is disposed
  20446. * @returns true if the geometry was disposed
  20447. */
  20448. isDisposed(): boolean;
  20449. private _disposeVertexArrayObjects;
  20450. /**
  20451. * Free all associated resources
  20452. */
  20453. dispose(): void;
  20454. /**
  20455. * Clone the current geometry into a new geometry
  20456. * @param id defines the unique ID of the new geometry
  20457. * @returns a new geometry object
  20458. */
  20459. copy(id: string): Geometry;
  20460. /**
  20461. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20462. * @return a JSON representation of the current geometry data (without the vertices data)
  20463. */
  20464. serialize(): any;
  20465. private toNumberArray;
  20466. /**
  20467. * Serialize all vertices data into a JSON oject
  20468. * @returns a JSON representation of the current geometry data
  20469. */
  20470. serializeVerticeData(): any;
  20471. /**
  20472. * Extracts a clone of a mesh geometry
  20473. * @param mesh defines the source mesh
  20474. * @param id defines the unique ID of the new geometry object
  20475. * @returns the new geometry object
  20476. */
  20477. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20478. /**
  20479. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20480. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20481. * Be aware Math.random() could cause collisions, but:
  20482. * "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"
  20483. * @returns a string containing a new GUID
  20484. */
  20485. static RandomId(): string;
  20486. /** @hidden */
  20487. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20488. private static _CleanMatricesWeights;
  20489. /**
  20490. * Create a new geometry from persisted data (Using .babylon file format)
  20491. * @param parsedVertexData defines the persisted data
  20492. * @param scene defines the hosting scene
  20493. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20494. * @returns the new geometry object
  20495. */
  20496. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20497. }
  20498. /**
  20499. * Abstract class used to provide common services for all typed geometries
  20500. * @hidden
  20501. */
  20502. class _PrimitiveGeometry extends Geometry {
  20503. private _canBeRegenerated;
  20504. private _beingRegenerated;
  20505. /**
  20506. * Creates a new typed geometry
  20507. * @param id defines the unique ID of the geometry
  20508. * @param scene defines the hosting scene
  20509. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20510. * @param mesh defines the hosting mesh (can be null)
  20511. */
  20512. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20513. /**
  20514. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20515. * @returns true if the geometry can be regenerated
  20516. */
  20517. canBeRegenerated(): boolean;
  20518. /**
  20519. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20520. */
  20521. regenerate(): void;
  20522. /**
  20523. * Clone the geometry
  20524. * @param id defines the unique ID of the new geometry
  20525. * @returns the new geometry
  20526. */
  20527. asNewGeometry(id: string): Geometry;
  20528. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20529. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20530. /** @hidden */
  20531. _regenerateVertexData(): VertexData;
  20532. copy(id: string): Geometry;
  20533. serialize(): any;
  20534. }
  20535. /**
  20536. * Creates a ribbon geometry
  20537. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20538. */
  20539. class RibbonGeometry extends _PrimitiveGeometry {
  20540. /**
  20541. * Defines the array of paths to use
  20542. */
  20543. pathArray: Vector3[][];
  20544. /**
  20545. * Defines if the last and first points of each path in your pathArray must be joined
  20546. */
  20547. closeArray: boolean;
  20548. /**
  20549. * Defines if the last and first points of each path in your pathArray must be joined
  20550. */
  20551. closePath: boolean;
  20552. /**
  20553. * Defines the offset between points
  20554. */
  20555. offset: number;
  20556. /**
  20557. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20558. */
  20559. side: number;
  20560. /**
  20561. * Creates a ribbon geometry
  20562. * @param id defines the unique ID of the geometry
  20563. * @param scene defines the hosting scene
  20564. * @param pathArray defines the array of paths to use
  20565. * @param closeArray defines if the last path and the first path must be joined
  20566. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20567. * @param offset defines the offset between points
  20568. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20569. * @param mesh defines the hosting mesh (can be null)
  20570. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20571. */
  20572. constructor(id: string, scene: Scene,
  20573. /**
  20574. * Defines the array of paths to use
  20575. */
  20576. pathArray: Vector3[][],
  20577. /**
  20578. * Defines if the last and first points of each path in your pathArray must be joined
  20579. */
  20580. closeArray: boolean,
  20581. /**
  20582. * Defines if the last and first points of each path in your pathArray must be joined
  20583. */
  20584. closePath: boolean,
  20585. /**
  20586. * Defines the offset between points
  20587. */
  20588. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20589. /**
  20590. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20591. */
  20592. side?: number);
  20593. /** @hidden */
  20594. _regenerateVertexData(): VertexData;
  20595. copy(id: string): Geometry;
  20596. }
  20597. /**
  20598. * Creates a box geometry
  20599. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20600. */
  20601. class BoxGeometry extends _PrimitiveGeometry {
  20602. /**
  20603. * Defines the zise of the box (width, height and depth are the same)
  20604. */
  20605. size: number;
  20606. /**
  20607. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20608. */
  20609. side: number;
  20610. /**
  20611. * Creates a box geometry
  20612. * @param id defines the unique ID of the geometry
  20613. * @param scene defines the hosting scene
  20614. * @param size defines the zise of the box (width, height and depth are the same)
  20615. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20616. * @param mesh defines the hosting mesh (can be null)
  20617. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20618. */
  20619. constructor(id: string, scene: Scene,
  20620. /**
  20621. * Defines the zise of the box (width, height and depth are the same)
  20622. */
  20623. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20624. /**
  20625. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20626. */
  20627. side?: number);
  20628. /** @hidden */
  20629. _regenerateVertexData(): VertexData;
  20630. copy(id: string): Geometry;
  20631. serialize(): any;
  20632. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20633. }
  20634. /**
  20635. * Creates a sphere geometry
  20636. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20637. */
  20638. class SphereGeometry extends _PrimitiveGeometry {
  20639. /**
  20640. * Defines the number of segments to use to create the sphere
  20641. */
  20642. segments: number;
  20643. /**
  20644. * Defines the diameter of the sphere
  20645. */
  20646. diameter: number;
  20647. /**
  20648. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20649. */
  20650. side: number;
  20651. /**
  20652. * Create a new sphere geometry
  20653. * @param id defines the unique ID of the geometry
  20654. * @param scene defines the hosting scene
  20655. * @param segments defines the number of segments to use to create the sphere
  20656. * @param diameter defines the diameter of the sphere
  20657. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20658. * @param mesh defines the hosting mesh (can be null)
  20659. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20660. */
  20661. constructor(id: string, scene: Scene,
  20662. /**
  20663. * Defines the number of segments to use to create the sphere
  20664. */
  20665. segments: number,
  20666. /**
  20667. * Defines the diameter of the sphere
  20668. */
  20669. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20670. /**
  20671. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20672. */
  20673. side?: number);
  20674. /** @hidden */
  20675. _regenerateVertexData(): VertexData;
  20676. copy(id: string): Geometry;
  20677. serialize(): any;
  20678. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20679. }
  20680. /**
  20681. * Creates a disc geometry
  20682. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20683. */
  20684. class DiscGeometry extends _PrimitiveGeometry {
  20685. /**
  20686. * Defines the radius of the disc
  20687. */
  20688. radius: number;
  20689. /**
  20690. * Defines the tesselation factor to apply to the disc
  20691. */
  20692. tessellation: number;
  20693. /**
  20694. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20695. */
  20696. side: number;
  20697. /**
  20698. * Creates a new disc geometry
  20699. * @param id defines the unique ID of the geometry
  20700. * @param scene defines the hosting scene
  20701. * @param radius defines the radius of the disc
  20702. * @param tessellation defines the tesselation factor to apply to the disc
  20703. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20704. * @param mesh defines the hosting mesh (can be null)
  20705. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20706. */
  20707. constructor(id: string, scene: Scene,
  20708. /**
  20709. * Defines the radius of the disc
  20710. */
  20711. radius: number,
  20712. /**
  20713. * Defines the tesselation factor to apply to the disc
  20714. */
  20715. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20716. /**
  20717. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20718. */
  20719. side?: number);
  20720. /** @hidden */
  20721. _regenerateVertexData(): VertexData;
  20722. copy(id: string): Geometry;
  20723. }
  20724. /**
  20725. * Creates a new cylinder geometry
  20726. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20727. */
  20728. class CylinderGeometry extends _PrimitiveGeometry {
  20729. /**
  20730. * Defines the height of the cylinder
  20731. */
  20732. height: number;
  20733. /**
  20734. * Defines the diameter of the cylinder's top cap
  20735. */
  20736. diameterTop: number;
  20737. /**
  20738. * Defines the diameter of the cylinder's bottom cap
  20739. */
  20740. diameterBottom: number;
  20741. /**
  20742. * Defines the tessellation factor to apply to the cylinder
  20743. */
  20744. tessellation: number;
  20745. /**
  20746. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20747. */
  20748. subdivisions: number;
  20749. /**
  20750. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20751. */
  20752. side: number;
  20753. /**
  20754. * Creates a new cylinder geometry
  20755. * @param id defines the unique ID of the geometry
  20756. * @param scene defines the hosting scene
  20757. * @param height defines the height of the cylinder
  20758. * @param diameterTop defines the diameter of the cylinder's top cap
  20759. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20760. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20761. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20762. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20763. * @param mesh defines the hosting mesh (can be null)
  20764. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20765. */
  20766. constructor(id: string, scene: Scene,
  20767. /**
  20768. * Defines the height of the cylinder
  20769. */
  20770. height: number,
  20771. /**
  20772. * Defines the diameter of the cylinder's top cap
  20773. */
  20774. diameterTop: number,
  20775. /**
  20776. * Defines the diameter of the cylinder's bottom cap
  20777. */
  20778. diameterBottom: number,
  20779. /**
  20780. * Defines the tessellation factor to apply to the cylinder
  20781. */
  20782. tessellation: number,
  20783. /**
  20784. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20785. */
  20786. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20787. /**
  20788. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20789. */
  20790. side?: number);
  20791. /** @hidden */
  20792. _regenerateVertexData(): VertexData;
  20793. copy(id: string): Geometry;
  20794. serialize(): any;
  20795. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20796. }
  20797. /**
  20798. * Creates a new torus geometry
  20799. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20800. */
  20801. class TorusGeometry extends _PrimitiveGeometry {
  20802. /**
  20803. * Defines the diameter of the torus
  20804. */
  20805. diameter: number;
  20806. /**
  20807. * Defines the thickness of the torus (ie. internal diameter)
  20808. */
  20809. thickness: number;
  20810. /**
  20811. * Defines the tesselation factor to apply to the torus
  20812. */
  20813. tessellation: number;
  20814. /**
  20815. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20816. */
  20817. side: number;
  20818. /**
  20819. * Creates a new torus geometry
  20820. * @param id defines the unique ID of the geometry
  20821. * @param scene defines the hosting scene
  20822. * @param diameter defines the diameter of the torus
  20823. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20824. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20825. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20826. * @param mesh defines the hosting mesh (can be null)
  20827. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20828. */
  20829. constructor(id: string, scene: Scene,
  20830. /**
  20831. * Defines the diameter of the torus
  20832. */
  20833. diameter: number,
  20834. /**
  20835. * Defines the thickness of the torus (ie. internal diameter)
  20836. */
  20837. thickness: number,
  20838. /**
  20839. * Defines the tesselation factor to apply to the torus
  20840. */
  20841. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20842. /**
  20843. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20844. */
  20845. side?: number);
  20846. /** @hidden */
  20847. _regenerateVertexData(): VertexData;
  20848. copy(id: string): Geometry;
  20849. serialize(): any;
  20850. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20851. }
  20852. /**
  20853. * Creates a new ground geometry
  20854. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20855. */
  20856. class GroundGeometry extends _PrimitiveGeometry {
  20857. /**
  20858. * Defines the width of the ground
  20859. */
  20860. width: number;
  20861. /**
  20862. * Defines the height of the ground
  20863. */
  20864. height: number;
  20865. /**
  20866. * Defines the subdivisions to apply to the ground
  20867. */
  20868. subdivisions: number;
  20869. /**
  20870. * Creates a new ground geometry
  20871. * @param id defines the unique ID of the geometry
  20872. * @param scene defines the hosting scene
  20873. * @param width defines the width of the ground
  20874. * @param height defines the height of the ground
  20875. * @param subdivisions defines the subdivisions to apply to the ground
  20876. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20877. * @param mesh defines the hosting mesh (can be null)
  20878. */
  20879. constructor(id: string, scene: Scene,
  20880. /**
  20881. * Defines the width of the ground
  20882. */
  20883. width: number,
  20884. /**
  20885. * Defines the height of the ground
  20886. */
  20887. height: number,
  20888. /**
  20889. * Defines the subdivisions to apply to the ground
  20890. */
  20891. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20892. /** @hidden */
  20893. _regenerateVertexData(): VertexData;
  20894. copy(id: string): Geometry;
  20895. serialize(): any;
  20896. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20897. }
  20898. /**
  20899. * Creates a tiled ground geometry
  20900. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20901. */
  20902. class TiledGroundGeometry extends _PrimitiveGeometry {
  20903. /**
  20904. * Defines the minimum value on X axis
  20905. */
  20906. xmin: number;
  20907. /**
  20908. * Defines the minimum value on Z axis
  20909. */
  20910. zmin: number;
  20911. /**
  20912. * Defines the maximum value on X axis
  20913. */
  20914. xmax: number;
  20915. /**
  20916. * Defines the maximum value on Z axis
  20917. */
  20918. zmax: number;
  20919. /**
  20920. * Defines the subdivisions to apply to the ground
  20921. */
  20922. subdivisions: {
  20923. w: number;
  20924. h: number;
  20925. };
  20926. /**
  20927. * Defines the precision to use when computing the tiles
  20928. */
  20929. precision: {
  20930. w: number;
  20931. h: number;
  20932. };
  20933. /**
  20934. * Creates a tiled ground geometry
  20935. * @param id defines the unique ID of the geometry
  20936. * @param scene defines the hosting scene
  20937. * @param xmin defines the minimum value on X axis
  20938. * @param zmin defines the minimum value on Z axis
  20939. * @param xmax defines the maximum value on X axis
  20940. * @param zmax defines the maximum value on Z axis
  20941. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20942. * @param precision defines the precision to use when computing the tiles
  20943. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20944. * @param mesh defines the hosting mesh (can be null)
  20945. */
  20946. constructor(id: string, scene: Scene,
  20947. /**
  20948. * Defines the minimum value on X axis
  20949. */
  20950. xmin: number,
  20951. /**
  20952. * Defines the minimum value on Z axis
  20953. */
  20954. zmin: number,
  20955. /**
  20956. * Defines the maximum value on X axis
  20957. */
  20958. xmax: number,
  20959. /**
  20960. * Defines the maximum value on Z axis
  20961. */
  20962. zmax: number,
  20963. /**
  20964. * Defines the subdivisions to apply to the ground
  20965. */
  20966. subdivisions: {
  20967. w: number;
  20968. h: number;
  20969. },
  20970. /**
  20971. * Defines the precision to use when computing the tiles
  20972. */
  20973. precision: {
  20974. w: number;
  20975. h: number;
  20976. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20977. /** @hidden */
  20978. _regenerateVertexData(): VertexData;
  20979. copy(id: string): Geometry;
  20980. }
  20981. /**
  20982. * Creates a plane geometry
  20983. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20984. */
  20985. class PlaneGeometry extends _PrimitiveGeometry {
  20986. /**
  20987. * Defines the size of the plane (width === height)
  20988. */
  20989. size: number;
  20990. /**
  20991. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20992. */
  20993. side: number;
  20994. /**
  20995. * Creates a plane geometry
  20996. * @param id defines the unique ID of the geometry
  20997. * @param scene defines the hosting scene
  20998. * @param size defines the size of the plane (width === height)
  20999. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21000. * @param mesh defines the hosting mesh (can be null)
  21001. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21002. */
  21003. constructor(id: string, scene: Scene,
  21004. /**
  21005. * Defines the size of the plane (width === height)
  21006. */
  21007. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21008. /**
  21009. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21010. */
  21011. side?: number);
  21012. /** @hidden */
  21013. _regenerateVertexData(): VertexData;
  21014. copy(id: string): Geometry;
  21015. serialize(): any;
  21016. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21017. }
  21018. /**
  21019. * Creates a torus knot geometry
  21020. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21021. */
  21022. class TorusKnotGeometry extends _PrimitiveGeometry {
  21023. /**
  21024. * Defines the radius of the torus knot
  21025. */
  21026. radius: number;
  21027. /**
  21028. * Defines the thickness of the torus knot tube
  21029. */
  21030. tube: number;
  21031. /**
  21032. * Defines the number of radial segments
  21033. */
  21034. radialSegments: number;
  21035. /**
  21036. * Defines the number of tubular segments
  21037. */
  21038. tubularSegments: number;
  21039. /**
  21040. * Defines the first number of windings
  21041. */
  21042. p: number;
  21043. /**
  21044. * Defines the second number of windings
  21045. */
  21046. q: number;
  21047. /**
  21048. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21049. */
  21050. side: number;
  21051. /**
  21052. * Creates a torus knot geometry
  21053. * @param id defines the unique ID of the geometry
  21054. * @param scene defines the hosting scene
  21055. * @param radius defines the radius of the torus knot
  21056. * @param tube defines the thickness of the torus knot tube
  21057. * @param radialSegments defines the number of radial segments
  21058. * @param tubularSegments defines the number of tubular segments
  21059. * @param p defines the first number of windings
  21060. * @param q defines the second number of windings
  21061. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21062. * @param mesh defines the hosting mesh (can be null)
  21063. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21064. */
  21065. constructor(id: string, scene: Scene,
  21066. /**
  21067. * Defines the radius of the torus knot
  21068. */
  21069. radius: number,
  21070. /**
  21071. * Defines the thickness of the torus knot tube
  21072. */
  21073. tube: number,
  21074. /**
  21075. * Defines the number of radial segments
  21076. */
  21077. radialSegments: number,
  21078. /**
  21079. * Defines the number of tubular segments
  21080. */
  21081. tubularSegments: number,
  21082. /**
  21083. * Defines the first number of windings
  21084. */
  21085. p: number,
  21086. /**
  21087. * Defines the second number of windings
  21088. */
  21089. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21090. /**
  21091. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21092. */
  21093. side?: number);
  21094. /** @hidden */
  21095. _regenerateVertexData(): VertexData;
  21096. copy(id: string): Geometry;
  21097. serialize(): any;
  21098. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21099. }
  21100. }
  21101. declare module BABYLON {
  21102. class GroundMesh extends Mesh {
  21103. generateOctree: boolean;
  21104. private _heightQuads;
  21105. /** @hidden */
  21106. _subdivisionsX: number;
  21107. /** @hidden */
  21108. _subdivisionsY: number;
  21109. /** @hidden */
  21110. _width: number;
  21111. /** @hidden */
  21112. _height: number;
  21113. /** @hidden */
  21114. _minX: number;
  21115. /** @hidden */
  21116. _maxX: number;
  21117. /** @hidden */
  21118. _minZ: number;
  21119. /** @hidden */
  21120. _maxZ: number;
  21121. constructor(name: string, scene: Scene);
  21122. getClassName(): string;
  21123. readonly subdivisions: number;
  21124. readonly subdivisionsX: number;
  21125. readonly subdivisionsY: number;
  21126. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21127. /**
  21128. * Returns a height (y) value in the Worl system :
  21129. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21130. * Returns the ground y position if (x, z) are outside the ground surface.
  21131. */
  21132. getHeightAtCoordinates(x: number, z: number): number;
  21133. /**
  21134. * Returns a normalized vector (Vector3) orthogonal to the ground
  21135. * at the ground coordinates (x, z) expressed in the World system.
  21136. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21137. */
  21138. getNormalAtCoordinates(x: number, z: number): Vector3;
  21139. /**
  21140. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21141. * at the ground coordinates (x, z) expressed in the World system.
  21142. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21143. * Returns the GroundMesh.
  21144. */
  21145. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21146. /**
  21147. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21148. * if the ground has been updated.
  21149. * This can be used in the render loop.
  21150. * Returns the GroundMesh.
  21151. */
  21152. updateCoordinateHeights(): GroundMesh;
  21153. private _getFacetAt;
  21154. private _initHeightQuads;
  21155. private _computeHeightQuads;
  21156. serialize(serializationObject: any): void;
  21157. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21158. }
  21159. }
  21160. declare module BABYLON {
  21161. /**
  21162. * Creates an instance based on a source mesh.
  21163. */
  21164. class InstancedMesh extends AbstractMesh {
  21165. private _sourceMesh;
  21166. private _currentLOD;
  21167. constructor(name: string, source: Mesh);
  21168. /**
  21169. * Returns the string "InstancedMesh".
  21170. */
  21171. getClassName(): string;
  21172. readonly receiveShadows: boolean;
  21173. readonly material: Nullable<Material>;
  21174. readonly visibility: number;
  21175. readonly skeleton: Nullable<Skeleton>;
  21176. renderingGroupId: number;
  21177. /**
  21178. * Returns the total number of vertices (integer).
  21179. */
  21180. getTotalVertices(): number;
  21181. readonly sourceMesh: Mesh;
  21182. /**
  21183. * Is this node ready to be used/rendered
  21184. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21185. * @return {boolean} is it ready
  21186. */
  21187. isReady(completeCheck?: boolean): boolean;
  21188. /**
  21189. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21190. */
  21191. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21192. /**
  21193. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21194. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21195. * The `data` are either a numeric array either a Float32Array.
  21196. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21197. * 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).
  21198. * Note that a new underlying VertexBuffer object is created each call.
  21199. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21200. *
  21201. * Possible `kind` values :
  21202. * - BABYLON.VertexBuffer.PositionKind
  21203. * - BABYLON.VertexBuffer.UVKind
  21204. * - BABYLON.VertexBuffer.UV2Kind
  21205. * - BABYLON.VertexBuffer.UV3Kind
  21206. * - BABYLON.VertexBuffer.UV4Kind
  21207. * - BABYLON.VertexBuffer.UV5Kind
  21208. * - BABYLON.VertexBuffer.UV6Kind
  21209. * - BABYLON.VertexBuffer.ColorKind
  21210. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21211. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21212. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21213. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21214. *
  21215. * Returns the Mesh.
  21216. */
  21217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21218. /**
  21219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21220. * If the mesh has no geometry, it is simply returned as it is.
  21221. * The `data` are either a numeric array either a Float32Array.
  21222. * No new underlying VertexBuffer object is created.
  21223. * 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.
  21224. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21225. *
  21226. * Possible `kind` values :
  21227. * - BABYLON.VertexBuffer.PositionKind
  21228. * - BABYLON.VertexBuffer.UVKind
  21229. * - BABYLON.VertexBuffer.UV2Kind
  21230. * - BABYLON.VertexBuffer.UV3Kind
  21231. * - BABYLON.VertexBuffer.UV4Kind
  21232. * - BABYLON.VertexBuffer.UV5Kind
  21233. * - BABYLON.VertexBuffer.UV6Kind
  21234. * - BABYLON.VertexBuffer.ColorKind
  21235. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21236. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21237. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21238. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21239. *
  21240. * Returns the Mesh.
  21241. */
  21242. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21243. /**
  21244. * Sets the mesh indices.
  21245. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21246. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21247. * This method creates a new index buffer each call.
  21248. * Returns the Mesh.
  21249. */
  21250. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21251. /**
  21252. * Boolean : True if the mesh owns the requested kind of data.
  21253. */
  21254. isVerticesDataPresent(kind: string): boolean;
  21255. /**
  21256. * Returns an array of indices (IndicesArray).
  21257. */
  21258. getIndices(): Nullable<IndicesArray>;
  21259. readonly _positions: Nullable<Vector3[]>;
  21260. /**
  21261. * Sets a new updated BoundingInfo to the mesh.
  21262. * Returns the mesh.
  21263. */
  21264. refreshBoundingInfo(): InstancedMesh;
  21265. /** @hidden */
  21266. _preActivate(): InstancedMesh;
  21267. /** @hidden */
  21268. _activate(renderId: number): InstancedMesh;
  21269. /**
  21270. * Returns the current associated LOD AbstractMesh.
  21271. */
  21272. getLOD(camera: Camera): AbstractMesh;
  21273. /** @hidden */
  21274. _syncSubMeshes(): InstancedMesh;
  21275. /** @hidden */
  21276. _generatePointsArray(): boolean;
  21277. /**
  21278. * Creates a new InstancedMesh from the current mesh.
  21279. * - name (string) : the cloned mesh name
  21280. * - newParent (optional Node) : the optional Node to parent the clone to.
  21281. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21282. *
  21283. * Returns the clone.
  21284. */
  21285. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21286. /**
  21287. * Disposes the InstancedMesh.
  21288. * Returns nothing.
  21289. */
  21290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21291. }
  21292. }
  21293. declare module BABYLON {
  21294. class LinesMesh extends Mesh {
  21295. useVertexColor?: boolean | undefined;
  21296. useVertexAlpha?: boolean | undefined;
  21297. color: Color3;
  21298. alpha: number;
  21299. /**
  21300. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21301. * This margin is expressed in world space coordinates, so its value may vary.
  21302. * Default value is 0.1
  21303. * @returns the intersection Threshold value.
  21304. */
  21305. /**
  21306. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21307. * This margin is expressed in world space coordinates, so its value may vary.
  21308. * @param value the new threshold to apply
  21309. */
  21310. intersectionThreshold: number;
  21311. private _intersectionThreshold;
  21312. private _colorShader;
  21313. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21314. /**
  21315. * Returns the string "LineMesh"
  21316. */
  21317. getClassName(): string;
  21318. /**
  21319. * @hidden
  21320. */
  21321. /**
  21322. * @hidden
  21323. */
  21324. material: Material;
  21325. /**
  21326. * @hidden
  21327. */
  21328. readonly checkCollisions: boolean;
  21329. createInstance(name: string): InstancedMesh;
  21330. /** @hidden */
  21331. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21332. /** @hidden */
  21333. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21334. dispose(doNotRecurse?: boolean): void;
  21335. /**
  21336. * Returns a new LineMesh object cloned from the current one.
  21337. */
  21338. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21339. }
  21340. }
  21341. declare module BABYLON {
  21342. /**
  21343. * @hidden
  21344. **/
  21345. class _InstancesBatch {
  21346. mustReturn: boolean;
  21347. visibleInstances: Nullable<InstancedMesh[]>[];
  21348. renderSelf: boolean[];
  21349. }
  21350. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21351. static _FRONTSIDE: number;
  21352. static _BACKSIDE: number;
  21353. static _DOUBLESIDE: number;
  21354. static _DEFAULTSIDE: number;
  21355. static _NO_CAP: number;
  21356. static _CAP_START: number;
  21357. static _CAP_END: number;
  21358. static _CAP_ALL: number;
  21359. /**
  21360. * Mesh side orientation : usually the external or front surface
  21361. */
  21362. static readonly FRONTSIDE: number;
  21363. /**
  21364. * Mesh side orientation : usually the internal or back surface
  21365. */
  21366. static readonly BACKSIDE: number;
  21367. /**
  21368. * Mesh side orientation : both internal and external or front and back surfaces
  21369. */
  21370. static readonly DOUBLESIDE: number;
  21371. /**
  21372. * Mesh side orientation : by default, `FRONTSIDE`
  21373. */
  21374. static readonly DEFAULTSIDE: number;
  21375. /**
  21376. * Mesh cap setting : no cap
  21377. */
  21378. static readonly NO_CAP: number;
  21379. /**
  21380. * Mesh cap setting : one cap at the beginning of the mesh
  21381. */
  21382. static readonly CAP_START: number;
  21383. /**
  21384. * Mesh cap setting : one cap at the end of the mesh
  21385. */
  21386. static readonly CAP_END: number;
  21387. /**
  21388. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21389. */
  21390. static readonly CAP_ALL: number;
  21391. private _onBeforeRenderObservable;
  21392. private _onAfterRenderObservable;
  21393. private _onBeforeDrawObservable;
  21394. /**
  21395. * An event triggered before rendering the mesh
  21396. */
  21397. readonly onBeforeRenderObservable: Observable<Mesh>;
  21398. /**
  21399. * An event triggered after rendering the mesh
  21400. */
  21401. readonly onAfterRenderObservable: Observable<Mesh>;
  21402. /**
  21403. * An event triggered before drawing the mesh
  21404. */
  21405. readonly onBeforeDrawObservable: Observable<Mesh>;
  21406. private _onBeforeDrawObserver;
  21407. onBeforeDraw: () => void;
  21408. delayLoadState: number;
  21409. instances: InstancedMesh[];
  21410. delayLoadingFile: string;
  21411. /** @hidden */
  21412. _binaryInfo: any;
  21413. private _LODLevels;
  21414. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21415. private _morphTargetManager;
  21416. morphTargetManager: Nullable<MorphTargetManager>;
  21417. /** @hidden */
  21418. _geometry: Nullable<Geometry>;
  21419. /** @hidden */
  21420. _delayInfo: Array<string>;
  21421. /** @hidden */
  21422. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21423. /** @hidden */
  21424. _visibleInstances: any;
  21425. private _renderIdForInstances;
  21426. private _batchCache;
  21427. private _instancesBufferSize;
  21428. private _instancesBuffer;
  21429. private _instancesData;
  21430. private _overridenInstanceCount;
  21431. private _effectiveMaterial;
  21432. /** @hidden */
  21433. _shouldGenerateFlatShading: boolean;
  21434. private _preActivateId;
  21435. /** @hidden */
  21436. _originalBuilderSideOrientation: number;
  21437. overrideMaterialSideOrientation: Nullable<number>;
  21438. private _areNormalsFrozen;
  21439. private _sourcePositions;
  21440. private _sourceNormals;
  21441. private _source;
  21442. readonly source: Nullable<Mesh>;
  21443. isUnIndexed: boolean;
  21444. /**
  21445. * @constructor
  21446. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21447. * @param {Scene} scene The scene to add this mesh to.
  21448. * @param {Node} parent The parent of this mesh, if it has one
  21449. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21450. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21451. * When false, achieved by calling a clone(), also passing False.
  21452. * This will make creation of children, recursive.
  21453. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21454. */
  21455. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21456. /**
  21457. * Returns the string "Mesh".
  21458. */
  21459. getClassName(): string;
  21460. /**
  21461. * Returns a string.
  21462. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21463. */
  21464. toString(fullDetails?: boolean): string;
  21465. /** @hidden */
  21466. _unBindEffect(): void;
  21467. /**
  21468. * True if the mesh has some Levels Of Details (LOD).
  21469. * Returns a boolean.
  21470. */
  21471. readonly hasLODLevels: boolean;
  21472. /**
  21473. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21474. * @returns an array of {BABYLON.MeshLODLevel}
  21475. */
  21476. getLODLevels(): MeshLODLevel[];
  21477. private _sortLODLevels;
  21478. /**
  21479. * Add a mesh as LOD level triggered at the given distance.
  21480. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21481. * @param distance The distance from the center of the object to show this level
  21482. * @param mesh The mesh to be added as LOD level (can be null)
  21483. * @return This mesh (for chaining)
  21484. */
  21485. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21486. /**
  21487. * Returns the LOD level mesh at the passed distance or null if not found.
  21488. * It is related to the method `addLODLevel(distance, mesh)`.
  21489. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21490. * Returns an object Mesh or `null`.
  21491. */
  21492. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21493. /**
  21494. * Remove a mesh from the LOD array
  21495. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21496. * @param {Mesh} mesh The mesh to be removed.
  21497. * @return {Mesh} This mesh (for chaining)
  21498. */
  21499. removeLODLevel(mesh: Mesh): Mesh;
  21500. /**
  21501. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21502. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21503. */
  21504. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21505. /**
  21506. * Returns the mesh internal Geometry object.
  21507. */
  21508. readonly geometry: Nullable<Geometry>;
  21509. /**
  21510. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21511. */
  21512. getTotalVertices(): number;
  21513. /**
  21514. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21515. * 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.
  21516. * You can force the copy with forceCopy === true
  21517. * Returns null if the mesh has no geometry or no vertex buffer.
  21518. * Possible `kind` values :
  21519. * - BABYLON.VertexBuffer.PositionKind
  21520. * - BABYLON.VertexBuffer.UVKind
  21521. * - BABYLON.VertexBuffer.UV2Kind
  21522. * - BABYLON.VertexBuffer.UV3Kind
  21523. * - BABYLON.VertexBuffer.UV4Kind
  21524. * - BABYLON.VertexBuffer.UV5Kind
  21525. * - BABYLON.VertexBuffer.UV6Kind
  21526. * - BABYLON.VertexBuffer.ColorKind
  21527. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21528. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21529. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21530. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21531. */
  21532. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21533. /**
  21534. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21535. * Returns `null` if the mesh has no geometry.
  21536. * Possible `kind` values :
  21537. * - BABYLON.VertexBuffer.PositionKind
  21538. * - BABYLON.VertexBuffer.UVKind
  21539. * - BABYLON.VertexBuffer.UV2Kind
  21540. * - BABYLON.VertexBuffer.UV3Kind
  21541. * - BABYLON.VertexBuffer.UV4Kind
  21542. * - BABYLON.VertexBuffer.UV5Kind
  21543. * - BABYLON.VertexBuffer.UV6Kind
  21544. * - BABYLON.VertexBuffer.ColorKind
  21545. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21546. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21547. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21548. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21549. */
  21550. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21551. isVerticesDataPresent(kind: string): boolean;
  21552. /**
  21553. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21554. * Possible `kind` values :
  21555. * - BABYLON.VertexBuffer.PositionKind
  21556. * - BABYLON.VertexBuffer.UVKind
  21557. * - BABYLON.VertexBuffer.UV2Kind
  21558. * - BABYLON.VertexBuffer.UV3Kind
  21559. * - BABYLON.VertexBuffer.UV4Kind
  21560. * - BABYLON.VertexBuffer.UV5Kind
  21561. * - BABYLON.VertexBuffer.UV6Kind
  21562. * - BABYLON.VertexBuffer.ColorKind
  21563. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21564. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21565. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21566. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21567. */
  21568. isVertexBufferUpdatable(kind: string): boolean;
  21569. /**
  21570. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21571. * Possible `kind` values :
  21572. * - BABYLON.VertexBuffer.PositionKind
  21573. * - BABYLON.VertexBuffer.UVKind
  21574. * - BABYLON.VertexBuffer.UV2Kind
  21575. * - BABYLON.VertexBuffer.UV3Kind
  21576. * - BABYLON.VertexBuffer.UV4Kind
  21577. * - BABYLON.VertexBuffer.UV5Kind
  21578. * - BABYLON.VertexBuffer.UV6Kind
  21579. * - BABYLON.VertexBuffer.ColorKind
  21580. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21581. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21582. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21583. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21584. */
  21585. getVerticesDataKinds(): string[];
  21586. /**
  21587. * Returns a positive integer : the total number of indices in this mesh geometry.
  21588. * Returns zero if the mesh has no geometry.
  21589. */
  21590. getTotalIndices(): number;
  21591. /**
  21592. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21593. * @param copyWhenShared If 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.
  21594. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21595. * @returns the indices array or an empty array if the mesh has no geometry
  21596. */
  21597. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21598. readonly isBlocked: boolean;
  21599. /**
  21600. * Determine if the current mesh is ready to be rendered
  21601. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21602. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21603. * @returns true if all associated assets are ready (material, textures, shaders)
  21604. */
  21605. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21606. /**
  21607. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21608. * This property is pertinent only for updatable parametric shapes.
  21609. */
  21610. readonly areNormalsFrozen: boolean;
  21611. /**
  21612. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21613. * It has no effect at all on other shapes.
  21614. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21615. * Returns the Mesh.
  21616. */
  21617. freezeNormals(): Mesh;
  21618. /**
  21619. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21620. * It has no effect at all on other shapes.
  21621. * It reactivates the mesh normals computation if it was previously frozen.
  21622. * Returns the Mesh.
  21623. */
  21624. unfreezeNormals(): Mesh;
  21625. /**
  21626. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21627. */
  21628. overridenInstanceCount: number;
  21629. /** @hidden */
  21630. _preActivate(): Mesh;
  21631. /** @hidden */
  21632. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21633. /** @hidden */
  21634. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21635. /**
  21636. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21637. * This means the mesh underlying bounding box and sphere are recomputed.
  21638. * Returns the Mesh.
  21639. */
  21640. refreshBoundingInfo(): Mesh;
  21641. /** @hidden */
  21642. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21643. private _getPositionData;
  21644. /** @hidden */
  21645. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21646. subdivide(count: number): void;
  21647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21648. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21649. /**
  21650. * Sets the mesh VertexBuffer.
  21651. * Returns the Mesh.
  21652. */
  21653. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21654. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21655. /**
  21656. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21657. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21658. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21659. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21660. * Returns the Mesh.
  21661. */
  21662. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21663. /**
  21664. * Creates a un-shared specific occurence of the geometry for the mesh.
  21665. * Returns the Mesh.
  21666. */
  21667. makeGeometryUnique(): Mesh;
  21668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21669. /**
  21670. * Update the current index buffer
  21671. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21672. * Returns the Mesh.
  21673. */
  21674. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21675. /**
  21676. * Invert the geometry to move from a right handed system to a left handed one.
  21677. * Returns the Mesh.
  21678. */
  21679. toLeftHanded(): Mesh;
  21680. /** @hidden */
  21681. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21682. /** @hidden */
  21683. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21684. /**
  21685. * Registers for this mesh a javascript function called just before the rendering process.
  21686. * This function is passed the current mesh.
  21687. * Return the Mesh.
  21688. */
  21689. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21690. /**
  21691. * Disposes a previously registered javascript function called before the rendering.
  21692. * This function is passed the current mesh.
  21693. * Returns the Mesh.
  21694. */
  21695. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21696. /**
  21697. * Registers for this mesh a javascript function called just after the rendering is complete.
  21698. * This function is passed the current mesh.
  21699. * Returns the Mesh.
  21700. */
  21701. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21702. /**
  21703. * Disposes a previously registered javascript function called after the rendering.
  21704. * This function is passed the current mesh.
  21705. * Return the Mesh.
  21706. */
  21707. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21708. /** @hidden */
  21709. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21710. /** @hidden */
  21711. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21712. /** @hidden */
  21713. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21714. /**
  21715. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  21716. * @param subMesh defines the subMesh to render
  21717. * @param enableAlphaMode defines if alpha mode can be changed
  21718. * @returns the current mesh
  21719. */
  21720. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21721. private _onBeforeDraw;
  21722. /**
  21723. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21724. */
  21725. getEmittedParticleSystems(): IParticleSystem[];
  21726. /**
  21727. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21728. */
  21729. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21730. /**
  21731. * Normalize matrix weights so that all vertices have a total weight set to 1
  21732. */
  21733. cleanMatrixWeights(): void;
  21734. /** @hidden */
  21735. _checkDelayState(): Mesh;
  21736. private _queueLoad;
  21737. /**
  21738. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21739. * A mesh is in the frustum if its bounding box intersects the frustum
  21740. * @param frustumPlanes defines the frustum to test
  21741. * @returns true if the mesh is in the frustum planes
  21742. */
  21743. isInFrustum(frustumPlanes: Plane[]): boolean;
  21744. /**
  21745. * Sets the mesh material by the material or multiMaterial `id` property.
  21746. * The material `id` is a string identifying the material or the multiMaterial.
  21747. * This method returns the Mesh.
  21748. */
  21749. setMaterialByID(id: string): Mesh;
  21750. /**
  21751. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21752. */
  21753. getAnimatables(): IAnimatable[];
  21754. /**
  21755. * Modifies the mesh geometry according to the passed transformation matrix.
  21756. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21757. * The mesh normals are modified using the same transformation.
  21758. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21759. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21760. * Returns the Mesh.
  21761. */
  21762. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21763. /**
  21764. * Modifies the mesh geometry according to its own current World Matrix.
  21765. * The mesh World Matrix is then reset.
  21766. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21767. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21768. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21769. * Returns the Mesh.
  21770. */
  21771. bakeCurrentTransformIntoVertices(): Mesh;
  21772. readonly _positions: Nullable<Vector3[]>;
  21773. /** @hidden */
  21774. _resetPointsArrayCache(): Mesh;
  21775. /** @hidden */
  21776. _generatePointsArray(): boolean;
  21777. /**
  21778. * Returns a new Mesh object generated from the current mesh properties.
  21779. * This method must not get confused with createInstance().
  21780. * The parameter `name` is a string, the name given to the new mesh.
  21781. * The optional parameter `newParent` can be any Node object (default `null`).
  21782. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21783. * 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.
  21784. */
  21785. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21786. /**
  21787. * Releases resources associated with this mesh.
  21788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21790. */
  21791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21792. /**
  21793. * Modifies the mesh geometry according to a displacement map.
  21794. * 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.
  21795. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21796. * This method returns nothing.
  21797. * @param url is a string, the URL from the image file is to be downloaded.
  21798. * @param minHeight is the lower limit of the displacement.
  21799. * @param maxHeight is the upper limit of the displacement.
  21800. * @param 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.
  21801. * @param uvOffset is an optional vector2 used to offset UV.
  21802. * @param uvScale is an optional vector2 used to scale UV.
  21803. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21804. * @returns the Mesh.
  21805. */
  21806. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21807. /**
  21808. * Modifies the mesh geometry according to a displacementMap buffer.
  21809. * 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.
  21810. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21811. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21812. * @param heightMapWidth is the width of the buffer image.
  21813. * @param heightMapHeight is the height of the buffer image.
  21814. * @param minHeight is the lower limit of the displacement.
  21815. * @param maxHeight is the upper limit of the displacement.
  21816. * @param 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.
  21817. * @param uvOffset is an optional vector2 used to offset UV.
  21818. * @param uvScale is an optional vector2 used to scale UV.
  21819. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21820. * @returns the Mesh.
  21821. */
  21822. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21823. /**
  21824. * Modify the mesh to get a flat shading rendering.
  21825. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21826. * This method returns the Mesh.
  21827. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21828. */
  21829. convertToFlatShadedMesh(): Mesh;
  21830. /**
  21831. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21832. * In other words, more vertices, no more indices and a single bigger VBO.
  21833. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21834. * Returns the Mesh.
  21835. */
  21836. convertToUnIndexedMesh(): Mesh;
  21837. /**
  21838. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21839. * This method returns the Mesh.
  21840. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21841. */
  21842. flipFaces(flipNormals?: boolean): Mesh;
  21843. /**
  21844. * Creates a new InstancedMesh object from the mesh model.
  21845. * An instance shares the same properties and the same material than its model.
  21846. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  21847. * Only these properties of each instance can then be set individually :
  21848. * - position
  21849. * - rotation
  21850. * - rotationQuaternion
  21851. * - setPivotMatrix
  21852. * - scaling
  21853. *
  21854. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21855. * Warning : this method is not supported for Line mesh and LineSystem
  21856. */
  21857. createInstance(name: string): InstancedMesh;
  21858. /**
  21859. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21860. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21861. * This method returns the Mesh.
  21862. */
  21863. synchronizeInstances(): Mesh;
  21864. /**
  21865. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21866. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21867. * This should be used together with the simplification to avoid disappearing triangles.
  21868. * Returns the Mesh.
  21869. * @param successCallback an optional success callback to be called after the optimization finished.
  21870. */
  21871. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21872. serialize(serializationObject: any): void;
  21873. /** @hidden */
  21874. _syncGeometryWithMorphTargetManager(): void;
  21875. /**
  21876. * Returns a new Mesh object parsed from the source provided.
  21877. * The parameter `parsedMesh` is the source.
  21878. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21879. */
  21880. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21881. /**
  21882. * Creates a ribbon mesh.
  21883. * Please consider using the same method from the MeshBuilder class instead.
  21884. * The ribbon is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21885. *
  21886. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21887. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21888. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21889. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21890. * 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.
  21891. * 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.
  21892. * 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
  21893. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21894. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21895. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21896. */
  21897. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21898. /**
  21899. * Creates a plane polygonal mesh. By default, this is a disc.
  21900. * Please consider using the same method from the MeshBuilder class instead.
  21901. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21902. * 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.
  21903. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21904. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21905. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21906. */
  21907. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21908. /**
  21909. * Creates a box mesh.
  21910. * Please consider using the same method from the MeshBuilder class instead.
  21911. * The parameter `size` sets the size (float) of each box side (default 1).
  21912. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21913. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21914. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21915. */
  21916. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21917. /**
  21918. * Creates a sphere mesh.
  21919. * Please consider using the same method from the MeshBuilder class instead.
  21920. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21921. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21922. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21923. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21924. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21925. */
  21926. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21927. /**
  21928. * Creates a cylinder or a cone mesh.
  21929. * Please consider using the same method from the MeshBuilder class instead.
  21930. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21931. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21932. * 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.
  21933. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21934. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21935. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21936. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21937. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21938. */
  21939. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21940. /**
  21941. * Creates a torus mesh.
  21942. * Please consider using the same method from the MeshBuilder class instead.
  21943. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21944. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21945. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21946. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21947. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21948. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21949. */
  21950. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21951. /**
  21952. * Creates a torus knot mesh.
  21953. * Please consider using the same method from the MeshBuilder class instead.
  21954. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21955. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21956. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21957. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21958. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21959. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21960. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21961. */
  21962. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21963. /**
  21964. * Creates a line mesh.
  21965. * Please consider using the same method from the MeshBuilder class instead.
  21966. * 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.
  21967. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21968. * The parameter `points` is an array successive Vector3.
  21969. * 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
  21970. * When updating an instance, remember that only point positions can change, not the number of points.
  21971. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21972. */
  21973. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21974. /**
  21975. * Creates a dashed line mesh.
  21976. * Please consider using the same method from the MeshBuilder class instead.
  21977. * 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.
  21978. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21979. * The parameter `points` is an array successive Vector3.
  21980. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21981. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21982. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21983. * 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
  21984. * When updating an instance, remember that only point positions can change, not the number of points.
  21985. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21986. */
  21987. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21988. /**
  21989. * Creates a polygon mesh.
  21990. * Please consider using the same method from the MeshBuilder class instead.
  21991. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21992. * 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.
  21993. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21994. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21995. * Remember you can only change the shape positions, not their number when updating a polygon.
  21996. */
  21997. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21998. /**
  21999. * Creates an extruded polygon mesh, with depth in the Y direction.
  22000. * Please consider using the same method from the MeshBuilder class instead.
  22001. */
  22002. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22003. /**
  22004. * Creates an extruded shape mesh.
  22005. * The extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22006. * Please consider using the same method from the MeshBuilder class instead.
  22007. *
  22008. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22009. * 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
  22010. * extruded along the Z axis.
  22011. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22012. * 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.
  22013. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22014. * 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
  22015. * 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
  22016. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22017. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22018. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22019. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22020. */
  22021. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22022. /**
  22023. * Creates an custom extruded shape mesh.
  22024. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22025. * Please consider using the same method from the MeshBuilder class instead.
  22026. *
  22027. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22028. * 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
  22029. * extruded along the Z axis.
  22030. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22031. * 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
  22032. * and the distance of this point from the begining of the path :
  22033. * ```javascript
  22034. * var rotationFunction = function(i, distance) {
  22035. * // do things
  22036. * return rotationValue; }
  22037. * ```
  22038. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22039. * 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
  22040. * and the distance of this point from the begining of the path :
  22041. * ```javascript
  22042. * var scaleFunction = function(i, distance) {
  22043. * // do things
  22044. * return scaleValue;}
  22045. * ```
  22046. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22047. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22048. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22049. * 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
  22050. * 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
  22051. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22052. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22053. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22054. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22055. */
  22056. 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;
  22057. /**
  22058. * Creates lathe mesh.
  22059. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22060. * Please consider using the same method from the MeshBuilder class instead.
  22061. * 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
  22062. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22063. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22064. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22065. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22066. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22067. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22068. */
  22069. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22070. /**
  22071. * Creates a plane mesh.
  22072. * Please consider using the same method from the MeshBuilder class instead.
  22073. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22074. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22075. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22076. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22077. */
  22078. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22079. /**
  22080. * Creates a ground mesh.
  22081. * Please consider using the same method from the MeshBuilder class instead.
  22082. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22083. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22084. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22085. */
  22086. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22087. /**
  22088. * Creates a tiled ground mesh.
  22089. * Please consider using the same method from the MeshBuilder class instead.
  22090. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22091. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22092. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22093. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22094. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22095. * numbers of subdivisions on the ground width and height of each tile.
  22096. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22097. */
  22098. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22099. w: number;
  22100. h: number;
  22101. }, precision: {
  22102. w: number;
  22103. h: number;
  22104. }, scene: Scene, updatable?: boolean): Mesh;
  22105. /**
  22106. * Creates a ground mesh from a height map.
  22107. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22108. * Please consider using the same method from the MeshBuilder class instead.
  22109. * The parameter `url` sets the URL of the height map image resource.
  22110. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22111. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22112. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22113. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22114. * 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).
  22115. * This function is passed the newly built mesh :
  22116. * ```javascript
  22117. * function(mesh) { // do things
  22118. * return; }
  22119. * ```
  22120. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22121. */
  22122. 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;
  22123. /**
  22124. * Creates a tube mesh.
  22125. * The tube is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22126. * Please consider using the same method from the MeshBuilder class instead.
  22127. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22128. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22129. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22130. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22131. * 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.
  22132. * It must return a radius value (positive float) :
  22133. * ```javascript
  22134. * var radiusFunction = function(i, distance) {
  22135. * // do things
  22136. * return radius; }
  22137. * ```
  22138. * 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
  22139. * 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
  22140. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22141. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22142. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22143. */
  22144. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22145. (i: number, distance: number): number;
  22146. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22147. /**
  22148. * Creates a polyhedron mesh.
  22149. * Please consider using the same method from the MeshBuilder class instead.
  22150. * 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
  22151. * to choose the wanted type.
  22152. * The parameter `size` (positive float, default 1) sets the polygon size.
  22153. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22154. * 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`.
  22155. * 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
  22156. * 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)`).
  22157. * 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
  22158. * 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.
  22159. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22160. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22161. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22162. */
  22163. static CreatePolyhedron(name: string, options: {
  22164. type?: number;
  22165. size?: number;
  22166. sizeX?: number;
  22167. sizeY?: number;
  22168. sizeZ?: number;
  22169. custom?: any;
  22170. faceUV?: Vector4[];
  22171. faceColors?: Color4[];
  22172. updatable?: boolean;
  22173. sideOrientation?: number;
  22174. }, scene: Scene): Mesh;
  22175. /**
  22176. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22177. * Please consider using the same method from the MeshBuilder class instead.
  22178. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22179. * 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`).
  22180. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22181. * 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.
  22182. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22183. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22184. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22185. */
  22186. static CreateIcoSphere(name: string, options: {
  22187. radius?: number;
  22188. flat?: boolean;
  22189. subdivisions?: number;
  22190. sideOrientation?: number;
  22191. updatable?: boolean;
  22192. }, scene: Scene): Mesh;
  22193. /**
  22194. * Creates a decal mesh.
  22195. * Please consider using the same method from the MeshBuilder class instead.
  22196. * 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.
  22197. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22198. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22199. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22200. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22201. */
  22202. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22203. /**
  22204. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22205. */
  22206. setPositionsForCPUSkinning(): Float32Array;
  22207. /**
  22208. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22209. */
  22210. setNormalsForCPUSkinning(): Float32Array;
  22211. /**
  22212. * Updates the vertex buffer by applying transformation from the bones.
  22213. * Returns the Mesh.
  22214. *
  22215. * @param {skeleton} skeleton to apply
  22216. */
  22217. applySkeleton(skeleton: Skeleton): Mesh;
  22218. /**
  22219. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22220. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22221. */
  22222. static MinMax(meshes: AbstractMesh[]): {
  22223. min: Vector3;
  22224. max: Vector3;
  22225. };
  22226. /**
  22227. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22228. */
  22229. static Center(meshesOrMinMaxVector: {
  22230. min: Vector3;
  22231. max: Vector3;
  22232. } | AbstractMesh[]): Vector3;
  22233. /**
  22234. * Merge the array of meshes into a single mesh for performance reasons.
  22235. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  22236. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  22237. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22238. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22239. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22240. */
  22241. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22242. }
  22243. }
  22244. declare module BABYLON {
  22245. /**
  22246. * Define an interface for all classes that will get and set the data on vertices
  22247. */
  22248. interface IGetSetVerticesData {
  22249. isVerticesDataPresent(kind: string): boolean;
  22250. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22251. /**
  22252. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22253. * @param copyWhenShared If 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.
  22254. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22255. * @returns the indices array or an empty array if the mesh has no geometry
  22256. */
  22257. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22258. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22259. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22260. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22261. }
  22262. /**
  22263. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22264. */
  22265. class VertexData {
  22266. /**
  22267. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22268. */
  22269. positions: Nullable<FloatArray>;
  22270. /**
  22271. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22272. */
  22273. normals: Nullable<FloatArray>;
  22274. /**
  22275. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22276. */
  22277. tangents: Nullable<FloatArray>;
  22278. /**
  22279. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22280. */
  22281. uvs: Nullable<FloatArray>;
  22282. /**
  22283. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22284. */
  22285. uvs2: Nullable<FloatArray>;
  22286. /**
  22287. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22288. */
  22289. uvs3: Nullable<FloatArray>;
  22290. /**
  22291. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22292. */
  22293. uvs4: Nullable<FloatArray>;
  22294. /**
  22295. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22296. */
  22297. uvs5: Nullable<FloatArray>;
  22298. /**
  22299. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22300. */
  22301. uvs6: Nullable<FloatArray>;
  22302. /**
  22303. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22304. */
  22305. colors: Nullable<FloatArray>;
  22306. /**
  22307. * 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).
  22308. */
  22309. matricesIndices: Nullable<FloatArray>;
  22310. /**
  22311. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22312. */
  22313. matricesWeights: Nullable<FloatArray>;
  22314. /**
  22315. * An array extending the number of possible indices
  22316. */
  22317. matricesIndicesExtra: Nullable<FloatArray>;
  22318. /**
  22319. * An array extending the number of possible weights when the number of indices is extended
  22320. */
  22321. matricesWeightsExtra: Nullable<FloatArray>;
  22322. /**
  22323. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22324. */
  22325. indices: Nullable<IndicesArray>;
  22326. /**
  22327. * Uses the passed data array to set the set the values for the specified kind of data
  22328. * @param data a linear array of floating numbers
  22329. * @param kind the type of data that is being set, eg positions, colors etc
  22330. */
  22331. set(data: FloatArray, kind: string): void;
  22332. /**
  22333. * Associates the vertexData to the passed Mesh.
  22334. * Sets it as updatable or not (default `false`)
  22335. * @param mesh the mesh the vertexData is applied to
  22336. * @param updatable when used and having the value true allows new data to update the vertexData
  22337. * @returns the VertexData
  22338. */
  22339. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22340. /**
  22341. * Associates the vertexData to the passed Geometry.
  22342. * Sets it as updatable or not (default `false`)
  22343. * @param geometry the geometry the vertexData is applied to
  22344. * @param updatable when used and having the value true allows new data to update the vertexData
  22345. * @returns VertexData
  22346. */
  22347. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22348. /**
  22349. * Updates the associated mesh
  22350. * @param mesh the mesh to be updated
  22351. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22352. * @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
  22353. * @returns VertexData
  22354. */
  22355. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22356. /**
  22357. * Updates the associated geometry
  22358. * @param geometry the geometry to be updated
  22359. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22360. * @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
  22361. * @returns VertexData.
  22362. */
  22363. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22364. private _applyTo;
  22365. private _update;
  22366. /**
  22367. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22368. * @param matrix the transforming matrix
  22369. * @returns the VertexData
  22370. */
  22371. transform(matrix: Matrix): VertexData;
  22372. /**
  22373. * Merges the passed VertexData into the current one
  22374. * @param other the VertexData to be merged into the current one
  22375. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22376. * @returns the modified VertexData
  22377. */
  22378. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22379. private _mergeElement;
  22380. private _validate;
  22381. /**
  22382. * Serializes the VertexData
  22383. * @returns a serialized object
  22384. */
  22385. serialize(): any;
  22386. /**
  22387. * Extracts the vertexData from a mesh
  22388. * @param mesh the mesh from which to extract the VertexData
  22389. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22390. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22391. * @returns the object VertexData associated to the passed mesh
  22392. */
  22393. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22394. /**
  22395. * Extracts the vertexData from the geometry
  22396. * @param geometry the geometry from which to extract the VertexData
  22397. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22398. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22399. * @returns the object VertexData associated to the passed mesh
  22400. */
  22401. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22402. private static _ExtractFrom;
  22403. /**
  22404. * Creates the VertexData for a Ribbon
  22405. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22406. * * pathArray array of paths, each of which an array of successive Vector3
  22407. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22408. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22409. * * 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
  22410. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22411. * * 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)
  22412. * * 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)
  22413. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22414. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22415. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22416. * @returns the VertexData of the ribbon
  22417. */
  22418. static CreateRibbon(options: {
  22419. pathArray: Vector3[][];
  22420. closeArray?: boolean;
  22421. closePath?: boolean;
  22422. offset?: number;
  22423. sideOrientation?: number;
  22424. frontUVs?: Vector4;
  22425. backUVs?: Vector4;
  22426. invertUV?: boolean;
  22427. uvs?: Vector2[];
  22428. colors?: Color4[];
  22429. }): VertexData;
  22430. /**
  22431. * Creates the VertexData for a box
  22432. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22433. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22434. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22435. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22436. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22437. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22438. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22439. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22440. * * 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)
  22441. * * 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)
  22442. * @returns the VertexData of the box
  22443. */
  22444. static CreateBox(options: {
  22445. size?: number;
  22446. width?: number;
  22447. height?: number;
  22448. depth?: number;
  22449. faceUV?: Vector4[];
  22450. faceColors?: Color4[];
  22451. sideOrientation?: number;
  22452. frontUVs?: Vector4;
  22453. backUVs?: Vector4;
  22454. }): VertexData;
  22455. /**
  22456. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22457. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22458. * * segments sets the number of horizontal strips optional, default 32
  22459. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22460. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22461. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22462. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22463. * * 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
  22464. * * 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
  22465. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22466. * * 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)
  22467. * * 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)
  22468. * @returns the VertexData of the ellipsoid
  22469. */
  22470. static CreateSphere(options: {
  22471. segments?: number;
  22472. diameter?: number;
  22473. diameterX?: number;
  22474. diameterY?: number;
  22475. diameterZ?: number;
  22476. arc?: number;
  22477. slice?: number;
  22478. sideOrientation?: number;
  22479. frontUVs?: Vector4;
  22480. backUVs?: Vector4;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a cylinder, cone or prism
  22484. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22485. * * height sets the height (y direction) of the cylinder, optional, default 2
  22486. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22487. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22488. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22489. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22490. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22491. * * 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
  22492. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22493. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22494. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22495. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22496. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22497. * * 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)
  22498. * * 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)
  22499. * @returns the VertexData of the cylinder, cone or prism
  22500. */
  22501. static CreateCylinder(options: {
  22502. height?: number;
  22503. diameterTop?: number;
  22504. diameterBottom?: number;
  22505. diameter?: number;
  22506. tessellation?: number;
  22507. subdivisions?: number;
  22508. arc?: number;
  22509. faceColors?: Color4[];
  22510. faceUV?: Vector4[];
  22511. hasRings?: boolean;
  22512. enclose?: boolean;
  22513. sideOrientation?: number;
  22514. frontUVs?: Vector4;
  22515. backUVs?: Vector4;
  22516. }): VertexData;
  22517. /**
  22518. * Creates the VertexData for a torus
  22519. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22520. * * diameter the diameter of the torus, optional default 1
  22521. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22522. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22523. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22524. * * 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)
  22525. * * 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)
  22526. * @returns the VertexData of the torus
  22527. */
  22528. static CreateTorus(options: {
  22529. diameter?: number;
  22530. thickness?: number;
  22531. tessellation?: number;
  22532. sideOrientation?: number;
  22533. frontUVs?: Vector4;
  22534. backUVs?: Vector4;
  22535. }): VertexData;
  22536. /**
  22537. * Creates the VertexData of the LineSystem
  22538. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22539. * - lines an array of lines, each line being an array of successive Vector3
  22540. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22541. * @returns the VertexData of the LineSystem
  22542. */
  22543. static CreateLineSystem(options: {
  22544. lines: Vector3[][];
  22545. colors?: Nullable<Color4[][]>;
  22546. }): VertexData;
  22547. /**
  22548. * Create the VertexData for a DashedLines
  22549. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22550. * - points an array successive Vector3
  22551. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22552. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22553. * - dashNb the intended total number of dashes, optional, default 200
  22554. * @returns the VertexData for the DashedLines
  22555. */
  22556. static CreateDashedLines(options: {
  22557. points: Vector3[];
  22558. dashSize?: number;
  22559. gapSize?: number;
  22560. dashNb?: number;
  22561. }): VertexData;
  22562. /**
  22563. * Creates the VertexData for a Ground
  22564. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22565. * - width the width (x direction) of the ground, optional, default 1
  22566. * - height the height (z direction) of the ground, optional, default 1
  22567. * - subdivisions the number of subdivisions per side, optional, default 1
  22568. * @returns the VertexData of the Ground
  22569. */
  22570. static CreateGround(options: {
  22571. width?: number;
  22572. height?: number;
  22573. subdivisions?: number;
  22574. subdivisionsX?: number;
  22575. subdivisionsY?: number;
  22576. }): VertexData;
  22577. /**
  22578. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22579. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22580. * * xmin the ground minimum X coordinate, optional, default -1
  22581. * * zmin the ground minimum Z coordinate, optional, default -1
  22582. * * xmax the ground maximum X coordinate, optional, default 1
  22583. * * zmax the ground maximum Z coordinate, optional, default 1
  22584. * * 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}
  22585. * * 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}
  22586. * @returns the VertexData of the TiledGround
  22587. */
  22588. static CreateTiledGround(options: {
  22589. xmin: number;
  22590. zmin: number;
  22591. xmax: number;
  22592. zmax: number;
  22593. subdivisions?: {
  22594. w: number;
  22595. h: number;
  22596. };
  22597. precision?: {
  22598. w: number;
  22599. h: number;
  22600. };
  22601. }): VertexData;
  22602. /**
  22603. * Creates the VertexData of the Ground designed from a heightmap
  22604. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22605. * * width the width (x direction) of the ground
  22606. * * height the height (z direction) of the ground
  22607. * * subdivisions the number of subdivisions per side
  22608. * * minHeight the minimum altitude on the ground, optional, default 0
  22609. * * maxHeight the maximum altitude on the ground, optional default 1
  22610. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22611. * * buffer the array holding the image color data
  22612. * * bufferWidth the width of image
  22613. * * bufferHeight the height of image
  22614. * @returns the VertexData of the Ground designed from a heightmap
  22615. */
  22616. static CreateGroundFromHeightMap(options: {
  22617. width: number;
  22618. height: number;
  22619. subdivisions: number;
  22620. minHeight: number;
  22621. maxHeight: number;
  22622. colorFilter: Color3;
  22623. buffer: Uint8Array;
  22624. bufferWidth: number;
  22625. bufferHeight: number;
  22626. }): VertexData;
  22627. /**
  22628. * Creates the VertexData for a Plane
  22629. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22630. * * size sets the width and height of the plane to the value of size, optional default 1
  22631. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22632. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22633. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22634. * * 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)
  22635. * * 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)
  22636. * @returns the VertexData of the box
  22637. */
  22638. static CreatePlane(options: {
  22639. size?: number;
  22640. width?: number;
  22641. height?: number;
  22642. sideOrientation?: number;
  22643. frontUVs?: Vector4;
  22644. backUVs?: Vector4;
  22645. }): VertexData;
  22646. /**
  22647. * Creates the VertexData of the Disc or regular Polygon
  22648. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22649. * * radius the radius of the disc, optional default 0.5
  22650. * * tessellation the number of polygon sides, optional, default 64
  22651. * * 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
  22652. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22653. * * 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)
  22654. * * 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)
  22655. * @returns the VertexData of the box
  22656. */
  22657. static CreateDisc(options: {
  22658. radius?: number;
  22659. tessellation?: number;
  22660. arc?: number;
  22661. sideOrientation?: number;
  22662. frontUVs?: Vector4;
  22663. backUVs?: Vector4;
  22664. }): VertexData;
  22665. /**
  22666. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22667. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22668. * @param polygon a mesh built from polygonTriangulation.build()
  22669. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22670. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22671. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22672. * @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)
  22673. * @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)
  22674. * @returns the VertexData of the Polygon
  22675. */
  22676. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22677. /**
  22678. * Creates the VertexData of the IcoSphere
  22679. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22680. * * radius the radius of the IcoSphere, optional default 1
  22681. * * radiusX allows stretching in the x direction, optional, default radius
  22682. * * radiusY allows stretching in the y direction, optional, default radius
  22683. * * radiusZ allows stretching in the z direction, optional, default radius
  22684. * * flat when true creates a flat shaded mesh, optional, default true
  22685. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22686. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22687. * * 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)
  22688. * * 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)
  22689. * @returns the VertexData of the IcoSphere
  22690. */
  22691. static CreateIcoSphere(options: {
  22692. radius?: number;
  22693. radiusX?: number;
  22694. radiusY?: number;
  22695. radiusZ?: number;
  22696. flat?: boolean;
  22697. subdivisions?: number;
  22698. sideOrientation?: number;
  22699. frontUVs?: Vector4;
  22700. backUVs?: Vector4;
  22701. }): VertexData;
  22702. /**
  22703. * Creates the VertexData for a Polyhedron
  22704. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22705. * * type provided types are:
  22706. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22707. * * 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)
  22708. * * size the size of the IcoSphere, optional default 1
  22709. * * sizeX allows stretching in the x direction, optional, default size
  22710. * * sizeY allows stretching in the y direction, optional, default size
  22711. * * sizeZ allows stretching in the z direction, optional, default size
  22712. * * 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
  22713. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22714. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22715. * * flat when true creates a flat shaded mesh, optional, default true
  22716. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22717. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22718. * * 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)
  22719. * * 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)
  22720. * @returns the VertexData of the Polyhedron
  22721. */
  22722. static CreatePolyhedron(options: {
  22723. type?: number;
  22724. size?: number;
  22725. sizeX?: number;
  22726. sizeY?: number;
  22727. sizeZ?: number;
  22728. custom?: any;
  22729. faceUV?: Vector4[];
  22730. faceColors?: Color4[];
  22731. flat?: boolean;
  22732. sideOrientation?: number;
  22733. frontUVs?: Vector4;
  22734. backUVs?: Vector4;
  22735. }): VertexData;
  22736. /**
  22737. * Creates the VertexData for a TorusKnot
  22738. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22739. * * radius the radius of the torus knot, optional, default 2
  22740. * * tube the thickness of the tube, optional, default 0.5
  22741. * * radialSegments the number of sides on each tube segments, optional, default 32
  22742. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22743. * * p the number of windings around the z axis, optional, default 2
  22744. * * q the number of windings around the x axis, optional, default 3
  22745. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22746. * * 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)
  22747. * * 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)
  22748. * @returns the VertexData of the Torus Knot
  22749. */
  22750. static CreateTorusKnot(options: {
  22751. radius?: number;
  22752. tube?: number;
  22753. radialSegments?: number;
  22754. tubularSegments?: number;
  22755. p?: number;
  22756. q?: number;
  22757. sideOrientation?: number;
  22758. frontUVs?: Vector4;
  22759. backUVs?: Vector4;
  22760. }): VertexData;
  22761. /**
  22762. * Compute normals for given positions and indices
  22763. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22764. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22765. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22766. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22767. * * facetNormals : optional array of facet normals (vector3)
  22768. * * facetPositions : optional array of facet positions (vector3)
  22769. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22770. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22771. * * bInfo : optional bounding info, required for facetPartitioning computation
  22772. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22773. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22774. * * useRightHandedSystem: optional boolean to for right handed system computation
  22775. * * depthSort : optional boolean to enable the facet depth sort computation
  22776. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22777. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22778. */
  22779. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22780. facetNormals?: any;
  22781. facetPositions?: any;
  22782. facetPartitioning?: any;
  22783. ratio?: number;
  22784. bInfo?: any;
  22785. bbSize?: Vector3;
  22786. subDiv?: any;
  22787. useRightHandedSystem?: boolean;
  22788. depthSort?: boolean;
  22789. distanceTo?: Vector3;
  22790. depthSortedFacets?: any;
  22791. }): void;
  22792. private static _ComputeSides;
  22793. /**
  22794. * Applies VertexData created from the imported parameters to the geometry
  22795. * @param parsedVertexData the parsed data from an imported file
  22796. * @param geometry the geometry to apply the VertexData to
  22797. */
  22798. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22799. }
  22800. }
  22801. declare module BABYLON {
  22802. /**
  22803. * Class containing static functions to help procedurally build meshes
  22804. */
  22805. class MeshBuilder {
  22806. private static updateSideOrientation;
  22807. /**
  22808. * Creates a box mesh
  22809. * * The parameter `size` sets the size (float) of each box side (default 1)
  22810. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22811. * * 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)
  22812. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22814. * * 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
  22815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22816. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22817. * @param name defines the name of the mesh
  22818. * @param options defines the options used to create the mesh
  22819. * @param scene defines the hosting scene
  22820. * @returns the box mesh
  22821. */
  22822. static CreateBox(name: string, options: {
  22823. size?: number;
  22824. width?: number;
  22825. height?: number;
  22826. depth?: number;
  22827. faceUV?: Vector4[];
  22828. faceColors?: Color4[];
  22829. sideOrientation?: number;
  22830. frontUVs?: Vector4;
  22831. backUVs?: Vector4;
  22832. updatable?: boolean;
  22833. }, scene?: Nullable<Scene>): Mesh;
  22834. /**
  22835. * Creates a sphere mesh
  22836. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22837. * * 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`)
  22838. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22839. * * 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
  22840. * * 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)
  22841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22842. * * 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
  22843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22844. * @param name defines the name of the mesh
  22845. * @param options defines the options used to create the mesh
  22846. * @param scene defines the hosting scene
  22847. * @returns the sphere mesh
  22848. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22849. */
  22850. static CreateSphere(name: string, options: {
  22851. segments?: number;
  22852. diameter?: number;
  22853. diameterX?: number;
  22854. diameterY?: number;
  22855. diameterZ?: number;
  22856. arc?: number;
  22857. slice?: number;
  22858. sideOrientation?: number;
  22859. frontUVs?: Vector4;
  22860. backUVs?: Vector4;
  22861. updatable?: boolean;
  22862. }, scene: any): Mesh;
  22863. /**
  22864. * Creates a plane polygonal mesh. By default, this is a disc
  22865. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22866. * * 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
  22867. * * 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
  22868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22869. * * 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
  22870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22871. * @param name defines the name of the mesh
  22872. * @param options defines the options used to create the mesh
  22873. * @param scene defines the hosting scene
  22874. * @returns the plane polygonal mesh
  22875. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22876. */
  22877. static CreateDisc(name: string, options: {
  22878. radius?: number;
  22879. tessellation?: number;
  22880. arc?: number;
  22881. updatable?: boolean;
  22882. sideOrientation?: number;
  22883. frontUVs?: Vector4;
  22884. backUVs?: Vector4;
  22885. }, scene?: Nullable<Scene>): Mesh;
  22886. /**
  22887. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22888. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22889. * * 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`)
  22890. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22891. * * 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
  22892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22893. * * 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
  22894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22895. * @param name defines the name of the mesh
  22896. * @param options defines the options used to create the mesh
  22897. * @param scene defines the hosting scene
  22898. * @returns the icosahedron mesh
  22899. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22900. */
  22901. static CreateIcoSphere(name: string, options: {
  22902. radius?: number;
  22903. radiusX?: number;
  22904. radiusY?: number;
  22905. radiusZ?: number;
  22906. flat?: boolean;
  22907. subdivisions?: number;
  22908. sideOrientation?: number;
  22909. frontUVs?: Vector4;
  22910. backUVs?: Vector4;
  22911. updatable?: boolean;
  22912. }, scene: Scene): Mesh;
  22913. /**
  22914. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22915. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22916. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22917. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22918. * * 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
  22919. * * 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
  22920. * * 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
  22921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22922. * * 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
  22923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22924. * * 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
  22925. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22926. * * 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
  22927. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22929. * @param name defines the name of the mesh
  22930. * @param options defines the options used to create the mesh
  22931. * @param scene defines the hosting scene
  22932. * @returns the ribbon mesh
  22933. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22934. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22935. */
  22936. static CreateRibbon(name: string, options: {
  22937. pathArray: Vector3[][];
  22938. closeArray?: boolean;
  22939. closePath?: boolean;
  22940. offset?: number;
  22941. updatable?: boolean;
  22942. sideOrientation?: number;
  22943. frontUVs?: Vector4;
  22944. backUVs?: Vector4;
  22945. instance?: Mesh;
  22946. invertUV?: boolean;
  22947. uvs?: Vector2[];
  22948. colors?: Color4[];
  22949. }, scene?: Nullable<Scene>): Mesh;
  22950. /**
  22951. * Creates a cylinder or a cone mesh
  22952. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22953. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22954. * * 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.
  22955. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22956. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22957. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22958. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22959. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22960. * * 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).
  22961. * * 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
  22962. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22963. * * 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
  22964. * * 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.
  22965. * * If `enclose` is false, a ring surface is one element.
  22966. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22967. * * 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
  22968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22969. * * 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
  22970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22971. * @param name defines the name of the mesh
  22972. * @param options defines the options used to create the mesh
  22973. * @param scene defines the hosting scene
  22974. * @returns the cylinder mesh
  22975. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22976. */
  22977. static CreateCylinder(name: string, options: {
  22978. height?: number;
  22979. diameterTop?: number;
  22980. diameterBottom?: number;
  22981. diameter?: number;
  22982. tessellation?: number;
  22983. subdivisions?: number;
  22984. arc?: number;
  22985. faceColors?: Color4[];
  22986. faceUV?: Vector4[];
  22987. updatable?: boolean;
  22988. hasRings?: boolean;
  22989. enclose?: boolean;
  22990. sideOrientation?: number;
  22991. frontUVs?: Vector4;
  22992. backUVs?: Vector4;
  22993. }, scene: any): Mesh;
  22994. /**
  22995. * Creates a torus mesh
  22996. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22997. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22998. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23000. * * 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
  23001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23002. * @param name defines the name of the mesh
  23003. * @param options defines the options used to create the mesh
  23004. * @param scene defines the hosting scene
  23005. * @returns the torus mesh
  23006. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23007. */
  23008. static CreateTorus(name: string, options: {
  23009. diameter?: number;
  23010. thickness?: number;
  23011. tessellation?: number;
  23012. updatable?: boolean;
  23013. sideOrientation?: number;
  23014. frontUVs?: Vector4;
  23015. backUVs?: Vector4;
  23016. }, scene: any): Mesh;
  23017. /**
  23018. * Creates a torus knot mesh
  23019. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23020. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23021. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23022. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23024. * * 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
  23025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23026. * @param name defines the name of the mesh
  23027. * @param options defines the options used to create the mesh
  23028. * @param scene defines the hosting scene
  23029. * @returns the torus knot mesh
  23030. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23031. */
  23032. static CreateTorusKnot(name: string, options: {
  23033. radius?: number;
  23034. tube?: number;
  23035. radialSegments?: number;
  23036. tubularSegments?: number;
  23037. p?: number;
  23038. q?: number;
  23039. updatable?: boolean;
  23040. sideOrientation?: number;
  23041. frontUVs?: Vector4;
  23042. backUVs?: Vector4;
  23043. }, scene: any): Mesh;
  23044. /**
  23045. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23046. * * 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
  23047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23048. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23049. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23050. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23051. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23052. * * 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
  23053. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23055. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23056. * @param name defines the name of the new line system
  23057. * @param options defines the options used to create the line system
  23058. * @param scene defines the hosting scene
  23059. * @returns a new line system mesh
  23060. */
  23061. static CreateLineSystem(name: string, options: {
  23062. lines: Vector3[][];
  23063. updatable?: boolean;
  23064. instance?: Nullable<LinesMesh>;
  23065. colors?: Nullable<Color4[][]>;
  23066. useVertexAlpha?: boolean;
  23067. }, scene: Nullable<Scene>): LinesMesh;
  23068. /**
  23069. * Creates a line mesh
  23070. * 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
  23071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23072. * * The parameter `points` is an array successive Vector3
  23073. * * 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
  23074. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23075. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23076. * * When updating an instance, remember that only point positions can change, not the number of points
  23077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23079. * @param name defines the name of the new line system
  23080. * @param options defines the options used to create the line system
  23081. * @param scene defines the hosting scene
  23082. * @returns a new line mesh
  23083. */
  23084. static CreateLines(name: string, options: {
  23085. points: Vector3[];
  23086. updatable?: boolean;
  23087. instance?: Nullable<LinesMesh>;
  23088. colors?: Color4[];
  23089. useVertexAlpha?: boolean;
  23090. }, scene?: Nullable<Scene>): LinesMesh;
  23091. /**
  23092. * Creates a dashed line mesh
  23093. * * 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
  23094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23095. * * The parameter `points` is an array successive Vector3
  23096. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23097. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23098. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23099. * * 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
  23100. * * When updating an instance, remember that only point positions can change, not the number of points
  23101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23102. * @param name defines the name of the mesh
  23103. * @param options defines the options used to create the mesh
  23104. * @param scene defines the hosting scene
  23105. * @returns the dashed line mesh
  23106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23107. */
  23108. static CreateDashedLines(name: string, options: {
  23109. points: Vector3[];
  23110. dashSize?: number;
  23111. gapSize?: number;
  23112. dashNb?: number;
  23113. updatable?: boolean;
  23114. instance?: LinesMesh;
  23115. }, scene?: Nullable<Scene>): LinesMesh;
  23116. /**
  23117. * 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.
  23118. * * 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.
  23119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23120. * * 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.
  23121. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23122. * * 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
  23123. * * 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
  23124. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23126. * * 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
  23127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23129. * @param name defines the name of the mesh
  23130. * @param options defines the options used to create the mesh
  23131. * @param scene defines the hosting scene
  23132. * @returns the extruded shape mesh
  23133. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23134. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23135. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23136. */
  23137. static ExtrudeShape(name: string, options: {
  23138. shape: Vector3[];
  23139. path: Vector3[];
  23140. scale?: number;
  23141. rotation?: number;
  23142. cap?: number;
  23143. updatable?: boolean;
  23144. sideOrientation?: number;
  23145. frontUVs?: Vector4;
  23146. backUVs?: Vector4;
  23147. instance?: Mesh;
  23148. invertUV?: boolean;
  23149. }, scene?: Nullable<Scene>): Mesh;
  23150. /**
  23151. * Creates an custom extruded shape mesh.
  23152. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23153. * * 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.
  23154. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23155. * * 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
  23156. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23157. * * 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
  23158. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23159. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23160. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23161. * * 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
  23162. * * 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
  23163. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23165. * * 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
  23166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23168. * @param name defines the name of the mesh
  23169. * @param options defines the options used to create the mesh
  23170. * @param scene defines the hosting scene
  23171. * @returns the custom extruded shape mesh
  23172. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23173. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23174. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23175. */
  23176. static ExtrudeShapeCustom(name: string, options: {
  23177. shape: Vector3[];
  23178. path: Vector3[];
  23179. scaleFunction?: any;
  23180. rotationFunction?: any;
  23181. ribbonCloseArray?: boolean;
  23182. ribbonClosePath?: boolean;
  23183. cap?: number;
  23184. updatable?: boolean;
  23185. sideOrientation?: number;
  23186. frontUVs?: Vector4;
  23187. backUVs?: Vector4;
  23188. instance?: Mesh;
  23189. invertUV?: boolean;
  23190. }, scene: Scene): Mesh;
  23191. /**
  23192. * Creates lathe mesh.
  23193. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23194. * * 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
  23195. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23196. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23197. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23198. * * 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
  23199. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23200. * * 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
  23201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23202. * * 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
  23203. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23205. * @param name defines the name of the mesh
  23206. * @param options defines the options used to create the mesh
  23207. * @param scene defines the hosting scene
  23208. * @returns the lathe mesh
  23209. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23210. */
  23211. static CreateLathe(name: string, options: {
  23212. shape: Vector3[];
  23213. radius?: number;
  23214. tessellation?: number;
  23215. clip?: number;
  23216. arc?: number;
  23217. closed?: boolean;
  23218. updatable?: boolean;
  23219. sideOrientation?: number;
  23220. frontUVs?: Vector4;
  23221. backUVs?: Vector4;
  23222. cap?: number;
  23223. invertUV?: boolean;
  23224. }, scene: Scene): Mesh;
  23225. /**
  23226. * Creates a plane mesh
  23227. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23228. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23229. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23231. * * 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
  23232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23233. * @param name defines the name of the mesh
  23234. * @param options defines the options used to create the mesh
  23235. * @param scene defines the hosting scene
  23236. * @returns the plane mesh
  23237. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23238. */
  23239. static CreatePlane(name: string, options: {
  23240. size?: number;
  23241. width?: number;
  23242. height?: number;
  23243. sideOrientation?: number;
  23244. frontUVs?: Vector4;
  23245. backUVs?: Vector4;
  23246. updatable?: boolean;
  23247. sourcePlane?: Plane;
  23248. }, scene: Scene): Mesh;
  23249. /**
  23250. * Creates a ground mesh
  23251. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23252. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23254. * @param name defines the name of the mesh
  23255. * @param options defines the options used to create the mesh
  23256. * @param scene defines the hosting scene
  23257. * @returns the ground mesh
  23258. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23259. */
  23260. static CreateGround(name: string, options: {
  23261. width?: number;
  23262. height?: number;
  23263. subdivisions?: number;
  23264. subdivisionsX?: number;
  23265. subdivisionsY?: number;
  23266. updatable?: boolean;
  23267. }, scene: any): Mesh;
  23268. /**
  23269. * Creates a tiled ground mesh
  23270. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23271. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23272. * * 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
  23273. * * 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
  23274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23275. * @param name defines the name of the mesh
  23276. * @param options defines the options used to create the mesh
  23277. * @param scene defines the hosting scene
  23278. * @returns the tiled ground mesh
  23279. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23280. */
  23281. static CreateTiledGround(name: string, options: {
  23282. xmin: number;
  23283. zmin: number;
  23284. xmax: number;
  23285. zmax: number;
  23286. subdivisions?: {
  23287. w: number;
  23288. h: number;
  23289. };
  23290. precision?: {
  23291. w: number;
  23292. h: number;
  23293. };
  23294. updatable?: boolean;
  23295. }, scene: Scene): Mesh;
  23296. /**
  23297. * Creates a ground mesh from a height map
  23298. * * The parameter `url` sets the URL of the height map image resource.
  23299. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23300. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23301. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23302. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23303. * * 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.
  23304. * * 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).
  23305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23306. * @param name defines the name of the mesh
  23307. * @param url defines the url to the height map
  23308. * @param options defines the options used to create the mesh
  23309. * @param scene defines the hosting scene
  23310. * @returns the ground mesh
  23311. * @see http://doc.babylonjs.com/babylon101/height_map
  23312. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23313. */
  23314. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23315. width?: number;
  23316. height?: number;
  23317. subdivisions?: number;
  23318. minHeight?: number;
  23319. maxHeight?: number;
  23320. colorFilter?: Color3;
  23321. updatable?: boolean;
  23322. onReady?: (mesh: GroundMesh) => void;
  23323. }, scene: Scene): GroundMesh;
  23324. /**
  23325. * Creates a polygon mesh
  23326. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23327. * * 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
  23328. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23330. * * 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)
  23331. * * Remember you can only change the shape positions, not their number when updating a polygon
  23332. * @param name defines the name of the mesh
  23333. * @param options defines the options used to create the mesh
  23334. * @param scene defines the hosting scene
  23335. * @returns the polygon mesh
  23336. */
  23337. static CreatePolygon(name: string, options: {
  23338. shape: Vector3[];
  23339. holes?: Vector3[][];
  23340. depth?: number;
  23341. faceUV?: Vector4[];
  23342. faceColors?: Color4[];
  23343. updatable?: boolean;
  23344. sideOrientation?: number;
  23345. frontUVs?: Vector4;
  23346. backUVs?: Vector4;
  23347. }, scene: Scene): Mesh;
  23348. /**
  23349. * Creates an extruded polygon mesh, with depth in the Y direction.
  23350. * * 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)
  23351. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23352. * @param name defines the name of the mesh
  23353. * @param options defines the options used to create the mesh
  23354. * @param scene defines the hosting scene
  23355. * @returns the polygon mesh
  23356. */
  23357. static ExtrudePolygon(name: string, options: {
  23358. shape: Vector3[];
  23359. holes?: Vector3[][];
  23360. depth?: number;
  23361. faceUV?: Vector4[];
  23362. faceColors?: Color4[];
  23363. updatable?: boolean;
  23364. sideOrientation?: number;
  23365. frontUVs?: Vector4;
  23366. backUVs?: Vector4;
  23367. }, scene: Scene): Mesh;
  23368. /**
  23369. * Creates a tube mesh.
  23370. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23371. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23372. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23373. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23374. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23375. * * 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)
  23376. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23377. * * 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
  23378. * * 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
  23379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23380. * * 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
  23381. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23383. * @param name defines the name of the mesh
  23384. * @param options defines the options used to create the mesh
  23385. * @param scene defines the hosting scene
  23386. * @returns the tube mesh
  23387. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23388. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23389. */
  23390. static CreateTube(name: string, options: {
  23391. path: Vector3[];
  23392. radius?: number;
  23393. tessellation?: number;
  23394. radiusFunction?: {
  23395. (i: number, distance: number): number;
  23396. };
  23397. cap?: number;
  23398. arc?: number;
  23399. updatable?: boolean;
  23400. sideOrientation?: number;
  23401. frontUVs?: Vector4;
  23402. backUVs?: Vector4;
  23403. instance?: Mesh;
  23404. invertUV?: boolean;
  23405. }, scene: Scene): Mesh;
  23406. /**
  23407. * Creates a polyhedron mesh
  23408. * * 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
  23409. * * The parameter `size` (positive float, default 1) sets the polygon size
  23410. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23411. * * 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`
  23412. * * 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
  23413. * * 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)`)
  23414. * * 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
  23415. * * 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
  23416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23417. * * 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
  23418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23419. * @param name defines the name of the mesh
  23420. * @param options defines the options used to create the mesh
  23421. * @param scene defines the hosting scene
  23422. * @returns the polyhedron mesh
  23423. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23424. */
  23425. static CreatePolyhedron(name: string, options: {
  23426. type?: number;
  23427. size?: number;
  23428. sizeX?: number;
  23429. sizeY?: number;
  23430. sizeZ?: number;
  23431. custom?: any;
  23432. faceUV?: Vector4[];
  23433. faceColors?: Color4[];
  23434. flat?: boolean;
  23435. updatable?: boolean;
  23436. sideOrientation?: number;
  23437. frontUVs?: Vector4;
  23438. backUVs?: Vector4;
  23439. }, scene: Scene): Mesh;
  23440. /**
  23441. * Creates a decal mesh.
  23442. * 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
  23443. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23444. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23445. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23446. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23447. * @param name defines the name of the mesh
  23448. * @param sourceMesh defines the mesh where the decal must be applied
  23449. * @param options defines the options used to create the mesh
  23450. * @param scene defines the hosting scene
  23451. * @returns the decal mesh
  23452. * @see http://doc.babylonjs.com/how_to/decals
  23453. */
  23454. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23455. position?: Vector3;
  23456. normal?: Vector3;
  23457. size?: Vector3;
  23458. angle?: number;
  23459. }): Mesh;
  23460. private static _ExtrudeShapeGeneric;
  23461. }
  23462. }
  23463. declare module BABYLON {
  23464. class MeshLODLevel {
  23465. distance: number;
  23466. mesh: Nullable<Mesh>;
  23467. constructor(distance: number, mesh: Nullable<Mesh>);
  23468. }
  23469. }
  23470. declare module BABYLON {
  23471. /**
  23472. * A simplifier interface for future simplification implementations.
  23473. */
  23474. interface ISimplifier {
  23475. /**
  23476. * Simplification of a given mesh according to the given settings.
  23477. * Since this requires computation, it is assumed that the function runs async.
  23478. * @param settings The settings of the simplification, including quality and distance
  23479. * @param successCallback A callback that will be called after the mesh was simplified.
  23480. * @param errorCallback in case of an error, this callback will be called. optional.
  23481. */
  23482. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23483. }
  23484. /**
  23485. * Expected simplification settings.
  23486. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23487. */
  23488. interface ISimplificationSettings {
  23489. quality: number;
  23490. distance: number;
  23491. optimizeMesh?: boolean;
  23492. }
  23493. class SimplificationSettings implements ISimplificationSettings {
  23494. quality: number;
  23495. distance: number;
  23496. optimizeMesh?: boolean | undefined;
  23497. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23498. }
  23499. interface ISimplificationTask {
  23500. settings: Array<ISimplificationSettings>;
  23501. simplificationType: SimplificationType;
  23502. mesh: Mesh;
  23503. successCallback?: () => void;
  23504. parallelProcessing: boolean;
  23505. }
  23506. class SimplificationQueue {
  23507. private _simplificationArray;
  23508. running: boolean;
  23509. constructor();
  23510. addTask(task: ISimplificationTask): void;
  23511. executeNext(): void;
  23512. runSimplification(task: ISimplificationTask): void;
  23513. private getSimplifier;
  23514. }
  23515. /**
  23516. * The implemented types of simplification
  23517. * At the moment only Quadratic Error Decimation is implemented
  23518. */
  23519. enum SimplificationType {
  23520. /** Quadratic error decimation */
  23521. QUADRATIC = 0
  23522. }
  23523. class DecimationTriangle {
  23524. vertices: Array<DecimationVertex>;
  23525. normal: Vector3;
  23526. error: Array<number>;
  23527. deleted: boolean;
  23528. isDirty: boolean;
  23529. borderFactor: number;
  23530. deletePending: boolean;
  23531. originalOffset: number;
  23532. constructor(vertices: Array<DecimationVertex>);
  23533. }
  23534. class DecimationVertex {
  23535. position: Vector3;
  23536. id: number;
  23537. q: QuadraticMatrix;
  23538. isBorder: boolean;
  23539. triangleStart: number;
  23540. triangleCount: number;
  23541. originalOffsets: Array<number>;
  23542. constructor(position: Vector3, id: number);
  23543. updatePosition(newPosition: Vector3): void;
  23544. }
  23545. class QuadraticMatrix {
  23546. data: Array<number>;
  23547. constructor(data?: Array<number>);
  23548. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23549. addInPlace(matrix: QuadraticMatrix): void;
  23550. addArrayInPlace(data: Array<number>): void;
  23551. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23552. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23553. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23554. }
  23555. class Reference {
  23556. vertexId: number;
  23557. triangleId: number;
  23558. constructor(vertexId: number, triangleId: number);
  23559. }
  23560. /**
  23561. * An implementation of the Quadratic Error simplification algorithm.
  23562. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23563. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23564. * @author RaananW
  23565. */
  23566. class QuadraticErrorSimplification implements ISimplifier {
  23567. private _mesh;
  23568. private triangles;
  23569. private vertices;
  23570. private references;
  23571. private _reconstructedMesh;
  23572. syncIterations: number;
  23573. aggressiveness: number;
  23574. decimationIterations: number;
  23575. boundingBoxEpsilon: number;
  23576. constructor(_mesh: Mesh);
  23577. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23578. private runDecimation;
  23579. private initWithMesh;
  23580. private init;
  23581. private reconstructMesh;
  23582. private initDecimatedMesh;
  23583. private isFlipped;
  23584. private updateTriangles;
  23585. private identifyBorder;
  23586. private updateMesh;
  23587. private vertexError;
  23588. private calculateError;
  23589. }
  23590. }
  23591. declare module BABYLON {
  23592. interface Scene {
  23593. /** @hidden (Backing field) */
  23594. _simplificationQueue: SimplificationQueue;
  23595. /**
  23596. * Gets or sets the simplification queue attached to the scene
  23597. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  23598. */
  23599. simplificationQueue: SimplificationQueue;
  23600. }
  23601. interface Mesh {
  23602. /**
  23603. * Simplify the mesh according to the given array of settings.
  23604. * Function will return immediately and will simplify async. It returns the Mesh.
  23605. * @param settings a collection of simplification settings.
  23606. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23607. * @param type the type of simplification to run.
  23608. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23609. */
  23610. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23611. }
  23612. /**
  23613. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  23614. * created in a scene
  23615. */
  23616. class SimplicationQueueSceneComponent implements ISceneComponent {
  23617. /**
  23618. * The component name helpfull to identify the component in the list of scene components.
  23619. */
  23620. readonly name: string;
  23621. /**
  23622. * The scene the component belongs to.
  23623. */
  23624. scene: Scene;
  23625. /**
  23626. * Creates a new instance of the component for the given scene
  23627. * @param scene Defines the scene to register the component in
  23628. */
  23629. constructor(scene: Scene);
  23630. /**
  23631. * Registers the component in a given scene
  23632. */
  23633. register(): void;
  23634. /**
  23635. * Rebuilds the elements related to this component in case of
  23636. * context lost for instance.
  23637. */
  23638. rebuild(): void;
  23639. /**
  23640. * Disposes the component and the associated ressources
  23641. */
  23642. dispose(): void;
  23643. private _beforeCameraUpdate;
  23644. }
  23645. }
  23646. declare module BABYLON {
  23647. class Polygon {
  23648. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23649. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23650. static Parse(input: string): Vector2[];
  23651. static StartingAt(x: number, y: number): Path2;
  23652. }
  23653. class PolygonMeshBuilder {
  23654. private _points;
  23655. private _outlinepoints;
  23656. private _holes;
  23657. private _name;
  23658. private _scene;
  23659. private _epoints;
  23660. private _eholes;
  23661. private _addToepoint;
  23662. constructor(name: string, contours: Path2, scene: Scene);
  23663. constructor(name: string, contours: Vector2[], scene: Scene);
  23664. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23665. build(updatable?: boolean, depth?: number): Mesh;
  23666. private addSide;
  23667. }
  23668. }
  23669. declare module BABYLON {
  23670. class BaseSubMesh {
  23671. /** @hidden */
  23672. _materialDefines: Nullable<MaterialDefines>;
  23673. /** @hidden */
  23674. _materialEffect: Nullable<Effect>;
  23675. readonly effect: Nullable<Effect>;
  23676. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23677. }
  23678. class SubMesh extends BaseSubMesh implements ICullable {
  23679. materialIndex: number;
  23680. verticesStart: number;
  23681. verticesCount: number;
  23682. indexStart: number;
  23683. indexCount: number;
  23684. linesIndexCount: number;
  23685. private _mesh;
  23686. private _renderingMesh;
  23687. private _boundingInfo;
  23688. private _linesIndexBuffer;
  23689. /** @hidden */
  23690. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23691. /** @hidden */
  23692. _trianglePlanes: Plane[];
  23693. /** @hidden */
  23694. _lastColliderTransformMatrix: Matrix;
  23695. /** @hidden */
  23696. _renderId: number;
  23697. /** @hidden */
  23698. _alphaIndex: number;
  23699. /** @hidden */
  23700. _distanceToCamera: number;
  23701. /** @hidden */
  23702. _id: number;
  23703. private _currentMaterial;
  23704. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23705. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23706. readonly IsGlobal: boolean;
  23707. /**
  23708. * Returns the submesh BoudingInfo object.
  23709. */
  23710. getBoundingInfo(): BoundingInfo;
  23711. /**
  23712. * Sets the submesh BoundingInfo.
  23713. * Return the SubMesh.
  23714. */
  23715. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23716. /**
  23717. * Returns the mesh of the current submesh.
  23718. */
  23719. getMesh(): AbstractMesh;
  23720. /**
  23721. * Returns the rendering mesh of the submesh.
  23722. */
  23723. getRenderingMesh(): Mesh;
  23724. /**
  23725. * Returns the submesh material.
  23726. */
  23727. getMaterial(): Nullable<Material>;
  23728. /**
  23729. * Sets a new updated BoundingInfo object to the submesh.
  23730. * Returns the SubMesh.
  23731. */
  23732. refreshBoundingInfo(): SubMesh;
  23733. /** @hidden */
  23734. _checkCollision(collider: Collider): boolean;
  23735. /**
  23736. * Updates the submesh BoundingInfo.
  23737. * Returns the Submesh.
  23738. */
  23739. updateBoundingInfo(world: Matrix): SubMesh;
  23740. /**
  23741. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23742. * Boolean returned.
  23743. */
  23744. isInFrustum(frustumPlanes: Plane[]): boolean;
  23745. /**
  23746. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23747. * Boolean returned.
  23748. */
  23749. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23750. /**
  23751. * Renders the submesh.
  23752. * Returns it.
  23753. */
  23754. render(enableAlphaMode: boolean): SubMesh;
  23755. /**
  23756. * Returns a new Index Buffer.
  23757. * Type returned : WebGLBuffer.
  23758. */
  23759. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23760. /**
  23761. * True is the passed Ray intersects the submesh bounding box.
  23762. * Boolean returned.
  23763. */
  23764. canIntersects(ray: Ray): boolean;
  23765. /**
  23766. * Returns an object IntersectionInfo.
  23767. */
  23768. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23769. /** @hidden */
  23770. _rebuild(): void;
  23771. /**
  23772. * Creates a new Submesh from the passed Mesh.
  23773. */
  23774. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23775. /**
  23776. * Disposes the Submesh.
  23777. * Returns nothing.
  23778. */
  23779. dispose(): void;
  23780. /**
  23781. * Creates a new Submesh from the passed parameters :
  23782. * - materialIndex (integer) : the index of the main mesh material.
  23783. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23784. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23785. * - mesh (Mesh) : the main mesh to create the submesh from.
  23786. * - renderingMesh (optional Mesh) : rendering mesh.
  23787. */
  23788. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23789. }
  23790. }
  23791. declare module BABYLON {
  23792. class TransformNode extends Node {
  23793. static BILLBOARDMODE_NONE: number;
  23794. static BILLBOARDMODE_X: number;
  23795. static BILLBOARDMODE_Y: number;
  23796. static BILLBOARDMODE_Z: number;
  23797. static BILLBOARDMODE_ALL: number;
  23798. private _forward;
  23799. private _forwardInverted;
  23800. private _up;
  23801. private _right;
  23802. private _rightInverted;
  23803. private _rotation;
  23804. private _rotationQuaternion;
  23805. protected _scaling: Vector3;
  23806. protected _isDirty: boolean;
  23807. private _transformToBoneReferal;
  23808. /**
  23809. * Set the billboard mode. Default is 0.
  23810. *
  23811. * | Value | Type | Description |
  23812. * | --- | --- | --- |
  23813. * | 0 | BILLBOARDMODE_NONE | |
  23814. * | 1 | BILLBOARDMODE_X | |
  23815. * | 2 | BILLBOARDMODE_Y | |
  23816. * | 4 | BILLBOARDMODE_Z | |
  23817. * | 7 | BILLBOARDMODE_ALL | |
  23818. *
  23819. */
  23820. billboardMode: number;
  23821. scalingDeterminant: number;
  23822. infiniteDistance: boolean;
  23823. /**
  23824. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23825. * By default the system will update normals to compensate
  23826. */
  23827. ignoreNonUniformScaling: boolean;
  23828. position: Vector3;
  23829. /** @hidden */
  23830. _poseMatrix: Matrix;
  23831. private _localWorld;
  23832. /** @hidden */
  23833. _worldMatrix: Matrix;
  23834. /** @hidden */
  23835. _worldMatrixDeterminant: number;
  23836. private _absolutePosition;
  23837. private _pivotMatrix;
  23838. private _pivotMatrixInverse;
  23839. private _postMultiplyPivotMatrix;
  23840. protected _isWorldMatrixFrozen: boolean;
  23841. /**
  23842. * An event triggered after the world matrix is updated
  23843. */
  23844. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23845. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23846. /**
  23847. * Gets a string identifying the name of the class
  23848. * @returns "TransformNode" string
  23849. */
  23850. getClassName(): string;
  23851. /**
  23852. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23853. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23854. * Default : (0.0, 0.0, 0.0)
  23855. */
  23856. rotation: Vector3;
  23857. /**
  23858. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23859. * Default : (1.0, 1.0, 1.0)
  23860. */
  23861. /**
  23862. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23863. * Default : (1.0, 1.0, 1.0)
  23864. */
  23865. scaling: Vector3;
  23866. /**
  23867. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23868. * It's null by default.
  23869. * 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)
  23870. */
  23871. rotationQuaternion: Nullable<Quaternion>;
  23872. /**
  23873. * The forward direction of that transform in world space.
  23874. */
  23875. readonly forward: Vector3;
  23876. /**
  23877. * The up direction of that transform in world space.
  23878. */
  23879. readonly up: Vector3;
  23880. /**
  23881. * The right direction of that transform in world space.
  23882. */
  23883. readonly right: Vector3;
  23884. /**
  23885. * Returns the latest update of the World matrix
  23886. * Returns a Matrix.
  23887. */
  23888. getWorldMatrix(): Matrix;
  23889. /** @hidden */
  23890. _getWorldMatrixDeterminant(): number;
  23891. /**
  23892. * Returns directly the latest state of the mesh World matrix.
  23893. * A Matrix is returned.
  23894. */
  23895. readonly worldMatrixFromCache: Matrix;
  23896. /**
  23897. * Copies the parameter passed Matrix into the mesh Pose matrix.
  23898. * Returns the TransformNode.
  23899. */
  23900. updatePoseMatrix(matrix: Matrix): TransformNode;
  23901. /**
  23902. * Returns the mesh Pose matrix.
  23903. * Returned object : Matrix
  23904. */
  23905. getPoseMatrix(): Matrix;
  23906. /** @hidden */
  23907. _isSynchronized(): boolean;
  23908. /** @hidden */
  23909. _initCache(): void;
  23910. markAsDirty(property: string): TransformNode;
  23911. /**
  23912. * Returns the current mesh absolute position.
  23913. * Returns a Vector3.
  23914. */
  23915. readonly absolutePosition: Vector3;
  23916. /**
  23917. * Sets a new matrix to apply before all other transformation
  23918. * @param matrix defines the transform matrix
  23919. * @returns the current TransformNode
  23920. */
  23921. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23922. /**
  23923. * Sets a new pivot matrix to the current node
  23924. * @param matrix defines the new pivot matrix to use
  23925. * @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
  23926. * @returns the current TransformNode
  23927. */
  23928. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23929. /**
  23930. * Returns the mesh pivot matrix.
  23931. * Default : Identity.
  23932. * A Matrix is returned.
  23933. */
  23934. getPivotMatrix(): Matrix;
  23935. /**
  23936. * Prevents the World matrix to be computed any longer.
  23937. * Returns the TransformNode.
  23938. */
  23939. freezeWorldMatrix(): TransformNode;
  23940. /**
  23941. * Allows back the World matrix computation.
  23942. * Returns the TransformNode.
  23943. */
  23944. unfreezeWorldMatrix(): this;
  23945. /**
  23946. * True if the World matrix has been frozen.
  23947. * Returns a boolean.
  23948. */
  23949. readonly isWorldMatrixFrozen: boolean;
  23950. /**
  23951. * Retuns the mesh absolute position in the World.
  23952. * Returns a Vector3.
  23953. */
  23954. getAbsolutePosition(): Vector3;
  23955. /**
  23956. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23957. * Returns the TransformNode.
  23958. */
  23959. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23960. /**
  23961. * Sets the mesh position in its local space.
  23962. * Returns the TransformNode.
  23963. */
  23964. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23965. /**
  23966. * Returns the mesh position in the local space from the current World matrix values.
  23967. * Returns a new Vector3.
  23968. */
  23969. getPositionExpressedInLocalSpace(): Vector3;
  23970. /**
  23971. * Translates the mesh along the passed Vector3 in its local space.
  23972. * Returns the TransformNode.
  23973. */
  23974. locallyTranslate(vector3: Vector3): TransformNode;
  23975. private static _lookAtVectorCache;
  23976. /**
  23977. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23978. * @param targetPoint the position (must be in same space as current mesh) to look at
  23979. * @param yawCor optional yaw (y-axis) correction in radians
  23980. * @param pitchCor optional pitch (x-axis) correction in radians
  23981. * @param rollCor optional roll (z-axis) correction in radians
  23982. * @param space the choosen space of the target
  23983. * @returns the TransformNode.
  23984. */
  23985. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23986. /**
  23987. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23988. * This Vector3 is expressed in the World space.
  23989. */
  23990. getDirection(localAxis: Vector3): Vector3;
  23991. /**
  23992. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23993. * localAxis is expressed in the mesh local space.
  23994. * result is computed in the Wordl space from the mesh World matrix.
  23995. * Returns the TransformNode.
  23996. */
  23997. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23998. /**
  23999. * Sets a new pivot point to the current node
  24000. * @param point defines the new pivot point to use
  24001. * @param space defines if the point is in world or local space (local by default)
  24002. * @returns the current TransformNode
  24003. */
  24004. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24005. /**
  24006. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24007. */
  24008. getPivotPoint(): Vector3;
  24009. /**
  24010. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24011. * Returns the TransformNode.
  24012. */
  24013. getPivotPointToRef(result: Vector3): TransformNode;
  24014. /**
  24015. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24016. */
  24017. getAbsolutePivotPoint(): Vector3;
  24018. /**
  24019. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24020. * Returns the TransformNode.
  24021. */
  24022. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24023. /**
  24024. * Defines the passed node as the parent of the current node.
  24025. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24026. * Returns the TransformNode.
  24027. */
  24028. setParent(node: Nullable<Node>): TransformNode;
  24029. private _nonUniformScaling;
  24030. readonly nonUniformScaling: boolean;
  24031. /** @hidden */
  24032. _updateNonUniformScalingState(value: boolean): boolean;
  24033. /**
  24034. * Attach the current TransformNode to another TransformNode associated with a bone
  24035. * @param bone Bone affecting the TransformNode
  24036. * @param affectedTransformNode TransformNode associated with the bone
  24037. */
  24038. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24039. detachFromBone(): TransformNode;
  24040. private static _rotationAxisCache;
  24041. /**
  24042. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24043. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24044. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24045. * The passed axis is also normalized.
  24046. * Returns the TransformNode.
  24047. */
  24048. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24049. /**
  24050. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24051. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24052. * The passed axis is also normalized.
  24053. * Returns the TransformNode.
  24054. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24055. */
  24056. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24057. /**
  24058. * Translates the mesh along the axis vector for the passed distance in the given space.
  24059. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24060. * Returns the TransformNode.
  24061. */
  24062. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24063. /**
  24064. * Adds a rotation step to the mesh current rotation.
  24065. * x, y, z are Euler angles expressed in radians.
  24066. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24067. * This means this rotation is made in the mesh local space only.
  24068. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24069. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24070. * ```javascript
  24071. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24072. * ```
  24073. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24074. * 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.
  24075. * Returns the TransformNode.
  24076. */
  24077. addRotation(x: number, y: number, z: number): TransformNode;
  24078. /**
  24079. * Computes the mesh World matrix and returns it.
  24080. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24081. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24082. * If the parameter `force`is set to `true`, the actual computation is done.
  24083. * Returns the mesh World Matrix.
  24084. */
  24085. computeWorldMatrix(force?: boolean): Matrix;
  24086. protected _afterComputeWorldMatrix(): void;
  24087. /**
  24088. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24089. * @param func: callback function to add
  24090. *
  24091. * Returns the TransformNode.
  24092. */
  24093. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24094. /**
  24095. * Removes a registered callback function.
  24096. * Returns the TransformNode.
  24097. */
  24098. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24099. /**
  24100. * Clone the current transform node
  24101. * Returns the new transform node
  24102. * @param name Name of the new clone
  24103. * @param newParent New parent for the clone
  24104. * @param doNotCloneChildren Do not clone children hierarchy
  24105. */
  24106. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24107. serialize(currentSerializationObject?: any): any;
  24108. /**
  24109. * Returns a new TransformNode object parsed from the source provided.
  24110. * The parameter `parsedMesh` is the source.
  24111. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24112. */
  24113. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24114. /**
  24115. * Releases resources associated with this transform node.
  24116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24118. */
  24119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24120. }
  24121. }
  24122. declare module BABYLON {
  24123. class VertexBuffer {
  24124. /** @hidden */
  24125. _buffer: Buffer;
  24126. private _kind;
  24127. private _size;
  24128. private _ownsBuffer;
  24129. private _instanced;
  24130. private _instanceDivisor;
  24131. /**
  24132. * The byte type.
  24133. */
  24134. static readonly BYTE: number;
  24135. /**
  24136. * The unsigned byte type.
  24137. */
  24138. static readonly UNSIGNED_BYTE: number;
  24139. /**
  24140. * The short type.
  24141. */
  24142. static readonly SHORT: number;
  24143. /**
  24144. * The unsigned short type.
  24145. */
  24146. static readonly UNSIGNED_SHORT: number;
  24147. /**
  24148. * The integer type.
  24149. */
  24150. static readonly INT: number;
  24151. /**
  24152. * The unsigned integer type.
  24153. */
  24154. static readonly UNSIGNED_INT: number;
  24155. /**
  24156. * The float type.
  24157. */
  24158. static readonly FLOAT: number;
  24159. /**
  24160. * Gets or sets the instance divisor when in instanced mode
  24161. */
  24162. instanceDivisor: number;
  24163. /**
  24164. * Gets the byte stride.
  24165. */
  24166. readonly byteStride: number;
  24167. /**
  24168. * Gets the byte offset.
  24169. */
  24170. readonly byteOffset: number;
  24171. /**
  24172. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24173. */
  24174. readonly normalized: boolean;
  24175. /**
  24176. * Gets the data type of each component in the array.
  24177. */
  24178. readonly type: number;
  24179. /**
  24180. * Constructor
  24181. * @param engine the engine
  24182. * @param data the data to use for this vertex buffer
  24183. * @param kind the vertex buffer kind
  24184. * @param updatable whether the data is updatable
  24185. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24186. * @param stride the stride (optional)
  24187. * @param instanced whether the buffer is instanced (optional)
  24188. * @param offset the offset of the data (optional)
  24189. * @param size the number of components (optional)
  24190. * @param type the type of the component (optional)
  24191. * @param normalized whether the data contains normalized data (optional)
  24192. * @param useBytes set to true if stride and offset are in bytes (optional)
  24193. */
  24194. 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);
  24195. /** @hidden */
  24196. _rebuild(): void;
  24197. /**
  24198. * Returns the kind of the VertexBuffer (string).
  24199. */
  24200. getKind(): string;
  24201. /**
  24202. * Boolean : is the VertexBuffer updatable ?
  24203. */
  24204. isUpdatable(): boolean;
  24205. /**
  24206. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24207. */
  24208. getData(): Nullable<DataArray>;
  24209. /**
  24210. * Returns the WebGLBuffer associated to the VertexBuffer.
  24211. */
  24212. getBuffer(): Nullable<WebGLBuffer>;
  24213. /**
  24214. * Returns the stride as a multiple of the type byte length.
  24215. * DEPRECATED. Use byteStride instead.
  24216. */
  24217. getStrideSize(): number;
  24218. /**
  24219. * Returns the offset as a multiple of the type byte length.
  24220. * DEPRECATED. Use byteOffset instead.
  24221. */
  24222. getOffset(): number;
  24223. /**
  24224. * Returns the number of components per vertex attribute (integer).
  24225. */
  24226. getSize(): number;
  24227. /**
  24228. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24229. */
  24230. getIsInstanced(): boolean;
  24231. /**
  24232. * Returns the instancing divisor, zero for non-instanced (integer).
  24233. */
  24234. getInstanceDivisor(): number;
  24235. /**
  24236. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24237. * Returns the created WebGLBuffer.
  24238. */
  24239. create(data?: DataArray): void;
  24240. /**
  24241. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24242. * This function will create a new buffer if the current one is not updatable
  24243. * Returns the updated WebGLBuffer.
  24244. */
  24245. update(data: DataArray): void;
  24246. /**
  24247. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24248. * Returns the directly updated WebGLBuffer.
  24249. * @param data the new data
  24250. * @param offset the new offset
  24251. * @param useBytes set to true if the offset is in bytes
  24252. */
  24253. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24254. /**
  24255. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24256. */
  24257. dispose(): void;
  24258. /**
  24259. * Enumerates each value of this vertex buffer as numbers.
  24260. * @param count the number of values to enumerate
  24261. * @param callback the callback function called for each value
  24262. */
  24263. forEach(count: number, callback: (value: number, index: number) => void): void;
  24264. private static _PositionKind;
  24265. private static _NormalKind;
  24266. private static _TangentKind;
  24267. private static _UVKind;
  24268. private static _UV2Kind;
  24269. private static _UV3Kind;
  24270. private static _UV4Kind;
  24271. private static _UV5Kind;
  24272. private static _UV6Kind;
  24273. private static _ColorKind;
  24274. private static _MatricesIndicesKind;
  24275. private static _MatricesWeightsKind;
  24276. private static _MatricesIndicesExtraKind;
  24277. private static _MatricesWeightsExtraKind;
  24278. static readonly PositionKind: string;
  24279. static readonly NormalKind: string;
  24280. static readonly TangentKind: string;
  24281. static readonly UVKind: string;
  24282. static readonly UV2Kind: string;
  24283. static readonly UV3Kind: string;
  24284. static readonly UV4Kind: string;
  24285. static readonly UV5Kind: string;
  24286. static readonly UV6Kind: string;
  24287. static readonly ColorKind: string;
  24288. static readonly MatricesIndicesKind: string;
  24289. static readonly MatricesWeightsKind: string;
  24290. static readonly MatricesIndicesExtraKind: string;
  24291. static readonly MatricesWeightsExtraKind: string;
  24292. /**
  24293. * Deduces the stride given a kind.
  24294. * @param kind The kind string to deduce
  24295. * @returns The deduced stride
  24296. */
  24297. static DeduceStride(kind: string): number;
  24298. /**
  24299. * Gets the byte length of the given type.
  24300. * @param type the type
  24301. * @returns the number of bytes
  24302. */
  24303. static GetTypeByteLength(type: number): number;
  24304. /**
  24305. * Enumerates each value of the given parameters as numbers.
  24306. * @param data the data to enumerate
  24307. * @param byteOffset the byte offset of the data
  24308. * @param byteStride the byte stride of the data
  24309. * @param componentCount the number of components per element
  24310. * @param componentType the type of the component
  24311. * @param count the total number of components
  24312. * @param normalized whether the data is normalized
  24313. * @param callback the callback function called for each value
  24314. */
  24315. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24316. private static _GetFloatValue;
  24317. }
  24318. }
  24319. declare module BABYLON {
  24320. /**
  24321. * Defines a target to use with MorphTargetManager
  24322. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24323. */
  24324. class MorphTarget implements IAnimatable {
  24325. /** defines the name of the target */
  24326. name: string;
  24327. /**
  24328. * Gets or sets the list of animations
  24329. */
  24330. animations: Animation[];
  24331. private _scene;
  24332. private _positions;
  24333. private _normals;
  24334. private _tangents;
  24335. private _influence;
  24336. /**
  24337. * Observable raised when the influence changes
  24338. */
  24339. onInfluenceChanged: Observable<boolean>;
  24340. /**
  24341. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24342. */
  24343. influence: number;
  24344. private _animationPropertiesOverride;
  24345. /**
  24346. * Gets or sets the animation properties override
  24347. */
  24348. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24349. /**
  24350. * Creates a new MorphTarget
  24351. * @param name defines the name of the target
  24352. * @param influence defines the influence to use
  24353. */
  24354. constructor(
  24355. /** defines the name of the target */
  24356. name: string, influence?: number, scene?: Nullable<Scene>);
  24357. /**
  24358. * Gets a boolean defining if the target contains position data
  24359. */
  24360. readonly hasPositions: boolean;
  24361. /**
  24362. * Gets a boolean defining if the target contains normal data
  24363. */
  24364. readonly hasNormals: boolean;
  24365. /**
  24366. * Gets a boolean defining if the target contains tangent data
  24367. */
  24368. readonly hasTangents: boolean;
  24369. /**
  24370. * Affects position data to this target
  24371. * @param data defines the position data to use
  24372. */
  24373. setPositions(data: Nullable<FloatArray>): void;
  24374. /**
  24375. * Gets the position data stored in this target
  24376. * @returns a FloatArray containing the position data (or null if not present)
  24377. */
  24378. getPositions(): Nullable<FloatArray>;
  24379. /**
  24380. * Affects normal data to this target
  24381. * @param data defines the normal data to use
  24382. */
  24383. setNormals(data: Nullable<FloatArray>): void;
  24384. /**
  24385. * Gets the normal data stored in this target
  24386. * @returns a FloatArray containing the normal data (or null if not present)
  24387. */
  24388. getNormals(): Nullable<FloatArray>;
  24389. /**
  24390. * Affects tangent data to this target
  24391. * @param data defines the tangent data to use
  24392. */
  24393. setTangents(data: Nullable<FloatArray>): void;
  24394. /**
  24395. * Gets the tangent data stored in this target
  24396. * @returns a FloatArray containing the tangent data (or null if not present)
  24397. */
  24398. getTangents(): Nullable<FloatArray>;
  24399. /**
  24400. * Serializes the current target into a Serialization object
  24401. * @returns the serialized object
  24402. */
  24403. serialize(): any;
  24404. /**
  24405. * Creates a new target from serialized data
  24406. * @param serializationObject defines the serialized data to use
  24407. * @returns a new MorphTarget
  24408. */
  24409. static Parse(serializationObject: any): MorphTarget;
  24410. /**
  24411. * Creates a MorphTarget from mesh data
  24412. * @param mesh defines the source mesh
  24413. * @param name defines the name to use for the new target
  24414. * @param influence defines the influence to attach to the target
  24415. * @returns a new MorphTarget
  24416. */
  24417. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24418. }
  24419. }
  24420. declare module BABYLON {
  24421. /**
  24422. * This class is used to deform meshes using morphing between different targets
  24423. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24424. */
  24425. class MorphTargetManager {
  24426. private _targets;
  24427. private _targetObservable;
  24428. private _activeTargets;
  24429. private _scene;
  24430. private _influences;
  24431. private _supportsNormals;
  24432. private _supportsTangents;
  24433. private _vertexCount;
  24434. private _uniqueId;
  24435. private _tempInfluences;
  24436. /**
  24437. * Creates a new MorphTargetManager
  24438. * @param scene defines the current scene
  24439. */
  24440. constructor(scene?: Nullable<Scene>);
  24441. /**
  24442. * Gets the unique ID of this manager
  24443. */
  24444. readonly uniqueId: number;
  24445. /**
  24446. * Gets the number of vertices handled by this manager
  24447. */
  24448. readonly vertexCount: number;
  24449. /**
  24450. * Gets a boolean indicating if this manager supports morphing of normals
  24451. */
  24452. readonly supportsNormals: boolean;
  24453. /**
  24454. * Gets a boolean indicating if this manager supports morphing of tangents
  24455. */
  24456. readonly supportsTangents: boolean;
  24457. /**
  24458. * Gets the number of targets stored in this manager
  24459. */
  24460. readonly numTargets: number;
  24461. /**
  24462. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24463. */
  24464. readonly numInfluencers: number;
  24465. /**
  24466. * Gets the list of influences (one per target)
  24467. */
  24468. readonly influences: Float32Array;
  24469. /**
  24470. * Gets the active target at specified index. An active target is a target with an influence > 0
  24471. * @param index defines the index to check
  24472. * @returns the requested target
  24473. */
  24474. getActiveTarget(index: number): MorphTarget;
  24475. /**
  24476. * Gets the target at specified index
  24477. * @param index defines the index to check
  24478. * @returns the requested target
  24479. */
  24480. getTarget(index: number): MorphTarget;
  24481. /**
  24482. * Add a new target to this manager
  24483. * @param target defines the target to add
  24484. */
  24485. addTarget(target: MorphTarget): void;
  24486. /**
  24487. * Removes a target from the manager
  24488. * @param target defines the target to remove
  24489. */
  24490. removeTarget(target: MorphTarget): void;
  24491. /**
  24492. * Serializes the current manager into a Serialization object
  24493. * @returns the serialized object
  24494. */
  24495. serialize(): any;
  24496. private _syncActiveTargets;
  24497. /**
  24498. * Syncrhonize the targets with all the meshes using this morph target manager
  24499. */
  24500. synchronize(): void;
  24501. /**
  24502. * Creates a new MorphTargetManager from serialized data
  24503. * @param serializationObject defines the serialized data
  24504. * @param scene defines the hosting scene
  24505. * @returns the new MorphTargetManager
  24506. */
  24507. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24508. }
  24509. }
  24510. declare module BABYLON {
  24511. interface PhysicsImpostorJoint {
  24512. mainImpostor: PhysicsImpostor;
  24513. connectedImpostor: PhysicsImpostor;
  24514. joint: PhysicsJoint;
  24515. }
  24516. class PhysicsEngine {
  24517. private _physicsPlugin;
  24518. gravity: Vector3;
  24519. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24520. setGravity(gravity: Vector3): void;
  24521. /**
  24522. * Set the time step of the physics engine.
  24523. * default is 1/60.
  24524. * To slow it down, enter 1/600 for example.
  24525. * To speed it up, 1/30
  24526. * @param {number} newTimeStep the new timestep to apply to this world.
  24527. */
  24528. setTimeStep(newTimeStep?: number): void;
  24529. /**
  24530. * Get the time step of the physics engine.
  24531. */
  24532. getTimeStep(): number;
  24533. dispose(): void;
  24534. getPhysicsPluginName(): string;
  24535. static Epsilon: number;
  24536. private _impostors;
  24537. private _joints;
  24538. /**
  24539. * Adding a new impostor for the impostor tracking.
  24540. * This will be done by the impostor itself.
  24541. * @param {PhysicsImpostor} impostor the impostor to add
  24542. */
  24543. addImpostor(impostor: PhysicsImpostor): void;
  24544. /**
  24545. * Remove an impostor from the engine.
  24546. * This impostor and its mesh will not longer be updated by the physics engine.
  24547. * @param {PhysicsImpostor} impostor the impostor to remove
  24548. */
  24549. removeImpostor(impostor: PhysicsImpostor): void;
  24550. /**
  24551. * Add a joint to the physics engine
  24552. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24553. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24554. * @param {PhysicsJoint} the joint that will connect both impostors.
  24555. */
  24556. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24557. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24558. /**
  24559. * Called by the scene. no need to call it.
  24560. * @hidden
  24561. */
  24562. _step(delta: number): void;
  24563. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24564. getImpostors(): Array<PhysicsImpostor>;
  24565. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24566. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24567. }
  24568. interface IPhysicsEnginePlugin {
  24569. world: any;
  24570. name: string;
  24571. setGravity(gravity: Vector3): void;
  24572. setTimeStep(timeStep: number): void;
  24573. getTimeStep(): number;
  24574. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24575. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24576. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24577. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24578. removePhysicsBody(impostor: PhysicsImpostor): void;
  24579. generateJoint(joint: PhysicsImpostorJoint): void;
  24580. removeJoint(joint: PhysicsImpostorJoint): void;
  24581. isSupported(): boolean;
  24582. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24583. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24584. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24585. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24586. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24588. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24589. getBodyMass(impostor: PhysicsImpostor): number;
  24590. getBodyFriction(impostor: PhysicsImpostor): number;
  24591. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24592. getBodyRestitution(impostor: PhysicsImpostor): number;
  24593. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24594. sleepBody(impostor: PhysicsImpostor): void;
  24595. wakeUpBody(impostor: PhysicsImpostor): void;
  24596. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24597. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24598. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24599. getRadius(impostor: PhysicsImpostor): number;
  24600. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24601. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24602. dispose(): void;
  24603. }
  24604. }
  24605. declare module BABYLON {
  24606. class PhysicsHelper {
  24607. private _scene;
  24608. private _physicsEngine;
  24609. constructor(scene: Scene);
  24610. /**
  24611. * @param {Vector3} origin the origin of the explosion
  24612. * @param {number} radius the explosion radius
  24613. * @param {number} strength the explosion strength
  24614. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24615. */
  24616. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24617. /**
  24618. * @param {Vector3} origin the origin of the explosion
  24619. * @param {number} radius the explosion radius
  24620. * @param {number} strength the explosion strength
  24621. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24622. */
  24623. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24624. /**
  24625. * @param {Vector3} origin the origin of the explosion
  24626. * @param {number} radius the explosion radius
  24627. * @param {number} strength the explosion strength
  24628. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24629. */
  24630. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24631. /**
  24632. * @param {Vector3} origin the origin of the updraft
  24633. * @param {number} radius the radius of the updraft
  24634. * @param {number} strength the strength of the updraft
  24635. * @param {number} height the height of the updraft
  24636. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24637. */
  24638. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24639. /**
  24640. * @param {Vector3} origin the of the vortex
  24641. * @param {number} radius the radius of the vortex
  24642. * @param {number} strength the strength of the vortex
  24643. * @param {number} height the height of the vortex
  24644. */
  24645. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24646. }
  24647. /***** Radial explosion *****/
  24648. class PhysicsRadialExplosionEvent {
  24649. private _scene;
  24650. private _sphere;
  24651. private _sphereOptions;
  24652. private _rays;
  24653. private _dataFetched;
  24654. constructor(scene: Scene);
  24655. /**
  24656. * Returns the data related to the radial explosion event (sphere & rays).
  24657. * @returns {PhysicsRadialExplosionEventData}
  24658. */
  24659. getData(): PhysicsRadialExplosionEventData;
  24660. /**
  24661. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24662. * @param impostor
  24663. * @param {Vector3} origin the origin of the explosion
  24664. * @param {number} radius the explosion radius
  24665. * @param {number} strength the explosion strength
  24666. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24667. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24668. */
  24669. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24670. /**
  24671. * Disposes the sphere.
  24672. * @param {bolean} force
  24673. */
  24674. dispose(force?: boolean): void;
  24675. /*** Helpers ***/
  24676. private _prepareSphere;
  24677. private _intersectsWithSphere;
  24678. }
  24679. /***** Gravitational Field *****/
  24680. class PhysicsGravitationalFieldEvent {
  24681. private _physicsHelper;
  24682. private _scene;
  24683. private _origin;
  24684. private _radius;
  24685. private _strength;
  24686. private _falloff;
  24687. private _tickCallback;
  24688. private _sphere;
  24689. private _dataFetched;
  24690. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24691. /**
  24692. * Returns the data related to the gravitational field event (sphere).
  24693. * @returns {PhysicsGravitationalFieldEventData}
  24694. */
  24695. getData(): PhysicsGravitationalFieldEventData;
  24696. /**
  24697. * Enables the gravitational field.
  24698. */
  24699. enable(): void;
  24700. /**
  24701. * Disables the gravitational field.
  24702. */
  24703. disable(): void;
  24704. /**
  24705. * Disposes the sphere.
  24706. * @param {bolean} force
  24707. */
  24708. dispose(force?: boolean): void;
  24709. private _tick;
  24710. }
  24711. /***** Updraft *****/
  24712. class PhysicsUpdraftEvent {
  24713. private _scene;
  24714. private _origin;
  24715. private _radius;
  24716. private _strength;
  24717. private _height;
  24718. private _updraftMode;
  24719. private _physicsEngine;
  24720. private _originTop;
  24721. private _originDirection;
  24722. private _tickCallback;
  24723. private _cylinder;
  24724. private _cylinderPosition;
  24725. private _dataFetched;
  24726. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24727. /**
  24728. * Returns the data related to the updraft event (cylinder).
  24729. * @returns {PhysicsUpdraftEventData}
  24730. */
  24731. getData(): PhysicsUpdraftEventData;
  24732. /**
  24733. * Enables the updraft.
  24734. */
  24735. enable(): void;
  24736. /**
  24737. * Disables the cortex.
  24738. */
  24739. disable(): void;
  24740. /**
  24741. * Disposes the sphere.
  24742. * @param {bolean} force
  24743. */
  24744. dispose(force?: boolean): void;
  24745. private getImpostorForceAndContactPoint;
  24746. private _tick;
  24747. /*** Helpers ***/
  24748. private _prepareCylinder;
  24749. private _intersectsWithCylinder;
  24750. }
  24751. /***** Vortex *****/
  24752. class PhysicsVortexEvent {
  24753. private _scene;
  24754. private _origin;
  24755. private _radius;
  24756. private _strength;
  24757. private _height;
  24758. private _physicsEngine;
  24759. private _originTop;
  24760. private _centripetalForceThreshold;
  24761. private _updraftMultiplier;
  24762. private _tickCallback;
  24763. private _cylinder;
  24764. private _cylinderPosition;
  24765. private _dataFetched;
  24766. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24767. /**
  24768. * Returns the data related to the vortex event (cylinder).
  24769. * @returns {PhysicsVortexEventData}
  24770. */
  24771. getData(): PhysicsVortexEventData;
  24772. /**
  24773. * Enables the vortex.
  24774. */
  24775. enable(): void;
  24776. /**
  24777. * Disables the cortex.
  24778. */
  24779. disable(): void;
  24780. /**
  24781. * Disposes the sphere.
  24782. * @param {bolean} force
  24783. */
  24784. dispose(force?: boolean): void;
  24785. private getImpostorForceAndContactPoint;
  24786. private _tick;
  24787. /*** Helpers ***/
  24788. private _prepareCylinder;
  24789. private _intersectsWithCylinder;
  24790. }
  24791. /***** Enums *****/
  24792. /**
  24793. * The strenght of the force in correspondence to the distance of the affected object
  24794. */
  24795. enum PhysicsRadialImpulseFalloff {
  24796. /** Defines that impulse is constant in strength across it's whole radius */
  24797. Constant = 0,
  24798. /** DEfines that impulse gets weaker if it's further from the origin */
  24799. Linear = 1
  24800. }
  24801. /**
  24802. * The strenght of the force in correspondence to the distance of the affected object
  24803. */
  24804. enum PhysicsUpdraftMode {
  24805. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24806. Center = 0,
  24807. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24808. Perpendicular = 1
  24809. }
  24810. /***** Data interfaces *****/
  24811. interface PhysicsForceAndContactPoint {
  24812. force: Vector3;
  24813. contactPoint: Vector3;
  24814. }
  24815. interface PhysicsRadialExplosionEventData {
  24816. sphere: Mesh;
  24817. rays: Array<Ray>;
  24818. }
  24819. interface PhysicsGravitationalFieldEventData {
  24820. sphere: Mesh;
  24821. }
  24822. interface PhysicsUpdraftEventData {
  24823. cylinder: Mesh;
  24824. }
  24825. interface PhysicsVortexEventData {
  24826. cylinder: Mesh;
  24827. }
  24828. }
  24829. declare module BABYLON {
  24830. interface PhysicsImpostorParameters {
  24831. mass: number;
  24832. friction?: number;
  24833. restitution?: number;
  24834. nativeOptions?: any;
  24835. ignoreParent?: boolean;
  24836. disableBidirectionalTransformation?: boolean;
  24837. }
  24838. interface IPhysicsEnabledObject {
  24839. position: Vector3;
  24840. rotationQuaternion: Nullable<Quaternion>;
  24841. scaling: Vector3;
  24842. rotation?: Vector3;
  24843. parent?: any;
  24844. getBoundingInfo(): BoundingInfo;
  24845. computeWorldMatrix(force: boolean): Matrix;
  24846. getWorldMatrix?(): Matrix;
  24847. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24848. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24849. getIndices?(): Nullable<IndicesArray>;
  24850. getScene?(): Scene;
  24851. getAbsolutePosition(): Vector3;
  24852. getAbsolutePivotPoint(): Vector3;
  24853. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24854. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24855. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24856. getClassName(): string;
  24857. }
  24858. class PhysicsImpostor {
  24859. object: IPhysicsEnabledObject;
  24860. type: number;
  24861. private _options;
  24862. private _scene?;
  24863. static DEFAULT_OBJECT_SIZE: Vector3;
  24864. static IDENTITY_QUATERNION: Quaternion;
  24865. private _physicsEngine;
  24866. private _physicsBody;
  24867. private _bodyUpdateRequired;
  24868. private _onBeforePhysicsStepCallbacks;
  24869. private _onAfterPhysicsStepCallbacks;
  24870. private _onPhysicsCollideCallbacks;
  24871. private _deltaPosition;
  24872. private _deltaRotation;
  24873. private _deltaRotationConjugated;
  24874. private _parent;
  24875. private _isDisposed;
  24876. private static _tmpVecs;
  24877. private static _tmpQuat;
  24878. readonly isDisposed: boolean;
  24879. mass: number;
  24880. friction: number;
  24881. restitution: number;
  24882. uniqueId: number;
  24883. private _joints;
  24884. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24885. /**
  24886. * This function will completly initialize this impostor.
  24887. * It will create a new body - but only if this mesh has no parent.
  24888. * If it has, this impostor will not be used other than to define the impostor
  24889. * of the child mesh.
  24890. * @hidden
  24891. */
  24892. _init(): void;
  24893. private _getPhysicsParent;
  24894. /**
  24895. * Should a new body be generated.
  24896. */
  24897. isBodyInitRequired(): boolean;
  24898. setScalingUpdated(updated: boolean): void;
  24899. /**
  24900. * Force a regeneration of this or the parent's impostor's body.
  24901. * Use under cautious - This will remove all joints already implemented.
  24902. */
  24903. forceUpdate(): void;
  24904. /**
  24905. * Gets the body that holds this impostor. Either its own, or its parent.
  24906. */
  24907. /**
  24908. * Set the physics body. Used mainly by the physics engine/plugin
  24909. */
  24910. physicsBody: any;
  24911. parent: Nullable<PhysicsImpostor>;
  24912. resetUpdateFlags(): void;
  24913. getObjectExtendSize(): Vector3;
  24914. getObjectCenter(): Vector3;
  24915. /**
  24916. * Get a specific parametes from the options parameter.
  24917. */
  24918. getParam(paramName: string): any;
  24919. /**
  24920. * Sets a specific parameter in the options given to the physics plugin
  24921. */
  24922. setParam(paramName: string, value: number): void;
  24923. /**
  24924. * Specifically change the body's mass option. Won't recreate the physics body object
  24925. */
  24926. setMass(mass: number): void;
  24927. getLinearVelocity(): Nullable<Vector3>;
  24928. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24929. getAngularVelocity(): Nullable<Vector3>;
  24930. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24931. /**
  24932. * Execute a function with the physics plugin native code.
  24933. * Provide a function the will have two variables - the world object and the physics body object.
  24934. */
  24935. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24936. /**
  24937. * Register a function that will be executed before the physics world is stepping forward.
  24938. */
  24939. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24940. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24941. /**
  24942. * Register a function that will be executed after the physics step
  24943. */
  24944. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24945. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24946. /**
  24947. * register a function that will be executed when this impostor collides against a different body.
  24948. */
  24949. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24950. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24951. private _tmpQuat;
  24952. private _tmpQuat2;
  24953. getParentsRotation(): Quaternion;
  24954. /**
  24955. * this function is executed by the physics engine.
  24956. */
  24957. beforeStep: () => void;
  24958. /**
  24959. * this function is executed by the physics engine.
  24960. */
  24961. afterStep: () => void;
  24962. /**
  24963. * Legacy collision detection event support
  24964. */
  24965. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24966. onCollide: (e: {
  24967. body: any;
  24968. }) => void;
  24969. /**
  24970. * Apply a force
  24971. */
  24972. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24973. /**
  24974. * Apply an impulse
  24975. */
  24976. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24977. /**
  24978. * A help function to create a joint.
  24979. */
  24980. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24981. /**
  24982. * Add a joint to this impostor with a different impostor.
  24983. */
  24984. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24985. /**
  24986. * Will keep this body still, in a sleep mode.
  24987. */
  24988. sleep(): PhysicsImpostor;
  24989. /**
  24990. * Wake the body up.
  24991. */
  24992. wakeUp(): PhysicsImpostor;
  24993. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24994. dispose(): void;
  24995. setDeltaPosition(position: Vector3): void;
  24996. setDeltaRotation(rotation: Quaternion): void;
  24997. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24998. getRadius(): number;
  24999. /**
  25000. * Sync a bone with this impostor
  25001. * @param bone The bone to sync to the impostor.
  25002. * @param boneMesh The mesh that the bone is influencing.
  25003. * @param jointPivot The pivot of the joint / bone in local space.
  25004. * @param distToJoint Optional distance from the impostor to the joint.
  25005. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25006. */
  25007. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25008. /**
  25009. * Sync impostor to a bone
  25010. * @param bone The bone that the impostor will be synced to.
  25011. * @param boneMesh The mesh that the bone is influencing.
  25012. * @param jointPivot The pivot of the joint / bone in local space.
  25013. * @param distToJoint Optional distance from the impostor to the joint.
  25014. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25015. * @param boneAxis Optional vector3 axis the bone is aligned with
  25016. */
  25017. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25018. static NoImpostor: number;
  25019. static SphereImpostor: number;
  25020. static BoxImpostor: number;
  25021. static PlaneImpostor: number;
  25022. static MeshImpostor: number;
  25023. static CylinderImpostor: number;
  25024. static ParticleImpostor: number;
  25025. static HeightmapImpostor: number;
  25026. }
  25027. }
  25028. declare module BABYLON {
  25029. interface PhysicsJointData {
  25030. mainPivot?: Vector3;
  25031. connectedPivot?: Vector3;
  25032. mainAxis?: Vector3;
  25033. connectedAxis?: Vector3;
  25034. collision?: boolean;
  25035. nativeParams?: any;
  25036. }
  25037. /**
  25038. * This is a holder class for the physics joint created by the physics plugin.
  25039. * It holds a set of functions to control the underlying joint.
  25040. */
  25041. class PhysicsJoint {
  25042. type: number;
  25043. jointData: PhysicsJointData;
  25044. private _physicsJoint;
  25045. protected _physicsPlugin: IPhysicsEnginePlugin;
  25046. constructor(type: number, jointData: PhysicsJointData);
  25047. physicsJoint: any;
  25048. physicsPlugin: IPhysicsEnginePlugin;
  25049. /**
  25050. * Execute a function that is physics-plugin specific.
  25051. * @param {Function} func the function that will be executed.
  25052. * It accepts two parameters: the physics world and the physics joint.
  25053. */
  25054. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25055. static DistanceJoint: number;
  25056. static HingeJoint: number;
  25057. static BallAndSocketJoint: number;
  25058. static WheelJoint: number;
  25059. static SliderJoint: number;
  25060. static PrismaticJoint: number;
  25061. static UniversalJoint: number;
  25062. static Hinge2Joint: number;
  25063. static PointToPointJoint: number;
  25064. static SpringJoint: number;
  25065. static LockJoint: number;
  25066. }
  25067. /**
  25068. * A class representing a physics distance joint.
  25069. */
  25070. class DistanceJoint extends PhysicsJoint {
  25071. constructor(jointData: DistanceJointData);
  25072. /**
  25073. * Update the predefined distance.
  25074. */
  25075. updateDistance(maxDistance: number, minDistance?: number): void;
  25076. }
  25077. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  25078. constructor(type: number, jointData: PhysicsJointData);
  25079. /**
  25080. * Set the motor values.
  25081. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25082. * @param {number} force the force to apply
  25083. * @param {number} maxForce max force for this motor.
  25084. */
  25085. setMotor(force?: number, maxForce?: number): void;
  25086. /**
  25087. * Set the motor's limits.
  25088. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25089. */
  25090. setLimit(upperLimit: number, lowerLimit?: number): void;
  25091. }
  25092. /**
  25093. * This class represents a single hinge physics joint
  25094. */
  25095. class HingeJoint extends MotorEnabledJoint {
  25096. constructor(jointData: PhysicsJointData);
  25097. /**
  25098. * Set the motor values.
  25099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25100. * @param {number} force the force to apply
  25101. * @param {number} maxForce max force for this motor.
  25102. */
  25103. setMotor(force?: number, maxForce?: number): void;
  25104. /**
  25105. * Set the motor's limits.
  25106. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25107. */
  25108. setLimit(upperLimit: number, lowerLimit?: number): void;
  25109. }
  25110. /**
  25111. * This class represents a dual hinge physics joint (same as wheel joint)
  25112. */
  25113. class Hinge2Joint extends MotorEnabledJoint {
  25114. constructor(jointData: PhysicsJointData);
  25115. /**
  25116. * Set the motor values.
  25117. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25118. * @param {number} force the force to apply
  25119. * @param {number} maxForce max force for this motor.
  25120. * @param {motorIndex} the motor's index, 0 or 1.
  25121. */
  25122. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25123. /**
  25124. * Set the motor limits.
  25125. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25126. * @param {number} upperLimit the upper limit
  25127. * @param {number} lowerLimit lower limit
  25128. * @param {motorIndex} the motor's index, 0 or 1.
  25129. */
  25130. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25131. }
  25132. interface IMotorEnabledJoint {
  25133. physicsJoint: any;
  25134. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25135. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25136. }
  25137. interface DistanceJointData extends PhysicsJointData {
  25138. maxDistance: number;
  25139. }
  25140. interface SpringJointData extends PhysicsJointData {
  25141. length: number;
  25142. stiffness: number;
  25143. damping: number;
  25144. /** this callback will be called when applying the force to the impostors. */
  25145. forceApplicationCallback: () => void;
  25146. }
  25147. }
  25148. declare module BABYLON {
  25149. /**
  25150. * This represents the base class for particle system in Babylon.
  25151. * 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.
  25152. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25153. * @example https://doc.babylonjs.com/babylon101/particles
  25154. */
  25155. class BaseParticleSystem {
  25156. /**
  25157. * Source color is added to the destination color without alpha affecting the result.
  25158. */
  25159. static BLENDMODE_ONEONE: number;
  25160. /**
  25161. * Blend current color and particle color using particle’s alpha.
  25162. */
  25163. static BLENDMODE_STANDARD: number;
  25164. /**
  25165. * Add current color and particle color multiplied by particle’s alpha.
  25166. */
  25167. static BLENDMODE_ADD: number;
  25168. /**
  25169. * Multiply current color with particle color
  25170. */
  25171. static BLENDMODE_MULTIPLY: number;
  25172. /**
  25173. * List of animations used by the particle system.
  25174. */
  25175. animations: Animation[];
  25176. /**
  25177. * The id of the Particle system.
  25178. */
  25179. id: string;
  25180. /**
  25181. * The friendly name of the Particle system.
  25182. */
  25183. name: string;
  25184. /**
  25185. * The rendering group used by the Particle system to chose when to render.
  25186. */
  25187. renderingGroupId: number;
  25188. /**
  25189. * The emitter represents the Mesh or position we are attaching the particle system to.
  25190. */
  25191. emitter: Nullable<AbstractMesh | Vector3>;
  25192. /**
  25193. * The maximum number of particles to emit per frame
  25194. */
  25195. emitRate: number;
  25196. /**
  25197. * If you want to launch only a few particles at once, that can be done, as well.
  25198. */
  25199. manualEmitCount: number;
  25200. /**
  25201. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25202. */
  25203. updateSpeed: number;
  25204. /**
  25205. * The amount of time the particle system is running (depends of the overall update speed).
  25206. */
  25207. targetStopDuration: number;
  25208. /**
  25209. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  25210. */
  25211. disposeOnStop: boolean;
  25212. /**
  25213. * Minimum power of emitting particles.
  25214. */
  25215. minEmitPower: number;
  25216. /**
  25217. * Maximum power of emitting particles.
  25218. */
  25219. maxEmitPower: number;
  25220. /**
  25221. * Minimum life time of emitting particles.
  25222. */
  25223. minLifeTime: number;
  25224. /**
  25225. * Maximum life time of emitting particles.
  25226. */
  25227. maxLifeTime: number;
  25228. /**
  25229. * Minimum Size of emitting particles.
  25230. */
  25231. minSize: number;
  25232. /**
  25233. * Maximum Size of emitting particles.
  25234. */
  25235. maxSize: number;
  25236. /**
  25237. * Minimum scale of emitting particles on X axis.
  25238. */
  25239. minScaleX: number;
  25240. /**
  25241. * Maximum scale of emitting particles on X axis.
  25242. */
  25243. maxScaleX: number;
  25244. /**
  25245. * Minimum scale of emitting particles on Y axis.
  25246. */
  25247. minScaleY: number;
  25248. /**
  25249. * Maximum scale of emitting particles on Y axis.
  25250. */
  25251. maxScaleY: number;
  25252. /**
  25253. * Gets or sets the minimal initial rotation in radians.
  25254. */
  25255. minInitialRotation: number;
  25256. /**
  25257. * Gets or sets the maximal initial rotation in radians.
  25258. */
  25259. maxInitialRotation: number;
  25260. /**
  25261. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25262. */
  25263. minAngularSpeed: number;
  25264. /**
  25265. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25266. */
  25267. maxAngularSpeed: number;
  25268. /**
  25269. * The texture used to render each particle. (this can be a spritesheet)
  25270. */
  25271. particleTexture: Nullable<Texture>;
  25272. /**
  25273. * The layer mask we are rendering the particles through.
  25274. */
  25275. layerMask: number;
  25276. /**
  25277. * This can help using your own shader to render the particle system.
  25278. * The according effect will be created
  25279. */
  25280. customShader: any;
  25281. /**
  25282. * By default particle system starts as soon as they are created. This prevents the
  25283. * automatic start to happen and let you decide when to start emitting particles.
  25284. */
  25285. preventAutoStart: boolean;
  25286. /**
  25287. * Gets or sets a texture used to add random noise to particle positions
  25288. */
  25289. noiseTexture: Nullable<BaseTexture>;
  25290. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25291. noiseStrength: Vector3;
  25292. /**
  25293. * Callback triggered when the particle animation is ending.
  25294. */
  25295. onAnimationEnd: Nullable<() => void>;
  25296. /**
  25297. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  25298. */
  25299. blendMode: number;
  25300. /**
  25301. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  25302. * to override the particles.
  25303. */
  25304. forceDepthWrite: boolean;
  25305. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  25306. preWarmCycles: number;
  25307. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  25308. preWarmStepOffset: number;
  25309. /**
  25310. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  25311. */
  25312. spriteCellChangeSpeed: number;
  25313. /**
  25314. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25315. */
  25316. startSpriteCellID: number;
  25317. /**
  25318. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25319. */
  25320. endSpriteCellID: number;
  25321. /**
  25322. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25323. */
  25324. spriteCellWidth: number;
  25325. /**
  25326. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25327. */
  25328. spriteCellHeight: number;
  25329. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25330. translationPivot: Vector2;
  25331. /** @hidden */
  25332. protected _isAnimationSheetEnabled: boolean;
  25333. /**
  25334. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  25335. */
  25336. isAnimationSheetEnabled: boolean;
  25337. /**
  25338. * Get hosting scene
  25339. * @returns the scene
  25340. */
  25341. getScene(): Scene;
  25342. /**
  25343. * You can use gravity if you want to give an orientation to your particles.
  25344. */
  25345. gravity: Vector3;
  25346. protected _colorGradients: Nullable<Array<ColorGradient>>;
  25347. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  25348. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  25349. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  25350. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  25351. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  25352. protected _dragGradients: Nullable<Array<FactorGradient>>;
  25353. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  25354. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  25355. /**
  25356. * Gets the current list of drag gradients.
  25357. * You must use addDragGradient and removeDragGradient to udpate this list
  25358. * @returns the list of drag gradients
  25359. */
  25360. getDragGradients(): Nullable<Array<FactorGradient>>;
  25361. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25362. limitVelocityDamping: number;
  25363. /**
  25364. * Gets the current list of limit velocity gradients.
  25365. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25366. * @returns the list of limit velocity gradients
  25367. */
  25368. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25369. /**
  25370. * Gets the current list of color gradients.
  25371. * You must use addColorGradient and removeColorGradient to udpate this list
  25372. * @returns the list of color gradients
  25373. */
  25374. getColorGradients(): Nullable<Array<ColorGradient>>;
  25375. /**
  25376. * Gets the current list of size gradients.
  25377. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25378. * @returns the list of size gradients
  25379. */
  25380. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25381. /**
  25382. * Gets the current list of life time gradients.
  25383. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  25384. * @returns the list of life time gradients
  25385. */
  25386. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  25387. /**
  25388. * Gets the current list of angular speed gradients.
  25389. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25390. * @returns the list of angular speed gradients
  25391. */
  25392. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25393. /**
  25394. * Gets the current list of velocity gradients.
  25395. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25396. * @returns the list of velocity gradients
  25397. */
  25398. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25399. /**
  25400. * Gets the current list of start size gradients.
  25401. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  25402. * @returns the list of start size gradients
  25403. */
  25404. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  25405. /**
  25406. * Gets the current list of emit rate gradients.
  25407. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  25408. * @returns the list of emit rate gradients
  25409. */
  25410. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  25411. /**
  25412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25413. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25414. */
  25415. direction1: Vector3;
  25416. /**
  25417. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25418. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25419. */
  25420. direction2: Vector3;
  25421. /**
  25422. * 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.
  25423. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25424. */
  25425. minEmitBox: Vector3;
  25426. /**
  25427. * 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.
  25428. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25429. */
  25430. maxEmitBox: Vector3;
  25431. /**
  25432. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25433. */
  25434. color1: Color4;
  25435. /**
  25436. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25437. */
  25438. color2: Color4;
  25439. /**
  25440. * Color the particle will have at the end of its lifetime
  25441. */
  25442. colorDead: Color4;
  25443. /**
  25444. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  25445. */
  25446. textureMask: Color4;
  25447. /**
  25448. * The particle emitter type defines the emitter used by the particle system.
  25449. * It can be for example box, sphere, or cone...
  25450. */
  25451. particleEmitterType: IParticleEmitterType;
  25452. /**
  25453. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25454. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25455. */
  25456. billboardMode: number;
  25457. protected _isBillboardBased: boolean;
  25458. /**
  25459. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25460. */
  25461. isBillboardBased: boolean;
  25462. /**
  25463. * The scene the particle system belongs to.
  25464. */
  25465. protected _scene: Scene;
  25466. /**
  25467. * Local cache of defines for image processing.
  25468. */
  25469. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  25470. /**
  25471. * Default configuration related to image processing available in the standard Material.
  25472. */
  25473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25474. /**
  25475. * Gets the image processing configuration used either in this material.
  25476. */
  25477. /**
  25478. * Sets the Default image processing configuration used either in the this material.
  25479. *
  25480. * If sets to null, the scene one is in use.
  25481. */
  25482. imageProcessingConfiguration: ImageProcessingConfiguration;
  25483. /**
  25484. * Attaches a new image processing configuration to the Standard Material.
  25485. * @param configuration
  25486. */
  25487. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25488. /** @hidden */
  25489. protected _reset(): void;
  25490. /**
  25491. * Instantiates a particle system.
  25492. * 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.
  25493. * @param name The name of the particle system
  25494. */
  25495. constructor(name: string);
  25496. /**
  25497. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  25498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25500. * @returns the emitter
  25501. */
  25502. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  25503. /**
  25504. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  25505. * @param radius The radius of the hemisphere to emit from
  25506. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25507. * @returns the emitter
  25508. */
  25509. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  25510. /**
  25511. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  25512. * @param radius The radius of the sphere to emit from
  25513. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25514. * @returns the emitter
  25515. */
  25516. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  25517. /**
  25518. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  25519. * @param radius The radius of the sphere to emit from
  25520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25522. * @returns the emitter
  25523. */
  25524. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  25525. /**
  25526. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  25527. * @param radius The radius of the emission cylinder
  25528. * @param height The height of the emission cylinder
  25529. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  25530. * @param directionRandomizer How much to randomize the particle direction [0-1]
  25531. * @returns the emitter
  25532. */
  25533. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  25534. /**
  25535. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  25536. * @param radius The radius of the cone to emit from
  25537. * @param angle The base angle of the cone
  25538. * @returns the emitter
  25539. */
  25540. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  25541. /**
  25542. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25545. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25546. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25547. * @returns the emitter
  25548. */
  25549. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25550. }
  25551. }
  25552. declare module BABYLON {
  25553. /**
  25554. * This represents a GPU particle system in Babylon
  25555. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  25556. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  25557. */
  25558. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  25559. /**
  25560. * The layer mask we are rendering the particles through.
  25561. */
  25562. layerMask: number;
  25563. private _capacity;
  25564. private _activeCount;
  25565. private _currentActiveCount;
  25566. private _accumulatedCount;
  25567. private _renderEffect;
  25568. private _updateEffect;
  25569. private _buffer0;
  25570. private _buffer1;
  25571. private _spriteBuffer;
  25572. private _updateVAO;
  25573. private _renderVAO;
  25574. private _targetIndex;
  25575. private _sourceBuffer;
  25576. private _targetBuffer;
  25577. private _engine;
  25578. private _currentRenderId;
  25579. private _started;
  25580. private _stopped;
  25581. private _timeDelta;
  25582. private _randomTexture;
  25583. private _randomTexture2;
  25584. private _attributesStrideSize;
  25585. private _updateEffectOptions;
  25586. private _randomTextureSize;
  25587. private _actualFrame;
  25588. private readonly _rawTextureWidth;
  25589. /**
  25590. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  25591. */
  25592. static readonly IsSupported: boolean;
  25593. /**
  25594. * An event triggered when the system is disposed.
  25595. */
  25596. onDisposeObservable: Observable<GPUParticleSystem>;
  25597. /**
  25598. * Gets the maximum number of particles active at the same time.
  25599. * @returns The max number of active particles.
  25600. */
  25601. getCapacity(): number;
  25602. /**
  25603. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  25604. * to override the particles.
  25605. */
  25606. forceDepthWrite: boolean;
  25607. /**
  25608. * Gets or set the number of active particles
  25609. */
  25610. activeParticleCount: number;
  25611. private _preWarmDone;
  25612. /**
  25613. * Is this system ready to be used/rendered
  25614. * @return true if the system is ready
  25615. */
  25616. isReady(): boolean;
  25617. /**
  25618. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25619. * @returns True if it has been started, otherwise false.
  25620. */
  25621. isStarted(): boolean;
  25622. /**
  25623. * Starts the particle system and begins to emit
  25624. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25625. */
  25626. start(delay?: number): void;
  25627. /**
  25628. * Stops the particle system.
  25629. */
  25630. stop(): void;
  25631. /**
  25632. * Remove all active particles
  25633. */
  25634. reset(): void;
  25635. /**
  25636. * Returns the string "GPUParticleSystem"
  25637. * @returns a string containing the class name
  25638. */
  25639. getClassName(): string;
  25640. private _colorGradientsTexture;
  25641. private _removeGradient;
  25642. /**
  25643. * Adds a new color gradient
  25644. * @param gradient defines the gradient to use (between 0 and 1)
  25645. * @param color defines the color to affect to the specified gradient
  25646. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25647. * @returns the current particle system
  25648. */
  25649. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  25650. /**
  25651. * Remove a specific color gradient
  25652. * @param gradient defines the gradient to remove
  25653. * @returns the current particle system
  25654. */
  25655. removeColorGradient(gradient: number): GPUParticleSystem;
  25656. private _angularSpeedGradientsTexture;
  25657. private _sizeGradientsTexture;
  25658. private _velocityGradientsTexture;
  25659. private _limitVelocityGradientsTexture;
  25660. private _dragGradientsTexture;
  25661. private _addFactorGradient;
  25662. /**
  25663. * Adds a new size gradient
  25664. * @param gradient defines the gradient to use (between 0 and 1)
  25665. * @param factor defines the size factor to affect to the specified gradient
  25666. * @returns the current particle system
  25667. */
  25668. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  25669. /**
  25670. * Remove a specific size gradient
  25671. * @param gradient defines the gradient to remove
  25672. * @returns the current particle system
  25673. */
  25674. removeSizeGradient(gradient: number): GPUParticleSystem;
  25675. /**
  25676. * Adds a new angular speed gradient
  25677. * @param gradient defines the gradient to use (between 0 and 1)
  25678. * @param factor defines the angular speed to affect to the specified gradient
  25679. * @returns the current particle system
  25680. */
  25681. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  25682. /**
  25683. * Remove a specific angular speed gradient
  25684. * @param gradient defines the gradient to remove
  25685. * @returns the current particle system
  25686. */
  25687. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  25688. /**
  25689. * Adds a new velocity gradient
  25690. * @param gradient defines the gradient to use (between 0 and 1)
  25691. * @param factor defines the velocity to affect to the specified gradient
  25692. * @returns the current particle system
  25693. */
  25694. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25695. /**
  25696. * Remove a specific velocity gradient
  25697. * @param gradient defines the gradient to remove
  25698. * @returns the current particle system
  25699. */
  25700. removeVelocityGradient(gradient: number): GPUParticleSystem;
  25701. /**
  25702. * Adds a new limit velocity gradient
  25703. * @param gradient defines the gradient to use (between 0 and 1)
  25704. * @param factor defines the limit velocity value to affect to the specified gradient
  25705. * @returns the current particle system
  25706. */
  25707. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25708. /**
  25709. * Remove a specific limit velocity gradient
  25710. * @param gradient defines the gradient to remove
  25711. * @returns the current particle system
  25712. */
  25713. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  25714. /**
  25715. * Adds a new drag gradient
  25716. * @param gradient defines the gradient to use (between 0 and 1)
  25717. * @param factor defines the drag value to affect to the specified gradient
  25718. * @returns the current particle system
  25719. */
  25720. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  25721. /**
  25722. * Remove a specific drag gradient
  25723. * @param gradient defines the gradient to remove
  25724. * @returns the current particle system
  25725. */
  25726. removeDragGradient(gradient: number): GPUParticleSystem;
  25727. /**
  25728. * Not supported by GPUParticleSystem
  25729. * @param gradient defines the gradient to use (between 0 and 1)
  25730. * @param factor defines the emit rate value to affect to the specified gradient
  25731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25732. * @returns the current particle system
  25733. */
  25734. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25735. /**
  25736. * Not supported by GPUParticleSystem
  25737. * @param gradient defines the gradient to remove
  25738. * @returns the current particle system
  25739. */
  25740. removeEmitRateGradient(gradient: number): IParticleSystem;
  25741. /**
  25742. * Not supported by GPUParticleSystem
  25743. * @param gradient defines the gradient to use (between 0 and 1)
  25744. * @param factor defines the start size value to affect to the specified gradient
  25745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25746. * @returns the current particle system
  25747. */
  25748. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25749. /**
  25750. * Not supported by GPUParticleSystem
  25751. * @param gradient defines the gradient to remove
  25752. * @returns the current particle system
  25753. */
  25754. removeStartSizeGradient(gradient: number): IParticleSystem;
  25755. /**
  25756. * Instantiates a GPU particle system.
  25757. * 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.
  25758. * @param name The name of the particle system
  25759. * @param options The options used to create the system
  25760. * @param scene The scene the particle system belongs to
  25761. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25762. */
  25763. constructor(name: string, options: Partial<{
  25764. capacity: number;
  25765. randomTextureSize: number;
  25766. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  25767. protected _reset(): void;
  25768. private _createUpdateVAO;
  25769. private _createRenderVAO;
  25770. private _initialize;
  25771. /** @hidden */
  25772. _recreateUpdateEffect(): void;
  25773. /** @hidden */
  25774. _recreateRenderEffect(): void;
  25775. /**
  25776. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25777. * @param preWarm defines if we are in the pre-warmimg phase
  25778. */
  25779. animate(preWarm?: boolean): void;
  25780. private _createFactorGradientTexture;
  25781. private _createSizeGradientTexture;
  25782. private _createAngularSpeedGradientTexture;
  25783. private _createVelocityGradientTexture;
  25784. private _createColorGradientTexture;
  25785. /**
  25786. * Renders the particle system in its current state
  25787. * @param preWarm defines if the system should only update the particles but not render them
  25788. * @returns the current number of particles
  25789. */
  25790. render(preWarm?: boolean): number;
  25791. /**
  25792. * Rebuilds the particle system
  25793. */
  25794. rebuild(): void;
  25795. private _releaseBuffers;
  25796. private _releaseVAOs;
  25797. /**
  25798. * Disposes the particle system and free the associated resources
  25799. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25800. */
  25801. dispose(disposeTexture?: boolean): void;
  25802. /**
  25803. * Clones the particle system.
  25804. * @param name The name of the cloned object
  25805. * @param newEmitter The new emitter to use
  25806. * @returns the cloned particle system
  25807. */
  25808. clone(name: string, newEmitter: any): GPUParticleSystem;
  25809. /**
  25810. * Serializes the particle system to a JSON object.
  25811. * @returns the JSON object
  25812. */
  25813. serialize(): any;
  25814. /**
  25815. * Parses a JSON object to create a GPU particle system.
  25816. * @param parsedParticleSystem The JSON object to parse
  25817. * @param scene The scene to create the particle system in
  25818. * @param rootUrl The root url to use to load external dependencies like texture
  25819. * @returns the parsed GPU particle system
  25820. */
  25821. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  25822. }
  25823. }
  25824. declare module BABYLON {
  25825. /**
  25826. * Interface representing a particle system in Babylon.js.
  25827. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  25828. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  25829. */
  25830. interface IParticleSystem {
  25831. /**
  25832. * List of animations used by the particle system.
  25833. */
  25834. animations: Animation[];
  25835. /**
  25836. * The id of the Particle system.
  25837. */
  25838. id: string;
  25839. /**
  25840. * The name of the Particle system.
  25841. */
  25842. name: string;
  25843. /**
  25844. * The emitter represents the Mesh or position we are attaching the particle system to.
  25845. */
  25846. emitter: Nullable<AbstractMesh | Vector3>;
  25847. /**
  25848. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25849. */
  25850. isBillboardBased: boolean;
  25851. /**
  25852. * The rendering group used by the Particle system to chose when to render.
  25853. */
  25854. renderingGroupId: number;
  25855. /**
  25856. * The layer mask we are rendering the particles through.
  25857. */
  25858. layerMask: number;
  25859. /**
  25860. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25861. */
  25862. updateSpeed: number;
  25863. /**
  25864. * The amount of time the particle system is running (depends of the overall update speed).
  25865. */
  25866. targetStopDuration: number;
  25867. /**
  25868. * The texture used to render each particle. (this can be a spritesheet)
  25869. */
  25870. particleTexture: Nullable<Texture>;
  25871. /**
  25872. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25873. */
  25874. blendMode: number;
  25875. /**
  25876. * Minimum life time of emitting particles.
  25877. */
  25878. minLifeTime: number;
  25879. /**
  25880. * Maximum life time of emitting particles.
  25881. */
  25882. maxLifeTime: number;
  25883. /**
  25884. * Minimum Size of emitting particles.
  25885. */
  25886. minSize: number;
  25887. /**
  25888. * Maximum Size of emitting particles.
  25889. */
  25890. maxSize: number;
  25891. /**
  25892. * Minimum scale of emitting particles on X axis.
  25893. */
  25894. minScaleX: number;
  25895. /**
  25896. * Maximum scale of emitting particles on X axis.
  25897. */
  25898. maxScaleX: number;
  25899. /**
  25900. * Minimum scale of emitting particles on Y axis.
  25901. */
  25902. minScaleY: number;
  25903. /**
  25904. * Maximum scale of emitting particles on Y axis.
  25905. */
  25906. maxScaleY: number;
  25907. /**
  25908. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25909. */
  25910. color1: Color4;
  25911. /**
  25912. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25913. */
  25914. color2: Color4;
  25915. /**
  25916. * Color the particle will have at the end of its lifetime.
  25917. */
  25918. colorDead: Color4;
  25919. /**
  25920. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25921. */
  25922. emitRate: number;
  25923. /**
  25924. * You can use gravity if you want to give an orientation to your particles.
  25925. */
  25926. gravity: Vector3;
  25927. /**
  25928. * Minimum power of emitting particles.
  25929. */
  25930. minEmitPower: number;
  25931. /**
  25932. * Maximum power of emitting particles.
  25933. */
  25934. maxEmitPower: number;
  25935. /**
  25936. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25937. */
  25938. minAngularSpeed: number;
  25939. /**
  25940. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25941. */
  25942. maxAngularSpeed: number;
  25943. /**
  25944. * Gets or sets the minimal initial rotation in radians.
  25945. */
  25946. minInitialRotation: number;
  25947. /**
  25948. * Gets or sets the maximal initial rotation in radians.
  25949. */
  25950. maxInitialRotation: number;
  25951. /**
  25952. * The particle emitter type defines the emitter used by the particle system.
  25953. * It can be for example box, sphere, or cone...
  25954. */
  25955. particleEmitterType: Nullable<IParticleEmitterType>;
  25956. /**
  25957. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  25958. */
  25959. preWarmCycles: number;
  25960. /**
  25961. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25962. */
  25963. preWarmStepOffset: number;
  25964. /**
  25965. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  25966. */
  25967. spriteCellChangeSpeed: number;
  25968. /**
  25969. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25970. */
  25971. startSpriteCellID: number;
  25972. /**
  25973. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25974. */
  25975. endSpriteCellID: number;
  25976. /**
  25977. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25978. */
  25979. spriteCellWidth: number;
  25980. /**
  25981. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25982. */
  25983. spriteCellHeight: number;
  25984. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25985. translationPivot: Vector2;
  25986. /**
  25987. * Gets or sets a texture used to add random noise to particle positions
  25988. */
  25989. noiseTexture: Nullable<BaseTexture>;
  25990. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25991. noiseStrength: Vector3;
  25992. /**
  25993. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25994. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25995. */
  25996. billboardMode: number;
  25997. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25998. limitVelocityDamping: number;
  25999. /**
  26000. * Gets the maximum number of particles active at the same time.
  26001. * @returns The max number of active particles.
  26002. */
  26003. getCapacity(): number;
  26004. /**
  26005. * Gets if the system has been started. (Note: this will still be true after stop is called)
  26006. * @returns True if it has been started, otherwise false.
  26007. */
  26008. isStarted(): boolean;
  26009. /**
  26010. * Animates the particle system for this frame.
  26011. */
  26012. animate(): void;
  26013. /**
  26014. * Renders the particle system in its current state.
  26015. * @returns the current number of particles
  26016. */
  26017. render(): number;
  26018. /**
  26019. * Dispose the particle system and frees its associated resources.
  26020. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  26021. */
  26022. dispose(disposeTexture?: boolean): void;
  26023. /**
  26024. * Clones the particle system.
  26025. * @param name The name of the cloned object
  26026. * @param newEmitter The new emitter to use
  26027. * @returns the cloned particle system
  26028. */
  26029. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  26030. /**
  26031. * Serializes the particle system to a JSON object.
  26032. * @returns the JSON object
  26033. */
  26034. serialize(): any;
  26035. /**
  26036. * Rebuild the particle system
  26037. */
  26038. rebuild(): void;
  26039. /**
  26040. * Starts the particle system and begins to emit
  26041. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  26042. */
  26043. start(delay?: number): void;
  26044. /**
  26045. * Stops the particle system.
  26046. */
  26047. stop(): void;
  26048. /**
  26049. * Remove all active particles
  26050. */
  26051. reset(): void;
  26052. /**
  26053. * Is this system ready to be used/rendered
  26054. * @return true if the system is ready
  26055. */
  26056. isReady(): boolean;
  26057. /**
  26058. * Adds a new color gradient
  26059. * @param gradient defines the gradient to use (between 0 and 1)
  26060. * @param color defines the color to affect to the specified gradient
  26061. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  26062. * @returns the current particle system
  26063. */
  26064. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  26065. /**
  26066. * Remove a specific color gradient
  26067. * @param gradient defines the gradient to remove
  26068. * @returns the current particle system
  26069. */
  26070. removeColorGradient(gradient: number): IParticleSystem;
  26071. /**
  26072. * Adds a new size gradient
  26073. * @param gradient defines the gradient to use (between 0 and 1)
  26074. * @param factor defines the size factor to affect to the specified gradient
  26075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26076. * @returns the current particle system
  26077. */
  26078. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26079. /**
  26080. * Remove a specific size gradient
  26081. * @param gradient defines the gradient to remove
  26082. * @returns the current particle system
  26083. */
  26084. removeSizeGradient(gradient: number): IParticleSystem;
  26085. /**
  26086. * Gets the current list of color gradients.
  26087. * You must use addColorGradient and removeColorGradient to udpate this list
  26088. * @returns the list of color gradients
  26089. */
  26090. getColorGradients(): Nullable<Array<ColorGradient>>;
  26091. /**
  26092. * Gets the current list of size gradients.
  26093. * You must use addSizeGradient and removeSizeGradient to udpate this list
  26094. * @returns the list of size gradients
  26095. */
  26096. getSizeGradients(): Nullable<Array<FactorGradient>>;
  26097. /**
  26098. * Gets the current list of angular speed gradients.
  26099. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  26100. * @returns the list of angular speed gradients
  26101. */
  26102. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  26103. /**
  26104. * Adds a new angular speed gradient
  26105. * @param gradient defines the gradient to use (between 0 and 1)
  26106. * @param factor defines the angular speed to affect to the specified gradient
  26107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26108. * @returns the current particle system
  26109. */
  26110. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26111. /**
  26112. * Remove a specific angular speed gradient
  26113. * @param gradient defines the gradient to remove
  26114. * @returns the current particle system
  26115. */
  26116. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  26117. /**
  26118. * Gets the current list of velocity gradients.
  26119. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  26120. * @returns the list of velocity gradients
  26121. */
  26122. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  26123. /**
  26124. * Adds a new velocity gradient
  26125. * @param gradient defines the gradient to use (between 0 and 1)
  26126. * @param factor defines the velocity to affect to the specified gradient
  26127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26128. * @returns the current particle system
  26129. */
  26130. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26131. /**
  26132. * Remove a specific velocity gradient
  26133. * @param gradient defines the gradient to remove
  26134. * @returns the current particle system
  26135. */
  26136. removeVelocityGradient(gradient: number): IParticleSystem;
  26137. /**
  26138. * Gets the current list of limit velocity gradients.
  26139. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  26140. * @returns the list of limit velocity gradients
  26141. */
  26142. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  26143. /**
  26144. * Adds a new limit velocity gradient
  26145. * @param gradient defines the gradient to use (between 0 and 1)
  26146. * @param factor defines the limit velocity to affect to the specified gradient
  26147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26148. * @returns the current particle system
  26149. */
  26150. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26151. /**
  26152. * Remove a specific limit velocity gradient
  26153. * @param gradient defines the gradient to remove
  26154. * @returns the current particle system
  26155. */
  26156. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  26157. /**
  26158. * Adds a new drag gradient
  26159. * @param gradient defines the gradient to use (between 0 and 1)
  26160. * @param factor defines the drag to affect to the specified gradient
  26161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26162. * @returns the current particle system
  26163. */
  26164. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26165. /**
  26166. * Remove a specific drag gradient
  26167. * @param gradient defines the gradient to remove
  26168. * @returns the current particle system
  26169. */
  26170. removeDragGradient(gradient: number): IParticleSystem;
  26171. /**
  26172. * Gets the current list of drag gradients.
  26173. * You must use addDragGradient and removeDragGradient to udpate this list
  26174. * @returns the list of drag gradients
  26175. */
  26176. getDragGradients(): Nullable<Array<FactorGradient>>;
  26177. /**
  26178. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  26179. * @param gradient defines the gradient to use (between 0 and 1)
  26180. * @param factor defines the emit rate to affect to the specified gradient
  26181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26182. * @returns the current particle system
  26183. */
  26184. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26185. /**
  26186. * Remove a specific emit rate gradient
  26187. * @param gradient defines the gradient to remove
  26188. * @returns the current particle system
  26189. */
  26190. removeEmitRateGradient(gradient: number): IParticleSystem;
  26191. /**
  26192. * Gets the current list of emit rate gradients.
  26193. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  26194. * @returns the list of emit rate gradients
  26195. */
  26196. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  26197. /**
  26198. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  26199. * @param gradient defines the gradient to use (between 0 and 1)
  26200. * @param factor defines the start size to affect to the specified gradient
  26201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26202. * @returns the current particle system
  26203. */
  26204. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26205. /**
  26206. * Remove a specific start size gradient
  26207. * @param gradient defines the gradient to remove
  26208. * @returns the current particle system
  26209. */
  26210. removeStartSizeGradient(gradient: number): IParticleSystem;
  26211. /**
  26212. * Gets the current list of start size gradients.
  26213. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  26214. * @returns the list of start size gradients
  26215. */
  26216. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  26217. /**
  26218. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  26219. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  26220. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  26221. * @returns the emitter
  26222. */
  26223. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  26224. /**
  26225. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  26226. * @param radius The radius of the hemisphere to emit from
  26227. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  26228. * @returns the emitter
  26229. */
  26230. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  26231. /**
  26232. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  26233. * @param radius The radius of the sphere to emit from
  26234. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  26235. * @returns the emitter
  26236. */
  26237. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  26238. /**
  26239. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  26240. * @param radius The radius of the sphere to emit from
  26241. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  26242. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  26243. * @returns the emitter
  26244. */
  26245. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  26246. /**
  26247. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  26248. * @param radius The radius of the emission cylinder
  26249. * @param height The height of the emission cylinder
  26250. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  26251. * @param directionRandomizer How much to randomize the particle direction [0-1]
  26252. * @returns the emitter
  26253. */
  26254. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  26255. /**
  26256. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  26257. * @param radius The radius of the cone to emit from
  26258. * @param angle The base angle of the cone
  26259. * @returns the emitter
  26260. */
  26261. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  26262. /**
  26263. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  26264. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  26265. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  26266. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  26267. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  26268. * @returns the emitter
  26269. */
  26270. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  26271. /**
  26272. * Get hosting scene
  26273. * @returns the scene
  26274. */
  26275. getScene(): Scene;
  26276. }
  26277. }
  26278. declare module BABYLON {
  26279. /**
  26280. * A particle represents one of the element emitted by a particle system.
  26281. * This is mainly define by its coordinates, direction, velocity and age.
  26282. */
  26283. class Particle {
  26284. /**
  26285. * particleSystem the particle system the particle belongs to.
  26286. */
  26287. particleSystem: ParticleSystem;
  26288. /**
  26289. * The world position of the particle in the scene.
  26290. */
  26291. position: Vector3;
  26292. /**
  26293. * The world direction of the particle in the scene.
  26294. */
  26295. direction: Vector3;
  26296. /**
  26297. * The color of the particle.
  26298. */
  26299. color: Color4;
  26300. /**
  26301. * The color change of the particle per step.
  26302. */
  26303. colorStep: Color4;
  26304. /**
  26305. * Defines how long will the life of the particle be.
  26306. */
  26307. lifeTime: number;
  26308. /**
  26309. * The current age of the particle.
  26310. */
  26311. age: number;
  26312. /**
  26313. * The current size of the particle.
  26314. */
  26315. size: number;
  26316. /**
  26317. * The current scale of the particle.
  26318. */
  26319. scale: Vector2;
  26320. /**
  26321. * The current angle of the particle.
  26322. */
  26323. angle: number;
  26324. /**
  26325. * Defines how fast is the angle changing.
  26326. */
  26327. angularSpeed: number;
  26328. /**
  26329. * Defines the cell index used by the particle to be rendered from a sprite.
  26330. */
  26331. cellIndex: number;
  26332. /** @hidden */
  26333. _initialDirection: Nullable<Vector3>;
  26334. /** @hidden */
  26335. _initialStartSpriteCellID: number;
  26336. _initialEndSpriteCellID: number;
  26337. /** @hidden */
  26338. _currentColorGradient: Nullable<ColorGradient>;
  26339. /** @hidden */
  26340. _currentColor1: Color4;
  26341. /** @hidden */
  26342. _currentColor2: Color4;
  26343. /** @hidden */
  26344. _currentSizeGradient: Nullable<FactorGradient>;
  26345. /** @hidden */
  26346. _currentSize1: number;
  26347. /** @hidden */
  26348. _currentSize2: number;
  26349. /** @hidden */
  26350. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  26351. /** @hidden */
  26352. _currentAngularSpeed1: number;
  26353. /** @hidden */
  26354. _currentAngularSpeed2: number;
  26355. /** @hidden */
  26356. _currentVelocityGradient: Nullable<FactorGradient>;
  26357. /** @hidden */
  26358. _currentVelocity1: number;
  26359. /** @hidden */
  26360. _currentVelocity2: number;
  26361. /** @hidden */
  26362. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  26363. /** @hidden */
  26364. _currentLimitVelocity1: number;
  26365. /** @hidden */
  26366. _currentLimitVelocity2: number;
  26367. /** @hidden */
  26368. _currentDragGradient: Nullable<FactorGradient>;
  26369. /** @hidden */
  26370. _currentDrag1: number;
  26371. /** @hidden */
  26372. _currentDrag2: number;
  26373. /**
  26374. * Creates a new instance Particle
  26375. * @param particleSystem the particle system the particle belongs to
  26376. */
  26377. constructor(
  26378. /**
  26379. * particleSystem the particle system the particle belongs to.
  26380. */
  26381. particleSystem: ParticleSystem);
  26382. private updateCellInfoFromSystem;
  26383. /**
  26384. * Defines how the sprite cell index is updated for the particle
  26385. */
  26386. updateCellIndex(): void;
  26387. /**
  26388. * Copy the properties of particle to another one.
  26389. * @param other the particle to copy the information to.
  26390. */
  26391. copyTo(other: Particle): void;
  26392. }
  26393. }
  26394. declare module BABYLON {
  26395. /**
  26396. * This class is made for on one-liner static method to help creating particle system set.
  26397. */
  26398. class ParticleHelper {
  26399. /**
  26400. * Gets or sets base Assets URL
  26401. */
  26402. static BaseAssetsUrl: string;
  26403. /**
  26404. * Create a default particle system that you can tweak
  26405. * @param emitter defines the emitter to use
  26406. * @param capacity defines the system capacity (default is 500 particles)
  26407. * @param scene defines the hosting scene
  26408. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  26409. * @returns the new Particle system
  26410. */
  26411. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  26412. /**
  26413. * This is the main static method (one-liner) of this helper to create different particle systems
  26414. * @param type This string represents the type to the particle system to create
  26415. * @param scene The scene where the particle system should live
  26416. * @param gpu If the system will use gpu
  26417. * @returns the ParticleSystemSet created
  26418. */
  26419. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  26420. /**
  26421. * Static function used to export a particle system to a ParticleSystemSet variable.
  26422. * Please note that the emitter shape is not exported
  26423. * @param system defines the particle systems to export
  26424. */
  26425. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  26426. }
  26427. }
  26428. declare module BABYLON {
  26429. /**
  26430. * This represents a particle system in Babylon.
  26431. * 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.
  26432. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  26433. * @example https://doc.babylonjs.com/babylon101/particles
  26434. */
  26435. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  26436. /**
  26437. * This function can be defined to provide custom update for active particles.
  26438. * This function will be called instead of regular update (age, position, color, etc.).
  26439. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  26440. */
  26441. updateFunction: (particles: Particle[]) => void;
  26442. private _emitterWorldMatrix;
  26443. /**
  26444. * This function can be defined to specify initial direction for every new particle.
  26445. * It by default use the emitterType defined function
  26446. */
  26447. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  26448. /**
  26449. * This function can be defined to specify initial position for every new particle.
  26450. * It by default use the emitterType defined function
  26451. */
  26452. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  26453. /**
  26454. * An event triggered when the system is disposed
  26455. */
  26456. onDisposeObservable: Observable<ParticleSystem>;
  26457. private _onDisposeObserver;
  26458. /**
  26459. * Sets a callback that will be triggered when the system is disposed
  26460. */
  26461. onDispose: () => void;
  26462. private _particles;
  26463. private _epsilon;
  26464. private _capacity;
  26465. private _stockParticles;
  26466. private _newPartsExcess;
  26467. private _vertexData;
  26468. private _vertexBuffer;
  26469. private _vertexBuffers;
  26470. private _spriteBuffer;
  26471. private _indexBuffer;
  26472. private _effect;
  26473. private _customEffect;
  26474. private _cachedDefines;
  26475. private _scaledColorStep;
  26476. private _colorDiff;
  26477. private _scaledDirection;
  26478. private _scaledGravity;
  26479. private _currentRenderId;
  26480. private _alive;
  26481. private _useInstancing;
  26482. private _started;
  26483. private _stopped;
  26484. private _actualFrame;
  26485. private _scaledUpdateSpeed;
  26486. private _vertexBufferSize;
  26487. /** @hidden */
  26488. _currentEmitRateGradient: Nullable<FactorGradient>;
  26489. /** @hidden */
  26490. _currentEmitRate1: number;
  26491. /** @hidden */
  26492. _currentEmitRate2: number;
  26493. /** @hidden */
  26494. _currentStartSizeGradient: Nullable<FactorGradient>;
  26495. /** @hidden */
  26496. _currentStartSize1: number;
  26497. /** @hidden */
  26498. _currentStartSize2: number;
  26499. /**
  26500. * 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.
  26501. */
  26502. subEmitters: ParticleSystem[];
  26503. /**
  26504. * The current active Sub-systems, this property is used by the root particle system only.
  26505. */
  26506. activeSubSystems: Array<ParticleSystem>;
  26507. private _rootParticleSystem;
  26508. /**
  26509. * Gets the current list of active particles
  26510. */
  26511. readonly particles: Particle[];
  26512. /**
  26513. * Returns the string "ParticleSystem"
  26514. * @returns a string containing the class name
  26515. */
  26516. getClassName(): string;
  26517. /**
  26518. * Instantiates a particle system.
  26519. * 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.
  26520. * @param name The name of the particle system
  26521. * @param capacity The max number of particles alive at the same time
  26522. * @param scene The scene the particle system belongs to
  26523. * @param customEffect a custom effect used to change the way particles are rendered by default
  26524. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  26525. * @param epsilon Offset used to render the particles
  26526. */
  26527. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  26528. private _addFactorGradient;
  26529. private _removeFactorGradient;
  26530. /**
  26531. * Adds a new life time gradient
  26532. * @param gradient defines the gradient to use (between 0 and 1)
  26533. * @param factor defines the life time factor to affect to the specified gradient
  26534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26535. * @returns the current particle system
  26536. */
  26537. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26538. /**
  26539. * Remove a specific life time gradient
  26540. * @param gradient defines the gradient to remove
  26541. * @returns the current particle system
  26542. */
  26543. removeLifeTimeGradient(gradient: number): IParticleSystem;
  26544. /**
  26545. * Adds a new size gradient
  26546. * @param gradient defines the gradient to use (between 0 and 1)
  26547. * @param factor defines the size factor to affect to the specified gradient
  26548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26549. * @returns the current particle system
  26550. */
  26551. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26552. /**
  26553. * Remove a specific size gradient
  26554. * @param gradient defines the gradient to remove
  26555. * @returns the current particle system
  26556. */
  26557. removeSizeGradient(gradient: number): IParticleSystem;
  26558. /**
  26559. * Adds a new angular speed gradient
  26560. * @param gradient defines the gradient to use (between 0 and 1)
  26561. * @param factor defines the angular speed to affect to the specified gradient
  26562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26563. * @returns the current particle system
  26564. */
  26565. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26566. /**
  26567. * Remove a specific angular speed gradient
  26568. * @param gradient defines the gradient to remove
  26569. * @returns the current particle system
  26570. */
  26571. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  26572. /**
  26573. * Adds a new velocity gradient
  26574. * @param gradient defines the gradient to use (between 0 and 1)
  26575. * @param factor defines the velocity to affect to the specified gradient
  26576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26577. * @returns the current particle system
  26578. */
  26579. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26580. /**
  26581. * Remove a specific velocity gradient
  26582. * @param gradient defines the gradient to remove
  26583. * @returns the current particle system
  26584. */
  26585. removeVelocityGradient(gradient: number): IParticleSystem;
  26586. /**
  26587. * Adds a new limit velocity gradient
  26588. * @param gradient defines the gradient to use (between 0 and 1)
  26589. * @param factor defines the limit velocity value to affect to the specified gradient
  26590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26591. * @returns the current particle system
  26592. */
  26593. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26594. /**
  26595. * Remove a specific limit velocity gradient
  26596. * @param gradient defines the gradient to remove
  26597. * @returns the current particle system
  26598. */
  26599. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  26600. /**
  26601. * Adds a new drag gradient
  26602. * @param gradient defines the gradient to use (between 0 and 1)
  26603. * @param factor defines the drag value to affect to the specified gradient
  26604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26605. * @returns the current particle system
  26606. */
  26607. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26608. /**
  26609. * Remove a specific drag gradient
  26610. * @param gradient defines the gradient to remove
  26611. * @returns the current particle system
  26612. */
  26613. removeDragGradient(gradient: number): IParticleSystem;
  26614. /**
  26615. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  26616. * @param gradient defines the gradient to use (between 0 and 1)
  26617. * @param factor defines the emit rate value to affect to the specified gradient
  26618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26619. * @returns the current particle system
  26620. */
  26621. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26622. /**
  26623. * Remove a specific emit rate gradient
  26624. * @param gradient defines the gradient to remove
  26625. * @returns the current particle system
  26626. */
  26627. removeEmitRateGradient(gradient: number): IParticleSystem;
  26628. /**
  26629. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  26630. * @param gradient defines the gradient to use (between 0 and 1)
  26631. * @param factor defines the start size value to affect to the specified gradient
  26632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26633. * @returns the current particle system
  26634. */
  26635. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26636. /**
  26637. * Remove a specific start size gradient
  26638. * @param gradient defines the gradient to remove
  26639. * @returns the current particle system
  26640. */
  26641. removeStartSizeGradient(gradient: number): IParticleSystem;
  26642. /**
  26643. * Adds a new color gradient
  26644. * @param gradient defines the gradient to use (between 0 and 1)
  26645. * @param color defines the color to affect to the specified gradient
  26646. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  26647. */
  26648. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  26649. /**
  26650. * Remove a specific color gradient
  26651. * @param gradient defines the gradient to remove
  26652. */
  26653. removeColorGradient(gradient: number): IParticleSystem;
  26654. private _fetchR;
  26655. protected _reset(): void;
  26656. private _resetEffect;
  26657. private _createVertexBuffers;
  26658. private _createIndexBuffer;
  26659. /**
  26660. * Gets the maximum number of particles active at the same time.
  26661. * @returns The max number of active particles.
  26662. */
  26663. getCapacity(): number;
  26664. /**
  26665. * Gets whether there are still active particles in the system.
  26666. * @returns True if it is alive, otherwise false.
  26667. */
  26668. isAlive(): boolean;
  26669. /**
  26670. * Gets if the system has been started. (Note: this will still be true after stop is called)
  26671. * @returns True if it has been started, otherwise false.
  26672. */
  26673. isStarted(): boolean;
  26674. /**
  26675. * Starts the particle system and begins to emit
  26676. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  26677. */
  26678. start(delay?: number): void;
  26679. /**
  26680. * Stops the particle system.
  26681. * @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.
  26682. */
  26683. stop(stopSubEmitters?: boolean): void;
  26684. /**
  26685. * Remove all active particles
  26686. */
  26687. reset(): void;
  26688. /**
  26689. * @hidden (for internal use only)
  26690. */
  26691. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  26692. /**
  26693. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  26694. * Its lifetime will start back at 0.
  26695. */
  26696. recycleParticle: (particle: Particle) => void;
  26697. private _stopSubEmitters;
  26698. private _createParticle;
  26699. private _removeFromRoot;
  26700. private _emitFromParticle;
  26701. private _update;
  26702. /** @hidden */
  26703. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  26704. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  26705. private _getEffect;
  26706. /**
  26707. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  26708. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  26709. */
  26710. animate(preWarmOnly?: boolean): void;
  26711. private _appendParticleVertices;
  26712. /**
  26713. * Rebuilds the particle system.
  26714. */
  26715. rebuild(): void;
  26716. /**
  26717. * Is this system ready to be used/rendered
  26718. * @return true if the system is ready
  26719. */
  26720. isReady(): boolean;
  26721. /**
  26722. * Renders the particle system in its current state.
  26723. * @returns the current number of particles
  26724. */
  26725. render(): number;
  26726. /**
  26727. * Disposes the particle system and free the associated resources
  26728. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  26729. */
  26730. dispose(disposeTexture?: boolean): void;
  26731. /**
  26732. * Clones the particle system.
  26733. * @param name The name of the cloned object
  26734. * @param newEmitter The new emitter to use
  26735. * @returns the cloned particle system
  26736. */
  26737. clone(name: string, newEmitter: any): ParticleSystem;
  26738. /**
  26739. * Serializes the particle system to a JSON object.
  26740. * @returns the JSON object
  26741. */
  26742. serialize(): any;
  26743. /** @hidden */
  26744. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  26745. /** @hidden */
  26746. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  26747. /**
  26748. * Parses a JSON object to create a particle system.
  26749. * @param parsedParticleSystem The JSON object to parse
  26750. * @param scene The scene to create the particle system in
  26751. * @param rootUrl The root url to use to load external dependencies like texture
  26752. * @returns the Parsed particle system
  26753. */
  26754. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  26755. }
  26756. }
  26757. declare module BABYLON {
  26758. interface Engine {
  26759. /**
  26760. * Create an effect to use with particle systems.
  26761. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  26762. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  26763. * @param uniformsNames defines a list of attribute names
  26764. * @param samplers defines an array of string used to represent textures
  26765. * @param defines defines the string containing the defines to use to compile the shaders
  26766. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26767. * @param onCompiled defines a function to call when the effect creation is successful
  26768. * @param onError defines a function to call when the effect creation has failed
  26769. * @returns the new Effect
  26770. */
  26771. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  26772. }
  26773. }
  26774. declare module BABYLON {
  26775. /**
  26776. * Represents a set of particle systems working together to create a specific effect
  26777. */
  26778. class ParticleSystemSet implements IDisposable {
  26779. private _emitterCreationOptions;
  26780. private _emitterNode;
  26781. /**
  26782. * Gets the particle system list
  26783. */
  26784. systems: IParticleSystem[];
  26785. /**
  26786. * Gets the emitter node used with this set
  26787. */
  26788. readonly emitterNode: Nullable<TransformNode>;
  26789. /**
  26790. * Creates a new emitter mesh as a sphere
  26791. * @param options defines the options used to create the sphere
  26792. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  26793. * @param scene defines the hosting scene
  26794. */
  26795. setEmitterAsSphere(options: {
  26796. diameter: number;
  26797. segments: number;
  26798. color: Color3;
  26799. }, renderingGroupId: number, scene: Scene): void;
  26800. /**
  26801. * Starts all particle systems of the set
  26802. * @param emitter defines an optional mesh to use as emitter for the particle systems
  26803. */
  26804. start(emitter?: AbstractMesh): void;
  26805. /**
  26806. * Release all associated resources
  26807. */
  26808. dispose(): void;
  26809. /**
  26810. * Serialize the set into a JSON compatible object
  26811. * @returns a JSON compatible representation of the set
  26812. */
  26813. serialize(): any;
  26814. /**
  26815. * Parse a new ParticleSystemSet from a serialized source
  26816. * @param data defines a JSON compatible representation of the set
  26817. * @param scene defines the hosting scene
  26818. * @param gpu defines if we want GPU particles or CPU particles
  26819. * @returns a new ParticleSystemSet
  26820. */
  26821. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  26822. }
  26823. }
  26824. declare module BABYLON {
  26825. /**
  26826. * Represents one particle of a solid particle system.
  26827. */
  26828. class SolidParticle {
  26829. /**
  26830. * particle global index
  26831. */
  26832. idx: number;
  26833. /**
  26834. * The color of the particle
  26835. */
  26836. color: Nullable<Color4>;
  26837. /**
  26838. * The world space position of the particle.
  26839. */
  26840. position: Vector3;
  26841. /**
  26842. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26843. */
  26844. rotation: Vector3;
  26845. /**
  26846. * The world space rotation quaternion of the particle.
  26847. */
  26848. rotationQuaternion: Nullable<Quaternion>;
  26849. /**
  26850. * The scaling of the particle.
  26851. */
  26852. scaling: Vector3;
  26853. /**
  26854. * The uvs of the particle.
  26855. */
  26856. uvs: Vector4;
  26857. /**
  26858. * The current speed of the particle.
  26859. */
  26860. velocity: Vector3;
  26861. /**
  26862. * The pivot point in the particle local space.
  26863. */
  26864. pivot: Vector3;
  26865. /**
  26866. * Must the particle be translated from its pivot point in its local space ?
  26867. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26868. * Default : false
  26869. */
  26870. translateFromPivot: boolean;
  26871. /**
  26872. * Is the particle active or not ?
  26873. */
  26874. alive: boolean;
  26875. /**
  26876. * Is the particle visible or not ?
  26877. */
  26878. isVisible: boolean;
  26879. /**
  26880. * Index of this particle in the global "positions" array (Internal use)
  26881. * @hidden
  26882. */
  26883. _pos: number;
  26884. /**
  26885. * @hidden Index of this particle in the global "indices" array (Internal use)
  26886. */
  26887. _ind: number;
  26888. /**
  26889. * @hidden ModelShape of this particle (Internal use)
  26890. */
  26891. _model: ModelShape;
  26892. /**
  26893. * ModelShape id of this particle
  26894. */
  26895. shapeId: number;
  26896. /**
  26897. * Index of the particle in its shape id (Internal use)
  26898. */
  26899. idxInShape: number;
  26900. /**
  26901. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26902. */
  26903. _modelBoundingInfo: BoundingInfo;
  26904. /**
  26905. * @hidden Particle BoundingInfo object (Internal use)
  26906. */
  26907. _boundingInfo: BoundingInfo;
  26908. /**
  26909. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26910. */
  26911. _sps: SolidParticleSystem;
  26912. /**
  26913. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26914. */
  26915. _stillInvisible: boolean;
  26916. /**
  26917. * @hidden Last computed particle rotation matrix
  26918. */
  26919. _rotationMatrix: number[];
  26920. /**
  26921. * Parent particle Id, if any.
  26922. * Default null.
  26923. */
  26924. parentId: Nullable<number>;
  26925. /**
  26926. * @hidden Internal global position in the SPS.
  26927. */
  26928. _globalPosition: Vector3;
  26929. /**
  26930. * Creates a Solid Particle object.
  26931. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26932. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26933. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26934. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26935. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26936. * @param shapeId (integer) is the model shape identifier in the SPS.
  26937. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26938. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26939. */
  26940. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26941. /**
  26942. * Legacy support, changed scale to scaling
  26943. */
  26944. /**
  26945. * Legacy support, changed scale to scaling
  26946. */
  26947. scale: Vector3;
  26948. /**
  26949. * Legacy support, changed quaternion to rotationQuaternion
  26950. */
  26951. /**
  26952. * Legacy support, changed quaternion to rotationQuaternion
  26953. */
  26954. quaternion: Nullable<Quaternion>;
  26955. /**
  26956. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26957. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26958. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26959. * @returns true if it intersects
  26960. */
  26961. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26962. }
  26963. /**
  26964. * Represents the shape of the model used by one particle of a solid particle system.
  26965. * SPS internal tool, don't use it manually.
  26966. */
  26967. class ModelShape {
  26968. /**
  26969. * The shape id
  26970. * @hidden
  26971. */
  26972. shapeID: number;
  26973. /**
  26974. * flat array of model positions (internal use)
  26975. * @hidden
  26976. */
  26977. _shape: Vector3[];
  26978. /**
  26979. * flat array of model UVs (internal use)
  26980. * @hidden
  26981. */
  26982. _shapeUV: number[];
  26983. /**
  26984. * length of the shape in the model indices array (internal use)
  26985. * @hidden
  26986. */
  26987. _indicesLength: number;
  26988. /**
  26989. * Custom position function (internal use)
  26990. * @hidden
  26991. */
  26992. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26993. /**
  26994. * Custom vertex function (internal use)
  26995. * @hidden
  26996. */
  26997. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26998. /**
  26999. * 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.
  27000. * SPS internal tool, don't use it manually.
  27001. * @hidden
  27002. */
  27003. 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>);
  27004. }
  27005. /**
  27006. * Represents a Depth Sorted Particle in the solid particle system.
  27007. */
  27008. class DepthSortedParticle {
  27009. /**
  27010. * Index of the particle in the "indices" array
  27011. */
  27012. ind: number;
  27013. /**
  27014. * Length of the particle shape in the "indices" array
  27015. */
  27016. indicesLength: number;
  27017. /**
  27018. * Squared distance from the particle to the camera
  27019. */
  27020. sqDistance: number;
  27021. }
  27022. }
  27023. declare module BABYLON {
  27024. /**
  27025. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27026. *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.
  27027. * The SPS is also a particle system. It provides some methods to manage the particles.
  27028. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27029. *
  27030. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  27031. */
  27032. class SolidParticleSystem implements IDisposable {
  27033. /**
  27034. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27035. * Example : var p = SPS.particles[i];
  27036. */
  27037. particles: SolidParticle[];
  27038. /**
  27039. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27040. */
  27041. nbParticles: number;
  27042. /**
  27043. * If the particles must ever face the camera (default false). Useful for planar particles.
  27044. */
  27045. billboard: boolean;
  27046. /**
  27047. * Recompute normals when adding a shape
  27048. */
  27049. recomputeNormals: boolean;
  27050. /**
  27051. * This a counter ofr your own usage. It's not set by any SPS functions.
  27052. */
  27053. counter: number;
  27054. /**
  27055. * The SPS name. This name is also given to the underlying mesh.
  27056. */
  27057. name: string;
  27058. /**
  27059. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27060. */
  27061. mesh: Mesh;
  27062. /**
  27063. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27064. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  27065. */
  27066. vars: any;
  27067. /**
  27068. * This array is populated when the SPS is set as 'pickable'.
  27069. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27070. * Each element of this array is an object `{idx: int, faceId: int}`.
  27071. * `idx` is the picked particle index in the `SPS.particles` array
  27072. * `faceId` is the picked face index counted within this particle.
  27073. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  27074. */
  27075. pickedParticles: {
  27076. idx: number;
  27077. faceId: number;
  27078. }[];
  27079. /**
  27080. * This array is populated when `enableDepthSort` is set to true.
  27081. * Each element of this array is an instance of the class DepthSortedParticle.
  27082. */
  27083. depthSortedParticles: DepthSortedParticle[];
  27084. /**
  27085. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27086. * @hidden
  27087. */
  27088. _bSphereOnly: boolean;
  27089. /**
  27090. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27091. * @hidden
  27092. */
  27093. _bSphereRadiusFactor: number;
  27094. private _scene;
  27095. private _positions;
  27096. private _indices;
  27097. private _normals;
  27098. private _colors;
  27099. private _uvs;
  27100. private _indices32;
  27101. private _positions32;
  27102. private _normals32;
  27103. private _fixedNormal32;
  27104. private _colors32;
  27105. private _uvs32;
  27106. private _index;
  27107. private _updatable;
  27108. private _pickable;
  27109. private _isVisibilityBoxLocked;
  27110. private _alwaysVisible;
  27111. private _depthSort;
  27112. private _shapeCounter;
  27113. private _copy;
  27114. private _shape;
  27115. private _shapeUV;
  27116. private _color;
  27117. private _computeParticleColor;
  27118. private _computeParticleTexture;
  27119. private _computeParticleRotation;
  27120. private _computeParticleVertex;
  27121. private _computeBoundingBox;
  27122. private _depthSortParticles;
  27123. private _cam_axisZ;
  27124. private _cam_axisY;
  27125. private _cam_axisX;
  27126. private _axisZ;
  27127. private _camera;
  27128. private _particle;
  27129. private _camDir;
  27130. private _camInvertedPosition;
  27131. private _rotMatrix;
  27132. private _invertMatrix;
  27133. private _rotated;
  27134. private _quaternion;
  27135. private _vertex;
  27136. private _normal;
  27137. private _yaw;
  27138. private _pitch;
  27139. private _roll;
  27140. private _halfroll;
  27141. private _halfpitch;
  27142. private _halfyaw;
  27143. private _sinRoll;
  27144. private _cosRoll;
  27145. private _sinPitch;
  27146. private _cosPitch;
  27147. private _sinYaw;
  27148. private _cosYaw;
  27149. private _mustUnrotateFixedNormals;
  27150. private _minimum;
  27151. private _maximum;
  27152. private _minBbox;
  27153. private _maxBbox;
  27154. private _particlesIntersect;
  27155. private _depthSortFunction;
  27156. private _needs32Bits;
  27157. private _pivotBackTranslation;
  27158. private _scaledPivot;
  27159. private _particleHasParent;
  27160. private _parent;
  27161. /**
  27162. * Creates a SPS (Solid Particle System) object.
  27163. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27164. * @param scene (Scene) is the scene in which the SPS is added.
  27165. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27166. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27167. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27168. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27169. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27170. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27171. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27172. */
  27173. constructor(name: string, scene: Scene, options?: {
  27174. updatable?: boolean;
  27175. isPickable?: boolean;
  27176. enableDepthSort?: boolean;
  27177. particleIntersection?: boolean;
  27178. boundingSphereOnly?: boolean;
  27179. bSphereRadiusFactor?: number;
  27180. });
  27181. /**
  27182. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27183. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27184. * @returns the created mesh
  27185. */
  27186. buildMesh(): Mesh;
  27187. /**
  27188. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27189. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27190. * Thus the particles generated from `digest()` have their property `position` set yet.
  27191. * @param mesh ( Mesh ) is the mesh to be digested
  27192. * @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
  27193. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27194. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27195. * @returns the current SPS
  27196. */
  27197. digest(mesh: Mesh, options?: {
  27198. facetNb?: number;
  27199. number?: number;
  27200. delta?: number;
  27201. }): SolidParticleSystem;
  27202. private _unrotateFixedNormals;
  27203. private _resetCopy;
  27204. private _meshBuilder;
  27205. private _posToShape;
  27206. private _uvsToShapeUV;
  27207. private _addParticle;
  27208. /**
  27209. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27210. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  27211. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27212. * @param nb (positive integer) the number of particles to be created from this model
  27213. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27214. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27215. * @returns the number of shapes in the system
  27216. */
  27217. addShape(mesh: Mesh, nb: number, options?: {
  27218. positionFunction?: any;
  27219. vertexFunction?: any;
  27220. }): number;
  27221. private _rebuildParticle;
  27222. /**
  27223. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27224. * @returns the SPS.
  27225. */
  27226. rebuildMesh(): SolidParticleSystem;
  27227. /**
  27228. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27229. * This method calls `updateParticle()` for each particle of the SPS.
  27230. * For an animated SPS, it is usually called within the render loop.
  27231. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27232. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27233. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27234. * @returns the SPS.
  27235. */
  27236. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27237. private _quaternionRotationYPR;
  27238. private _quaternionToRotationMatrix;
  27239. /**
  27240. * Disposes the SPS.
  27241. */
  27242. dispose(): void;
  27243. /**
  27244. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27245. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  27246. * @returns the SPS.
  27247. */
  27248. refreshVisibleSize(): SolidParticleSystem;
  27249. /**
  27250. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27251. * @param size the size (float) of the visibility box
  27252. * note : this doesn't lock the SPS mesh bounding box.
  27253. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  27254. */
  27255. setVisibilityBox(size: number): void;
  27256. /**
  27257. * Gets whether the SPS as always visible or not
  27258. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  27259. */
  27260. /**
  27261. * Sets the SPS as always visible or not
  27262. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  27263. */
  27264. isAlwaysVisible: boolean;
  27265. /**
  27266. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27267. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  27268. */
  27269. /**
  27270. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27271. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  27272. */
  27273. isVisibilityBoxLocked: boolean;
  27274. /**
  27275. * Tells to `setParticles()` to compute the particle rotations or not.
  27276. * Default value : true. The SPS is faster when it's set to false.
  27277. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27278. */
  27279. /**
  27280. * Gets if `setParticles()` computes the particle rotations or not.
  27281. * Default value : true. The SPS is faster when it's set to false.
  27282. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27283. */
  27284. computeParticleRotation: boolean;
  27285. /**
  27286. * Tells to `setParticles()` to compute the particle colors or not.
  27287. * Default value : true. The SPS is faster when it's set to false.
  27288. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27289. */
  27290. /**
  27291. * Gets if `setParticles()` computes the particle colors or not.
  27292. * Default value : true. The SPS is faster when it's set to false.
  27293. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27294. */
  27295. computeParticleColor: boolean;
  27296. /**
  27297. * Gets if `setParticles()` computes the particle textures or not.
  27298. * Default value : true. The SPS is faster when it's set to false.
  27299. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27300. */
  27301. computeParticleTexture: boolean;
  27302. /**
  27303. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27304. * Default value : false. The SPS is faster when it's set to false.
  27305. * Note : the particle custom vertex positions aren't stored values.
  27306. */
  27307. /**
  27308. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27309. * Default value : false. The SPS is faster when it's set to false.
  27310. * Note : the particle custom vertex positions aren't stored values.
  27311. */
  27312. computeParticleVertex: boolean;
  27313. /**
  27314. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27315. */
  27316. /**
  27317. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27318. */
  27319. computeBoundingBox: boolean;
  27320. /**
  27321. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27322. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27323. * Default : `true`
  27324. */
  27325. /**
  27326. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27327. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27328. * Default : `true`
  27329. */
  27330. depthSortParticles: boolean;
  27331. /**
  27332. * This function does nothing. It may be overwritten to set all the particle first values.
  27333. * The SPS doesn't call this function, you may have to call it by your own.
  27334. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  27335. */
  27336. initParticles(): void;
  27337. /**
  27338. * This function does nothing. It may be overwritten to recycle a particle.
  27339. * The SPS doesn't call this function, you may have to call it by your own.
  27340. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  27341. * @param particle The particle to recycle
  27342. * @returns the recycled particle
  27343. */
  27344. recycleParticle(particle: SolidParticle): SolidParticle;
  27345. /**
  27346. * Updates a particle : this function should be overwritten by the user.
  27347. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27348. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  27349. * @example : just set a particle position or velocity and recycle conditions
  27350. * @param particle The particle to update
  27351. * @returns the updated particle
  27352. */
  27353. updateParticle(particle: SolidParticle): SolidParticle;
  27354. /**
  27355. * Updates a vertex of a particle : it can be overwritten by the user.
  27356. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27357. * @param particle the current particle
  27358. * @param vertex the current index of the current particle
  27359. * @param pt the index of the current vertex in the particle shape
  27360. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  27361. * @example : just set a vertex particle position
  27362. * @returns the updated vertex
  27363. */
  27364. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27365. /**
  27366. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27367. * This does nothing and may be overwritten by the user.
  27368. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27369. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27370. * @param update the boolean update value actually passed to setParticles()
  27371. */
  27372. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27373. /**
  27374. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27375. * This will be passed three parameters.
  27376. * This does nothing and may be overwritten by the user.
  27377. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27378. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27379. * @param update the boolean update value actually passed to setParticles()
  27380. */
  27381. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27382. }
  27383. }
  27384. declare module BABYLON {
  27385. /**
  27386. * Class used to generate realtime reflection / refraction cube textures
  27387. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  27388. */
  27389. class ReflectionProbe {
  27390. /** defines the name of the probe */
  27391. name: string;
  27392. private _scene;
  27393. private _renderTargetTexture;
  27394. private _projectionMatrix;
  27395. private _viewMatrix;
  27396. private _target;
  27397. private _add;
  27398. private _attachedMesh;
  27399. private _invertYAxis;
  27400. /** Gets or sets probe position (center of the cube map) */
  27401. position: Vector3;
  27402. /**
  27403. * Creates a new reflection probe
  27404. * @param name defines the name of the probe
  27405. * @param size defines the texture resolution (for each face)
  27406. * @param scene defines the hosting scene
  27407. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  27408. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  27409. */
  27410. constructor(
  27411. /** defines the name of the probe */
  27412. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  27413. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  27414. samples: number;
  27415. /** Gets or sets the refresh rate to use (on every frame by default) */
  27416. refreshRate: number;
  27417. /**
  27418. * Gets the hosting scene
  27419. * @returns a Scene
  27420. */
  27421. getScene(): Scene;
  27422. /** Gets the internal CubeTexture used to render to */
  27423. readonly cubeTexture: RenderTargetTexture;
  27424. /** Gets the list of meshes to render */
  27425. readonly renderList: Nullable<AbstractMesh[]>;
  27426. /**
  27427. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  27428. * @param mesh defines the mesh to attach to
  27429. */
  27430. attachToMesh(mesh: AbstractMesh): void;
  27431. /**
  27432. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  27433. * @param renderingGroupId The rendering group id corresponding to its index
  27434. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27435. */
  27436. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27437. /**
  27438. * Clean all associated resources
  27439. */
  27440. dispose(): void;
  27441. }
  27442. }
  27443. declare module BABYLON {
  27444. /**
  27445. * Postprocess used to generate anaglyphic rendering
  27446. */
  27447. class AnaglyphPostProcess extends PostProcess {
  27448. private _passedProcess;
  27449. /**
  27450. * Creates a new AnaglyphPostProcess
  27451. * @param name defines postprocess name
  27452. * @param options defines creation options or target ratio scale
  27453. * @param rigCameras defines cameras using this postprocess
  27454. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27455. * @param engine defines hosting engine
  27456. * @param reusable defines if the postprocess will be reused multiple times per frame
  27457. */
  27458. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27459. }
  27460. }
  27461. declare module BABYLON {
  27462. class BlackAndWhitePostProcess extends PostProcess {
  27463. degree: number;
  27464. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27465. }
  27466. }
  27467. declare module BABYLON {
  27468. /**
  27469. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27470. */
  27471. class BloomEffect extends PostProcessRenderEffect {
  27472. private bloomScale;
  27473. /**
  27474. * @hidden Internal
  27475. */
  27476. _effects: Array<PostProcess>;
  27477. /**
  27478. * @hidden Internal
  27479. */
  27480. _downscale: ExtractHighlightsPostProcess;
  27481. private _blurX;
  27482. private _blurY;
  27483. private _merge;
  27484. /**
  27485. * The luminance threshold to find bright areas of the image to bloom.
  27486. */
  27487. threshold: number;
  27488. /**
  27489. * The strength of the bloom.
  27490. */
  27491. weight: number;
  27492. /**
  27493. * Specifies the size of the bloom blur kernel, relative to the final output size
  27494. */
  27495. kernel: number;
  27496. /**
  27497. * Creates a new instance of @see BloomEffect
  27498. * @param scene The scene the effect belongs to.
  27499. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27500. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27501. * @param bloomWeight The the strength of bloom.
  27502. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27503. * @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)
  27504. */
  27505. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27506. /**
  27507. * Disposes each of the internal effects for a given camera.
  27508. * @param camera The camera to dispose the effect on.
  27509. */
  27510. disposeEffects(camera: Camera): void;
  27511. /**
  27512. * @hidden Internal
  27513. */
  27514. _updateEffects(): void;
  27515. /**
  27516. * Internal
  27517. * @returns if all the contained post processes are ready.
  27518. * @hidden
  27519. */
  27520. _isReady(): boolean;
  27521. }
  27522. }
  27523. declare module BABYLON {
  27524. /**
  27525. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27526. */
  27527. class BloomMergePostProcess extends PostProcess {
  27528. /** Weight of the bloom to be added to the original input. */
  27529. weight: number;
  27530. /**
  27531. * Creates a new instance of @see BloomMergePostProcess
  27532. * @param name The name of the effect.
  27533. * @param originalFromInput Post process which's input will be used for the merge.
  27534. * @param blurred Blurred highlights post process which's output will be used.
  27535. * @param weight Weight of the bloom to be added to the original input.
  27536. * @param options The required width/height ratio to downsize to before computing the render pass.
  27537. * @param camera The camera to apply the render pass to.
  27538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27539. * @param engine The engine which the post process will be applied. (default: current engine)
  27540. * @param reusable If the post process can be reused on the same frame. (default: false)
  27541. * @param textureType Type of textures used when performing the post process. (default: 0)
  27542. * @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)
  27543. */
  27544. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27545. /** Weight of the bloom to be added to the original input. */
  27546. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27547. }
  27548. }
  27549. declare module BABYLON {
  27550. /**
  27551. * The Blur Post Process which blurs an image based on a kernel and direction.
  27552. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27553. */
  27554. class BlurPostProcess extends PostProcess {
  27555. /** The direction in which to blur the image. */
  27556. direction: Vector2;
  27557. private blockCompilation;
  27558. protected _kernel: number;
  27559. protected _idealKernel: number;
  27560. protected _packedFloat: boolean;
  27561. private _staticDefines;
  27562. /**
  27563. * Sets the length in pixels of the blur sample region
  27564. */
  27565. /**
  27566. * Gets the length in pixels of the blur sample region
  27567. */
  27568. kernel: number;
  27569. /**
  27570. * Sets wether or not the blur needs to unpack/repack floats
  27571. */
  27572. /**
  27573. * Gets wether or not the blur is unpacking/repacking floats
  27574. */
  27575. packedFloat: boolean;
  27576. /**
  27577. * Creates a new instance BlurPostProcess
  27578. * @param name The name of the effect.
  27579. * @param direction The direction in which to blur the image.
  27580. * @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.
  27581. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27582. * @param camera The camera to apply the render pass to.
  27583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27584. * @param engine The engine which the post process will be applied. (default: current engine)
  27585. * @param reusable If the post process can be reused on the same frame. (default: false)
  27586. * @param textureType Type of textures used when performing the post process. (default: 0)
  27587. * @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)
  27588. */
  27589. constructor(name: string,
  27590. /** The direction in which to blur the image. */
  27591. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27592. /**
  27593. * Updates the effect with the current post process compile time values and recompiles the shader.
  27594. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27595. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27596. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27597. * @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
  27598. * @param onCompiled Called when the shader has been compiled.
  27599. * @param onError Called if there is an error when compiling a shader.
  27600. */
  27601. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27602. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27603. /**
  27604. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27605. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27606. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27607. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27608. * The gaps between physical kernels are compensated for in the weighting of the samples
  27609. * @param idealKernel Ideal blur kernel.
  27610. * @return Nearest best kernel.
  27611. */
  27612. protected _nearestBestKernel(idealKernel: number): number;
  27613. /**
  27614. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27615. * @param x The point on the Gaussian distribution to sample.
  27616. * @return the value of the Gaussian function at x.
  27617. */
  27618. protected _gaussianWeight(x: number): number;
  27619. /**
  27620. * Generates a string that can be used as a floating point number in GLSL.
  27621. * @param x Value to print.
  27622. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27623. * @return GLSL float string.
  27624. */
  27625. protected _glslFloat(x: number, decimalFigures?: number): string;
  27626. }
  27627. }
  27628. declare module BABYLON {
  27629. /**
  27630. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27631. */
  27632. class ChromaticAberrationPostProcess extends PostProcess {
  27633. /**
  27634. * The amount of seperation of rgb channels (default: 30)
  27635. */
  27636. aberrationAmount: number;
  27637. /**
  27638. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27639. */
  27640. radialIntensity: number;
  27641. /**
  27642. * 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))
  27643. */
  27644. direction: Vector2;
  27645. /**
  27646. * 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))
  27647. */
  27648. centerPosition: Vector2;
  27649. /**
  27650. * Creates a new instance ChromaticAberrationPostProcess
  27651. * @param name The name of the effect.
  27652. * @param screenWidth The width of the screen to apply the effect on.
  27653. * @param screenHeight The height of the screen to apply the effect on.
  27654. * @param options The required width/height ratio to downsize to before computing the render pass.
  27655. * @param camera The camera to apply the render pass to.
  27656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27657. * @param engine The engine which the post process will be applied. (default: current engine)
  27658. * @param reusable If the post process can be reused on the same frame. (default: false)
  27659. * @param textureType Type of textures used when performing the post process. (default: 0)
  27660. * @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)
  27661. */
  27662. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27663. }
  27664. }
  27665. declare module BABYLON {
  27666. /**
  27667. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27668. */
  27669. class CircleOfConfusionPostProcess extends PostProcess {
  27670. /**
  27671. * 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.
  27672. */
  27673. lensSize: number;
  27674. /**
  27675. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27676. */
  27677. fStop: number;
  27678. /**
  27679. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27680. */
  27681. focusDistance: number;
  27682. /**
  27683. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27684. */
  27685. focalLength: number;
  27686. private _depthTexture;
  27687. /**
  27688. * Creates a new instance CircleOfConfusionPostProcess
  27689. * @param name The name of the effect.
  27690. * @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.
  27691. * @param options The required width/height ratio to downsize to before computing the render pass.
  27692. * @param camera The camera to apply the render pass to.
  27693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27694. * @param engine The engine which the post process will be applied. (default: current engine)
  27695. * @param reusable If the post process can be reused on the same frame. (default: false)
  27696. * @param textureType Type of textures used when performing the post process. (default: 0)
  27697. * @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)
  27698. */
  27699. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27700. /**
  27701. * 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.
  27702. */
  27703. depthTexture: RenderTargetTexture;
  27704. }
  27705. }
  27706. declare module BABYLON {
  27707. class ColorCorrectionPostProcess extends PostProcess {
  27708. private _colorTableTexture;
  27709. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27710. }
  27711. }
  27712. declare module BABYLON {
  27713. /**
  27714. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27715. * input texture to perform effects such as edge detection or sharpening
  27716. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27717. */
  27718. class ConvolutionPostProcess extends PostProcess {
  27719. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27720. kernel: number[];
  27721. /**
  27722. * Creates a new instance ConvolutionPostProcess
  27723. * @param name The name of the effect.
  27724. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27725. * @param options The required width/height ratio to downsize to before computing the render pass.
  27726. * @param camera The camera to apply the render pass to.
  27727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27728. * @param engine The engine which the post process will be applied. (default: current engine)
  27729. * @param reusable If the post process can be reused on the same frame. (default: false)
  27730. * @param textureType Type of textures used when performing the post process. (default: 0)
  27731. */
  27732. constructor(name: string,
  27733. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27734. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27735. /**
  27736. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27737. */
  27738. static EdgeDetect0Kernel: number[];
  27739. /**
  27740. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27741. */
  27742. static EdgeDetect1Kernel: number[];
  27743. /**
  27744. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27745. */
  27746. static EdgeDetect2Kernel: number[];
  27747. /**
  27748. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27749. */
  27750. static SharpenKernel: number[];
  27751. /**
  27752. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27753. */
  27754. static EmbossKernel: number[];
  27755. /**
  27756. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27757. */
  27758. static GaussianKernel: number[];
  27759. }
  27760. }
  27761. declare module BABYLON {
  27762. /**
  27763. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27764. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27765. * based on samples that have a large difference in distance than the center pixel.
  27766. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27767. */
  27768. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27769. direction: Vector2;
  27770. /**
  27771. * Creates a new instance CircleOfConfusionPostProcess
  27772. * @param name The name of the effect.
  27773. * @param scene The scene the effect belongs to.
  27774. * @param direction The direction the blur should be applied.
  27775. * @param kernel The size of the kernel used to blur.
  27776. * @param options The required width/height ratio to downsize to before computing the render pass.
  27777. * @param camera The camera to apply the render pass to.
  27778. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27779. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27781. * @param engine The engine which the post process will be applied. (default: current engine)
  27782. * @param reusable If the post process can be reused on the same frame. (default: false)
  27783. * @param textureType Type of textures used when performing the post process. (default: 0)
  27784. * @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)
  27785. */
  27786. 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);
  27787. }
  27788. }
  27789. declare module BABYLON {
  27790. /**
  27791. * Specifies the level of max blur that should be applied when using the depth of field effect
  27792. */
  27793. enum DepthOfFieldEffectBlurLevel {
  27794. /**
  27795. * Subtle blur
  27796. */
  27797. Low = 0,
  27798. /**
  27799. * Medium blur
  27800. */
  27801. Medium = 1,
  27802. /**
  27803. * Large blur
  27804. */
  27805. High = 2
  27806. }
  27807. /**
  27808. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27809. */
  27810. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27811. private _circleOfConfusion;
  27812. /**
  27813. * @hidden Internal, blurs from high to low
  27814. */
  27815. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27816. private _depthOfFieldBlurY;
  27817. private _dofMerge;
  27818. /**
  27819. * @hidden Internal post processes in depth of field effect
  27820. */
  27821. _effects: Array<PostProcess>;
  27822. /**
  27823. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27824. */
  27825. focalLength: number;
  27826. /**
  27827. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27828. */
  27829. fStop: number;
  27830. /**
  27831. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27832. */
  27833. focusDistance: number;
  27834. /**
  27835. * 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.
  27836. */
  27837. lensSize: number;
  27838. /**
  27839. * Creates a new instance DepthOfFieldEffect
  27840. * @param scene The scene the effect belongs to.
  27841. * @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.
  27842. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27843. * @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)
  27844. */
  27845. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27846. /**
  27847. * 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.
  27848. */
  27849. depthTexture: RenderTargetTexture;
  27850. /**
  27851. * Disposes each of the internal effects for a given camera.
  27852. * @param camera The camera to dispose the effect on.
  27853. */
  27854. disposeEffects(camera: Camera): void;
  27855. /**
  27856. * @hidden Internal
  27857. */
  27858. _updateEffects(): void;
  27859. /**
  27860. * Internal
  27861. * @returns if all the contained post processes are ready.
  27862. * @hidden
  27863. */
  27864. _isReady(): boolean;
  27865. }
  27866. }
  27867. declare module BABYLON {
  27868. /**
  27869. * Options to be set when merging outputs from the default pipeline.
  27870. */
  27871. class DepthOfFieldMergePostProcessOptions {
  27872. /**
  27873. * The original image to merge on top of
  27874. */
  27875. originalFromInput: PostProcess;
  27876. /**
  27877. * Parameters to perform the merge of the depth of field effect
  27878. */
  27879. depthOfField?: {
  27880. circleOfConfusion: PostProcess;
  27881. blurSteps: Array<PostProcess>;
  27882. };
  27883. /**
  27884. * Parameters to perform the merge of bloom effect
  27885. */
  27886. bloom?: {
  27887. blurred: PostProcess;
  27888. weight: number;
  27889. };
  27890. }
  27891. /**
  27892. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27893. */
  27894. class DepthOfFieldMergePostProcess extends PostProcess {
  27895. private blurSteps;
  27896. /**
  27897. * Creates a new instance of DepthOfFieldMergePostProcess
  27898. * @param name The name of the effect.
  27899. * @param originalFromInput Post process which's input will be used for the merge.
  27900. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27901. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27902. * @param options The required width/height ratio to downsize to before computing the render pass.
  27903. * @param camera The camera to apply the render pass to.
  27904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27905. * @param engine The engine which the post process will be applied. (default: current engine)
  27906. * @param reusable If the post process can be reused on the same frame. (default: false)
  27907. * @param textureType Type of textures used when performing the post process. (default: 0)
  27908. * @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)
  27909. */
  27910. 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);
  27911. /**
  27912. * Updates the effect with the current post process compile time values and recompiles the shader.
  27913. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27914. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27915. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27916. * @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
  27917. * @param onCompiled Called when the shader has been compiled.
  27918. * @param onError Called if there is an error when compiling a shader.
  27919. */
  27920. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27921. }
  27922. }
  27923. declare module BABYLON {
  27924. class DisplayPassPostProcess extends PostProcess {
  27925. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27926. }
  27927. }
  27928. declare module BABYLON {
  27929. /**
  27930. * 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.
  27931. */
  27932. class ExtractHighlightsPostProcess extends PostProcess {
  27933. /**
  27934. * The luminance threshold, pixels below this value will be set to black.
  27935. */
  27936. threshold: number;
  27937. /** @hidden */
  27938. _exposure: number;
  27939. /**
  27940. * Post process which has the input texture to be used when performing highlight extraction
  27941. * @hidden
  27942. */
  27943. _inputPostProcess: Nullable<PostProcess>;
  27944. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27945. }
  27946. }
  27947. declare module BABYLON {
  27948. class FilterPostProcess extends PostProcess {
  27949. kernelMatrix: Matrix;
  27950. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27951. }
  27952. }
  27953. declare module BABYLON {
  27954. class FxaaPostProcess extends PostProcess {
  27955. texelWidth: number;
  27956. texelHeight: number;
  27957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27958. private _getDefines;
  27959. }
  27960. }
  27961. declare module BABYLON {
  27962. /**
  27963. * The GrainPostProcess adds noise to the image at mid luminance levels
  27964. */
  27965. class GrainPostProcess extends PostProcess {
  27966. /**
  27967. * The intensity of the grain added (default: 30)
  27968. */
  27969. intensity: number;
  27970. /**
  27971. * If the grain should be randomized on every frame
  27972. */
  27973. animated: boolean;
  27974. /**
  27975. * Creates a new instance of @see GrainPostProcess
  27976. * @param name The name of the effect.
  27977. * @param options The required width/height ratio to downsize to before computing the render pass.
  27978. * @param camera The camera to apply the render pass to.
  27979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27980. * @param engine The engine which the post process will be applied. (default: current engine)
  27981. * @param reusable If the post process can be reused on the same frame. (default: false)
  27982. * @param textureType Type of textures used when performing the post process. (default: 0)
  27983. * @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)
  27984. */
  27985. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27986. }
  27987. }
  27988. declare module BABYLON {
  27989. class HighlightsPostProcess extends PostProcess {
  27990. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27991. }
  27992. }
  27993. declare module BABYLON {
  27994. class ImageProcessingPostProcess extends PostProcess {
  27995. /**
  27996. * Default configuration related to image processing available in the PBR Material.
  27997. */
  27998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27999. /**
  28000. * Gets the image processing configuration used either in this material.
  28001. */
  28002. /**
  28003. * Sets the Default image processing configuration used either in the this material.
  28004. *
  28005. * If sets to null, the scene one is in use.
  28006. */
  28007. imageProcessingConfiguration: ImageProcessingConfiguration;
  28008. /**
  28009. * Keep track of the image processing observer to allow dispose and replace.
  28010. */
  28011. private _imageProcessingObserver;
  28012. /**
  28013. * Attaches a new image processing configuration to the PBR Material.
  28014. * @param configuration
  28015. */
  28016. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  28017. /**
  28018. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28019. */
  28020. /**
  28021. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28022. */
  28023. colorCurves: Nullable<ColorCurves>;
  28024. /**
  28025. * Gets wether the color curves effect is enabled.
  28026. */
  28027. /**
  28028. * Sets wether the color curves effect is enabled.
  28029. */
  28030. colorCurvesEnabled: boolean;
  28031. /**
  28032. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28033. */
  28034. /**
  28035. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28036. */
  28037. colorGradingTexture: Nullable<BaseTexture>;
  28038. /**
  28039. * Gets wether the color grading effect is enabled.
  28040. */
  28041. /**
  28042. * Gets wether the color grading effect is enabled.
  28043. */
  28044. colorGradingEnabled: boolean;
  28045. /**
  28046. * Gets exposure used in the effect.
  28047. */
  28048. /**
  28049. * Sets exposure used in the effect.
  28050. */
  28051. exposure: number;
  28052. /**
  28053. * Gets wether tonemapping is enabled or not.
  28054. */
  28055. /**
  28056. * Sets wether tonemapping is enabled or not
  28057. */
  28058. toneMappingEnabled: boolean;
  28059. /**
  28060. * Gets contrast used in the effect.
  28061. */
  28062. /**
  28063. * Sets contrast used in the effect.
  28064. */
  28065. contrast: number;
  28066. /**
  28067. * Gets Vignette stretch size.
  28068. */
  28069. /**
  28070. * Sets Vignette stretch size.
  28071. */
  28072. vignetteStretch: number;
  28073. /**
  28074. * Gets Vignette centre X Offset.
  28075. */
  28076. /**
  28077. * Sets Vignette centre X Offset.
  28078. */
  28079. vignetteCentreX: number;
  28080. /**
  28081. * Gets Vignette centre Y Offset.
  28082. */
  28083. /**
  28084. * Sets Vignette centre Y Offset.
  28085. */
  28086. vignetteCentreY: number;
  28087. /**
  28088. * Gets Vignette weight or intensity of the vignette effect.
  28089. */
  28090. /**
  28091. * Sets Vignette weight or intensity of the vignette effect.
  28092. */
  28093. vignetteWeight: number;
  28094. /**
  28095. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28096. * if vignetteEnabled is set to true.
  28097. */
  28098. /**
  28099. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28100. * if vignetteEnabled is set to true.
  28101. */
  28102. vignetteColor: Color4;
  28103. /**
  28104. * Gets Camera field of view used by the Vignette effect.
  28105. */
  28106. /**
  28107. * Sets Camera field of view used by the Vignette effect.
  28108. */
  28109. vignetteCameraFov: number;
  28110. /**
  28111. * Gets the vignette blend mode allowing different kind of effect.
  28112. */
  28113. /**
  28114. * Sets the vignette blend mode allowing different kind of effect.
  28115. */
  28116. vignetteBlendMode: number;
  28117. /**
  28118. * Gets wether the vignette effect is enabled.
  28119. */
  28120. /**
  28121. * Sets wether the vignette effect is enabled.
  28122. */
  28123. vignetteEnabled: boolean;
  28124. private _fromLinearSpace;
  28125. /**
  28126. * Gets wether the input of the processing is in Gamma or Linear Space.
  28127. */
  28128. /**
  28129. * Sets wether the input of the processing is in Gamma or Linear Space.
  28130. */
  28131. fromLinearSpace: boolean;
  28132. /**
  28133. * Defines cache preventing GC.
  28134. */
  28135. private _defines;
  28136. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  28137. getClassName(): string;
  28138. protected _updateParameters(): void;
  28139. dispose(camera?: Camera): void;
  28140. }
  28141. }
  28142. declare module BABYLON {
  28143. class PassPostProcess extends PostProcess {
  28144. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28145. }
  28146. }
  28147. declare module BABYLON {
  28148. type PostProcessOptions = {
  28149. width: number;
  28150. height: number;
  28151. };
  28152. /**
  28153. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28154. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28155. */
  28156. class PostProcess {
  28157. /** Name of the PostProcess. */
  28158. name: string;
  28159. /**
  28160. * Width of the texture to apply the post process on
  28161. */
  28162. width: number;
  28163. /**
  28164. * Height of the texture to apply the post process on
  28165. */
  28166. height: number;
  28167. /**
  28168. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28169. * @hidden
  28170. */
  28171. _outputTexture: Nullable<InternalTexture>;
  28172. /**
  28173. * Sampling mode used by the shader
  28174. * See https://doc.babylonjs.com/classes/3.1/texture
  28175. */
  28176. renderTargetSamplingMode: number;
  28177. /**
  28178. * Clear color to use when screen clearing
  28179. */
  28180. clearColor: Color4;
  28181. /**
  28182. * If the buffer needs to be cleared before applying the post process. (default: true)
  28183. * Should be set to false if shader will overwrite all previous pixels.
  28184. */
  28185. autoClear: boolean;
  28186. /**
  28187. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28188. */
  28189. alphaMode: number;
  28190. /**
  28191. * Sets the setAlphaBlendConstants of the babylon engine
  28192. */
  28193. alphaConstants: Color4;
  28194. /**
  28195. * Animations to be used for the post processing
  28196. */
  28197. animations: Animation[];
  28198. /**
  28199. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28200. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28201. */
  28202. enablePixelPerfectMode: boolean;
  28203. /**
  28204. * Force the postprocess to be applied without taking in account viewport
  28205. */
  28206. forceFullscreenViewport: boolean;
  28207. /**
  28208. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28209. *
  28210. * | Value | Type | Description |
  28211. * | ----- | ----------------------------------- | ----------- |
  28212. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28213. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28214. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28215. *
  28216. */
  28217. scaleMode: number;
  28218. /**
  28219. * Force textures to be a power of two (default: false)
  28220. */
  28221. alwaysForcePOT: boolean;
  28222. private _samples;
  28223. /**
  28224. * Number of sample textures (default: 1)
  28225. */
  28226. samples: number;
  28227. /**
  28228. * Modify the scale of the post process to be the same as the viewport (default: false)
  28229. */
  28230. adaptScaleToCurrentViewport: boolean;
  28231. private _camera;
  28232. private _scene;
  28233. private _engine;
  28234. private _options;
  28235. private _reusable;
  28236. private _textureType;
  28237. /**
  28238. * Smart array of input and output textures for the post process.
  28239. * @hidden
  28240. */
  28241. _textures: SmartArray<InternalTexture>;
  28242. /**
  28243. * The index in _textures that corresponds to the output texture.
  28244. * @hidden
  28245. */
  28246. _currentRenderTextureInd: number;
  28247. private _effect;
  28248. private _samplers;
  28249. private _fragmentUrl;
  28250. private _vertexUrl;
  28251. private _parameters;
  28252. private _scaleRatio;
  28253. protected _indexParameters: any;
  28254. private _shareOutputWithPostProcess;
  28255. private _texelSize;
  28256. private _forcedOutputTexture;
  28257. /**
  28258. * An event triggered when the postprocess is activated.
  28259. */
  28260. onActivateObservable: Observable<Camera>;
  28261. private _onActivateObserver;
  28262. /**
  28263. * A function that is added to the onActivateObservable
  28264. */
  28265. onActivate: Nullable<(camera: Camera) => void>;
  28266. /**
  28267. * An event triggered when the postprocess changes its size.
  28268. */
  28269. onSizeChangedObservable: Observable<PostProcess>;
  28270. private _onSizeChangedObserver;
  28271. /**
  28272. * A function that is added to the onSizeChangedObservable
  28273. */
  28274. onSizeChanged: (postProcess: PostProcess) => void;
  28275. /**
  28276. * An event triggered when the postprocess applies its effect.
  28277. */
  28278. onApplyObservable: Observable<Effect>;
  28279. private _onApplyObserver;
  28280. /**
  28281. * A function that is added to the onApplyObservable
  28282. */
  28283. onApply: (effect: Effect) => void;
  28284. /**
  28285. * An event triggered before rendering the postprocess
  28286. */
  28287. onBeforeRenderObservable: Observable<Effect>;
  28288. private _onBeforeRenderObserver;
  28289. /**
  28290. * A function that is added to the onBeforeRenderObservable
  28291. */
  28292. onBeforeRender: (effect: Effect) => void;
  28293. /**
  28294. * An event triggered after rendering the postprocess
  28295. */
  28296. onAfterRenderObservable: Observable<Effect>;
  28297. private _onAfterRenderObserver;
  28298. /**
  28299. * A function that is added to the onAfterRenderObservable
  28300. */
  28301. onAfterRender: (efect: Effect) => void;
  28302. /**
  28303. * 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
  28304. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28305. */
  28306. inputTexture: InternalTexture;
  28307. /**
  28308. * Gets the camera which post process is applied to.
  28309. * @returns The camera the post process is applied to.
  28310. */
  28311. getCamera(): Camera;
  28312. /**
  28313. * Gets the texel size of the postprocess.
  28314. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28315. */
  28316. readonly texelSize: Vector2;
  28317. /**
  28318. * Creates a new instance PostProcess
  28319. * @param name The name of the PostProcess.
  28320. * @param fragmentUrl The url of the fragment shader to be used.
  28321. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28322. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28323. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28324. * @param camera The camera to apply the render pass to.
  28325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28326. * @param engine The engine which the post process will be applied. (default: current engine)
  28327. * @param reusable If the post process can be reused on the same frame. (default: false)
  28328. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28329. * @param textureType Type of textures used when performing the post process. (default: 0)
  28330. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28331. * @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
  28332. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28333. */
  28334. constructor(
  28335. /** Name of the PostProcess. */
  28336. 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);
  28337. /**
  28338. * Gets the engine which this post process belongs to.
  28339. * @returns The engine the post process was enabled with.
  28340. */
  28341. getEngine(): Engine;
  28342. /**
  28343. * The effect that is created when initializing the post process.
  28344. * @returns The created effect corrisponding the the postprocess.
  28345. */
  28346. getEffect(): Effect;
  28347. /**
  28348. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28349. * @param postProcess The post process to share the output with.
  28350. * @returns This post process.
  28351. */
  28352. shareOutputWith(postProcess: PostProcess): PostProcess;
  28353. /**
  28354. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28355. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28356. */
  28357. useOwnOutput(): void;
  28358. /**
  28359. * Updates the effect with the current post process compile time values and recompiles the shader.
  28360. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28361. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28362. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28363. * @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
  28364. * @param onCompiled Called when the shader has been compiled.
  28365. * @param onError Called if there is an error when compiling a shader.
  28366. */
  28367. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28368. /**
  28369. * The post process is reusable if it can be used multiple times within one frame.
  28370. * @returns If the post process is reusable
  28371. */
  28372. isReusable(): boolean;
  28373. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28374. markTextureDirty(): void;
  28375. /**
  28376. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28377. * 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.
  28378. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28379. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28380. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28381. * @returns The target texture that was bound to be written to.
  28382. */
  28383. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28384. /**
  28385. * If the post process is supported.
  28386. */
  28387. readonly isSupported: boolean;
  28388. /**
  28389. * The aspect ratio of the output texture.
  28390. */
  28391. readonly aspectRatio: number;
  28392. /**
  28393. * Get a value indicating if the post-process is ready to be used
  28394. * @returns true if the post-process is ready (shader is compiled)
  28395. */
  28396. isReady(): boolean;
  28397. /**
  28398. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28399. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28400. */
  28401. apply(): Nullable<Effect>;
  28402. private _disposeTextures;
  28403. /**
  28404. * Disposes the post process.
  28405. * @param camera The camera to dispose the post process on.
  28406. */
  28407. dispose(camera?: Camera): void;
  28408. }
  28409. }
  28410. declare module BABYLON {
  28411. /**
  28412. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28414. */
  28415. class PostProcessManager {
  28416. private _scene;
  28417. private _indexBuffer;
  28418. private _vertexBuffers;
  28419. /**
  28420. * Creates a new instance PostProcess
  28421. * @param scene The scene that the post process is associated with.
  28422. */
  28423. constructor(scene: Scene);
  28424. private _prepareBuffers;
  28425. private _buildIndexBuffer;
  28426. /**
  28427. * Rebuilds the vertex buffers of the manager.
  28428. * @hidden
  28429. */
  28430. _rebuild(): void;
  28431. /**
  28432. * Prepares a frame to be run through a post process.
  28433. * @param sourceTexture The input texture to the post procesess. (default: null)
  28434. * @param postProcesses An array of post processes to be run. (default: null)
  28435. * @returns True if the post processes were able to be run.
  28436. * @hidden
  28437. */
  28438. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28439. /**
  28440. * Manually render a set of post processes to a texture.
  28441. * @param postProcesses An array of post processes to be run.
  28442. * @param targetTexture The target texture to render to.
  28443. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28444. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28445. * @param lodLevel defines which lod of the texture to render to
  28446. */
  28447. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28448. /**
  28449. * Finalize the result of the output of the postprocesses.
  28450. * @param doNotPresent If true the result will not be displayed to the screen.
  28451. * @param targetTexture The target texture to render to.
  28452. * @param faceIndex The index of the face to bind the target texture to.
  28453. * @param postProcesses The array of post processes to render.
  28454. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28455. * @hidden
  28456. */
  28457. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28458. /**
  28459. * Disposes of the post process manager.
  28460. */
  28461. dispose(): void;
  28462. }
  28463. }
  28464. declare module BABYLON {
  28465. class RefractionPostProcess extends PostProcess {
  28466. color: Color3;
  28467. depth: number;
  28468. colorLevel: number;
  28469. private _refTexture;
  28470. private _ownRefractionTexture;
  28471. /**
  28472. * Gets or sets the refraction texture
  28473. * Please note that you are responsible for disposing the texture if you set it manually
  28474. */
  28475. refractionTexture: Texture;
  28476. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28477. dispose(camera: Camera): void;
  28478. }
  28479. }
  28480. declare module BABYLON {
  28481. /**
  28482. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28483. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28484. */
  28485. class SharpenPostProcess extends PostProcess {
  28486. /**
  28487. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28488. */
  28489. colorAmount: number;
  28490. /**
  28491. * How much sharpness should be applied (default: 0.3)
  28492. */
  28493. edgeAmount: number;
  28494. /**
  28495. * Creates a new instance ConvolutionPostProcess
  28496. * @param name The name of the effect.
  28497. * @param options The required width/height ratio to downsize to before computing the render pass.
  28498. * @param camera The camera to apply the render pass to.
  28499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28500. * @param engine The engine which the post process will be applied. (default: current engine)
  28501. * @param reusable If the post process can be reused on the same frame. (default: false)
  28502. * @param textureType Type of textures used when performing the post process. (default: 0)
  28503. * @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)
  28504. */
  28505. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28506. }
  28507. }
  28508. declare module BABYLON {
  28509. class StereoscopicInterlacePostProcess extends PostProcess {
  28510. private _stepSize;
  28511. private _passedProcess;
  28512. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28513. }
  28514. }
  28515. declare module BABYLON {
  28516. /** Defines operator used for tonemapping */
  28517. enum TonemappingOperator {
  28518. /** Hable */
  28519. Hable = 0,
  28520. /** Reinhard */
  28521. Reinhard = 1,
  28522. /** HejiDawson */
  28523. HejiDawson = 2,
  28524. /** Photographic */
  28525. Photographic = 3
  28526. }
  28527. /**
  28528. * Defines a post process to apply tone mapping
  28529. */
  28530. class TonemapPostProcess extends PostProcess {
  28531. private _operator;
  28532. /** Defines the required exposure adjustement */
  28533. exposureAdjustment: number;
  28534. /**
  28535. * Creates a new TonemapPostProcess
  28536. * @param name defines the name of the postprocess
  28537. * @param _operator defines the operator to use
  28538. * @param exposureAdjustment defines the required exposure adjustement
  28539. * @param camera defines the camera to use (can be null)
  28540. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28541. * @param engine defines the hosting engine (can be ignore if camera is set)
  28542. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28543. */
  28544. constructor(name: string, _operator: TonemappingOperator,
  28545. /** Defines the required exposure adjustement */
  28546. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28547. }
  28548. }
  28549. declare module BABYLON {
  28550. class VolumetricLightScatteringPostProcess extends PostProcess {
  28551. private _volumetricLightScatteringPass;
  28552. private _volumetricLightScatteringRTT;
  28553. private _viewPort;
  28554. private _screenCoordinates;
  28555. private _cachedDefines;
  28556. /**
  28557. * If not undefined, the mesh position is computed from the attached node position
  28558. */
  28559. attachedNode: {
  28560. position: Vector3;
  28561. };
  28562. /**
  28563. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28564. */
  28565. customMeshPosition: Vector3;
  28566. /**
  28567. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28568. */
  28569. useCustomMeshPosition: boolean;
  28570. /**
  28571. * If the post-process should inverse the light scattering direction
  28572. */
  28573. invert: boolean;
  28574. /**
  28575. * The internal mesh used by the post-process
  28576. */
  28577. mesh: Mesh;
  28578. useDiffuseColor: boolean;
  28579. /**
  28580. * Array containing the excluded meshes not rendered in the internal pass
  28581. */
  28582. excludedMeshes: AbstractMesh[];
  28583. /**
  28584. * Controls the overall intensity of the post-process
  28585. */
  28586. exposure: number;
  28587. /**
  28588. * Dissipates each sample's contribution in range [0, 1]
  28589. */
  28590. decay: number;
  28591. /**
  28592. * Controls the overall intensity of each sample
  28593. */
  28594. weight: number;
  28595. /**
  28596. * Controls the density of each sample
  28597. */
  28598. density: number;
  28599. /**
  28600. * @constructor
  28601. * @param {string} name - The post-process name
  28602. * @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)
  28603. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28604. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28605. * @param {number} samples - The post-process quality, default 100
  28606. * @param {number} samplingMode - The post-process filtering mode
  28607. * @param {BABYLON.Engine} engine - The babylon engine
  28608. * @param {boolean} reusable - If the post-process is reusable
  28609. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28610. */
  28611. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28612. getClassName(): string;
  28613. private _isReady;
  28614. /**
  28615. * Sets the new light position for light scattering effect
  28616. * @param {BABYLON.Vector3} The new custom light position
  28617. */
  28618. setCustomMeshPosition(position: Vector3): void;
  28619. /**
  28620. * Returns the light position for light scattering effect
  28621. * @return {BABYLON.Vector3} The custom light position
  28622. */
  28623. getCustomMeshPosition(): Vector3;
  28624. /**
  28625. * Disposes the internal assets and detaches the post-process from the camera
  28626. */
  28627. dispose(camera: Camera): void;
  28628. /**
  28629. * Returns the render target texture used by the post-process
  28630. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28631. */
  28632. getPass(): RenderTargetTexture;
  28633. private _meshExcluded;
  28634. private _createPass;
  28635. private _updateMeshScreenCoordinates;
  28636. /**
  28637. * Creates a default mesh for the Volumeric Light Scattering post-process
  28638. * @param {string} The mesh name
  28639. * @param {BABYLON.Scene} The scene where to create the mesh
  28640. * @return {BABYLON.Mesh} the default mesh
  28641. */
  28642. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28643. }
  28644. }
  28645. declare module BABYLON {
  28646. class VRDistortionCorrectionPostProcess extends PostProcess {
  28647. private _isRightEye;
  28648. private _distortionFactors;
  28649. private _postProcessScaleFactor;
  28650. private _lensCenterOffset;
  28651. private _scaleIn;
  28652. private _scaleFactor;
  28653. private _lensCenter;
  28654. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28655. }
  28656. }
  28657. declare module BABYLON {
  28658. interface Scene {
  28659. /** @hidden (Backing field) */
  28660. _boundingBoxRenderer: BoundingBoxRenderer;
  28661. /** @hidden (Backing field) */
  28662. _forceShowBoundingBoxes: boolean;
  28663. /**
  28664. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28665. */
  28666. forceShowBoundingBoxes: boolean;
  28667. /**
  28668. * Gets the bounding box renderer associated with the scene
  28669. * @returns a BoundingBoxRenderer
  28670. */
  28671. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28672. }
  28673. interface AbstractMesh {
  28674. /** @hidden (Backing field) */
  28675. _showBoundingBox: boolean;
  28676. /**
  28677. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  28678. */
  28679. showBoundingBox: boolean;
  28680. }
  28681. class BoundingBoxRenderer implements ISceneComponent {
  28682. /**
  28683. * The component name helpfull to identify the component in the list of scene components.
  28684. */
  28685. readonly name: string;
  28686. /**
  28687. * The scene the component belongs to.
  28688. */
  28689. scene: Scene;
  28690. frontColor: Color3;
  28691. backColor: Color3;
  28692. showBackLines: boolean;
  28693. renderList: SmartArray<BoundingBox>;
  28694. private _colorShader;
  28695. private _vertexBuffers;
  28696. private _indexBuffer;
  28697. constructor(scene: Scene);
  28698. /**
  28699. * Registers the component in a given scene
  28700. */
  28701. register(): void;
  28702. private _evaluateSubMesh;
  28703. private _activeMesh;
  28704. private _prepareRessources;
  28705. private _createIndexBuffer;
  28706. /**
  28707. * Rebuilds the elements related to this component in case of
  28708. * context lost for instance.
  28709. */
  28710. rebuild(): void;
  28711. reset(): void;
  28712. render(): void;
  28713. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  28714. dispose(): void;
  28715. }
  28716. }
  28717. declare module BABYLON {
  28718. /**
  28719. * This represents a depth renderer in Babylon.
  28720. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  28721. */
  28722. class DepthRenderer {
  28723. private _scene;
  28724. private _depthMap;
  28725. private _effect;
  28726. private _cachedDefines;
  28727. private _camera;
  28728. /**
  28729. * Instantiates a depth renderer
  28730. * @param scene The scene the renderer belongs to
  28731. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  28732. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  28733. */
  28734. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  28735. /**
  28736. * Creates the depth rendering effect and checks if the effect is ready.
  28737. * @param subMesh The submesh to be used to render the depth map of
  28738. * @param useInstances If multiple world instances should be used
  28739. * @returns if the depth renderer is ready to render the depth map
  28740. */
  28741. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28742. /**
  28743. * Gets the texture which the depth map will be written to.
  28744. * @returns The depth map texture
  28745. */
  28746. getDepthMap(): RenderTargetTexture;
  28747. /**
  28748. * Disposes of the depth renderer.
  28749. */
  28750. dispose(): void;
  28751. }
  28752. }
  28753. declare module BABYLON {
  28754. interface Scene {
  28755. /** @hidden (Backing field) */
  28756. _depthRenderer: {
  28757. [id: string]: DepthRenderer;
  28758. };
  28759. /**
  28760. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  28761. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  28762. * @returns the created depth renderer
  28763. */
  28764. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  28765. /**
  28766. * Disables a depth renderer for a given camera
  28767. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  28768. */
  28769. disableDepthRenderer(camera?: Nullable<Camera>): void;
  28770. }
  28771. /**
  28772. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  28773. * in several rendering techniques.
  28774. */
  28775. class DepthRendererSceneComponent implements ISceneComponent {
  28776. /**
  28777. * The component name helpfull to identify the component in the list of scene components.
  28778. */
  28779. readonly name: string;
  28780. /**
  28781. * The scene the component belongs to.
  28782. */
  28783. scene: Scene;
  28784. /**
  28785. * Creates a new instance of the component for the given scene
  28786. * @param scene Defines the scene to register the component in
  28787. */
  28788. constructor(scene: Scene);
  28789. /**
  28790. * Registers the component in a given scene
  28791. */
  28792. register(): void;
  28793. /**
  28794. * Rebuilds the elements related to this component in case of
  28795. * context lost for instance.
  28796. */
  28797. rebuild(): void;
  28798. /**
  28799. * Disposes the component and the associated ressources
  28800. */
  28801. dispose(): void;
  28802. private _gatherRenderTargets;
  28803. }
  28804. }
  28805. declare module BABYLON {
  28806. interface AbstractMesh {
  28807. /**
  28808. * Disables the mesh edge rendering mode
  28809. * @returns the currentAbstractMesh
  28810. */
  28811. disableEdgesRendering(): AbstractMesh;
  28812. /**
  28813. * Enables the edge rendering mode on the mesh.
  28814. * This mode makes the mesh edges visible
  28815. * @param epsilon defines the maximal distance between two angles to detect a face
  28816. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28817. * @returns the currentAbstractMesh
  28818. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28819. */
  28820. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28821. /**
  28822. * Gets the edgesRenderer associated with the mesh
  28823. */
  28824. edgesRenderer: Nullable<EdgesRenderer>;
  28825. }
  28826. interface LinesMesh {
  28827. /**
  28828. * Enables the edge rendering mode on the mesh.
  28829. * This mode makes the mesh edges visible
  28830. * @param epsilon defines the maximal distance between two angles to detect a face
  28831. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28832. * @returns the currentAbstractMesh
  28833. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28834. */
  28835. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28836. }
  28837. /**
  28838. * Defines the minimum contract an Edges renderer should follow.
  28839. */
  28840. interface IEdgesRenderer extends IDisposable {
  28841. /**
  28842. * Gets or sets a boolean indicating if the edgesRenderer is active
  28843. */
  28844. isEnabled: boolean;
  28845. /**
  28846. * Renders the edges of the attached mesh,
  28847. */
  28848. render(): void;
  28849. /**
  28850. * Checks wether or not the edges renderer is ready to render.
  28851. * @return true if ready, otherwise false.
  28852. */
  28853. isReady(): boolean;
  28854. }
  28855. /**
  28856. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28857. */
  28858. class EdgesRenderer implements IEdgesRenderer {
  28859. edgesWidthScalerForOrthographic: number;
  28860. edgesWidthScalerForPerspective: number;
  28861. protected _source: AbstractMesh;
  28862. protected _linesPositions: number[];
  28863. protected _linesNormals: number[];
  28864. protected _linesIndices: number[];
  28865. protected _epsilon: number;
  28866. protected _indicesCount: number;
  28867. protected _lineShader: ShaderMaterial;
  28868. protected _ib: WebGLBuffer;
  28869. protected _buffers: {
  28870. [key: string]: Nullable<VertexBuffer>;
  28871. };
  28872. protected _checkVerticesInsteadOfIndices: boolean;
  28873. private _meshRebuildObserver;
  28874. private _meshDisposeObserver;
  28875. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28876. isEnabled: boolean;
  28877. /**
  28878. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28879. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28880. * @param source Mesh used to create edges
  28881. * @param epsilon sum of angles in adjacency to check for edge
  28882. * @param checkVerticesInsteadOfIndices
  28883. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28884. */
  28885. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  28886. protected _prepareRessources(): void;
  28887. /** @hidden */
  28888. _rebuild(): void;
  28889. /**
  28890. * Releases the required resources for the edges renderer
  28891. */
  28892. dispose(): void;
  28893. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28894. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28895. /**
  28896. * Checks if the pair of p0 and p1 is en edge
  28897. * @param faceIndex
  28898. * @param edge
  28899. * @param faceNormals
  28900. * @param p0
  28901. * @param p1
  28902. * @private
  28903. */
  28904. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28905. /**
  28906. * Generates lines edges from adjacencjes
  28907. * @private
  28908. */
  28909. _generateEdgesLines(): void;
  28910. /**
  28911. * Checks wether or not the edges renderer is ready to render.
  28912. * @return true if ready, otherwise false.
  28913. */
  28914. isReady(): boolean;
  28915. /**
  28916. * Renders the edges of the attached mesh,
  28917. */
  28918. render(): void;
  28919. }
  28920. }
  28921. declare module BABYLON {
  28922. /**
  28923. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28924. */
  28925. class GeometryBufferRenderer {
  28926. private _scene;
  28927. private _multiRenderTarget;
  28928. private _ratio;
  28929. private _enablePosition;
  28930. protected _effect: Effect;
  28931. protected _cachedDefines: string;
  28932. /**
  28933. * Set the render list (meshes to be rendered) used in the G buffer.
  28934. */
  28935. renderList: Mesh[];
  28936. /**
  28937. * Gets wether or not G buffer are supported by the running hardware.
  28938. * This requires draw buffer supports
  28939. */
  28940. readonly isSupported: boolean;
  28941. /**
  28942. * Gets wether or not position are enabled for the G buffer.
  28943. */
  28944. /**
  28945. * Sets wether or not position are enabled for the G buffer.
  28946. */
  28947. enablePosition: boolean;
  28948. /**
  28949. * Gets the scene associated with the buffer.
  28950. */
  28951. readonly scene: Scene;
  28952. /**
  28953. * Gets the ratio used by the buffer during its creation.
  28954. * How big is the buffer related to the main canvas.
  28955. */
  28956. readonly ratio: number;
  28957. /**
  28958. * Creates a new G Buffer for the scene
  28959. * @param scene The scene the buffer belongs to
  28960. * @param ratio How big is the buffer related to the main canvas.
  28961. */
  28962. constructor(scene: Scene, ratio?: number);
  28963. /**
  28964. * Checks wether everything is ready to render a submesh to the G buffer.
  28965. * @param subMesh the submesh to check readiness for
  28966. * @param useInstances is the mesh drawn using instance or not
  28967. * @returns true if ready otherwise false
  28968. */
  28969. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28970. /**
  28971. * Gets the current underlying G Buffer.
  28972. * @returns the buffer
  28973. */
  28974. getGBuffer(): MultiRenderTarget;
  28975. /**
  28976. * Gets the number of samples used to render the buffer (anti aliasing).
  28977. */
  28978. /**
  28979. * Sets the number of samples used to render the buffer (anti aliasing).
  28980. */
  28981. samples: number;
  28982. /**
  28983. * Disposes the renderer and frees up associated resources.
  28984. */
  28985. dispose(): void;
  28986. protected _createRenderTargets(): void;
  28987. }
  28988. }
  28989. declare module BABYLON {
  28990. interface Scene {
  28991. /** @hidden (Backing field) */
  28992. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28993. /**
  28994. * Gets or Sets the current geometry buffer associated to the scene.
  28995. */
  28996. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28997. /**
  28998. * Enables a GeometryBufferRender and associates it with the scene
  28999. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  29000. * @returns the GeometryBufferRenderer
  29001. */
  29002. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  29003. /**
  29004. * Disables the GeometryBufferRender associated with the scene
  29005. */
  29006. disableGeometryBufferRenderer(): void;
  29007. }
  29008. /**
  29009. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  29010. * in several rendering techniques.
  29011. */
  29012. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  29013. /**
  29014. * The component name helpfull to identify the component in the list of scene components.
  29015. */
  29016. readonly name: string;
  29017. /**
  29018. * The scene the component belongs to.
  29019. */
  29020. scene: Scene;
  29021. /**
  29022. * Creates a new instance of the component for the given scene
  29023. * @param scene Defines the scene to register the component in
  29024. */
  29025. constructor(scene: Scene);
  29026. /**
  29027. * Registers the component in a given scene
  29028. */
  29029. register(): void;
  29030. /**
  29031. * Rebuilds the elements related to this component in case of
  29032. * context lost for instance.
  29033. */
  29034. rebuild(): void;
  29035. /**
  29036. * Disposes the component and the associated ressources
  29037. */
  29038. dispose(): void;
  29039. private _gatherRenderTargets;
  29040. }
  29041. }
  29042. declare module BABYLON {
  29043. /**
  29044. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29045. */
  29046. class LineEdgesRenderer extends EdgesRenderer {
  29047. /**
  29048. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29049. * @param source LineMesh used to generate edges
  29050. * @param epsilon not important (specified angle for edge detection)
  29051. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29052. */
  29053. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29054. /**
  29055. * Always create the edge since its a line so only important things are p0 and p1
  29056. * @param faceIndex not important for LineMesh
  29057. * @param edge not important for LineMesh
  29058. * @param faceNormals not important for LineMesh
  29059. * @param p0 beginnig of line
  29060. * @param p1 end of line
  29061. */
  29062. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29063. /**
  29064. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29065. */
  29066. _generateEdgesLines(): void;
  29067. }
  29068. }
  29069. declare module BABYLON {
  29070. interface Scene {
  29071. /** @hidden */
  29072. _outlineRenderer: OutlineRenderer;
  29073. /**
  29074. * Gets the outline renderer associated with the scene
  29075. * @returns a OutlineRenderer
  29076. */
  29077. getOutlineRenderer(): OutlineRenderer;
  29078. }
  29079. interface AbstractMesh {
  29080. /** @hidden (Backing field) */
  29081. _renderOutline: boolean;
  29082. /**
  29083. * Gets or sets a boolean indicating if the outline must be rendered as well
  29084. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  29085. */
  29086. renderOutline: boolean;
  29087. /** @hidden (Backing field) */
  29088. _renderOverlay: boolean;
  29089. /**
  29090. * Gets or sets a boolean indicating if the overlay must be rendered as well
  29091. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  29092. */
  29093. renderOverlay: boolean;
  29094. }
  29095. /**
  29096. * This class is responsible to draw bothe outline/overlay of meshes.
  29097. * It should not be used directly but through the available method on mesh.
  29098. */
  29099. class OutlineRenderer implements ISceneComponent {
  29100. /**
  29101. * The name of the component. Each component must have a unique name.
  29102. */
  29103. name: string;
  29104. /**
  29105. * The scene the component belongs to.
  29106. */
  29107. scene: Scene;
  29108. /**
  29109. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  29110. */
  29111. zOffset: number;
  29112. private _engine;
  29113. private _effect;
  29114. private _cachedDefines;
  29115. private _savedDepthWrite;
  29116. /**
  29117. * Instantiates a new outline renderer. (There could be only one per scene).
  29118. * @param scene Defines the scene it belongs to
  29119. */
  29120. constructor(scene: Scene);
  29121. /**
  29122. * Register the component to one instance of a scene.
  29123. */
  29124. register(): void;
  29125. /**
  29126. * Rebuilds the elements related to this component in case of
  29127. * context lost for instance.
  29128. */
  29129. rebuild(): void;
  29130. /**
  29131. * Disposes the component and the associated ressources.
  29132. */
  29133. dispose(): void;
  29134. /**
  29135. * Renders the outline in the canvas.
  29136. * @param subMesh Defines the sumesh to render
  29137. * @param batch Defines the batch of meshes in case of instances
  29138. * @param useOverlay Defines if the rendering is for the overlay or the outline
  29139. */
  29140. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  29141. /**
  29142. * Returns whether or not the outline renderer is ready for a given submesh.
  29143. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  29144. * @param subMesh Defines the submesh to check readyness for
  29145. * @param useInstances Defines wheter wee are trying to render instances or not
  29146. * @returns true if ready otherwise false
  29147. */
  29148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29149. private _beforeRenderingMesh;
  29150. private _afterRenderingMesh;
  29151. }
  29152. }
  29153. declare module BABYLON {
  29154. class RenderingGroup {
  29155. index: number;
  29156. private _scene;
  29157. private _opaqueSubMeshes;
  29158. private _transparentSubMeshes;
  29159. private _alphaTestSubMeshes;
  29160. private _depthOnlySubMeshes;
  29161. private _particleSystems;
  29162. private _spriteManagers;
  29163. private _opaqueSortCompareFn;
  29164. private _alphaTestSortCompareFn;
  29165. private _transparentSortCompareFn;
  29166. private _renderOpaque;
  29167. private _renderAlphaTest;
  29168. private _renderTransparent;
  29169. private _edgesRenderers;
  29170. onBeforeTransparentRendering: () => void;
  29171. /**
  29172. * Set the opaque sort comparison function.
  29173. * If null the sub meshes will be render in the order they were created
  29174. */
  29175. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29176. /**
  29177. * Set the alpha test sort comparison function.
  29178. * If null the sub meshes will be render in the order they were created
  29179. */
  29180. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29181. /**
  29182. * Set the transparent sort comparison function.
  29183. * If null the sub meshes will be render in the order they were created
  29184. */
  29185. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29186. /**
  29187. * Creates a new rendering group.
  29188. * @param index The rendering group index
  29189. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29190. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29191. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29192. */
  29193. 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>);
  29194. /**
  29195. * Render all the sub meshes contained in the group.
  29196. * @param customRenderFunction Used to override the default render behaviour of the group.
  29197. * @returns true if rendered some submeshes.
  29198. */
  29199. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29200. /**
  29201. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29202. * @param subMeshes The submeshes to render
  29203. */
  29204. private renderOpaqueSorted;
  29205. /**
  29206. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29207. * @param subMeshes The submeshes to render
  29208. */
  29209. private renderAlphaTestSorted;
  29210. /**
  29211. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29212. * @param subMeshes The submeshes to render
  29213. */
  29214. private renderTransparentSorted;
  29215. /**
  29216. * Renders the submeshes in a specified order.
  29217. * @param subMeshes The submeshes to sort before render
  29218. * @param sortCompareFn The comparison function use to sort
  29219. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29220. * @param transparent Specifies to activate blending if true
  29221. */
  29222. private static renderSorted;
  29223. /**
  29224. * Renders the submeshes in the order they were dispatched (no sort applied).
  29225. * @param subMeshes The submeshes to render
  29226. */
  29227. private static renderUnsorted;
  29228. /**
  29229. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29230. * are rendered back to front if in the same alpha index.
  29231. *
  29232. * @param a The first submesh
  29233. * @param b The second submesh
  29234. * @returns The result of the comparison
  29235. */
  29236. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29237. /**
  29238. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29239. * are rendered back to front.
  29240. *
  29241. * @param a The first submesh
  29242. * @param b The second submesh
  29243. * @returns The result of the comparison
  29244. */
  29245. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29246. /**
  29247. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29248. * are rendered front to back (prevent overdraw).
  29249. *
  29250. * @param a The first submesh
  29251. * @param b The second submesh
  29252. * @returns The result of the comparison
  29253. */
  29254. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29255. /**
  29256. * Resets the different lists of submeshes to prepare a new frame.
  29257. */
  29258. prepare(): void;
  29259. dispose(): void;
  29260. /**
  29261. * Inserts the submesh in its correct queue depending on its material.
  29262. * @param subMesh The submesh to dispatch
  29263. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29264. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29265. */
  29266. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29267. dispatchSprites(spriteManager: ISpriteManager): void;
  29268. dispatchParticles(particleSystem: IParticleSystem): void;
  29269. private _renderParticles;
  29270. private _renderSprites;
  29271. }
  29272. }
  29273. declare module BABYLON {
  29274. /**
  29275. * Interface describing the different options available in the rendering manager
  29276. * regarding Auto Clear between groups.
  29277. */
  29278. interface IRenderingManagerAutoClearSetup {
  29279. /**
  29280. * Defines whether or not autoclear is enable.
  29281. */
  29282. autoClear: boolean;
  29283. /**
  29284. * Defines whether or not to autoclear the depth buffer.
  29285. */
  29286. depth: boolean;
  29287. /**
  29288. * Defines whether or not to autoclear the stencil buffer.
  29289. */
  29290. stencil: boolean;
  29291. }
  29292. class RenderingManager {
  29293. /**
  29294. * The max id used for rendering groups (not included)
  29295. */
  29296. static MAX_RENDERINGGROUPS: number;
  29297. /**
  29298. * The min id used for rendering groups (included)
  29299. */
  29300. static MIN_RENDERINGGROUPS: number;
  29301. /**
  29302. * Used to globally prevent autoclearing scenes.
  29303. */
  29304. static AUTOCLEAR: boolean;
  29305. /**
  29306. * @hidden
  29307. */
  29308. _useSceneAutoClearSetup: boolean;
  29309. private _scene;
  29310. private _renderingGroups;
  29311. private _depthStencilBufferAlreadyCleaned;
  29312. private _autoClearDepthStencil;
  29313. private _customOpaqueSortCompareFn;
  29314. private _customAlphaTestSortCompareFn;
  29315. private _customTransparentSortCompareFn;
  29316. private _renderingGroupInfo;
  29317. constructor(scene: Scene);
  29318. private _clearDepthStencilBuffer;
  29319. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29320. reset(): void;
  29321. dispose(): void;
  29322. /**
  29323. * Clear the info related to rendering groups preventing retention points during dispose.
  29324. */
  29325. freeRenderingGroups(): void;
  29326. private _prepareRenderingGroup;
  29327. dispatchSprites(spriteManager: ISpriteManager): void;
  29328. dispatchParticles(particleSystem: IParticleSystem): void;
  29329. /**
  29330. * @param subMesh The submesh to dispatch
  29331. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29332. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29333. */
  29334. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29335. /**
  29336. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29337. * This allowed control for front to back rendering or reversly depending of the special needs.
  29338. *
  29339. * @param renderingGroupId The rendering group id corresponding to its index
  29340. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29341. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29342. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29343. */
  29344. 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;
  29345. /**
  29346. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29347. *
  29348. * @param renderingGroupId The rendering group id corresponding to its index
  29349. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29350. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29351. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29352. */
  29353. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29354. /**
  29355. * Gets the current auto clear configuration for one rendering group of the rendering
  29356. * manager.
  29357. * @param index the rendering group index to get the information for
  29358. * @returns The auto clear setup for the requested rendering group
  29359. */
  29360. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29361. }
  29362. }
  29363. declare module BABYLON {
  29364. /**
  29365. * Renders a layer on top of an existing scene
  29366. */
  29367. class UtilityLayerRenderer implements IDisposable {
  29368. /** the original scene that will be rendered on top of */
  29369. originalScene: Scene;
  29370. private _pointerCaptures;
  29371. private _lastPointerEvents;
  29372. private static _DefaultUtilityLayer;
  29373. private static _DefaultKeepDepthUtilityLayer;
  29374. /**
  29375. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  29376. */
  29377. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  29378. /**
  29379. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  29380. */
  29381. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  29382. /**
  29383. * The scene that is rendered on top of the original scene
  29384. */
  29385. utilityLayerScene: Scene;
  29386. /**
  29387. * If the utility layer should automatically be rendered on top of existing scene
  29388. */
  29389. shouldRender: boolean;
  29390. /**
  29391. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  29392. */
  29393. onlyCheckPointerDownEvents: boolean;
  29394. /**
  29395. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  29396. */
  29397. processAllEvents: boolean;
  29398. /**
  29399. * Observable raised when the pointer move from the utility layer scene to the main scene
  29400. */
  29401. onPointerOutObservable: Observable<number>;
  29402. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  29403. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  29404. private _afterRenderObserver;
  29405. private _sceneDisposeObserver;
  29406. private _originalPointerObserver;
  29407. /**
  29408. * Instantiates a UtilityLayerRenderer
  29409. * @param originalScene the original scene that will be rendered on top of
  29410. */
  29411. constructor(
  29412. /** the original scene that will be rendered on top of */
  29413. originalScene: Scene);
  29414. private _notifyObservers;
  29415. /**
  29416. * Renders the utility layers scene on top of the original scene
  29417. */
  29418. render(): void;
  29419. /**
  29420. * Disposes of the renderer
  29421. */
  29422. dispose(): void;
  29423. private _updateCamera;
  29424. }
  29425. }
  29426. declare module BABYLON {
  29427. class Sprite {
  29428. name: string;
  29429. position: Vector3;
  29430. color: Color4;
  29431. width: number;
  29432. height: number;
  29433. angle: number;
  29434. cellIndex: number;
  29435. invertU: number;
  29436. invertV: number;
  29437. disposeWhenFinishedAnimating: boolean;
  29438. animations: Animation[];
  29439. isPickable: boolean;
  29440. actionManager: ActionManager;
  29441. private _animationStarted;
  29442. private _loopAnimation;
  29443. private _fromIndex;
  29444. private _toIndex;
  29445. private _delay;
  29446. private _direction;
  29447. private _manager;
  29448. private _time;
  29449. private _onAnimationEnd;
  29450. /**
  29451. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  29452. */
  29453. isVisible: boolean;
  29454. size: number;
  29455. constructor(name: string, manager: ISpriteManager);
  29456. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  29457. stopAnimation(): void;
  29458. /** @hidden */
  29459. _animate(deltaTime: number): void;
  29460. dispose(): void;
  29461. }
  29462. }
  29463. declare module BABYLON {
  29464. /**
  29465. * Defines the minimum interface to fullfil in order to be a sprite manager.
  29466. */
  29467. interface ISpriteManager extends IDisposable {
  29468. /**
  29469. * Restricts the camera to viewing objects with the same layerMask.
  29470. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  29471. */
  29472. layerMask: number;
  29473. /**
  29474. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29475. */
  29476. isPickable: boolean;
  29477. /**
  29478. * Specifies the rendering group id for this mesh (0 by default)
  29479. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29480. */
  29481. renderingGroupId: number;
  29482. /**
  29483. * Defines the list of sprites managed by the manager.
  29484. */
  29485. sprites: Array<Sprite>;
  29486. /**
  29487. * Tests the intersection of a sprite with a specific ray.
  29488. * @param ray The ray we are sending to test the collision
  29489. * @param camera The camera space we are sending rays in
  29490. * @param predicate A predicate allowing excluding sprites from the list of object to test
  29491. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  29492. * @returns picking info or null.
  29493. */
  29494. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29495. /**
  29496. * Renders the list of sprites on screen.
  29497. */
  29498. render(): void;
  29499. }
  29500. class SpriteManager implements ISpriteManager {
  29501. name: string;
  29502. sprites: Sprite[];
  29503. renderingGroupId: number;
  29504. layerMask: number;
  29505. fogEnabled: boolean;
  29506. isPickable: boolean;
  29507. cellWidth: number;
  29508. cellHeight: number;
  29509. /**
  29510. * An event triggered when the manager is disposed.
  29511. */
  29512. onDisposeObservable: Observable<SpriteManager>;
  29513. private _onDisposeObserver;
  29514. onDispose: () => void;
  29515. private _capacity;
  29516. private _spriteTexture;
  29517. private _epsilon;
  29518. private _scene;
  29519. private _vertexData;
  29520. private _buffer;
  29521. private _vertexBuffers;
  29522. private _indexBuffer;
  29523. private _effectBase;
  29524. private _effectFog;
  29525. texture: Texture;
  29526. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29527. private _appendSpriteVertex;
  29528. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29529. render(): void;
  29530. dispose(): void;
  29531. }
  29532. }
  29533. declare module BABYLON {
  29534. interface Scene {
  29535. /** @hidden */
  29536. _pointerOverSprite: Nullable<Sprite>;
  29537. /** @hidden */
  29538. _pickedDownSprite: Nullable<Sprite>;
  29539. /** @hidden */
  29540. _tempSpritePickingRay: Nullable<Ray>;
  29541. /**
  29542. * All of the sprite managers added to this scene
  29543. * @see http://doc.babylonjs.com/babylon101/sprites
  29544. */
  29545. spriteManagers: Array<ISpriteManager>;
  29546. /**
  29547. * An event triggered when sprites rendering is about to start
  29548. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29549. */
  29550. onBeforeSpritesRenderingObservable: Observable<Scene>;
  29551. /**
  29552. * An event triggered when sprites rendering is done
  29553. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29554. */
  29555. onAfterSpritesRenderingObservable: Observable<Scene>;
  29556. /** @hidden */
  29557. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29558. /** Launch a ray to try to pick a sprite in the scene
  29559. * @param x position on screen
  29560. * @param y position on screen
  29561. * @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
  29562. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29563. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  29564. * @returns a PickingInfo
  29565. */
  29566. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29567. /** Use the given ray to pick a sprite in the scene
  29568. * @param ray The ray (in world space) to use to pick meshes
  29569. * @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
  29570. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29571. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  29572. * @returns a PickingInfo
  29573. */
  29574. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29575. /**
  29576. * Force the sprite under the pointer
  29577. * @param sprite defines the sprite to use
  29578. */
  29579. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  29580. /**
  29581. * Gets the sprite under the pointer
  29582. * @returns a Sprite or null if no sprite is under the pointer
  29583. */
  29584. getPointerOverSprite(): Nullable<Sprite>;
  29585. }
  29586. /**
  29587. * Defines the sprite scene component responsible to manage sprites
  29588. * in a given scene.
  29589. */
  29590. class SpriteSceneComponent implements ISceneComponent {
  29591. /**
  29592. * The component name helpfull to identify the component in the list of scene components.
  29593. */
  29594. readonly name: string;
  29595. /**
  29596. * The scene the component belongs to.
  29597. */
  29598. scene: Scene;
  29599. /** @hidden */
  29600. private _spritePredicate;
  29601. /**
  29602. * Creates a new instance of the component for the given scene
  29603. * @param scene Defines the scene to register the component in
  29604. */
  29605. constructor(scene: Scene);
  29606. /**
  29607. * Registers the component in a given scene
  29608. */
  29609. register(): void;
  29610. /**
  29611. * Rebuilds the elements related to this component in case of
  29612. * context lost for instance.
  29613. */
  29614. rebuild(): void;
  29615. /**
  29616. * Disposes the component and the associated ressources.
  29617. */
  29618. dispose(): void;
  29619. private _pickSpriteButKeepRay;
  29620. private _pointerMove;
  29621. private _pointerDown;
  29622. private _pointerUp;
  29623. }
  29624. }
  29625. declare module BABYLON {
  29626. /**
  29627. * @hidden
  29628. **/
  29629. class _AlphaState {
  29630. private _isAlphaBlendDirty;
  29631. private _isBlendFunctionParametersDirty;
  29632. private _isBlendEquationParametersDirty;
  29633. private _isBlendConstantsDirty;
  29634. private _alphaBlend;
  29635. private _blendFunctionParameters;
  29636. private _blendEquationParameters;
  29637. private _blendConstants;
  29638. /**
  29639. * Initializes the state.
  29640. */
  29641. constructor();
  29642. readonly isDirty: boolean;
  29643. alphaBlend: boolean;
  29644. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29645. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29646. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29647. reset(): void;
  29648. apply(gl: WebGLRenderingContext): void;
  29649. }
  29650. }
  29651. declare module BABYLON {
  29652. /**
  29653. * @hidden
  29654. **/
  29655. class _DepthCullingState {
  29656. private _isDepthTestDirty;
  29657. private _isDepthMaskDirty;
  29658. private _isDepthFuncDirty;
  29659. private _isCullFaceDirty;
  29660. private _isCullDirty;
  29661. private _isZOffsetDirty;
  29662. private _isFrontFaceDirty;
  29663. private _depthTest;
  29664. private _depthMask;
  29665. private _depthFunc;
  29666. private _cull;
  29667. private _cullFace;
  29668. private _zOffset;
  29669. private _frontFace;
  29670. /**
  29671. * Initializes the state.
  29672. */
  29673. constructor();
  29674. readonly isDirty: boolean;
  29675. zOffset: number;
  29676. cullFace: Nullable<number>;
  29677. cull: Nullable<boolean>;
  29678. depthFunc: Nullable<number>;
  29679. depthMask: boolean;
  29680. depthTest: boolean;
  29681. frontFace: Nullable<number>;
  29682. reset(): void;
  29683. apply(gl: WebGLRenderingContext): void;
  29684. }
  29685. }
  29686. declare module BABYLON {
  29687. /**
  29688. * @hidden
  29689. **/
  29690. class _StencilState {
  29691. private _isStencilTestDirty;
  29692. private _isStencilMaskDirty;
  29693. private _isStencilFuncDirty;
  29694. private _isStencilOpDirty;
  29695. private _stencilTest;
  29696. private _stencilMask;
  29697. private _stencilFunc;
  29698. private _stencilFuncRef;
  29699. private _stencilFuncMask;
  29700. private _stencilOpStencilFail;
  29701. private _stencilOpDepthFail;
  29702. private _stencilOpStencilDepthPass;
  29703. readonly isDirty: boolean;
  29704. stencilFunc: number;
  29705. stencilFuncRef: number;
  29706. stencilFuncMask: number;
  29707. stencilOpStencilFail: number;
  29708. stencilOpDepthFail: number;
  29709. stencilOpStencilDepthPass: number;
  29710. stencilMask: number;
  29711. stencilTest: boolean;
  29712. constructor();
  29713. reset(): void;
  29714. apply(gl: WebGLRenderingContext): void;
  29715. }
  29716. }
  29717. declare module BABYLON {
  29718. /**
  29719. * Class used to evalaute queries containing `and` and `or` operators
  29720. */
  29721. class AndOrNotEvaluator {
  29722. /**
  29723. * Evaluate a query
  29724. * @param query defines the query to evaluate
  29725. * @param evaluateCallback defines the callback used to filter result
  29726. * @returns true if the query matches
  29727. */
  29728. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  29729. private static _HandleParenthesisContent;
  29730. private static _SimplifyNegation;
  29731. }
  29732. }
  29733. declare module BABYLON {
  29734. /**
  29735. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  29736. */
  29737. enum AssetTaskState {
  29738. /**
  29739. * Initialization
  29740. */
  29741. INIT = 0,
  29742. /**
  29743. * Running
  29744. */
  29745. RUNNING = 1,
  29746. /**
  29747. * Done
  29748. */
  29749. DONE = 2,
  29750. /**
  29751. * Error
  29752. */
  29753. ERROR = 3
  29754. }
  29755. /**
  29756. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  29757. */
  29758. abstract class AbstractAssetTask {
  29759. /**
  29760. * Task name
  29761. */ name: string;
  29762. /**
  29763. * Callback called when the task is successful
  29764. */
  29765. onSuccess: (task: any) => void;
  29766. /**
  29767. * Callback called when the task is not successful
  29768. */
  29769. onError: (task: any, message?: string, exception?: any) => void;
  29770. /**
  29771. * Creates a new {BABYLON.AssetsManager}
  29772. * @param name defines the name of the task
  29773. */
  29774. constructor(
  29775. /**
  29776. * Task name
  29777. */ name: string);
  29778. private _isCompleted;
  29779. private _taskState;
  29780. private _errorObject;
  29781. /**
  29782. * Get if the task is completed
  29783. */
  29784. readonly isCompleted: boolean;
  29785. /**
  29786. * Gets the current state of the task
  29787. */
  29788. readonly taskState: AssetTaskState;
  29789. /**
  29790. * Gets the current error object (if task is in error)
  29791. */
  29792. readonly errorObject: {
  29793. message?: string;
  29794. exception?: any;
  29795. };
  29796. /**
  29797. * Internal only
  29798. * @hidden
  29799. */
  29800. _setErrorObject(message?: string, exception?: any): void;
  29801. /**
  29802. * Execute the current task
  29803. * @param scene defines the scene where you want your assets to be loaded
  29804. * @param onSuccess is a callback called when the task is successfully executed
  29805. * @param onError is a callback called if an error occurs
  29806. */
  29807. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29808. /**
  29809. * Execute the current task
  29810. * @param scene defines the scene where you want your assets to be loaded
  29811. * @param onSuccess is a callback called when the task is successfully executed
  29812. * @param onError is a callback called if an error occurs
  29813. */
  29814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29815. /**
  29816. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  29817. * This can be used with failed tasks that have the reason for failure fixed.
  29818. */
  29819. reset(): void;
  29820. private onErrorCallback;
  29821. private onDoneCallback;
  29822. }
  29823. /**
  29824. * Define the interface used by progress events raised during assets loading
  29825. */
  29826. interface IAssetsProgressEvent {
  29827. /**
  29828. * Defines the number of remaining tasks to process
  29829. */
  29830. remainingCount: number;
  29831. /**
  29832. * Defines the total number of tasks
  29833. */
  29834. totalCount: number;
  29835. /**
  29836. * Defines the task that was just processed
  29837. */
  29838. task: AbstractAssetTask;
  29839. }
  29840. /**
  29841. * Class used to share progress information about assets loading
  29842. */
  29843. class AssetsProgressEvent implements IAssetsProgressEvent {
  29844. /**
  29845. * Defines the number of remaining tasks to process
  29846. */
  29847. remainingCount: number;
  29848. /**
  29849. * Defines the total number of tasks
  29850. */
  29851. totalCount: number;
  29852. /**
  29853. * Defines the task that was just processed
  29854. */
  29855. task: AbstractAssetTask;
  29856. /**
  29857. * Creates a {BABYLON.AssetsProgressEvent}
  29858. * @param remainingCount defines the number of remaining tasks to process
  29859. * @param totalCount defines the total number of tasks
  29860. * @param task defines the task that was just processed
  29861. */
  29862. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  29863. }
  29864. /**
  29865. * Define a task used by {BABYLON.AssetsManager} to load meshes
  29866. */
  29867. class MeshAssetTask extends AbstractAssetTask {
  29868. /**
  29869. * Defines the name of the task
  29870. */
  29871. name: string;
  29872. /**
  29873. * Defines the list of mesh's names you want to load
  29874. */
  29875. meshesNames: any;
  29876. /**
  29877. * Defines the root url to use as a base to load your meshes and associated resources
  29878. */
  29879. rootUrl: string;
  29880. /**
  29881. * Defines the filename of the scene to load from
  29882. */
  29883. sceneFilename: string;
  29884. /**
  29885. * Gets the list of loaded meshes
  29886. */
  29887. loadedMeshes: Array<AbstractMesh>;
  29888. /**
  29889. * Gets the list of loaded particle systems
  29890. */
  29891. loadedParticleSystems: Array<IParticleSystem>;
  29892. /**
  29893. * Gets the list of loaded skeletons
  29894. */
  29895. loadedSkeletons: Array<Skeleton>;
  29896. /**
  29897. * Callback called when the task is successful
  29898. */
  29899. onSuccess: (task: MeshAssetTask) => void;
  29900. /**
  29901. * Callback called when the task is successful
  29902. */
  29903. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  29904. /**
  29905. * Creates a new {BABYLON.MeshAssetTask}
  29906. * @param name defines the name of the task
  29907. * @param meshesNames defines the list of mesh's names you want to load
  29908. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  29909. * @param sceneFilename defines the filename of the scene to load from
  29910. */
  29911. constructor(
  29912. /**
  29913. * Defines the name of the task
  29914. */
  29915. name: string,
  29916. /**
  29917. * Defines the list of mesh's names you want to load
  29918. */
  29919. meshesNames: any,
  29920. /**
  29921. * Defines the root url to use as a base to load your meshes and associated resources
  29922. */
  29923. rootUrl: string,
  29924. /**
  29925. * Defines the filename of the scene to load from
  29926. */
  29927. sceneFilename: string);
  29928. /**
  29929. * Execute the current task
  29930. * @param scene defines the scene where you want your assets to be loaded
  29931. * @param onSuccess is a callback called when the task is successfully executed
  29932. * @param onError is a callback called if an error occurs
  29933. */
  29934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29935. }
  29936. /**
  29937. * Define a task used by {BABYLON.AssetsManager} to load text content
  29938. */
  29939. class TextFileAssetTask extends AbstractAssetTask {
  29940. /**
  29941. * Defines the name of the task
  29942. */
  29943. name: string;
  29944. /**
  29945. * Defines the location of the file to load
  29946. */
  29947. url: string;
  29948. /**
  29949. * Gets the loaded text string
  29950. */
  29951. text: string;
  29952. /**
  29953. * Callback called when the task is successful
  29954. */
  29955. onSuccess: (task: TextFileAssetTask) => void;
  29956. /**
  29957. * Callback called when the task is successful
  29958. */
  29959. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  29960. /**
  29961. * Creates a new TextFileAssetTask object
  29962. * @param name defines the name of the task
  29963. * @param url defines the location of the file to load
  29964. */
  29965. constructor(
  29966. /**
  29967. * Defines the name of the task
  29968. */
  29969. name: string,
  29970. /**
  29971. * Defines the location of the file to load
  29972. */
  29973. url: string);
  29974. /**
  29975. * Execute the current task
  29976. * @param scene defines the scene where you want your assets to be loaded
  29977. * @param onSuccess is a callback called when the task is successfully executed
  29978. * @param onError is a callback called if an error occurs
  29979. */
  29980. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29981. }
  29982. /**
  29983. * Define a task used by {BABYLON.AssetsManager} to load binary data
  29984. */
  29985. class BinaryFileAssetTask extends AbstractAssetTask {
  29986. /**
  29987. * Defines the name of the task
  29988. */
  29989. name: string;
  29990. /**
  29991. * Defines the location of the file to load
  29992. */
  29993. url: string;
  29994. /**
  29995. * Gets the lodaded data (as an array buffer)
  29996. */
  29997. data: ArrayBuffer;
  29998. /**
  29999. * Callback called when the task is successful
  30000. */
  30001. onSuccess: (task: BinaryFileAssetTask) => void;
  30002. /**
  30003. * Callback called when the task is successful
  30004. */
  30005. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  30006. /**
  30007. * Creates a new BinaryFileAssetTask object
  30008. * @param name defines the name of the new task
  30009. * @param url defines the location of the file to load
  30010. */
  30011. constructor(
  30012. /**
  30013. * Defines the name of the task
  30014. */
  30015. name: string,
  30016. /**
  30017. * Defines the location of the file to load
  30018. */
  30019. url: string);
  30020. /**
  30021. * Execute the current task
  30022. * @param scene defines the scene where you want your assets to be loaded
  30023. * @param onSuccess is a callback called when the task is successfully executed
  30024. * @param onError is a callback called if an error occurs
  30025. */
  30026. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30027. }
  30028. /**
  30029. * Define a task used by {BABYLON.AssetsManager} to load images
  30030. */
  30031. class ImageAssetTask extends AbstractAssetTask {
  30032. /**
  30033. * Defines the name of the task
  30034. */
  30035. name: string;
  30036. /**
  30037. * Defines the location of the image to load
  30038. */
  30039. url: string;
  30040. /**
  30041. * Gets the loaded images
  30042. */
  30043. image: HTMLImageElement;
  30044. /**
  30045. * Callback called when the task is successful
  30046. */
  30047. onSuccess: (task: ImageAssetTask) => void;
  30048. /**
  30049. * Callback called when the task is successful
  30050. */
  30051. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  30052. /**
  30053. * Creates a new ImageAssetTask
  30054. * @param name defines the name of the task
  30055. * @param url defines the location of the image to load
  30056. */
  30057. constructor(
  30058. /**
  30059. * Defines the name of the task
  30060. */
  30061. name: string,
  30062. /**
  30063. * Defines the location of the image to load
  30064. */
  30065. url: string);
  30066. /**
  30067. * Execute the current task
  30068. * @param scene defines the scene where you want your assets to be loaded
  30069. * @param onSuccess is a callback called when the task is successfully executed
  30070. * @param onError is a callback called if an error occurs
  30071. */
  30072. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30073. }
  30074. /**
  30075. * Defines the interface used by texture loading tasks
  30076. */
  30077. interface ITextureAssetTask<TEX extends BaseTexture> {
  30078. /**
  30079. * Gets the loaded texture
  30080. */
  30081. texture: TEX;
  30082. }
  30083. /**
  30084. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  30085. */
  30086. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  30087. /**
  30088. * Defines the name of the task
  30089. */
  30090. name: string;
  30091. /**
  30092. * Defines the location of the file to load
  30093. */
  30094. url: string;
  30095. /**
  30096. * Defines if mipmap should not be generated (default is false)
  30097. */
  30098. noMipmap?: boolean | undefined;
  30099. /**
  30100. * Defines if texture must be inverted on Y axis (default is false)
  30101. */
  30102. invertY?: boolean | undefined;
  30103. /**
  30104. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30105. */
  30106. samplingMode: number;
  30107. /**
  30108. * Gets the loaded texture
  30109. */
  30110. texture: Texture;
  30111. /**
  30112. * Callback called when the task is successful
  30113. */
  30114. onSuccess: (task: TextureAssetTask) => void;
  30115. /**
  30116. * Callback called when the task is successful
  30117. */
  30118. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  30119. /**
  30120. * Creates a new TextureAssetTask object
  30121. * @param name defines the name of the task
  30122. * @param url defines the location of the file to load
  30123. * @param noMipmap defines if mipmap should not be generated (default is false)
  30124. * @param invertY defines if texture must be inverted on Y axis (default is false)
  30125. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30126. */
  30127. constructor(
  30128. /**
  30129. * Defines the name of the task
  30130. */
  30131. name: string,
  30132. /**
  30133. * Defines the location of the file to load
  30134. */
  30135. url: string,
  30136. /**
  30137. * Defines if mipmap should not be generated (default is false)
  30138. */
  30139. noMipmap?: boolean | undefined,
  30140. /**
  30141. * Defines if texture must be inverted on Y axis (default is false)
  30142. */
  30143. invertY?: boolean | undefined,
  30144. /**
  30145. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30146. */
  30147. samplingMode?: number);
  30148. /**
  30149. * Execute the current task
  30150. * @param scene defines the scene where you want your assets to be loaded
  30151. * @param onSuccess is a callback called when the task is successfully executed
  30152. * @param onError is a callback called if an error occurs
  30153. */
  30154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30155. }
  30156. /**
  30157. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  30158. */
  30159. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  30160. /**
  30161. * Defines the name of the task
  30162. */
  30163. name: string;
  30164. /**
  30165. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30166. */
  30167. url: string;
  30168. /**
  30169. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30170. */
  30171. extensions?: string[] | undefined;
  30172. /**
  30173. * Defines if mipmaps should not be generated (default is false)
  30174. */
  30175. noMipmap?: boolean | undefined;
  30176. /**
  30177. * Defines the explicit list of files (undefined by default)
  30178. */
  30179. files?: string[] | undefined;
  30180. /**
  30181. * Gets the loaded texture
  30182. */
  30183. texture: CubeTexture;
  30184. /**
  30185. * Callback called when the task is successful
  30186. */
  30187. onSuccess: (task: CubeTextureAssetTask) => void;
  30188. /**
  30189. * Callback called when the task is successful
  30190. */
  30191. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  30192. /**
  30193. * Creates a new CubeTextureAssetTask
  30194. * @param name defines the name of the task
  30195. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30196. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30197. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30198. * @param files defines the explicit list of files (undefined by default)
  30199. */
  30200. constructor(
  30201. /**
  30202. * Defines the name of the task
  30203. */
  30204. name: string,
  30205. /**
  30206. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30207. */
  30208. url: string,
  30209. /**
  30210. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30211. */
  30212. extensions?: string[] | undefined,
  30213. /**
  30214. * Defines if mipmaps should not be generated (default is false)
  30215. */
  30216. noMipmap?: boolean | undefined,
  30217. /**
  30218. * Defines the explicit list of files (undefined by default)
  30219. */
  30220. files?: string[] | undefined);
  30221. /**
  30222. * Execute the current task
  30223. * @param scene defines the scene where you want your assets to be loaded
  30224. * @param onSuccess is a callback called when the task is successfully executed
  30225. * @param onError is a callback called if an error occurs
  30226. */
  30227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30228. }
  30229. /**
  30230. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  30231. */
  30232. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  30233. /**
  30234. * Defines the name of the task
  30235. */
  30236. name: string;
  30237. /**
  30238. * Defines the location of the file to load
  30239. */
  30240. url: string;
  30241. /**
  30242. * Defines the desired size (the more it increases the longer the generation will be)
  30243. */
  30244. size: number;
  30245. /**
  30246. * Defines if mipmaps should not be generated (default is false)
  30247. */
  30248. noMipmap: boolean;
  30249. /**
  30250. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30251. */
  30252. generateHarmonics: boolean;
  30253. /**
  30254. * 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)
  30255. */
  30256. gammaSpace: boolean;
  30257. /**
  30258. * Internal Use Only
  30259. */
  30260. reserved: boolean;
  30261. /**
  30262. * Gets the loaded texture
  30263. */
  30264. texture: HDRCubeTexture;
  30265. /**
  30266. * Callback called when the task is successful
  30267. */
  30268. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  30269. /**
  30270. * Callback called when the task is successful
  30271. */
  30272. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  30273. /**
  30274. * Creates a new HDRCubeTextureAssetTask object
  30275. * @param name defines the name of the task
  30276. * @param url defines the location of the file to load
  30277. * @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.
  30278. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30279. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30280. * @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)
  30281. * @param reserved Internal use only
  30282. */
  30283. constructor(
  30284. /**
  30285. * Defines the name of the task
  30286. */
  30287. name: string,
  30288. /**
  30289. * Defines the location of the file to load
  30290. */
  30291. url: string,
  30292. /**
  30293. * Defines the desired size (the more it increases the longer the generation will be)
  30294. */
  30295. size: number,
  30296. /**
  30297. * Defines if mipmaps should not be generated (default is false)
  30298. */
  30299. noMipmap?: boolean,
  30300. /**
  30301. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30302. */
  30303. generateHarmonics?: boolean,
  30304. /**
  30305. * 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)
  30306. */
  30307. gammaSpace?: boolean,
  30308. /**
  30309. * Internal Use Only
  30310. */
  30311. reserved?: boolean);
  30312. /**
  30313. * Execute the current task
  30314. * @param scene defines the scene where you want your assets to be loaded
  30315. * @param onSuccess is a callback called when the task is successfully executed
  30316. * @param onError is a callback called if an error occurs
  30317. */
  30318. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30319. }
  30320. /**
  30321. * This class can be used to easily import assets into a scene
  30322. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  30323. */
  30324. class AssetsManager {
  30325. private _scene;
  30326. private _isLoading;
  30327. protected _tasks: AbstractAssetTask[];
  30328. protected _waitingTasksCount: number;
  30329. protected _totalTasksCount: number;
  30330. /**
  30331. * Callback called when all tasks are processed
  30332. */
  30333. onFinish: (tasks: AbstractAssetTask[]) => void;
  30334. /**
  30335. * Callback called when a task is successful
  30336. */
  30337. onTaskSuccess: (task: AbstractAssetTask) => void;
  30338. /**
  30339. * Callback called when a task had an error
  30340. */
  30341. onTaskError: (task: AbstractAssetTask) => void;
  30342. /**
  30343. * Callback called when a task is done (whatever the result is)
  30344. */
  30345. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  30346. /**
  30347. * Observable called when all tasks are processed
  30348. */
  30349. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  30350. /**
  30351. * Observable called when a task had an error
  30352. */
  30353. onTaskErrorObservable: Observable<AbstractAssetTask>;
  30354. /**
  30355. * Observable called when a task is successful
  30356. */
  30357. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  30358. /**
  30359. * Observable called when a task is done (whatever the result is)
  30360. */
  30361. onProgressObservable: Observable<IAssetsProgressEvent>;
  30362. /**
  30363. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  30364. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30365. */
  30366. useDefaultLoadingScreen: boolean;
  30367. /**
  30368. * Creates a new AssetsManager
  30369. * @param scene defines the scene to work on
  30370. */
  30371. constructor(scene: Scene);
  30372. /**
  30373. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  30374. * @param taskName defines the name of the new task
  30375. * @param meshesNames defines the name of meshes to load
  30376. * @param rootUrl defines the root url to use to locate files
  30377. * @param sceneFilename defines the filename of the scene file
  30378. * @returns a new {BABYLON.MeshAssetTask} object
  30379. */
  30380. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  30381. /**
  30382. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  30383. * @param taskName defines the name of the new task
  30384. * @param url defines the url of the file to load
  30385. * @returns a new {BABYLON.TextFileAssetTask} object
  30386. */
  30387. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  30388. /**
  30389. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  30390. * @param taskName defines the name of the new task
  30391. * @param url defines the url of the file to load
  30392. * @returns a new {BABYLON.BinaryFileAssetTask} object
  30393. */
  30394. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  30395. /**
  30396. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  30397. * @param taskName defines the name of the new task
  30398. * @param url defines the url of the file to load
  30399. * @returns a new {BABYLON.ImageAssetTask} object
  30400. */
  30401. addImageTask(taskName: string, url: string): ImageAssetTask;
  30402. /**
  30403. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  30404. * @param taskName defines the name of the new task
  30405. * @param url defines the url of the file to load
  30406. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30407. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  30408. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  30409. * @returns a new {BABYLON.TextureAssetTask} object
  30410. */
  30411. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  30412. /**
  30413. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  30414. * @param taskName defines the name of the new task
  30415. * @param url defines the url of the file to load
  30416. * @param extensions defines the extension to use to load the cube map (can be null)
  30417. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30418. * @param files defines the list of files to load (can be null)
  30419. * @returns a new {BABYLON.CubeTextureAssetTask} object
  30420. */
  30421. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  30422. /**
  30423. *
  30424. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  30425. * @param taskName defines the name of the new task
  30426. * @param url defines the url of the file to load
  30427. * @param size defines the size you want for the cubemap (can be null)
  30428. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30429. * @param generateHarmonics defines if you want to automatically generate (true by default)
  30430. * @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)
  30431. * @param reserved Internal use only
  30432. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  30433. */
  30434. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  30435. /**
  30436. * Remove a task from the assets manager.
  30437. * @param task the task to remove
  30438. */
  30439. removeTask(task: AbstractAssetTask): void;
  30440. private _decreaseWaitingTasksCount;
  30441. private _runTask;
  30442. /**
  30443. * Reset the {BABYLON.AssetsManager} and remove all tasks
  30444. * @return the current instance of the {BABYLON.AssetsManager}
  30445. */
  30446. reset(): AssetsManager;
  30447. /**
  30448. * Start the loading process
  30449. * @return the current instance of the {BABYLON.AssetsManager}
  30450. */
  30451. load(): AssetsManager;
  30452. }
  30453. }
  30454. declare module BABYLON {
  30455. /**
  30456. * Class used to enable access to IndexedDB
  30457. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  30458. */
  30459. class Database {
  30460. private callbackManifestChecked;
  30461. private currentSceneUrl;
  30462. private db;
  30463. private _enableSceneOffline;
  30464. private _enableTexturesOffline;
  30465. private manifestVersionFound;
  30466. private mustUpdateRessources;
  30467. private hasReachedQuota;
  30468. private isSupported;
  30469. private idbFactory;
  30470. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30471. static IsUASupportingBlobStorage: boolean;
  30472. /** Gets a boolean indicating if Database storate is enabled */
  30473. static IDBStorageEnabled: boolean;
  30474. /**
  30475. * Gets a boolean indicating if scene must be saved in the database
  30476. */
  30477. readonly enableSceneOffline: boolean;
  30478. /**
  30479. * Gets a boolean indicating if textures must be saved in the database
  30480. */
  30481. readonly enableTexturesOffline: boolean;
  30482. /**
  30483. * Creates a new Database
  30484. * @param urlToScene defines the url to load the scene
  30485. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30486. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30487. */
  30488. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30489. private static _ParseURL;
  30490. private static _ReturnFullUrlLocation;
  30491. private _checkManifestFile;
  30492. /**
  30493. * Open the database and make it available
  30494. * @param successCallback defines the callback to call on success
  30495. * @param errorCallback defines the callback to call on error
  30496. */
  30497. openAsync(successCallback: () => void, errorCallback: () => void): void;
  30498. /**
  30499. * Loads an image from the database
  30500. * @param url defines the url to load from
  30501. * @param image defines the target DOM image
  30502. */
  30503. loadImageFromDB(url: string, image: HTMLImageElement): void;
  30504. private _loadImageFromDBAsync;
  30505. private _saveImageIntoDBAsync;
  30506. private _checkVersionFromDB;
  30507. private _loadVersionFromDBAsync;
  30508. private _saveVersionIntoDBAsync;
  30509. /**
  30510. * Loads a file from database
  30511. * @param url defines the URL to load from
  30512. * @param sceneLoaded defines a callback to call on success
  30513. * @param progressCallBack defines a callback to call when progress changed
  30514. * @param errorCallback defines a callback to call on error
  30515. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30516. */
  30517. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30518. private _loadFileFromDBAsync;
  30519. private _saveFileIntoDBAsync;
  30520. }
  30521. }
  30522. declare module BABYLON {
  30523. interface DDSInfo {
  30524. width: number;
  30525. height: number;
  30526. mipmapCount: number;
  30527. isFourCC: boolean;
  30528. isRGB: boolean;
  30529. isLuminance: boolean;
  30530. isCube: boolean;
  30531. isCompressed: boolean;
  30532. dxgiFormat: number;
  30533. textureType: number;
  30534. /** Sphericle polynomial created for the dds texture */
  30535. sphericalPolynomial?: SphericalPolynomial;
  30536. }
  30537. class DDSTools {
  30538. static StoreLODInAlphaChannel: boolean;
  30539. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30540. private static _FloatView;
  30541. private static _Int32View;
  30542. private static _ToHalfFloat;
  30543. private static _FromHalfFloat;
  30544. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30545. private static _GetHalfFloatRGBAArrayBuffer;
  30546. private static _GetFloatRGBAArrayBuffer;
  30547. private static _GetFloatAsUIntRGBAArrayBuffer;
  30548. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30549. private static _GetRGBAArrayBuffer;
  30550. private static _ExtractLongWordOrder;
  30551. private static _GetRGBArrayBuffer;
  30552. private static _GetLuminanceArrayBuffer;
  30553. /**
  30554. * Uploads DDS Levels to a Babylon Texture
  30555. * @hidden
  30556. */
  30557. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30558. }
  30559. }
  30560. declare module BABYLON {
  30561. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30562. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30563. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30564. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30565. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30566. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30567. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30568. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30569. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30570. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30571. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30572. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30573. /**
  30574. * Decorator used to define property that can be serialized as reference to a camera
  30575. * @param sourceName defines the name of the property to decorate
  30576. */
  30577. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30578. class SerializationHelper {
  30579. static Serialize<T>(entity: T, serializationObject?: any): any;
  30580. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30581. static Clone<T>(creationFunction: () => T, source: T): T;
  30582. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30583. }
  30584. }
  30585. declare module BABYLON {
  30586. /**
  30587. * Wrapper class for promise with external resolve and reject.
  30588. */
  30589. class Deferred<T> {
  30590. /**
  30591. * The promise associated with this deferred object.
  30592. */
  30593. readonly promise: Promise<T>;
  30594. private _resolve;
  30595. private _reject;
  30596. /**
  30597. * The resolve method of the promise associated with this deferred object.
  30598. */
  30599. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30600. /**
  30601. * The reject method of the promise associated with this deferred object.
  30602. */
  30603. readonly reject: (reason?: any) => void;
  30604. /**
  30605. * Constructor for this deferred object.
  30606. */
  30607. constructor();
  30608. }
  30609. }
  30610. declare module BABYLON {
  30611. /**
  30612. * Raw texture data and descriptor sufficient for WebGL texture upload
  30613. */
  30614. interface EnvironmentTextureInfo {
  30615. /**
  30616. * Version of the environment map
  30617. */
  30618. version: number;
  30619. /**
  30620. * Width of image
  30621. */
  30622. width: number;
  30623. /**
  30624. * Irradiance information stored in the file.
  30625. */
  30626. irradiance: any;
  30627. /**
  30628. * Specular information stored in the file.
  30629. */
  30630. specular: any;
  30631. }
  30632. /**
  30633. * Sets of helpers addressing the serialization and deserialization of environment texture
  30634. * stored in a BabylonJS env file.
  30635. * Those files are usually stored as .env files.
  30636. */
  30637. class EnvironmentTextureTools {
  30638. /**
  30639. * Magic number identifying the env file.
  30640. */
  30641. private static _MagicBytes;
  30642. /**
  30643. * Gets the environment info from an env file.
  30644. * @param data The array buffer containing the .env bytes.
  30645. * @returns the environment file info (the json header) if successfully parsed.
  30646. */
  30647. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30648. /**
  30649. * Creates an environment texture from a loaded cube texture.
  30650. * @param texture defines the cube texture to convert in env file
  30651. * @return a promise containing the environment data if succesfull.
  30652. */
  30653. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30654. /**
  30655. * Creates a JSON representation of the spherical data.
  30656. * @param texture defines the texture containing the polynomials
  30657. * @return the JSON representation of the spherical info
  30658. */
  30659. private static _CreateEnvTextureIrradiance;
  30660. /**
  30661. * Uploads the texture info contained in the env file to the GPU.
  30662. * @param texture defines the internal texture to upload to
  30663. * @param arrayBuffer defines the buffer cotaining the data to load
  30664. * @param info defines the texture info retrieved through the GetEnvInfo method
  30665. * @returns a promise
  30666. */
  30667. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  30668. /**
  30669. * Uploads the levels of image data to the GPU.
  30670. * @param texture defines the internal texture to upload to
  30671. * @param imageData defines the array buffer views of image data [mipmap][face]
  30672. * @returns a promise
  30673. */
  30674. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  30675. /**
  30676. * Uploads spherical polynomials information to the texture.
  30677. * @param texture defines the texture we are trying to upload the information to
  30678. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  30679. */
  30680. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  30681. }
  30682. }
  30683. declare module BABYLON {
  30684. class FilesInput {
  30685. static FilesToLoad: {
  30686. [key: string]: File;
  30687. };
  30688. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  30689. private _engine;
  30690. private _currentScene;
  30691. private _sceneLoadedCallback;
  30692. private _progressCallback;
  30693. private _additionalRenderLoopLogicCallback;
  30694. private _textureLoadingCallback;
  30695. private _startingProcessingFilesCallback;
  30696. private _onReloadCallback;
  30697. private _errorCallback;
  30698. private _elementToMonitor;
  30699. private _sceneFileToLoad;
  30700. private _filesToLoad;
  30701. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  30702. private _dragEnterHandler;
  30703. private _dragOverHandler;
  30704. private _dropHandler;
  30705. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  30706. dispose(): void;
  30707. private renderFunction;
  30708. private drag;
  30709. private drop;
  30710. private _traverseFolder;
  30711. private _processFiles;
  30712. loadFiles(event: any): void;
  30713. private _processReload;
  30714. reload(): void;
  30715. }
  30716. }
  30717. declare module BABYLON {
  30718. /**
  30719. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30720. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30721. */
  30722. class KhronosTextureContainer {
  30723. arrayBuffer: any;
  30724. static HEADER_LEN: number;
  30725. static COMPRESSED_2D: number;
  30726. static COMPRESSED_3D: number;
  30727. static TEX_2D: number;
  30728. static TEX_3D: number;
  30729. glType: number;
  30730. glTypeSize: number;
  30731. glFormat: number;
  30732. glInternalFormat: number;
  30733. glBaseInternalFormat: number;
  30734. pixelWidth: number;
  30735. pixelHeight: number;
  30736. pixelDepth: number;
  30737. numberOfArrayElements: number;
  30738. numberOfFaces: number;
  30739. numberOfMipmapLevels: number;
  30740. bytesOfKeyValueData: number;
  30741. loadType: number;
  30742. /**
  30743. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  30744. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  30745. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  30746. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  30747. */
  30748. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  30749. switchEndainness(val: number): number;
  30750. /**
  30751. * Uploads KTX content to a Babylon Texture.
  30752. * It is assumed that the texture has already been created & is currently bound
  30753. * @hidden
  30754. */
  30755. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  30756. private _upload2DCompressedLevels;
  30757. }
  30758. }
  30759. declare module BABYLON {
  30760. /**
  30761. * A class serves as a medium between the observable and its observers
  30762. */
  30763. class EventState {
  30764. /**
  30765. * Create a new EventState
  30766. * @param mask defines the mask associated with this state
  30767. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30768. * @param target defines the original target of the state
  30769. * @param currentTarget defines the current target of the state
  30770. */
  30771. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  30772. /**
  30773. * Initialize the current event state
  30774. * @param mask defines the mask associated with this state
  30775. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30776. * @param target defines the original target of the state
  30777. * @param currentTarget defines the current target of the state
  30778. * @returns the current event state
  30779. */
  30780. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  30781. /**
  30782. * An Observer can set this property to true to prevent subsequent observers of being notified
  30783. */
  30784. skipNextObservers: boolean;
  30785. /**
  30786. * Get the mask value that were used to trigger the event corresponding to this EventState object
  30787. */
  30788. mask: number;
  30789. /**
  30790. * The object that originally notified the event
  30791. */
  30792. target?: any;
  30793. /**
  30794. * The current object in the bubbling phase
  30795. */
  30796. currentTarget?: any;
  30797. /**
  30798. * This will be populated with the return value of the last function that was executed.
  30799. * If it is the first function in the callback chain it will be the event data.
  30800. */
  30801. lastReturnValue?: any;
  30802. }
  30803. /**
  30804. * Represent an Observer registered to a given Observable object.
  30805. */
  30806. class Observer<T> {
  30807. /**
  30808. * Defines the callback to call when the observer is notified
  30809. */
  30810. callback: (eventData: T, eventState: EventState) => void;
  30811. /**
  30812. * Defines the mask of the observer (used to filter notifications)
  30813. */
  30814. mask: number;
  30815. /**
  30816. * Defines the current scope used to restore the JS context
  30817. */
  30818. scope: any;
  30819. /** @hidden */
  30820. _willBeUnregistered: boolean;
  30821. /**
  30822. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  30823. */
  30824. unregisterOnNextCall: boolean;
  30825. /**
  30826. * Creates a new observer
  30827. * @param callback defines the callback to call when the observer is notified
  30828. * @param mask defines the mask of the observer (used to filter notifications)
  30829. * @param scope defines the current scope used to restore the JS context
  30830. */
  30831. constructor(
  30832. /**
  30833. * Defines the callback to call when the observer is notified
  30834. */
  30835. callback: (eventData: T, eventState: EventState) => void,
  30836. /**
  30837. * Defines the mask of the observer (used to filter notifications)
  30838. */
  30839. mask: number,
  30840. /**
  30841. * Defines the current scope used to restore the JS context
  30842. */
  30843. scope?: any);
  30844. }
  30845. /**
  30846. * Represent a list of observers registered to multiple Observables object.
  30847. */
  30848. class MultiObserver<T> {
  30849. private _observers;
  30850. private _observables;
  30851. /**
  30852. * Release associated resources
  30853. */
  30854. dispose(): void;
  30855. /**
  30856. * Raise a callback when one of the observable will notify
  30857. * @param observables defines a list of observables to watch
  30858. * @param callback defines the callback to call on notification
  30859. * @param mask defines the mask used to filter notifications
  30860. * @param scope defines the current scope used to restore the JS context
  30861. * @returns the new MultiObserver
  30862. */
  30863. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  30864. }
  30865. /**
  30866. * The Observable class is a simple implementation of the Observable pattern.
  30867. *
  30868. * 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.
  30869. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  30870. * 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).
  30871. * 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.
  30872. */
  30873. class Observable<T> {
  30874. private _observers;
  30875. private _eventState;
  30876. private _onObserverAdded;
  30877. /**
  30878. * Creates a new observable
  30879. * @param onObserverAdded defines a callback to call when a new observer is added
  30880. */
  30881. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  30882. /**
  30883. * Create a new Observer with the specified callback
  30884. * @param callback the callback that will be executed for that Observer
  30885. * @param mask the mask used to filter observers
  30886. * @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.
  30887. * @param scope optional scope for the callback to be called from
  30888. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  30889. * @returns the new observer created for the callback
  30890. */
  30891. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  30892. /**
  30893. * Create a new Observer with the specified callback and unregisters after the next notification
  30894. * @param callback the callback that will be executed for that Observer
  30895. * @returns the new observer created for the callback
  30896. */
  30897. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  30898. /**
  30899. * Remove an Observer from the Observable object
  30900. * @param observer the instance of the Observer to remove
  30901. * @returns false if it doesn't belong to this Observable
  30902. */
  30903. remove(observer: Nullable<Observer<T>>): boolean;
  30904. /**
  30905. * Remove a callback from the Observable object
  30906. * @param callback the callback to remove
  30907. * @param scope optional scope. If used only the callbacks with this scope will be removed
  30908. * @returns false if it doesn't belong to this Observable
  30909. */
  30910. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  30911. private _deferUnregister;
  30912. private _remove;
  30913. /**
  30914. * Notify all Observers by calling their respective callback with the given data
  30915. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  30916. * @param eventData defines the data to send to all observers
  30917. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  30918. * @param target defines the original target of the state
  30919. * @param currentTarget defines the current target of the state
  30920. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  30921. */
  30922. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  30923. /**
  30924. * Calling this will execute each callback, expecting it to be a promise or return a value.
  30925. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  30926. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  30927. * and it is crucial that all callbacks will be executed.
  30928. * The order of the callbacks is kept, callbacks are not executed parallel.
  30929. *
  30930. * @param eventData The data to be sent to each callback
  30931. * @param mask is used to filter observers defaults to -1
  30932. * @param target defines the callback target (see EventState)
  30933. * @param currentTarget defines he current object in the bubbling phase
  30934. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  30935. */
  30936. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  30937. /**
  30938. * Notify a specific observer
  30939. * @param observer defines the observer to notify
  30940. * @param eventData defines the data to be sent to each callback
  30941. * @param mask is used to filter observers defaults to -1
  30942. */
  30943. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  30944. /**
  30945. * Gets a boolean indicating if the observable has at least one observer
  30946. * @returns true is the Observable has at least one Observer registered
  30947. */
  30948. hasObservers(): boolean;
  30949. /**
  30950. * Clear the list of observers
  30951. */
  30952. clear(): void;
  30953. /**
  30954. * Clone the current observable
  30955. * @returns a new observable
  30956. */
  30957. clone(): Observable<T>;
  30958. /**
  30959. * Does this observable handles observer registered with a given mask
  30960. * @param mask defines the mask to be tested
  30961. * @return whether or not one observer registered with the given mask is handeled
  30962. **/
  30963. hasSpecificMask(mask?: number): boolean;
  30964. }
  30965. }
  30966. declare module BABYLON {
  30967. /**
  30968. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30969. */
  30970. class PerformanceMonitor {
  30971. private _enabled;
  30972. private _rollingFrameTime;
  30973. private _lastFrameTimeMs;
  30974. /**
  30975. * constructor
  30976. * @param frameSampleSize The number of samples required to saturate the sliding window
  30977. */
  30978. constructor(frameSampleSize?: number);
  30979. /**
  30980. * Samples current frame
  30981. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30982. */
  30983. sampleFrame(timeMs?: number): void;
  30984. /**
  30985. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30986. * @return Average frame time in milliseconds
  30987. */
  30988. readonly averageFrameTime: number;
  30989. /**
  30990. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30991. * @return Frame time variance in milliseconds squared
  30992. */
  30993. readonly averageFrameTimeVariance: number;
  30994. /**
  30995. * Returns the frame time of the most recent frame
  30996. * @return Frame time in milliseconds
  30997. */
  30998. readonly instantaneousFrameTime: number;
  30999. /**
  31000. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31001. * @return Framerate in frames per second
  31002. */
  31003. readonly averageFPS: number;
  31004. /**
  31005. * Returns the average framerate in frames per second using the most recent frame time
  31006. * @return Framerate in frames per second
  31007. */
  31008. readonly instantaneousFPS: number;
  31009. /**
  31010. * Returns true if enough samples have been taken to completely fill the sliding window
  31011. * @return true if saturated
  31012. */
  31013. readonly isSaturated: boolean;
  31014. /**
  31015. * Enables contributions to the sliding window sample set
  31016. */
  31017. enable(): void;
  31018. /**
  31019. * Disables contributions to the sliding window sample set
  31020. * Samples will not be interpolated over the disabled period
  31021. */
  31022. disable(): void;
  31023. /**
  31024. * Returns true if sampling is enabled
  31025. * @return true if enabled
  31026. */
  31027. readonly isEnabled: boolean;
  31028. /**
  31029. * Resets performance monitor
  31030. */
  31031. reset(): void;
  31032. }
  31033. /**
  31034. * RollingAverage
  31035. *
  31036. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31037. */
  31038. class RollingAverage {
  31039. /**
  31040. * Current average
  31041. */
  31042. average: number;
  31043. /**
  31044. * Current variance
  31045. */
  31046. variance: number;
  31047. protected _samples: Array<number>;
  31048. protected _sampleCount: number;
  31049. protected _pos: number;
  31050. protected _m2: number;
  31051. /**
  31052. * constructor
  31053. * @param length The number of samples required to saturate the sliding window
  31054. */
  31055. constructor(length: number);
  31056. /**
  31057. * Adds a sample to the sample set
  31058. * @param v The sample value
  31059. */
  31060. add(v: number): void;
  31061. /**
  31062. * Returns previously added values or null if outside of history or outside the sliding window domain
  31063. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31064. * @return Value previously recorded with add() or null if outside of range
  31065. */
  31066. history(i: number): number;
  31067. /**
  31068. * Returns true if enough samples have been taken to completely fill the sliding window
  31069. * @return true if sample-set saturated
  31070. */
  31071. isSaturated(): boolean;
  31072. /**
  31073. * Resets the rolling average (equivalent to 0 samples taken so far)
  31074. */
  31075. reset(): void;
  31076. /**
  31077. * Wraps a value around the sample range boundaries
  31078. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31079. * @return Wrapped position in sample range
  31080. */
  31081. protected _wrapPosition(i: number): number;
  31082. }
  31083. }
  31084. declare module BABYLON {
  31085. /**
  31086. * Helper class that provides a small promise polyfill
  31087. */
  31088. class PromisePolyfill {
  31089. /**
  31090. * Static function used to check if the polyfill is required
  31091. * If this is the case then the function will inject the polyfill to window.Promise
  31092. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31093. */
  31094. static Apply(force?: boolean): void;
  31095. }
  31096. }
  31097. declare module BABYLON {
  31098. /**
  31099. * Defines the root class used to create scene optimization to use with SceneOptimizer
  31100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31101. */
  31102. class SceneOptimization {
  31103. /**
  31104. * Defines the priority of this optimization (0 by default which means first in the list)
  31105. */
  31106. priority: number;
  31107. /**
  31108. * Gets a string describing the action executed by the current optimization
  31109. * @returns description string
  31110. */
  31111. getDescription(): string;
  31112. /**
  31113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31114. * @param scene defines the current scene where to apply this optimization
  31115. * @param optimizer defines the current optimizer
  31116. * @returns true if everything that can be done was applied
  31117. */
  31118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31119. /**
  31120. * Creates the SceneOptimization object
  31121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31122. * @param desc defines the description associated with the optimization
  31123. */
  31124. constructor(
  31125. /**
  31126. * Defines the priority of this optimization (0 by default which means first in the list)
  31127. */
  31128. priority?: number);
  31129. }
  31130. /**
  31131. * Defines an optimization used to reduce the size of render target textures
  31132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31133. */
  31134. class TextureOptimization extends SceneOptimization {
  31135. /**
  31136. * Defines the priority of this optimization (0 by default which means first in the list)
  31137. */
  31138. priority: number;
  31139. /**
  31140. * 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
  31141. */
  31142. maximumSize: number;
  31143. /**
  31144. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31145. */
  31146. step: number;
  31147. /**
  31148. * Gets a string describing the action executed by the current optimization
  31149. * @returns description string
  31150. */
  31151. getDescription(): string;
  31152. /**
  31153. * Creates the TextureOptimization object
  31154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31155. * @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
  31156. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31157. */
  31158. constructor(
  31159. /**
  31160. * Defines the priority of this optimization (0 by default which means first in the list)
  31161. */
  31162. priority?: number,
  31163. /**
  31164. * 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
  31165. */
  31166. maximumSize?: number,
  31167. /**
  31168. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31169. */
  31170. step?: number);
  31171. /**
  31172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31173. * @param scene defines the current scene where to apply this optimization
  31174. * @param optimizer defines the current optimizer
  31175. * @returns true if everything that can be done was applied
  31176. */
  31177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31178. }
  31179. /**
  31180. * Defines an optimization used to increase or decrease the rendering resolution
  31181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31182. */
  31183. class HardwareScalingOptimization extends SceneOptimization {
  31184. /**
  31185. * Defines the priority of this optimization (0 by default which means first in the list)
  31186. */
  31187. priority: number;
  31188. /**
  31189. * Defines the maximum scale to use (2 by default)
  31190. */
  31191. maximumScale: number;
  31192. /**
  31193. * Defines the step to use between two passes (0.5 by default)
  31194. */
  31195. step: number;
  31196. private _currentScale;
  31197. private _directionOffset;
  31198. /**
  31199. * Gets a string describing the action executed by the current optimization
  31200. * @return description string
  31201. */
  31202. getDescription(): string;
  31203. /**
  31204. * Creates the HardwareScalingOptimization object
  31205. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31206. * @param maximumScale defines the maximum scale to use (2 by default)
  31207. * @param step defines the step to use between two passes (0.5 by default)
  31208. */
  31209. constructor(
  31210. /**
  31211. * Defines the priority of this optimization (0 by default which means first in the list)
  31212. */
  31213. priority?: number,
  31214. /**
  31215. * Defines the maximum scale to use (2 by default)
  31216. */
  31217. maximumScale?: number,
  31218. /**
  31219. * Defines the step to use between two passes (0.5 by default)
  31220. */
  31221. step?: number);
  31222. /**
  31223. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31224. * @param scene defines the current scene where to apply this optimization
  31225. * @param optimizer defines the current optimizer
  31226. * @returns true if everything that can be done was applied
  31227. */
  31228. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31229. }
  31230. /**
  31231. * Defines an optimization used to remove shadows
  31232. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31233. */
  31234. class ShadowsOptimization extends SceneOptimization {
  31235. /**
  31236. * Gets a string describing the action executed by the current optimization
  31237. * @return description string
  31238. */
  31239. getDescription(): string;
  31240. /**
  31241. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31242. * @param scene defines the current scene where to apply this optimization
  31243. * @param optimizer defines the current optimizer
  31244. * @returns true if everything that can be done was applied
  31245. */
  31246. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31247. }
  31248. /**
  31249. * Defines an optimization used to turn post-processes off
  31250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31251. */
  31252. class PostProcessesOptimization extends SceneOptimization {
  31253. /**
  31254. * Gets a string describing the action executed by the current optimization
  31255. * @return description string
  31256. */
  31257. getDescription(): string;
  31258. /**
  31259. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31260. * @param scene defines the current scene where to apply this optimization
  31261. * @param optimizer defines the current optimizer
  31262. * @returns true if everything that can be done was applied
  31263. */
  31264. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31265. }
  31266. /**
  31267. * Defines an optimization used to turn lens flares off
  31268. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31269. */
  31270. class LensFlaresOptimization extends SceneOptimization {
  31271. /**
  31272. * Gets a string describing the action executed by the current optimization
  31273. * @return description string
  31274. */
  31275. getDescription(): string;
  31276. /**
  31277. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31278. * @param scene defines the current scene where to apply this optimization
  31279. * @param optimizer defines the current optimizer
  31280. * @returns true if everything that can be done was applied
  31281. */
  31282. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31283. }
  31284. /**
  31285. * Defines an optimization based on user defined callback.
  31286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31287. */
  31288. class CustomOptimization extends SceneOptimization {
  31289. /**
  31290. * Callback called to apply the custom optimization.
  31291. */
  31292. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  31293. /**
  31294. * Callback called to get custom description
  31295. */
  31296. onGetDescription: () => string;
  31297. /**
  31298. * Gets a string describing the action executed by the current optimization
  31299. * @returns description string
  31300. */
  31301. getDescription(): string;
  31302. /**
  31303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31304. * @param scene defines the current scene where to apply this optimization
  31305. * @param optimizer defines the current optimizer
  31306. * @returns true if everything that can be done was applied
  31307. */
  31308. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31309. }
  31310. /**
  31311. * Defines an optimization used to turn particles off
  31312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31313. */
  31314. class ParticlesOptimization extends SceneOptimization {
  31315. /**
  31316. * Gets a string describing the action executed by the current optimization
  31317. * @return description string
  31318. */
  31319. getDescription(): string;
  31320. /**
  31321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31322. * @param scene defines the current scene where to apply this optimization
  31323. * @param optimizer defines the current optimizer
  31324. * @returns true if everything that can be done was applied
  31325. */
  31326. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31327. }
  31328. /**
  31329. * Defines an optimization used to turn render targets off
  31330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31331. */
  31332. class RenderTargetsOptimization extends SceneOptimization {
  31333. /**
  31334. * Gets a string describing the action executed by the current optimization
  31335. * @return description string
  31336. */
  31337. getDescription(): string;
  31338. /**
  31339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31340. * @param scene defines the current scene where to apply this optimization
  31341. * @param optimizer defines the current optimizer
  31342. * @returns true if everything that can be done was applied
  31343. */
  31344. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31345. }
  31346. /**
  31347. * Defines an optimization used to merge meshes with compatible materials
  31348. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31349. */
  31350. class MergeMeshesOptimization extends SceneOptimization {
  31351. private static _UpdateSelectionTree;
  31352. /**
  31353. * Gets or sets a boolean which defines if optimization octree has to be updated
  31354. */
  31355. /**
  31356. * Gets or sets a boolean which defines if optimization octree has to be updated
  31357. */
  31358. static UpdateSelectionTree: boolean;
  31359. /**
  31360. * Gets a string describing the action executed by the current optimization
  31361. * @return description string
  31362. */
  31363. getDescription(): string;
  31364. private _canBeMerged;
  31365. /**
  31366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31367. * @param scene defines the current scene where to apply this optimization
  31368. * @param optimizer defines the current optimizer
  31369. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  31370. * @returns true if everything that can be done was applied
  31371. */
  31372. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  31373. }
  31374. /**
  31375. * Defines a list of options used by SceneOptimizer
  31376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31377. */
  31378. class SceneOptimizerOptions {
  31379. /**
  31380. * Defines the target frame rate to reach (60 by default)
  31381. */
  31382. targetFrameRate: number;
  31383. /**
  31384. * Defines the interval between two checkes (2000ms by default)
  31385. */
  31386. trackerDuration: number;
  31387. /**
  31388. * Gets the list of optimizations to apply
  31389. */
  31390. optimizations: SceneOptimization[];
  31391. /**
  31392. * Creates a new list of options used by SceneOptimizer
  31393. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  31394. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  31395. */
  31396. constructor(
  31397. /**
  31398. * Defines the target frame rate to reach (60 by default)
  31399. */
  31400. targetFrameRate?: number,
  31401. /**
  31402. * Defines the interval between two checkes (2000ms by default)
  31403. */
  31404. trackerDuration?: number);
  31405. /**
  31406. * Add a new optimization
  31407. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  31408. * @returns the current SceneOptimizerOptions
  31409. */
  31410. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  31411. /**
  31412. * Add a new custom optimization
  31413. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  31414. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  31415. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31416. * @returns the current SceneOptimizerOptions
  31417. */
  31418. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  31419. /**
  31420. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  31421. * @param targetFrameRate defines the target frame rate (60 by default)
  31422. * @returns a SceneOptimizerOptions object
  31423. */
  31424. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31425. /**
  31426. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  31427. * @param targetFrameRate defines the target frame rate (60 by default)
  31428. * @returns a SceneOptimizerOptions object
  31429. */
  31430. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31431. /**
  31432. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  31433. * @param targetFrameRate defines the target frame rate (60 by default)
  31434. * @returns a SceneOptimizerOptions object
  31435. */
  31436. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31437. }
  31438. /**
  31439. * Class used to run optimizations in order to reach a target frame rate
  31440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31441. */
  31442. class SceneOptimizer implements IDisposable {
  31443. private _isRunning;
  31444. private _options;
  31445. private _scene;
  31446. private _currentPriorityLevel;
  31447. private _targetFrameRate;
  31448. private _trackerDuration;
  31449. private _currentFrameRate;
  31450. private _sceneDisposeObserver;
  31451. private _improvementMode;
  31452. /**
  31453. * Defines an observable called when the optimizer reaches the target frame rate
  31454. */
  31455. onSuccessObservable: Observable<SceneOptimizer>;
  31456. /**
  31457. * Defines an observable called when the optimizer enables an optimization
  31458. */
  31459. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  31460. /**
  31461. * Defines an observable called when the optimizer is not able to reach the target frame rate
  31462. */
  31463. onFailureObservable: Observable<SceneOptimizer>;
  31464. /**
  31465. * Gets a boolean indicating if the optimizer is in improvement mode
  31466. */
  31467. readonly isInImprovementMode: boolean;
  31468. /**
  31469. * Gets the current priority level (0 at start)
  31470. */
  31471. readonly currentPriorityLevel: number;
  31472. /**
  31473. * Gets the current frame rate checked by the SceneOptimizer
  31474. */
  31475. readonly currentFrameRate: number;
  31476. /**
  31477. * Gets or sets the current target frame rate (60 by default)
  31478. */
  31479. /**
  31480. * Gets or sets the current target frame rate (60 by default)
  31481. */
  31482. targetFrameRate: number;
  31483. /**
  31484. * Gets or sets the current interval between two checks (every 2000ms by default)
  31485. */
  31486. /**
  31487. * Gets or sets the current interval between two checks (every 2000ms by default)
  31488. */
  31489. trackerDuration: number;
  31490. /**
  31491. * Gets the list of active optimizations
  31492. */
  31493. readonly optimizations: SceneOptimization[];
  31494. /**
  31495. * Creates a new SceneOptimizer
  31496. * @param scene defines the scene to work on
  31497. * @param options defines the options to use with the SceneOptimizer
  31498. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  31499. * @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)
  31500. */
  31501. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  31502. /**
  31503. * Stops the current optimizer
  31504. */
  31505. stop(): void;
  31506. /**
  31507. * Reset the optimizer to initial step (current priority level = 0)
  31508. */
  31509. reset(): void;
  31510. /**
  31511. * Start the optimizer. By default it will try to reach a specific framerate
  31512. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31513. */
  31514. start(): void;
  31515. private _checkCurrentState;
  31516. /**
  31517. * Release all resources
  31518. */
  31519. dispose(): void;
  31520. /**
  31521. * Helper function to create a SceneOptimizer with one single line of code
  31522. * @param scene defines the scene to work on
  31523. * @param options defines the options to use with the SceneOptimizer
  31524. * @param onSuccess defines a callback to call on success
  31525. * @param onFailure defines a callback to call on failure
  31526. * @returns the new SceneOptimizer object
  31527. */
  31528. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31529. }
  31530. }
  31531. declare module BABYLON {
  31532. class SceneSerializer {
  31533. static ClearCache(): void;
  31534. static Serialize(scene: Scene): any;
  31535. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31536. }
  31537. }
  31538. declare module BABYLON {
  31539. class SmartArray<T> {
  31540. data: Array<T>;
  31541. length: number;
  31542. protected _id: number;
  31543. [index: number]: T;
  31544. constructor(capacity: number);
  31545. push(value: T): void;
  31546. forEach(func: (content: T) => void): void;
  31547. sort(compareFn: (a: T, b: T) => number): void;
  31548. reset(): void;
  31549. dispose(): void;
  31550. concat(array: any): void;
  31551. indexOf(value: T): number;
  31552. contains(value: T): boolean;
  31553. private static _GlobalId;
  31554. }
  31555. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31556. private _duplicateId;
  31557. [index: number]: T;
  31558. push(value: T): void;
  31559. pushNoDuplicate(value: T): boolean;
  31560. reset(): void;
  31561. concatWithNoDuplicate(array: any): void;
  31562. }
  31563. }
  31564. declare module BABYLON {
  31565. /**
  31566. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31567. * The underlying implementation relies on an associative array to ensure the best performances.
  31568. * The value can be anything including 'null' but except 'undefined'
  31569. */
  31570. class StringDictionary<T> {
  31571. /**
  31572. * This will clear this dictionary and copy the content from the 'source' one.
  31573. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31574. * @param source the dictionary to take the content from and copy to this dictionary
  31575. */
  31576. copyFrom(source: StringDictionary<T>): void;
  31577. /**
  31578. * Get a value based from its key
  31579. * @param key the given key to get the matching value from
  31580. * @return the value if found, otherwise undefined is returned
  31581. */
  31582. get(key: string): T | undefined;
  31583. /**
  31584. * Get a value from its key or add it if it doesn't exist.
  31585. * This method will ensure you that a given key/data will be present in the dictionary.
  31586. * @param key the given key to get the matching value from
  31587. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31588. * The factory will only be invoked if there's no data for the given key.
  31589. * @return the value corresponding to the key.
  31590. */
  31591. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31592. /**
  31593. * Get a value from its key if present in the dictionary otherwise add it
  31594. * @param key the key to get the value from
  31595. * @param val if there's no such key/value pair in the dictionary add it with this value
  31596. * @return the value corresponding to the key
  31597. */
  31598. getOrAdd(key: string, val: T): T;
  31599. /**
  31600. * Check if there's a given key in the dictionary
  31601. * @param key the key to check for
  31602. * @return true if the key is present, false otherwise
  31603. */
  31604. contains(key: string): boolean;
  31605. /**
  31606. * Add a new key and its corresponding value
  31607. * @param key the key to add
  31608. * @param value the value corresponding to the key
  31609. * @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
  31610. */
  31611. add(key: string, value: T): boolean;
  31612. set(key: string, value: T): boolean;
  31613. /**
  31614. * Get the element of the given key and remove it from the dictionary
  31615. * @param key
  31616. */
  31617. getAndRemove(key: string): Nullable<T>;
  31618. /**
  31619. * Remove a key/value from the dictionary.
  31620. * @param key the key to remove
  31621. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31622. */
  31623. remove(key: string): boolean;
  31624. /**
  31625. * Clear the whole content of the dictionary
  31626. */
  31627. clear(): void;
  31628. readonly count: number;
  31629. /**
  31630. * Execute a callback on each key/val of the dictionary.
  31631. * Note that you can remove any element in this dictionary in the callback implementation
  31632. * @param callback the callback to execute on a given key/value pair
  31633. */
  31634. forEach(callback: (key: string, val: T) => void): void;
  31635. /**
  31636. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31637. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31638. * Note that you can remove any element in this dictionary in the callback implementation
  31639. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31640. */
  31641. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31642. private _count;
  31643. private _data;
  31644. }
  31645. }
  31646. declare module BABYLON {
  31647. class Tags {
  31648. static EnableFor(obj: any): void;
  31649. static DisableFor(obj: any): void;
  31650. static HasTags(obj: any): boolean;
  31651. static GetTags(obj: any, asString?: boolean): any;
  31652. static AddTagsTo(obj: any, tagsString: string): void;
  31653. static _AddTagTo(obj: any, tag: string): void;
  31654. static RemoveTagsFrom(obj: any, tagsString: string): void;
  31655. static _RemoveTagFrom(obj: any, tag: string): void;
  31656. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  31657. }
  31658. }
  31659. declare module BABYLON {
  31660. class TextureTools {
  31661. /**
  31662. * Uses the GPU to create a copy texture rescaled at a given size
  31663. * @param texture Texture to copy from
  31664. * @param width Desired width
  31665. * @param height Desired height
  31666. * @return Generated texture
  31667. */
  31668. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  31669. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  31670. private static _environmentBRDFBase64Texture;
  31671. }
  31672. }
  31673. declare module BABYLON {
  31674. class TGATools {
  31675. private static _TYPE_INDEXED;
  31676. private static _TYPE_RGB;
  31677. private static _TYPE_GREY;
  31678. private static _TYPE_RLE_INDEXED;
  31679. private static _TYPE_RLE_RGB;
  31680. private static _TYPE_RLE_GREY;
  31681. private static _ORIGIN_MASK;
  31682. private static _ORIGIN_SHIFT;
  31683. private static _ORIGIN_BL;
  31684. private static _ORIGIN_BR;
  31685. private static _ORIGIN_UL;
  31686. private static _ORIGIN_UR;
  31687. static GetTGAHeader(data: Uint8Array): any;
  31688. /**
  31689. * Uploads TGA content to a Babylon Texture
  31690. * @hidden
  31691. */
  31692. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  31693. 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;
  31694. 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;
  31695. 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;
  31696. 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;
  31697. 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;
  31698. 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;
  31699. }
  31700. }
  31701. declare module BABYLON {
  31702. interface IAnimatable {
  31703. animations: Array<Animation>;
  31704. }
  31705. /** Interface used by value gradients (color, factor, ...) */
  31706. interface IValueGradient {
  31707. /**
  31708. * Gets or sets the gradient value (between 0 and 1)
  31709. */
  31710. gradient: number;
  31711. }
  31712. /** Class used to store color gradient */
  31713. class ColorGradient implements IValueGradient {
  31714. /**
  31715. * Gets or sets the gradient value (between 0 and 1)
  31716. */
  31717. gradient: number;
  31718. /**
  31719. * Gets or sets first associated color
  31720. */
  31721. color1: Color4;
  31722. /**
  31723. * Gets or sets second associated color
  31724. */
  31725. color2?: Color4;
  31726. /**
  31727. * Will get a color picked randomly between color1 and color2.
  31728. * If color2 is undefined then color1 will be used
  31729. * @param result defines the target Color4 to store the result in
  31730. */
  31731. getColorToRef(result: Color4): void;
  31732. }
  31733. /** Class used to store factor gradient */
  31734. class FactorGradient implements IValueGradient {
  31735. /**
  31736. * Gets or sets the gradient value (between 0 and 1)
  31737. */
  31738. gradient: number;
  31739. /**
  31740. * Gets or sets first associated factor
  31741. */
  31742. factor1: number;
  31743. /**
  31744. * Gets or sets second associated factor
  31745. */
  31746. factor2?: number;
  31747. /**
  31748. * Will get a number picked randomly between factor1 and factor2.
  31749. * If factor2 is undefined then factor1 will be used
  31750. * @returns the picked number
  31751. */
  31752. getFactor(): number;
  31753. }
  31754. class LoadFileError extends Error {
  31755. request?: XMLHttpRequest | undefined;
  31756. private static _setPrototypeOf;
  31757. constructor(message: string, request?: XMLHttpRequest | undefined);
  31758. }
  31759. class RetryStrategy {
  31760. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31761. }
  31762. interface IFileRequest {
  31763. /**
  31764. * Raised when the request is complete (success or error).
  31765. */
  31766. onCompleteObservable: Observable<IFileRequest>;
  31767. /**
  31768. * Aborts the request for a file.
  31769. */
  31770. abort: () => void;
  31771. }
  31772. class Tools {
  31773. static BaseUrl: string;
  31774. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31775. /**
  31776. * Default behaviour for cors in the application.
  31777. * It can be a string if the expected behavior is identical in the entire app.
  31778. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31779. */
  31780. static CorsBehavior: string | ((url: string | string[]) => string);
  31781. static UseFallbackTexture: boolean;
  31782. /**
  31783. * Use this object to register external classes like custom textures or material
  31784. * to allow the laoders to instantiate them
  31785. */
  31786. static RegisteredExternalClasses: {
  31787. [key: string]: Object;
  31788. };
  31789. static fallbackTexture: string;
  31790. /**
  31791. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31792. * @param u defines the coordinate on X axis
  31793. * @param v defines the coordinate on Y axis
  31794. * @param width defines the width of the source data
  31795. * @param height defines the height of the source data
  31796. * @param pixels defines the source byte array
  31797. * @param color defines the output color
  31798. */
  31799. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31800. /**
  31801. * Interpolates between a and b via alpha
  31802. * @param a The lower value (returned when alpha = 0)
  31803. * @param b The upper value (returned when alpha = 1)
  31804. * @param alpha The interpolation-factor
  31805. * @return The mixed value
  31806. */
  31807. static Mix(a: number, b: number, alpha: number): number;
  31808. static Instantiate(className: string): any;
  31809. /**
  31810. * Provides a slice function that will work even on IE
  31811. * @param data defines the array to slice
  31812. * @param start defines the start of the data (optional)
  31813. * @param end defines the end of the data (optional)
  31814. * @returns the new sliced array
  31815. */
  31816. static Slice<T>(data: T, start?: number, end?: number): T;
  31817. static SetImmediate(action: () => void): void;
  31818. static IsExponentOfTwo(value: number): boolean;
  31819. private static _tmpFloatArray;
  31820. /**
  31821. * Returns the nearest 32-bit single precision float representation of a Number
  31822. * @param value A Number. If the parameter is of a different type, it will get converted
  31823. * to a number or to NaN if it cannot be converted
  31824. * @returns number
  31825. */
  31826. static FloatRound(value: number): number;
  31827. /**
  31828. * Find the next highest power of two.
  31829. * @param x Number to start search from.
  31830. * @return Next highest power of two.
  31831. */
  31832. static CeilingPOT(x: number): number;
  31833. /**
  31834. * Find the next lowest power of two.
  31835. * @param x Number to start search from.
  31836. * @return Next lowest power of two.
  31837. */
  31838. static FloorPOT(x: number): number;
  31839. /**
  31840. * Find the nearest power of two.
  31841. * @param x Number to start search from.
  31842. * @return Next nearest power of two.
  31843. */
  31844. static NearestPOT(x: number): number;
  31845. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31846. static GetFilename(path: string): string;
  31847. /**
  31848. * Extracts the "folder" part of a path (everything before the filename).
  31849. * @param uri The URI to extract the info from
  31850. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31851. * @returns The "folder" part of the path
  31852. */
  31853. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31854. static GetDOMTextContent(element: HTMLElement): string;
  31855. static ToDegrees(angle: number): number;
  31856. static ToRadians(angle: number): number;
  31857. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31858. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31859. minimum: Vector3;
  31860. maximum: Vector3;
  31861. };
  31862. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31863. minimum: Vector3;
  31864. maximum: Vector3;
  31865. };
  31866. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  31867. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  31868. minimum: Vector2;
  31869. maximum: Vector2;
  31870. };
  31871. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31872. static GetPointerPrefix(): string;
  31873. /**
  31874. * @param func - the function to be called
  31875. * @param requester - the object that will request the next frame. Falls back to window.
  31876. */
  31877. static QueueNewFrame(func: () => void, requester?: any): number;
  31878. static RequestFullscreen(element: HTMLElement): void;
  31879. static ExitFullscreen(): void;
  31880. static SetCorsBehavior(url: string | string[], element: {
  31881. crossOrigin: string | null;
  31882. }): void;
  31883. static CleanUrl(url: string): string;
  31884. static PreprocessUrl: (url: string) => string;
  31885. /**
  31886. * Loads an image as an HTMLImageElement.
  31887. * @param input url string, ArrayBuffer, or Blob to load
  31888. * @param onLoad callback called when the image successfully loads
  31889. * @param onError callback called when the image fails to load
  31890. * @param database database for caching
  31891. * @returns the HTMLImageElement of the loaded image
  31892. */
  31893. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  31894. 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;
  31895. /**
  31896. * Load a script (identified by an url). When the url returns, the
  31897. * content of this file is added into a new script element, attached to the DOM (body element)
  31898. */
  31899. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31900. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31901. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31902. static FileAsURL(content: string): string;
  31903. static Format(value: number, decimals?: number): string;
  31904. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31905. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31906. static IsEmpty(obj: any): boolean;
  31907. static RegisterTopRootEvents(events: {
  31908. name: string;
  31909. handler: Nullable<(e: FocusEvent) => any>;
  31910. }[]): void;
  31911. static UnregisterTopRootEvents(events: {
  31912. name: string;
  31913. handler: Nullable<(e: FocusEvent) => any>;
  31914. }[]): void;
  31915. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31916. /**
  31917. * Converts the canvas data to blob.
  31918. * This acts as a polyfill for browsers not supporting the to blob function.
  31919. * @param canvas Defines the canvas to extract the data from
  31920. * @param successCallback Defines the callback triggered once the data are available
  31921. * @param mimeType Defines the mime type of the result
  31922. */
  31923. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31924. /**
  31925. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31926. * @param successCallback Defines the callback triggered once the data are available
  31927. * @param mimeType Defines the mime type of the result
  31928. * @param fileName The filename to download. If present, the result will automatically be downloaded
  31929. */
  31930. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31931. /**
  31932. * Downloads a blob in the browser
  31933. * @param blob defines the blob to download
  31934. * @param fileName defines the name of the downloaded file
  31935. */
  31936. static Download(blob: Blob, fileName: string): void;
  31937. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31938. /**
  31939. * Generates an image screenshot from the specified camera.
  31940. *
  31941. * @param engine The engine to use for rendering
  31942. * @param camera The camera to use for rendering
  31943. * @param size This parameter can be set to a single number or to an object with the
  31944. * following (optional) properties: precision, width, height. If a single number is passed,
  31945. * it will be used for both width and height. If an object is passed, the screenshot size
  31946. * will be derived from the parameters. The precision property is a multiplier allowing
  31947. * rendering at a higher or lower resolution.
  31948. * @param successCallback The callback receives a single parameter which contains the
  31949. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31950. * src parameter of an <img> to display it.
  31951. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31952. * Check your browser for supported MIME types.
  31953. * @param samples Texture samples (default: 1)
  31954. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31955. * @param fileName A name for for the downloaded file.
  31956. * @constructor
  31957. */
  31958. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31959. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  31960. /**
  31961. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31962. * Be aware Math.random() could cause collisions, but:
  31963. * "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"
  31964. */
  31965. static RandomId(): string;
  31966. /**
  31967. * Test if the given uri is a base64 string.
  31968. * @param uri The uri to test
  31969. * @return True if the uri is a base64 string or false otherwise.
  31970. */
  31971. static IsBase64(uri: string): boolean;
  31972. /**
  31973. * Decode the given base64 uri.
  31974. * @param uri The uri to decode
  31975. * @return The decoded base64 data.
  31976. */
  31977. static DecodeBase64(uri: string): ArrayBuffer;
  31978. private static _NoneLogLevel;
  31979. private static _MessageLogLevel;
  31980. private static _WarningLogLevel;
  31981. private static _ErrorLogLevel;
  31982. private static _LogCache;
  31983. static errorsCount: number;
  31984. static OnNewCacheEntry: (entry: string) => void;
  31985. static readonly NoneLogLevel: number;
  31986. static readonly MessageLogLevel: number;
  31987. static readonly WarningLogLevel: number;
  31988. static readonly ErrorLogLevel: number;
  31989. static readonly AllLogLevel: number;
  31990. private static _AddLogEntry;
  31991. private static _FormatMessage;
  31992. private static _LogDisabled;
  31993. private static _LogEnabled;
  31994. private static _WarnDisabled;
  31995. private static _WarnEnabled;
  31996. private static _ErrorDisabled;
  31997. private static _ErrorEnabled;
  31998. static Log: (message: string) => void;
  31999. static Warn: (message: string) => void;
  32000. static Error: (message: string) => void;
  32001. static readonly LogCache: string;
  32002. static ClearLogCache(): void;
  32003. static LogLevels: number;
  32004. /**
  32005. * Check if the loaded document was accessed via `file:`-Protocol.
  32006. * @returns boolean
  32007. */
  32008. static IsFileURL(): boolean;
  32009. static IsWindowObjectExist(): boolean;
  32010. private static _PerformanceNoneLogLevel;
  32011. private static _PerformanceUserMarkLogLevel;
  32012. private static _PerformanceConsoleLogLevel;
  32013. private static _performance;
  32014. static readonly PerformanceNoneLogLevel: number;
  32015. static readonly PerformanceUserMarkLogLevel: number;
  32016. static readonly PerformanceConsoleLogLevel: number;
  32017. static PerformanceLogLevel: number;
  32018. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32019. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32020. static _StartUserMark(counterName: string, condition?: boolean): void;
  32021. static _EndUserMark(counterName: string, condition?: boolean): void;
  32022. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  32023. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  32024. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32025. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32026. static readonly Now: number;
  32027. /**
  32028. * This method will return the name of the class used to create the instance of the given object.
  32029. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32030. * @param object the object to get the class name from
  32031. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  32032. */
  32033. static GetClassName(object: any, isType?: boolean): string;
  32034. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32035. /**
  32036. * This method will return the name of the full name of the class, including its owning module (if any).
  32037. * 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).
  32038. * @param object the object to get the class name from
  32039. * @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.
  32040. */
  32041. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32042. /**
  32043. * 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.
  32044. * @param array
  32045. */
  32046. static arrayOrStringFeeder(array: any): (i: number) => number;
  32047. /**
  32048. * Compute the hashCode of a stream of number
  32049. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  32050. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  32051. * @return the hash code computed
  32052. */
  32053. static hashCodeFromStream(feeder: (index: number) => number): number;
  32054. /**
  32055. * Returns a promise that resolves after the given amount of time.
  32056. * @param delay Number of milliseconds to delay
  32057. * @returns Promise that resolves after the given amount of time
  32058. */
  32059. static DelayAsync(delay: number): Promise<void>;
  32060. /**
  32061. * Gets the current gradient from an array of IValueGradient
  32062. * @param ratio defines the current ratio to get
  32063. * @param gradients defines the array of IValueGradient
  32064. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32065. */
  32066. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32067. }
  32068. /**
  32069. * This class is used to track a performance counter which is number based.
  32070. * The user has access to many properties which give statistics of different nature
  32071. *
  32072. * The implementer can track two kinds of Performance Counter: time and count
  32073. * 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.
  32074. * 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.
  32075. */
  32076. class PerfCounter {
  32077. static Enabled: boolean;
  32078. /**
  32079. * Returns the smallest value ever
  32080. */
  32081. readonly min: number;
  32082. /**
  32083. * Returns the biggest value ever
  32084. */
  32085. readonly max: number;
  32086. /**
  32087. * Returns the average value since the performance counter is running
  32088. */
  32089. readonly average: number;
  32090. /**
  32091. * Returns the average value of the last second the counter was monitored
  32092. */
  32093. readonly lastSecAverage: number;
  32094. /**
  32095. * Returns the current value
  32096. */
  32097. readonly current: number;
  32098. readonly total: number;
  32099. readonly count: number;
  32100. constructor();
  32101. /**
  32102. * Call this method to start monitoring a new frame.
  32103. * 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.
  32104. */
  32105. fetchNewFrame(): void;
  32106. /**
  32107. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32108. * @param newCount the count value to add to the monitored count
  32109. * @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.
  32110. */
  32111. addCount(newCount: number, fetchResult: boolean): void;
  32112. /**
  32113. * Start monitoring this performance counter
  32114. */
  32115. beginMonitoring(): void;
  32116. /**
  32117. * Compute the time lapsed since the previous beginMonitoring() call.
  32118. * @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
  32119. */
  32120. endMonitoring(newFrame?: boolean): void;
  32121. private _fetchResult;
  32122. private _startMonitoringTime;
  32123. private _min;
  32124. private _max;
  32125. private _average;
  32126. private _current;
  32127. private _totalValueCount;
  32128. private _totalAccumulated;
  32129. private _lastSecAverage;
  32130. private _lastSecAccumulated;
  32131. private _lastSecTime;
  32132. private _lastSecValueCount;
  32133. }
  32134. /**
  32135. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32136. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32137. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32138. * @param name The name of the class, case should be preserved
  32139. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32140. */
  32141. function className(name: string, module?: string): (target: Object) => void;
  32142. /**
  32143. * An implementation of a loop for asynchronous functions.
  32144. */
  32145. class AsyncLoop {
  32146. iterations: number;
  32147. private _fn;
  32148. private _successCallback;
  32149. index: number;
  32150. private _done;
  32151. /**
  32152. * Constroctor.
  32153. * @param iterations the number of iterations.
  32154. * @param _fn the function to run each iteration
  32155. * @param _successCallback the callback that will be called upon succesful execution
  32156. * @param offset starting offset.
  32157. */
  32158. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  32159. /**
  32160. * Execute the next iteration. Must be called after the last iteration was finished.
  32161. */
  32162. executeNext(): void;
  32163. /**
  32164. * Break the loop and run the success callback.
  32165. */
  32166. breakLoop(): void;
  32167. /**
  32168. * Helper function
  32169. */
  32170. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  32171. /**
  32172. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32173. * @param iterations total number of iterations
  32174. * @param syncedIterations number of synchronous iterations in each async iteration.
  32175. * @param fn the function to call each iteration.
  32176. * @param callback a success call back that will be called when iterating stops.
  32177. * @param breakFunction a break condition (optional)
  32178. * @param timeout timeout settings for the setTimeout function. default - 0.
  32179. * @constructor
  32180. */
  32181. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  32182. }
  32183. }
  32184. interface HTMLCanvasElement {
  32185. /** Track wether a record is in progress */
  32186. isRecording: boolean;
  32187. /** Capture Stream method defined by some browsers */
  32188. captureStream(fps?: number): MediaStream;
  32189. }
  32190. interface MediaRecorder {
  32191. /** Starts recording */
  32192. start(timeSlice: number): void;
  32193. /** Stops recording */
  32194. stop(): void;
  32195. /** Event raised when an error arised. */
  32196. onerror: (event: ErrorEvent) => void;
  32197. /** Event raised when the recording stops. */
  32198. onstop: (event: Event) => void;
  32199. /** Event raised when a new chunk of data is available and should be tracked. */
  32200. ondataavailable: (event: Event) => void;
  32201. }
  32202. interface MediaRecorderOptions {
  32203. /** The mime type you want to use as the recording container for the new MediaRecorder */
  32204. mimeType?: string;
  32205. /** The chosen bitrate for the audio component of the media. */
  32206. audioBitsPerSecond?: number;
  32207. /** The chosen bitrate for the video component of the media. */
  32208. videoBitsPerSecond?: number;
  32209. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  32210. bitsPerSecond?: number;
  32211. }
  32212. interface MediaRecorderConstructor {
  32213. /**
  32214. * A reference to the prototype.
  32215. */
  32216. readonly prototype: MediaRecorder;
  32217. /**
  32218. * Creates a new MediaRecorder.
  32219. * @param stream Defines the stream to record.
  32220. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  32221. */
  32222. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  32223. }
  32224. /**
  32225. * MediaRecoreder object available in some browsers.
  32226. */
  32227. declare var MediaRecorder: MediaRecorderConstructor;
  32228. declare module BABYLON {
  32229. /**
  32230. * This represents the different options avilable for the video capture.
  32231. */
  32232. interface VideoRecorderOptions {
  32233. /** Defines the mime type of the video */
  32234. mimeType: string;
  32235. /** Defines the video the video should be recorded at */
  32236. fps: number;
  32237. /** Defines the chunk size for the recording data */
  32238. recordChunckSize: number;
  32239. }
  32240. /**
  32241. * This can helps recording videos from BabylonJS.
  32242. * This is based on the available WebRTC functionalities of the browser.
  32243. *
  32244. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  32245. */
  32246. class VideoRecorder {
  32247. private static readonly _defaultOptions;
  32248. /**
  32249. * Returns wehther or not the VideoRecorder is available in your browser.
  32250. * @param engine Defines the Babylon Engine to check the support for
  32251. * @returns true if supported otherwise false
  32252. */
  32253. static IsSupported(engine: Engine): boolean;
  32254. private readonly _options;
  32255. private _canvas;
  32256. private _mediaRecorder;
  32257. private _recordedChunks;
  32258. private _fileName;
  32259. private _resolve;
  32260. private _reject;
  32261. /**
  32262. * True wether a recording is already in progress.
  32263. */
  32264. readonly isRecording: boolean;
  32265. /**
  32266. * Create a new VideoCapture object which can help converting what you see in Babylon to
  32267. * a video file.
  32268. * @param engine Defines the BabylonJS Engine you wish to record
  32269. * @param options Defines options that can be used to customized the capture
  32270. */
  32271. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  32272. /**
  32273. * Stops the current recording before the default capture timeout passed in the startRecording
  32274. * functions.
  32275. */
  32276. stopRecording(): void;
  32277. /**
  32278. * Starts recording the canvas for a max duration specified in parameters.
  32279. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  32280. * @param maxDuration Defines the maximum recording time in seconds.
  32281. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  32282. * @return a promise callback at the end of the recording with the video data in Blob.
  32283. */
  32284. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  32285. /**
  32286. * Releases internal resources used during the recording.
  32287. */
  32288. dispose(): void;
  32289. private _handleDataAvailable;
  32290. private _handleError;
  32291. private _handleStop;
  32292. }
  32293. }
  32294. declare module BABYLON {
  32295. /**
  32296. * Defines the potential axis of a Joystick
  32297. */
  32298. enum JoystickAxis {
  32299. /** X axis */
  32300. X = 0,
  32301. /** Y axis */
  32302. Y = 1,
  32303. /** Z axis */
  32304. Z = 2
  32305. }
  32306. /**
  32307. * Class used to define virtual joystick (used in touch mode)
  32308. */
  32309. class VirtualJoystick {
  32310. /**
  32311. * Gets or sets a boolean indicating that left and right values must be inverted
  32312. */
  32313. reverseLeftRight: boolean;
  32314. /**
  32315. * Gets or sets a boolean indicating that up and down values must be inverted
  32316. */
  32317. reverseUpDown: boolean;
  32318. /**
  32319. * Gets the offset value for the position (ie. the change of the position value)
  32320. */
  32321. deltaPosition: Vector3;
  32322. /**
  32323. * Gets a boolean indicating if the virtual joystick was pressed
  32324. */
  32325. pressed: boolean;
  32326. private static _globalJoystickIndex;
  32327. private static vjCanvas;
  32328. private static vjCanvasContext;
  32329. private static vjCanvasWidth;
  32330. private static vjCanvasHeight;
  32331. private static halfWidth;
  32332. private _action;
  32333. private _axisTargetedByLeftAndRight;
  32334. private _axisTargetedByUpAndDown;
  32335. private _joystickSensibility;
  32336. private _inversedSensibility;
  32337. private _joystickPointerID;
  32338. private _joystickColor;
  32339. private _joystickPointerPos;
  32340. private _joystickPreviousPointerPos;
  32341. private _joystickPointerStartPos;
  32342. private _deltaJoystickVector;
  32343. private _leftJoystick;
  32344. private _touches;
  32345. private _onPointerDownHandlerRef;
  32346. private _onPointerMoveHandlerRef;
  32347. private _onPointerUpHandlerRef;
  32348. private _onResize;
  32349. /**
  32350. * Creates a new virtual joystick
  32351. * @param leftJoystick defines that the joystick is for left hand (false by default)
  32352. */
  32353. constructor(leftJoystick?: boolean);
  32354. /**
  32355. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  32356. * @param newJoystickSensibility defines the new sensibility
  32357. */
  32358. setJoystickSensibility(newJoystickSensibility: number): void;
  32359. private _onPointerDown;
  32360. private _onPointerMove;
  32361. private _onPointerUp;
  32362. /**
  32363. * Change the color of the virtual joystick
  32364. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  32365. */
  32366. setJoystickColor(newColor: string): void;
  32367. /**
  32368. * Defines a callback to call when the joystick is touched
  32369. * @param action defines the callback
  32370. */
  32371. setActionOnTouch(action: () => any): void;
  32372. /**
  32373. * Defines which axis you'd like to control for left & right
  32374. * @param axis defines the axis to use
  32375. */
  32376. setAxisForLeftRight(axis: JoystickAxis): void;
  32377. /**
  32378. * Defines which axis you'd like to control for up & down
  32379. * @param axis defines the axis to use
  32380. */
  32381. setAxisForUpDown(axis: JoystickAxis): void;
  32382. private _drawVirtualJoystick;
  32383. /**
  32384. * Release internal HTML canvas
  32385. */
  32386. releaseCanvas(): void;
  32387. }
  32388. }
  32389. declare module BABYLON {
  32390. /**
  32391. * Helper class to push actions to a pool of workers.
  32392. */
  32393. class WorkerPool implements IDisposable {
  32394. private _workerInfos;
  32395. private _pendingActions;
  32396. /**
  32397. * Constructor
  32398. * @param workers Array of workers to use for actions
  32399. */
  32400. constructor(workers: Array<Worker>);
  32401. /**
  32402. * Terminates all workers and clears any pending actions.
  32403. */
  32404. dispose(): void;
  32405. /**
  32406. * Pushes an action to the worker pool. If all the workers are active, the action will be
  32407. * pended until a worker has completed its action.
  32408. * @param action The action to perform. Call onComplete when the action is complete.
  32409. */
  32410. push(action: (worker: Worker, onComplete: () => void) => void): void;
  32411. private _execute;
  32412. }
  32413. }
  32414. declare module BABYLON {
  32415. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  32416. readonly name: string;
  32417. private _zoomStopsAnimation;
  32418. private _idleRotationSpeed;
  32419. private _idleRotationWaitTime;
  32420. private _idleRotationSpinupTime;
  32421. /**
  32422. * Sets the flag that indicates if user zooming should stop animation.
  32423. */
  32424. /**
  32425. * Gets the flag that indicates if user zooming should stop animation.
  32426. */
  32427. zoomStopsAnimation: boolean;
  32428. /**
  32429. * Sets the default speed at which the camera rotates around the model.
  32430. */
  32431. /**
  32432. * Gets the default speed at which the camera rotates around the model.
  32433. */
  32434. idleRotationSpeed: number;
  32435. /**
  32436. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  32437. */
  32438. /**
  32439. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  32440. */
  32441. idleRotationWaitTime: number;
  32442. /**
  32443. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32444. */
  32445. /**
  32446. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32447. */
  32448. idleRotationSpinupTime: number;
  32449. /**
  32450. * Gets a value indicating if the camera is currently rotating because of this behavior
  32451. */
  32452. readonly rotationInProgress: boolean;
  32453. private _onPrePointerObservableObserver;
  32454. private _onAfterCheckInputsObserver;
  32455. private _attachedCamera;
  32456. private _isPointerDown;
  32457. private _lastFrameTime;
  32458. private _lastInteractionTime;
  32459. private _cameraRotationSpeed;
  32460. init(): void;
  32461. attach(camera: ArcRotateCamera): void;
  32462. detach(): void;
  32463. /**
  32464. * Returns true if user is scrolling.
  32465. * @return true if user is scrolling.
  32466. */
  32467. private _userIsZooming;
  32468. private _lastFrameRadius;
  32469. private _shouldAnimationStopForInteraction;
  32470. /**
  32471. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32472. */
  32473. private _applyUserInteraction;
  32474. private _userIsMoving;
  32475. }
  32476. }
  32477. declare module BABYLON {
  32478. /**
  32479. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32480. */
  32481. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32482. readonly name: string;
  32483. /**
  32484. * The easing function used by animations
  32485. */
  32486. static EasingFunction: BackEase;
  32487. /**
  32488. * The easing mode used by animations
  32489. */
  32490. static EasingMode: number;
  32491. /**
  32492. * The duration of the animation, in milliseconds
  32493. */
  32494. transitionDuration: number;
  32495. /**
  32496. * Length of the distance animated by the transition when lower radius is reached
  32497. */
  32498. lowerRadiusTransitionRange: number;
  32499. /**
  32500. * Length of the distance animated by the transition when upper radius is reached
  32501. */
  32502. upperRadiusTransitionRange: number;
  32503. private _autoTransitionRange;
  32504. /**
  32505. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32506. */
  32507. /**
  32508. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32509. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32510. */
  32511. autoTransitionRange: boolean;
  32512. private _attachedCamera;
  32513. private _onAfterCheckInputsObserver;
  32514. private _onMeshTargetChangedObserver;
  32515. init(): void;
  32516. attach(camera: ArcRotateCamera): void;
  32517. detach(): void;
  32518. private _radiusIsAnimating;
  32519. private _radiusBounceTransition;
  32520. private _animatables;
  32521. private _cachedWheelPrecision;
  32522. /**
  32523. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32524. * @param radiusLimit The limit to check against.
  32525. * @return Bool to indicate if at limit.
  32526. */
  32527. private _isRadiusAtLimit;
  32528. /**
  32529. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32530. * @param radiusDelta The delta by which to animate to. Can be negative.
  32531. */
  32532. private _applyBoundRadiusAnimation;
  32533. /**
  32534. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32535. */
  32536. protected _clearAnimationLocks(): void;
  32537. /**
  32538. * Stops and removes all animations that have been applied to the camera
  32539. */
  32540. stopAllAnimations(): void;
  32541. }
  32542. }
  32543. declare module BABYLON {
  32544. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32545. readonly name: string;
  32546. private _mode;
  32547. private _radiusScale;
  32548. private _positionScale;
  32549. private _defaultElevation;
  32550. private _elevationReturnTime;
  32551. private _elevationReturnWaitTime;
  32552. private _zoomStopsAnimation;
  32553. private _framingTime;
  32554. /**
  32555. * The easing function used by animations
  32556. */
  32557. static EasingFunction: ExponentialEase;
  32558. /**
  32559. * The easing mode used by animations
  32560. */
  32561. static EasingMode: number;
  32562. /**
  32563. * Sets the current mode used by the behavior
  32564. */
  32565. /**
  32566. * Gets current mode used by the behavior.
  32567. */
  32568. mode: number;
  32569. /**
  32570. * Sets the scale applied to the radius (1 by default)
  32571. */
  32572. /**
  32573. * Gets the scale applied to the radius
  32574. */
  32575. radiusScale: number;
  32576. /**
  32577. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32578. */
  32579. /**
  32580. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32581. */
  32582. positionScale: number;
  32583. /**
  32584. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32585. * behaviour is triggered, in radians.
  32586. */
  32587. /**
  32588. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32589. * behaviour is triggered, in radians.
  32590. */
  32591. defaultElevation: number;
  32592. /**
  32593. * Sets the time (in milliseconds) taken to return to the default beta position.
  32594. * Negative value indicates camera should not return to default.
  32595. */
  32596. /**
  32597. * Gets the time (in milliseconds) taken to return to the default beta position.
  32598. * Negative value indicates camera should not return to default.
  32599. */
  32600. elevationReturnTime: number;
  32601. /**
  32602. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32603. */
  32604. /**
  32605. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32606. */
  32607. elevationReturnWaitTime: number;
  32608. /**
  32609. * Sets the flag that indicates if user zooming should stop animation.
  32610. */
  32611. /**
  32612. * Gets the flag that indicates if user zooming should stop animation.
  32613. */
  32614. zoomStopsAnimation: boolean;
  32615. /**
  32616. * Sets the transition time when framing the mesh, in milliseconds
  32617. */
  32618. /**
  32619. * Gets the transition time when framing the mesh, in milliseconds
  32620. */
  32621. framingTime: number;
  32622. private _onPrePointerObservableObserver;
  32623. private _onAfterCheckInputsObserver;
  32624. private _onMeshTargetChangedObserver;
  32625. private _attachedCamera;
  32626. private _isPointerDown;
  32627. private _lastInteractionTime;
  32628. init(): void;
  32629. attach(camera: ArcRotateCamera): void;
  32630. detach(): void;
  32631. private _animatables;
  32632. private _betaIsAnimating;
  32633. private _betaTransition;
  32634. private _radiusTransition;
  32635. private _vectorTransition;
  32636. /**
  32637. * Targets the given mesh and updates zoom level accordingly.
  32638. * @param mesh The mesh to target.
  32639. * @param radius Optional. If a cached radius position already exists, overrides default.
  32640. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32641. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32642. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32643. */
  32644. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32645. /**
  32646. * Targets the given mesh with its children and updates zoom level accordingly.
  32647. * @param mesh The mesh to target.
  32648. * @param radius Optional. If a cached radius position already exists, overrides default.
  32649. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32650. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32651. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32652. */
  32653. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32654. /**
  32655. * Targets the given meshes with their children and updates zoom level accordingly.
  32656. * @param meshes The mesh to target.
  32657. * @param radius Optional. If a cached radius position already exists, overrides default.
  32658. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32661. */
  32662. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32663. /**
  32664. * Targets the given mesh and updates zoom level accordingly.
  32665. * @param mesh The mesh to target.
  32666. * @param radius Optional. If a cached radius position already exists, overrides default.
  32667. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32670. */
  32671. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32672. /**
  32673. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  32674. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  32675. * frustum width.
  32676. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  32677. * to fully enclose the mesh in the viewing frustum.
  32678. */
  32679. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  32680. /**
  32681. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  32682. * is automatically returned to its default position (expected to be above ground plane).
  32683. */
  32684. private _maintainCameraAboveGround;
  32685. /**
  32686. * Returns the frustum slope based on the canvas ratio and camera FOV
  32687. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  32688. */
  32689. private _getFrustumSlope;
  32690. /**
  32691. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  32692. */
  32693. private _clearAnimationLocks;
  32694. /**
  32695. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32696. */
  32697. private _applyUserInteraction;
  32698. /**
  32699. * Stops and removes all animations that have been applied to the camera
  32700. */
  32701. stopAllAnimations(): void;
  32702. /**
  32703. * Gets a value indicating if the user is moving the camera
  32704. */
  32705. readonly isUserIsMoving: boolean;
  32706. /**
  32707. * The camera can move all the way towards the mesh.
  32708. */
  32709. static IgnoreBoundsSizeMode: number;
  32710. /**
  32711. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  32712. */
  32713. static FitFrustumSidesMode: number;
  32714. }
  32715. }
  32716. declare module BABYLON {
  32717. /**
  32718. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  32719. */
  32720. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  32721. private ui;
  32722. /**
  32723. * The name of the behavior
  32724. */
  32725. name: string;
  32726. /**
  32727. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  32728. */
  32729. distanceAwayFromFace: number;
  32730. /**
  32731. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  32732. */
  32733. distanceAwayFromBottomOfFace: number;
  32734. private _faceVectors;
  32735. private _target;
  32736. private _scene;
  32737. private _onRenderObserver;
  32738. private _tmpMatrix;
  32739. private _tmpVector;
  32740. /**
  32741. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  32742. * @param ui The transform node that should be attched to the mesh
  32743. */
  32744. constructor(ui: BABYLON.TransformNode);
  32745. /**
  32746. * Initializes the behavior
  32747. */
  32748. init(): void;
  32749. private _closestFace;
  32750. private _zeroVector;
  32751. private _lookAtTmpMatrix;
  32752. private _lookAtToRef;
  32753. /**
  32754. * Attaches the AttachToBoxBehavior to the passed in mesh
  32755. * @param target The mesh that the specified node will be attached to
  32756. */
  32757. attach(target: BABYLON.Mesh): void;
  32758. /**
  32759. * Detaches the behavior from the mesh
  32760. */
  32761. detach(): void;
  32762. }
  32763. }
  32764. declare module BABYLON {
  32765. /**
  32766. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  32767. */
  32768. class FadeInOutBehavior implements Behavior<Mesh> {
  32769. /**
  32770. * Time in milliseconds to delay before fading in (Default: 0)
  32771. */
  32772. delay: number;
  32773. /**
  32774. * Time in milliseconds for the mesh to fade in (Default: 300)
  32775. */
  32776. fadeInTime: number;
  32777. private _millisecondsPerFrame;
  32778. private _hovered;
  32779. private _hoverValue;
  32780. private _ownerNode;
  32781. /**
  32782. * Instatiates the FadeInOutBehavior
  32783. */
  32784. constructor();
  32785. /**
  32786. * The name of the behavior
  32787. */
  32788. readonly name: string;
  32789. /**
  32790. * Initializes the behavior
  32791. */
  32792. init(): void;
  32793. /**
  32794. * Attaches the fade behavior on the passed in mesh
  32795. * @param ownerNode The mesh that will be faded in/out once attached
  32796. */
  32797. attach(ownerNode: Mesh): void;
  32798. /**
  32799. * Detaches the behavior from the mesh
  32800. */
  32801. detach(): void;
  32802. /**
  32803. * Triggers the mesh to begin fading in or out
  32804. * @param value if the object should fade in or out (true to fade in)
  32805. */
  32806. fadeIn(value: boolean): void;
  32807. private _update;
  32808. private _setAllVisibility;
  32809. }
  32810. }
  32811. declare module BABYLON {
  32812. /**
  32813. * A behavior that when attached to a mesh will allow the mesh to be scaled
  32814. */
  32815. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  32816. private _dragBehaviorA;
  32817. private _dragBehaviorB;
  32818. private _startDistance;
  32819. private _initialScale;
  32820. private _targetScale;
  32821. private _ownerNode;
  32822. private _sceneRenderObserver;
  32823. constructor();
  32824. /**
  32825. * The name of the behavior
  32826. */
  32827. readonly name: string;
  32828. /**
  32829. * Initializes the behavior
  32830. */
  32831. init(): void;
  32832. private _getCurrentDistance;
  32833. /**
  32834. * Attaches the scale behavior the passed in mesh
  32835. * @param ownerNode The mesh that will be scaled around once attached
  32836. */
  32837. attach(ownerNode: Mesh): void;
  32838. /**
  32839. * Detaches the behavior from the mesh
  32840. */
  32841. detach(): void;
  32842. }
  32843. }
  32844. declare module BABYLON {
  32845. /**
  32846. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  32847. */
  32848. class PointerDragBehavior implements Behavior<Mesh> {
  32849. private _attachedNode;
  32850. private _dragPlane;
  32851. private _scene;
  32852. private _pointerObserver;
  32853. private _beforeRenderObserver;
  32854. private static _planeScene;
  32855. /**
  32856. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  32857. */
  32858. maxDragAngle: number;
  32859. /**
  32860. * @hidden
  32861. */
  32862. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  32863. /**
  32864. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32865. */
  32866. currentDraggingPointerID: number;
  32867. /**
  32868. * The last position where the pointer hit the drag plane in world space
  32869. */
  32870. lastDragPosition: Vector3;
  32871. /**
  32872. * If the behavior is currently in a dragging state
  32873. */
  32874. dragging: boolean;
  32875. /**
  32876. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  32877. */
  32878. dragDeltaRatio: number;
  32879. /**
  32880. * If the drag plane orientation should be updated during the dragging (Default: true)
  32881. */
  32882. updateDragPlane: boolean;
  32883. private _debugMode;
  32884. private _moving;
  32885. /**
  32886. * Fires each time the attached mesh is dragged with the pointer
  32887. * * delta between last drag position and current drag position in world space
  32888. * * dragDistance along the drag axis
  32889. * * dragPlaneNormal normal of the current drag plane used during the drag
  32890. * * dragPlanePoint in world space where the drag intersects the drag plane
  32891. */
  32892. onDragObservable: Observable<{
  32893. delta: Vector3;
  32894. dragPlanePoint: Vector3;
  32895. dragPlaneNormal: Vector3;
  32896. dragDistance: number;
  32897. pointerId: number;
  32898. }>;
  32899. /**
  32900. * Fires each time a drag begins (eg. mouse down on mesh)
  32901. */
  32902. onDragStartObservable: Observable<{
  32903. dragPlanePoint: Vector3;
  32904. pointerId: number;
  32905. }>;
  32906. /**
  32907. * Fires each time a drag ends (eg. mouse release after drag)
  32908. */
  32909. onDragEndObservable: Observable<{
  32910. dragPlanePoint: Vector3;
  32911. pointerId: number;
  32912. }>;
  32913. /**
  32914. * If the attached mesh should be moved when dragged
  32915. */
  32916. moveAttached: boolean;
  32917. /**
  32918. * If the drag behavior will react to drag events (Default: true)
  32919. */
  32920. enabled: boolean;
  32921. /**
  32922. * If camera controls should be detached during the drag
  32923. */
  32924. detachCameraControls: boolean;
  32925. /**
  32926. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  32927. */
  32928. useObjectOrienationForDragging: boolean;
  32929. private _options;
  32930. /**
  32931. * Creates a pointer drag behavior that can be attached to a mesh
  32932. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  32933. */
  32934. constructor(options?: {
  32935. dragAxis?: Vector3;
  32936. dragPlaneNormal?: Vector3;
  32937. });
  32938. /**
  32939. * The name of the behavior
  32940. */
  32941. readonly name: string;
  32942. /**
  32943. * Initializes the behavior
  32944. */
  32945. init(): void;
  32946. private _tmpVector;
  32947. private _alternatePickedPoint;
  32948. private _worldDragAxis;
  32949. private _targetPosition;
  32950. private _attachedElement;
  32951. /**
  32952. * Attaches the drag behavior the passed in mesh
  32953. * @param ownerNode The mesh that will be dragged around once attached
  32954. */
  32955. attach(ownerNode: Mesh): void;
  32956. releaseDrag(): void;
  32957. private _startDragRay;
  32958. private _lastPointerRay;
  32959. /**
  32960. * Simulates the start of a pointer drag event on the behavior
  32961. * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
  32962. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  32963. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  32964. */
  32965. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  32966. private _startDrag;
  32967. private _dragDelta;
  32968. private _moveDrag;
  32969. private _pickWithRayOnDragPlane;
  32970. private _pointA;
  32971. private _pointB;
  32972. private _pointC;
  32973. private _lineA;
  32974. private _lineB;
  32975. private _localAxis;
  32976. private _lookAt;
  32977. private _updateDragPlanePosition;
  32978. /**
  32979. * Detaches the behavior from the mesh
  32980. */
  32981. detach(): void;
  32982. }
  32983. }
  32984. declare module BABYLON {
  32985. /**
  32986. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  32987. */
  32988. class SixDofDragBehavior implements Behavior<Mesh> {
  32989. private static _virtualScene;
  32990. private _ownerNode;
  32991. private _sceneRenderObserver;
  32992. private _scene;
  32993. private _targetPosition;
  32994. private _virtualOriginMesh;
  32995. private _virtualDragMesh;
  32996. private _pointerObserver;
  32997. private _moving;
  32998. private _startingOrientation;
  32999. /**
  33000. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  33001. */
  33002. private zDragFactor;
  33003. /**
  33004. * If the behavior is currently in a dragging state
  33005. */
  33006. dragging: boolean;
  33007. /**
  33008. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  33009. */
  33010. dragDeltaRatio: number;
  33011. /**
  33012. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33013. */
  33014. currentDraggingPointerID: number;
  33015. /**
  33016. * If camera controls should be detached during the drag
  33017. */
  33018. detachCameraControls: boolean;
  33019. constructor();
  33020. /**
  33021. * The name of the behavior
  33022. */
  33023. readonly name: string;
  33024. /**
  33025. * Initializes the behavior
  33026. */
  33027. init(): void;
  33028. /**
  33029. * Attaches the scale behavior the passed in mesh
  33030. * @param ownerNode The mesh that will be scaled around once attached
  33031. */
  33032. attach(ownerNode: Mesh): void;
  33033. /**
  33034. * Detaches the behavior from the mesh
  33035. */
  33036. detach(): void;
  33037. }
  33038. }
  33039. declare module BABYLON {
  33040. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  33041. camera: ArcRotateCamera;
  33042. gamepad: Nullable<Gamepad>;
  33043. private _onGamepadConnectedObserver;
  33044. private _onGamepadDisconnectedObserver;
  33045. gamepadRotationSensibility: number;
  33046. gamepadMoveSensibility: number;
  33047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33048. detachControl(element: Nullable<HTMLElement>): void;
  33049. checkInputs(): void;
  33050. getClassName(): string;
  33051. getSimpleName(): string;
  33052. }
  33053. }
  33054. declare module BABYLON {
  33055. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33056. camera: ArcRotateCamera;
  33057. private _keys;
  33058. keysUp: number[];
  33059. keysDown: number[];
  33060. keysLeft: number[];
  33061. keysRight: number[];
  33062. keysReset: number[];
  33063. panningSensibility: number;
  33064. zoomingSensibility: number;
  33065. useAltToZoom: boolean;
  33066. private _ctrlPressed;
  33067. private _altPressed;
  33068. private _onCanvasBlurObserver;
  33069. private _onKeyboardObserver;
  33070. private _engine;
  33071. private _scene;
  33072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33073. detachControl(element: Nullable<HTMLElement>): void;
  33074. checkInputs(): void;
  33075. getClassName(): string;
  33076. getSimpleName(): string;
  33077. }
  33078. }
  33079. declare module BABYLON {
  33080. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33081. camera: ArcRotateCamera;
  33082. private _wheel;
  33083. private _observer;
  33084. wheelPrecision: number;
  33085. /**
  33086. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33087. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33088. */
  33089. wheelDeltaPercentage: number;
  33090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33091. detachControl(element: Nullable<HTMLElement>): void;
  33092. getClassName(): string;
  33093. getSimpleName(): string;
  33094. }
  33095. }
  33096. declare module BABYLON {
  33097. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33098. camera: ArcRotateCamera;
  33099. buttons: number[];
  33100. angularSensibilityX: number;
  33101. angularSensibilityY: number;
  33102. pinchPrecision: number;
  33103. /**
  33104. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33105. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33106. */
  33107. pinchDeltaPercentage: number;
  33108. panningSensibility: number;
  33109. multiTouchPanning: boolean;
  33110. multiTouchPanAndZoom: boolean;
  33111. private _isPanClick;
  33112. pinchInwards: boolean;
  33113. private _pointerInput;
  33114. private _observer;
  33115. private _onMouseMove;
  33116. private _onGestureStart;
  33117. private _onGesture;
  33118. private _MSGestureHandler;
  33119. private _onLostFocus;
  33120. private _onContextMenu;
  33121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33122. detachControl(element: Nullable<HTMLElement>): void;
  33123. getClassName(): string;
  33124. getSimpleName(): string;
  33125. }
  33126. }
  33127. declare module BABYLON {
  33128. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  33129. camera: ArcRotateCamera;
  33130. alphaCorrection: number;
  33131. betaCorrection: number;
  33132. gammaCorrection: number;
  33133. private _alpha;
  33134. private _gamma;
  33135. private _dirty;
  33136. private _deviceOrientationHandler;
  33137. constructor();
  33138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33139. /** @hidden */
  33140. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  33141. checkInputs(): void;
  33142. detachControl(element: Nullable<HTMLElement>): void;
  33143. getClassName(): string;
  33144. getSimpleName(): string;
  33145. }
  33146. }
  33147. declare module BABYLON {
  33148. /**
  33149. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  33150. * Screen rotation is taken into account.
  33151. */
  33152. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  33153. private _camera;
  33154. private _screenOrientationAngle;
  33155. private _constantTranform;
  33156. private _screenQuaternion;
  33157. private _alpha;
  33158. private _beta;
  33159. private _gamma;
  33160. constructor();
  33161. camera: FreeCamera;
  33162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33163. private _orientationChanged;
  33164. private _deviceOrientation;
  33165. detachControl(element: Nullable<HTMLElement>): void;
  33166. checkInputs(): void;
  33167. getClassName(): string;
  33168. getSimpleName(): string;
  33169. }
  33170. }
  33171. declare module BABYLON {
  33172. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  33173. camera: FreeCamera;
  33174. gamepad: Nullable<Gamepad>;
  33175. private _onGamepadConnectedObserver;
  33176. private _onGamepadDisconnectedObserver;
  33177. gamepadAngularSensibility: number;
  33178. gamepadMoveSensibility: number;
  33179. private _cameraTransform;
  33180. private _deltaTransform;
  33181. private _vector3;
  33182. private _vector2;
  33183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33184. detachControl(element: Nullable<HTMLElement>): void;
  33185. checkInputs(): void;
  33186. getClassName(): string;
  33187. getSimpleName(): string;
  33188. }
  33189. }
  33190. declare module BABYLON {
  33191. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  33192. camera: FreeCamera;
  33193. private _keys;
  33194. private _onCanvasBlurObserver;
  33195. private _onKeyboardObserver;
  33196. private _engine;
  33197. private _scene;
  33198. keysUp: number[];
  33199. keysDown: number[];
  33200. keysLeft: number[];
  33201. keysRight: number[];
  33202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33203. detachControl(element: Nullable<HTMLElement>): void;
  33204. checkInputs(): void;
  33205. getClassName(): string;
  33206. /** @hidden */
  33207. _onLostFocus(e: FocusEvent): void;
  33208. getSimpleName(): string;
  33209. }
  33210. }
  33211. declare module BABYLON {
  33212. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  33213. touchEnabled: boolean;
  33214. camera: FreeCamera;
  33215. buttons: number[];
  33216. angularSensibility: number;
  33217. private _pointerInput;
  33218. private _onMouseMove;
  33219. private _observer;
  33220. private previousPosition;
  33221. constructor(touchEnabled?: boolean);
  33222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33223. detachControl(element: Nullable<HTMLElement>): void;
  33224. getClassName(): string;
  33225. getSimpleName(): string;
  33226. }
  33227. }
  33228. declare module BABYLON {
  33229. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  33230. camera: FreeCamera;
  33231. private _offsetX;
  33232. private _offsetY;
  33233. private _pointerPressed;
  33234. private _pointerInput;
  33235. private _observer;
  33236. private _onLostFocus;
  33237. touchAngularSensibility: number;
  33238. touchMoveSensibility: number;
  33239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33240. detachControl(element: Nullable<HTMLElement>): void;
  33241. checkInputs(): void;
  33242. getClassName(): string;
  33243. getSimpleName(): string;
  33244. }
  33245. }
  33246. declare module BABYLON {
  33247. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  33248. camera: FreeCamera;
  33249. private _leftjoystick;
  33250. private _rightjoystick;
  33251. getLeftJoystick(): VirtualJoystick;
  33252. getRightJoystick(): VirtualJoystick;
  33253. checkInputs(): void;
  33254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33255. detachControl(element: Nullable<HTMLElement>): void;
  33256. getClassName(): string;
  33257. getSimpleName(): string;
  33258. }
  33259. }
  33260. declare module BABYLON {
  33261. /**
  33262. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  33263. */
  33264. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  33265. /**
  33266. * Creates a new AnaglyphArcRotateCamera
  33267. * @param name defines camera name
  33268. * @param alpha defines alpha angle (in radians)
  33269. * @param beta defines beta angle (in radians)
  33270. * @param radius defines radius
  33271. * @param target defines camera target
  33272. * @param interaxialDistance defines distance between each color axis
  33273. * @param scene defines the hosting scene
  33274. */
  33275. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  33276. /**
  33277. * Gets camera class name
  33278. * @returns AnaglyphArcRotateCamera
  33279. */
  33280. getClassName(): string;
  33281. }
  33282. }
  33283. declare module BABYLON {
  33284. /**
  33285. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  33286. */
  33287. class AnaglyphFreeCamera extends FreeCamera {
  33288. /**
  33289. * Creates a new AnaglyphFreeCamera
  33290. * @param name defines camera name
  33291. * @param position defines initial position
  33292. * @param interaxialDistance defines distance between each color axis
  33293. * @param scene defines the hosting scene
  33294. */
  33295. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33296. /**
  33297. * Gets camera class name
  33298. * @returns AnaglyphFreeCamera
  33299. */
  33300. getClassName(): string;
  33301. }
  33302. }
  33303. declare module BABYLON {
  33304. /**
  33305. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  33306. */
  33307. class AnaglyphGamepadCamera extends GamepadCamera {
  33308. /**
  33309. * Creates a new AnaglyphGamepadCamera
  33310. * @param name defines camera name
  33311. * @param position defines initial position
  33312. * @param interaxialDistance defines distance between each color axis
  33313. * @param scene defines the hosting scene
  33314. */
  33315. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33316. /**
  33317. * Gets camera class name
  33318. * @returns AnaglyphGamepadCamera
  33319. */
  33320. getClassName(): string;
  33321. }
  33322. }
  33323. declare module BABYLON {
  33324. /**
  33325. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  33326. */
  33327. class AnaglyphUniversalCamera extends UniversalCamera {
  33328. /**
  33329. * Creates a new AnaglyphUniversalCamera
  33330. * @param name defines camera name
  33331. * @param position defines initial position
  33332. * @param interaxialDistance defines distance between each color axis
  33333. * @param scene defines the hosting scene
  33334. */
  33335. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33336. /**
  33337. * Gets camera class name
  33338. * @returns AnaglyphUniversalCamera
  33339. */
  33340. getClassName(): string;
  33341. }
  33342. }
  33343. declare module BABYLON {
  33344. /**
  33345. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  33346. */
  33347. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  33348. /**
  33349. * Creates a new StereoscopicArcRotateCamera
  33350. * @param name defines camera name
  33351. * @param alpha defines alpha angle (in radians)
  33352. * @param beta defines beta angle (in radians)
  33353. * @param radius defines radius
  33354. * @param target defines camera target
  33355. * @param interaxialDistance defines distance between each color axis
  33356. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33357. * @param scene defines the hosting scene
  33358. */
  33359. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33360. /**
  33361. * Gets camera class name
  33362. * @returns StereoscopicArcRotateCamera
  33363. */
  33364. getClassName(): string;
  33365. }
  33366. }
  33367. declare module BABYLON {
  33368. /**
  33369. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  33370. */
  33371. class StereoscopicFreeCamera extends FreeCamera {
  33372. /**
  33373. * Creates a new StereoscopicFreeCamera
  33374. * @param name defines camera name
  33375. * @param position defines initial position
  33376. * @param interaxialDistance defines distance between each color axis
  33377. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33378. * @param scene defines the hosting scene
  33379. */
  33380. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33381. /**
  33382. * Gets camera class name
  33383. * @returns StereoscopicFreeCamera
  33384. */
  33385. getClassName(): string;
  33386. }
  33387. }
  33388. declare module BABYLON {
  33389. /**
  33390. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  33391. */
  33392. class StereoscopicGamepadCamera extends GamepadCamera {
  33393. /**
  33394. * Creates a new StereoscopicGamepadCamera
  33395. * @param name defines camera name
  33396. * @param position defines initial position
  33397. * @param interaxialDistance defines distance between each color axis
  33398. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33399. * @param scene defines the hosting scene
  33400. */
  33401. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33402. /**
  33403. * Gets camera class name
  33404. * @returns StereoscopicGamepadCamera
  33405. */
  33406. getClassName(): string;
  33407. }
  33408. }
  33409. declare module BABYLON {
  33410. /**
  33411. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  33412. */
  33413. class StereoscopicUniversalCamera extends UniversalCamera {
  33414. /**
  33415. * Creates a new StereoscopicUniversalCamera
  33416. * @param name defines camera name
  33417. * @param position defines initial position
  33418. * @param interaxialDistance defines distance between each color axis
  33419. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33420. * @param scene defines the hosting scene
  33421. */
  33422. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33423. /**
  33424. * Gets camera class name
  33425. * @returns StereoscopicUniversalCamera
  33426. */
  33427. getClassName(): string;
  33428. }
  33429. }
  33430. declare module BABYLON {
  33431. class VRCameraMetrics {
  33432. hResolution: number;
  33433. vResolution: number;
  33434. hScreenSize: number;
  33435. vScreenSize: number;
  33436. vScreenCenter: number;
  33437. eyeToScreenDistance: number;
  33438. lensSeparationDistance: number;
  33439. interpupillaryDistance: number;
  33440. distortionK: number[];
  33441. chromaAbCorrection: number[];
  33442. postProcessScaleFactor: number;
  33443. lensCenterOffset: number;
  33444. compensateDistortion: boolean;
  33445. readonly aspectRatio: number;
  33446. readonly aspectRatioFov: number;
  33447. readonly leftHMatrix: Matrix;
  33448. readonly rightHMatrix: Matrix;
  33449. readonly leftPreViewMatrix: Matrix;
  33450. readonly rightPreViewMatrix: Matrix;
  33451. static GetDefault(): VRCameraMetrics;
  33452. }
  33453. }
  33454. declare module BABYLON {
  33455. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  33456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33457. getClassName(): string;
  33458. }
  33459. }
  33460. declare module BABYLON {
  33461. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  33462. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33463. getClassName(): string;
  33464. }
  33465. }
  33466. declare module BABYLON {
  33467. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  33468. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33469. getClassName(): string;
  33470. }
  33471. }
  33472. declare module BABYLON {
  33473. /**
  33474. * Options to modify the vr teleportation behavior.
  33475. */
  33476. interface VRTeleportationOptions {
  33477. /**
  33478. * The name of the mesh which should be used as the teleportation floor. (default: null)
  33479. */
  33480. floorMeshName?: string;
  33481. /**
  33482. * A list of meshes to be used as the teleportation floor. (default: empty)
  33483. */
  33484. floorMeshes?: Mesh[];
  33485. }
  33486. /**
  33487. * Options to modify the vr experience helper's behavior.
  33488. */
  33489. interface VRExperienceHelperOptions extends WebVROptions {
  33490. /**
  33491. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  33492. */
  33493. createDeviceOrientationCamera?: boolean;
  33494. /**
  33495. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  33496. */
  33497. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  33498. /**
  33499. * Uses the main button on the controller to toggle the laser casted. (default: true)
  33500. */
  33501. laserToggle?: boolean;
  33502. /**
  33503. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  33504. */
  33505. floorMeshes?: Mesh[];
  33506. }
  33507. /**
  33508. * Helps to quickly add VR support to an existing scene.
  33509. * See http://doc.babylonjs.com/how_to/webvr_helper
  33510. */
  33511. class VRExperienceHelper {
  33512. /** Options to modify the vr experience helper's behavior. */
  33513. webVROptions: VRExperienceHelperOptions;
  33514. private _scene;
  33515. private _position;
  33516. private _btnVR;
  33517. private _btnVRDisplayed;
  33518. private _webVRsupported;
  33519. private _webVRready;
  33520. private _webVRrequesting;
  33521. private _webVRpresenting;
  33522. private _hasEnteredVR;
  33523. private _fullscreenVRpresenting;
  33524. private _canvas;
  33525. private _webVRCamera;
  33526. private _vrDeviceOrientationCamera;
  33527. private _deviceOrientationCamera;
  33528. private _existingCamera;
  33529. private _onKeyDown;
  33530. private _onVrDisplayPresentChange;
  33531. private _onVRDisplayChanged;
  33532. private _onVRRequestPresentStart;
  33533. private _onVRRequestPresentComplete;
  33534. /**
  33535. * Observable raised when entering VR.
  33536. */
  33537. onEnteringVRObservable: Observable<VRExperienceHelper>;
  33538. /**
  33539. * Observable raised when exiting VR.
  33540. */
  33541. onExitingVRObservable: Observable<VRExperienceHelper>;
  33542. /**
  33543. * Observable raised when controller mesh is loaded.
  33544. */
  33545. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33546. /** Return this.onEnteringVRObservable
  33547. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  33548. */
  33549. readonly onEnteringVR: Observable<VRExperienceHelper>;
  33550. /** Return this.onExitingVRObservable
  33551. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  33552. */
  33553. readonly onExitingVR: Observable<VRExperienceHelper>;
  33554. /** Return this.onControllerMeshLoadedObservable
  33555. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  33556. */
  33557. readonly onControllerMeshLoaded: Observable<WebVRController>;
  33558. private _rayLength;
  33559. private _useCustomVRButton;
  33560. private _teleportationRequested;
  33561. private _teleportActive;
  33562. private _floorMeshName;
  33563. private _floorMeshesCollection;
  33564. private _rotationAllowed;
  33565. private _teleportBackwardsVector;
  33566. private _teleportationTarget;
  33567. private _isDefaultTeleportationTarget;
  33568. private _postProcessMove;
  33569. private _teleportationFillColor;
  33570. private _teleportationBorderColor;
  33571. private _rotationAngle;
  33572. private _haloCenter;
  33573. private _cameraGazer;
  33574. private _padSensibilityUp;
  33575. private _padSensibilityDown;
  33576. private _leftController;
  33577. private _rightController;
  33578. /**
  33579. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  33580. */
  33581. onNewMeshSelected: Observable<AbstractMesh>;
  33582. /**
  33583. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  33584. */
  33585. onNewMeshPicked: Observable<PickingInfo>;
  33586. private _circleEase;
  33587. /**
  33588. * Observable raised before camera teleportation
  33589. */
  33590. onBeforeCameraTeleport: Observable<Vector3>;
  33591. /**
  33592. * Observable raised after camera teleportation
  33593. */
  33594. onAfterCameraTeleport: Observable<Vector3>;
  33595. /**
  33596. * Observable raised when current selected mesh gets unselected
  33597. */
  33598. onSelectedMeshUnselected: Observable<AbstractMesh>;
  33599. private _raySelectionPredicate;
  33600. /**
  33601. * To be optionaly changed by user to define custom ray selection
  33602. */
  33603. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  33604. /**
  33605. * To be optionaly changed by user to define custom selection logic (after ray selection)
  33606. */
  33607. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  33608. /**
  33609. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  33610. */
  33611. teleportationEnabled: boolean;
  33612. private _defaultHeight;
  33613. private _teleportationInitialized;
  33614. private _interactionsEnabled;
  33615. private _interactionsRequested;
  33616. private _displayGaze;
  33617. private _displayLaserPointer;
  33618. /**
  33619. * The mesh used to display where the user is going to teleport.
  33620. */
  33621. /**
  33622. * Sets the mesh to be used to display where the user is going to teleport.
  33623. */
  33624. teleportationTarget: Mesh;
  33625. /**
  33626. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  33627. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  33628. * See http://doc.babylonjs.com/resources/baking_transformations
  33629. */
  33630. gazeTrackerMesh: Mesh;
  33631. /**
  33632. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  33633. */
  33634. updateGazeTrackerScale: boolean;
  33635. /**
  33636. * The gaze tracking mesh corresponding to the left controller
  33637. */
  33638. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  33639. /**
  33640. * The gaze tracking mesh corresponding to the right controller
  33641. */
  33642. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  33643. /**
  33644. * If the ray of the gaze should be displayed.
  33645. */
  33646. /**
  33647. * Sets if the ray of the gaze should be displayed.
  33648. */
  33649. displayGaze: boolean;
  33650. /**
  33651. * If the ray of the LaserPointer should be displayed.
  33652. */
  33653. /**
  33654. * Sets if the ray of the LaserPointer should be displayed.
  33655. */
  33656. displayLaserPointer: boolean;
  33657. /**
  33658. * The deviceOrientationCamera used as the camera when not in VR.
  33659. */
  33660. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  33661. /**
  33662. * Based on the current WebVR support, returns the current VR camera used.
  33663. */
  33664. readonly currentVRCamera: Nullable<Camera>;
  33665. /**
  33666. * The webVRCamera which is used when in VR.
  33667. */
  33668. readonly webVRCamera: WebVRFreeCamera;
  33669. /**
  33670. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  33671. */
  33672. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  33673. private readonly _teleportationRequestInitiated;
  33674. /**
  33675. * Instantiates a VRExperienceHelper.
  33676. * Helps to quickly add VR support to an existing scene.
  33677. * @param scene The scene the VRExperienceHelper belongs to.
  33678. * @param webVROptions Options to modify the vr experience helper's behavior.
  33679. */
  33680. constructor(scene: Scene,
  33681. /** Options to modify the vr experience helper's behavior. */
  33682. webVROptions?: VRExperienceHelperOptions);
  33683. private _onDefaultMeshLoaded;
  33684. private _onResize;
  33685. private _onFullscreenChange;
  33686. /**
  33687. * Gets a value indicating if we are currently in VR mode.
  33688. */
  33689. readonly isInVRMode: boolean;
  33690. private onVrDisplayPresentChange;
  33691. private onVRDisplayChanged;
  33692. private moveButtonToBottomRight;
  33693. private displayVRButton;
  33694. private updateButtonVisibility;
  33695. /**
  33696. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  33697. * Otherwise, will use the fullscreen API.
  33698. */
  33699. enterVR(): void;
  33700. /**
  33701. * Attempt to exit VR, or fullscreen.
  33702. */
  33703. exitVR(): void;
  33704. /**
  33705. * The position of the vr experience helper.
  33706. */
  33707. /**
  33708. * Sets the position of the vr experience helper.
  33709. */
  33710. position: Vector3;
  33711. /**
  33712. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  33713. */
  33714. enableInteractions(): void;
  33715. private readonly _noControllerIsActive;
  33716. private beforeRender;
  33717. private _isTeleportationFloor;
  33718. /**
  33719. * Adds a floor mesh to be used for teleportation.
  33720. * @param floorMesh the mesh to be used for teleportation.
  33721. */
  33722. addFloorMesh(floorMesh: Mesh): void;
  33723. /**
  33724. * Removes a floor mesh from being used for teleportation.
  33725. * @param floorMesh the mesh to be removed.
  33726. */
  33727. removeFloorMesh(floorMesh: Mesh): void;
  33728. /**
  33729. * Enables interactions and teleportation using the VR controllers and gaze.
  33730. * @param vrTeleportationOptions options to modify teleportation behavior.
  33731. */
  33732. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  33733. private _onNewGamepadConnected;
  33734. private _tryEnableInteractionOnController;
  33735. private _onNewGamepadDisconnected;
  33736. private _enableInteractionOnController;
  33737. private _checkTeleportWithRay;
  33738. private _checkRotate;
  33739. private _checkTeleportBackwards;
  33740. private _enableTeleportationOnController;
  33741. private _createTeleportationCircles;
  33742. private _displayTeleportationTarget;
  33743. private _hideTeleportationTarget;
  33744. private _rotateCamera;
  33745. private _moveTeleportationSelectorTo;
  33746. private _workingVector;
  33747. private _workingQuaternion;
  33748. private _workingMatrix;
  33749. private _teleportCamera;
  33750. private _convertNormalToDirectionOfRay;
  33751. private _castRayAndSelectObject;
  33752. private _notifySelectedMeshUnselected;
  33753. /**
  33754. * Sets the color of the laser ray from the vr controllers.
  33755. * @param color new color for the ray.
  33756. */
  33757. changeLaserColor(color: Color3): void;
  33758. /**
  33759. * Sets the color of the ray from the vr headsets gaze.
  33760. * @param color new color for the ray.
  33761. */
  33762. changeGazeColor(color: Color3): void;
  33763. /**
  33764. * Exits VR and disposes of the vr experience helper
  33765. */
  33766. dispose(): void;
  33767. /**
  33768. * Gets the name of the VRExperienceHelper class
  33769. * @returns "VRExperienceHelper"
  33770. */
  33771. getClassName(): string;
  33772. }
  33773. }
  33774. declare module BABYLON {
  33775. /**
  33776. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  33777. * IMPORTANT!! The data is right-hand data.
  33778. * @export
  33779. * @interface DevicePose
  33780. */
  33781. interface DevicePose {
  33782. /**
  33783. * The position of the device, values in array are [x,y,z].
  33784. */
  33785. readonly position: Nullable<Float32Array>;
  33786. /**
  33787. * The linearVelocity of the device, values in array are [x,y,z].
  33788. */
  33789. readonly linearVelocity: Nullable<Float32Array>;
  33790. /**
  33791. * The linearAcceleration of the device, values in array are [x,y,z].
  33792. */
  33793. readonly linearAcceleration: Nullable<Float32Array>;
  33794. /**
  33795. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  33796. */
  33797. readonly orientation: Nullable<Float32Array>;
  33798. /**
  33799. * The angularVelocity of the device, values in array are [x,y,z].
  33800. */
  33801. readonly angularVelocity: Nullable<Float32Array>;
  33802. /**
  33803. * The angularAcceleration of the device, values in array are [x,y,z].
  33804. */
  33805. readonly angularAcceleration: Nullable<Float32Array>;
  33806. }
  33807. /**
  33808. * Interface representing a pose controlled object in Babylon.
  33809. * A pose controlled object has both regular pose values as well as pose values
  33810. * from an external device such as a VR head mounted display
  33811. */
  33812. interface PoseControlled {
  33813. /**
  33814. * The position of the object in babylon space.
  33815. */
  33816. position: Vector3;
  33817. /**
  33818. * The rotation quaternion of the object in babylon space.
  33819. */
  33820. rotationQuaternion: Quaternion;
  33821. /**
  33822. * The position of the device in babylon space.
  33823. */
  33824. devicePosition?: Vector3;
  33825. /**
  33826. * The rotation quaternion of the device in babylon space.
  33827. */
  33828. deviceRotationQuaternion: Quaternion;
  33829. /**
  33830. * The raw pose coming from the device.
  33831. */
  33832. rawPose: Nullable<DevicePose>;
  33833. /**
  33834. * The scale of the device to be used when translating from device space to babylon space.
  33835. */
  33836. deviceScaleFactor: number;
  33837. /**
  33838. * Updates the poseControlled values based on the input device pose.
  33839. * @param poseData the pose data to update the object with
  33840. */
  33841. updateFromDevice(poseData: DevicePose): void;
  33842. }
  33843. /**
  33844. * Set of options to customize the webVRCamera
  33845. */
  33846. interface WebVROptions {
  33847. /**
  33848. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  33849. */
  33850. trackPosition?: boolean;
  33851. /**
  33852. * Sets the scale of the vrDevice in babylon space. (default: 1)
  33853. */
  33854. positionScale?: number;
  33855. /**
  33856. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  33857. */
  33858. displayName?: string;
  33859. /**
  33860. * Should the native controller meshes be initialized. (default: true)
  33861. */
  33862. controllerMeshes?: boolean;
  33863. /**
  33864. * Creating a default HemiLight only on controllers. (default: true)
  33865. */
  33866. defaultLightingOnControllers?: boolean;
  33867. /**
  33868. * If you don't want to use the default VR button of the helper. (default: false)
  33869. */
  33870. useCustomVRButton?: boolean;
  33871. /**
  33872. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  33873. */
  33874. customVRButton?: HTMLButtonElement;
  33875. /**
  33876. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  33877. */
  33878. rayLength?: number;
  33879. /**
  33880. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  33881. */
  33882. defaultHeight?: number;
  33883. }
  33884. /**
  33885. * This represents a WebVR camera.
  33886. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  33887. * @example http://doc.babylonjs.com/how_to/webvr_camera
  33888. */
  33889. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  33890. private webVROptions;
  33891. /**
  33892. * @hidden
  33893. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  33894. */
  33895. _vrDevice: any;
  33896. /**
  33897. * The rawPose of the vrDevice.
  33898. */
  33899. rawPose: Nullable<DevicePose>;
  33900. private _onVREnabled;
  33901. private _specsVersion;
  33902. private _attached;
  33903. private _frameData;
  33904. protected _descendants: Array<Node>;
  33905. private _deviceRoomPosition;
  33906. /** @hidden */
  33907. _deviceRoomRotationQuaternion: Quaternion;
  33908. private _standingMatrix;
  33909. /**
  33910. * Represents device position in babylon space.
  33911. */
  33912. devicePosition: Vector3;
  33913. /**
  33914. * Represents device rotation in babylon space.
  33915. */
  33916. deviceRotationQuaternion: Quaternion;
  33917. /**
  33918. * The scale of the device to be used when translating from device space to babylon space.
  33919. */
  33920. deviceScaleFactor: number;
  33921. private _deviceToWorld;
  33922. private _worldToDevice;
  33923. /**
  33924. * References to the webVR controllers for the vrDevice.
  33925. */
  33926. controllers: Array<WebVRController>;
  33927. /**
  33928. * Emits an event when a controller is attached.
  33929. */
  33930. onControllersAttachedObservable: Observable<WebVRController[]>;
  33931. /**
  33932. * Emits an event when a controller's mesh has been loaded;
  33933. */
  33934. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33935. /**
  33936. * Emits an event when the HMD's pose has been updated.
  33937. */
  33938. onPoseUpdatedFromDeviceObservable: Observable<any>;
  33939. private _poseSet;
  33940. /**
  33941. * If the rig cameras be used as parent instead of this camera.
  33942. */
  33943. rigParenting: boolean;
  33944. private _lightOnControllers;
  33945. private _defaultHeight?;
  33946. /**
  33947. * Instantiates a WebVRFreeCamera.
  33948. * @param name The name of the WebVRFreeCamera
  33949. * @param position The starting anchor position for the camera
  33950. * @param scene The scene the camera belongs to
  33951. * @param webVROptions a set of customizable options for the webVRCamera
  33952. */
  33953. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  33954. /**
  33955. * Gets the device distance from the ground in meters.
  33956. * @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.
  33957. */
  33958. deviceDistanceToRoomGround(): number;
  33959. /**
  33960. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33961. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  33962. */
  33963. useStandingMatrix(callback?: (bool: boolean) => void): void;
  33964. /**
  33965. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33966. * @returns A promise with a boolean set to if the standing matrix is supported.
  33967. */
  33968. useStandingMatrixAsync(): Promise<boolean>;
  33969. /**
  33970. * Disposes the camera
  33971. */
  33972. dispose(): void;
  33973. /**
  33974. * Gets a vrController by name.
  33975. * @param name The name of the controller to retreive
  33976. * @returns the controller matching the name specified or null if not found
  33977. */
  33978. getControllerByName(name: string): Nullable<WebVRController>;
  33979. private _leftController;
  33980. /**
  33981. * The controller corrisponding to the users left hand.
  33982. */
  33983. readonly leftController: Nullable<WebVRController>;
  33984. private _rightController;
  33985. /**
  33986. * The controller corrisponding to the users right hand.
  33987. */
  33988. readonly rightController: Nullable<WebVRController>;
  33989. /**
  33990. * Casts a ray forward from the vrCamera's gaze.
  33991. * @param length Length of the ray (default: 100)
  33992. * @returns the ray corrisponding to the gaze
  33993. */
  33994. getForwardRay(length?: number): Ray;
  33995. /**
  33996. * @hidden
  33997. * Updates the camera based on device's frame data
  33998. */
  33999. _checkInputs(): void;
  34000. /**
  34001. * Updates the poseControlled values based on the input device pose.
  34002. * @param poseData Pose coming from the device
  34003. */
  34004. updateFromDevice(poseData: DevicePose): void;
  34005. private _htmlElementAttached;
  34006. private _detachIfAttached;
  34007. /**
  34008. * WebVR's attach control will start broadcasting frames to the device.
  34009. * Note that in certain browsers (chrome for example) this function must be called
  34010. * within a user-interaction callback. Example:
  34011. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  34012. *
  34013. * @param element html element to attach the vrDevice to
  34014. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  34015. */
  34016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34017. /**
  34018. * Detaches the camera from the html element and disables VR
  34019. *
  34020. * @param element html element to detach from
  34021. */
  34022. detachControl(element: HTMLElement): void;
  34023. /**
  34024. * @returns the name of this class
  34025. */
  34026. getClassName(): string;
  34027. /**
  34028. * Calls resetPose on the vrDisplay
  34029. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  34030. */
  34031. resetToCurrentRotation(): void;
  34032. /**
  34033. * @hidden
  34034. * Updates the rig cameras (left and right eye)
  34035. */
  34036. _updateRigCameras(): void;
  34037. private _workingVector;
  34038. private _oneVector;
  34039. private _workingMatrix;
  34040. private updateCacheCalled;
  34041. private _correctPositionIfNotTrackPosition;
  34042. /**
  34043. * @hidden
  34044. * Updates the cached values of the camera
  34045. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  34046. */
  34047. _updateCache(ignoreParentClass?: boolean): void;
  34048. /**
  34049. * Updates the current device position and rotation in the babylon world
  34050. */
  34051. update(): void;
  34052. /**
  34053. * @hidden
  34054. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  34055. * @returns an identity matrix
  34056. */
  34057. _getViewMatrix(): Matrix;
  34058. private _tmpMatrix;
  34059. /**
  34060. * This function is called by the two RIG cameras.
  34061. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  34062. */
  34063. protected _getWebVRViewMatrix(): Matrix;
  34064. protected _getWebVRProjectionMatrix(): Matrix;
  34065. private _onGamepadConnectedObserver;
  34066. private _onGamepadDisconnectedObserver;
  34067. /**
  34068. * Initializes the controllers and their meshes
  34069. */
  34070. initControllers(): void;
  34071. }
  34072. }
  34073. declare module BABYLON {
  34074. interface IOctreeContainer<T> {
  34075. blocks: Array<OctreeBlock<T>>;
  34076. }
  34077. class Octree<T> {
  34078. maxDepth: number;
  34079. blocks: Array<OctreeBlock<T>>;
  34080. dynamicContent: T[];
  34081. private _maxBlockCapacity;
  34082. private _selectionContent;
  34083. private _creationFunc;
  34084. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  34085. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  34086. addMesh(entry: T): void;
  34087. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  34088. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  34089. intersectsRay(ray: Ray): SmartArray<T>;
  34090. 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;
  34091. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  34092. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  34093. }
  34094. }
  34095. declare module BABYLON {
  34096. class OctreeBlock<T> {
  34097. entries: T[];
  34098. blocks: Array<OctreeBlock<T>>;
  34099. private _depth;
  34100. private _maxDepth;
  34101. private _capacity;
  34102. private _minPoint;
  34103. private _maxPoint;
  34104. private _boundingVectors;
  34105. private _creationFunc;
  34106. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  34107. readonly capacity: number;
  34108. readonly minPoint: Vector3;
  34109. readonly maxPoint: Vector3;
  34110. addEntry(entry: T): void;
  34111. addEntries(entries: T[]): void;
  34112. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  34113. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  34114. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  34115. createInnerBlocks(): void;
  34116. }
  34117. }
  34118. declare module BABYLON {
  34119. interface Engine {
  34120. /**
  34121. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  34122. * @return the new query
  34123. */
  34124. createQuery(): WebGLQuery;
  34125. /**
  34126. * Delete and release a webGL query
  34127. * @param query defines the query to delete
  34128. * @return the current engine
  34129. */
  34130. deleteQuery(query: WebGLQuery): Engine;
  34131. /**
  34132. * Check if a given query has resolved and got its value
  34133. * @param query defines the query to check
  34134. * @returns true if the query got its value
  34135. */
  34136. isQueryResultAvailable(query: WebGLQuery): boolean;
  34137. /**
  34138. * Gets the value of a given query
  34139. * @param query defines the query to check
  34140. * @returns the value of the query
  34141. */
  34142. getQueryResult(query: WebGLQuery): number;
  34143. /**
  34144. * Initiates an occlusion query
  34145. * @param algorithmType defines the algorithm to use
  34146. * @param query defines the query to use
  34147. * @returns the current engine
  34148. * @see http://doc.babylonjs.com/features/occlusionquery
  34149. */
  34150. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  34151. /**
  34152. * Ends an occlusion query
  34153. * @see http://doc.babylonjs.com/features/occlusionquery
  34154. * @param algorithmType defines the algorithm to use
  34155. * @returns the current engine
  34156. */
  34157. endOcclusionQuery(algorithmType: number): Engine;
  34158. /**
  34159. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  34160. * Please note that only one query can be issued at a time
  34161. * @returns a time token used to track the time span
  34162. */
  34163. startTimeQuery(): Nullable<_TimeToken>;
  34164. /**
  34165. * Ends a time query
  34166. * @param token defines the token used to measure the time span
  34167. * @returns the time spent (in ns)
  34168. */
  34169. endTimeQuery(token: _TimeToken): int;
  34170. /** @hidden */
  34171. _currentNonTimestampToken: Nullable<_TimeToken>;
  34172. /** @hidden */
  34173. _createTimeQuery(): WebGLQuery;
  34174. /** @hidden */
  34175. _deleteTimeQuery(query: WebGLQuery): void;
  34176. /** @hidden */
  34177. _getGlAlgorithmType(algorithmType: number): number;
  34178. /** @hidden */
  34179. _getTimeQueryResult(query: WebGLQuery): any;
  34180. /** @hidden */
  34181. _getTimeQueryAvailability(query: WebGLQuery): any;
  34182. }
  34183. }
  34184. declare module BABYLON {
  34185. interface Engine {
  34186. /**
  34187. * Creates a webGL transform feedback object
  34188. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  34189. * @returns the webGL transform feedback object
  34190. */
  34191. createTransformFeedback(): WebGLTransformFeedback;
  34192. /**
  34193. * Delete a webGL transform feedback object
  34194. * @param value defines the webGL transform feedback object to delete
  34195. */
  34196. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  34197. /**
  34198. * Bind a webGL transform feedback object to the webgl context
  34199. * @param value defines the webGL transform feedback object to bind
  34200. */
  34201. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  34202. /**
  34203. * Begins a transform feedback operation
  34204. * @param usePoints defines if points or triangles must be used
  34205. */
  34206. beginTransformFeedback(usePoints: boolean): void;
  34207. /**
  34208. * Ends a transform feedback operation
  34209. */
  34210. endTransformFeedback(): void;
  34211. /**
  34212. * Specify the varyings to use with transform feedback
  34213. * @param program defines the associated webGL program
  34214. * @param value defines the list of strings representing the varying names
  34215. */
  34216. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  34217. /**
  34218. * Bind a webGL buffer for a transform feedback operation
  34219. * @param value defines the webGL buffer to bind
  34220. */
  34221. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  34222. }
  34223. }
  34224. declare module BABYLON {
  34225. /**
  34226. * Google Daydream controller
  34227. */
  34228. class DaydreamController extends WebVRController {
  34229. /**
  34230. * Base Url for the controller model.
  34231. */
  34232. static MODEL_BASE_URL: string;
  34233. /**
  34234. * File name for the controller model.
  34235. */
  34236. static MODEL_FILENAME: string;
  34237. /**
  34238. * Gamepad Id prefix used to identify Daydream Controller.
  34239. */
  34240. static readonly GAMEPAD_ID_PREFIX: string;
  34241. /**
  34242. * Creates a new DaydreamController from a gamepad
  34243. * @param vrGamepad the gamepad that the controller should be created from
  34244. */
  34245. constructor(vrGamepad: any);
  34246. /**
  34247. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34248. * @param scene scene in which to add meshes
  34249. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34250. */
  34251. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34252. /**
  34253. * Called once for each button that changed state since the last frame
  34254. * @param buttonIdx Which button index changed
  34255. * @param state New state of the button
  34256. * @param changes Which properties on the state changed since last frame
  34257. */
  34258. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34259. }
  34260. }
  34261. declare module BABYLON {
  34262. /**
  34263. * Gear VR Controller
  34264. */
  34265. class GearVRController extends WebVRController {
  34266. /**
  34267. * Base Url for the controller model.
  34268. */
  34269. static MODEL_BASE_URL: string;
  34270. /**
  34271. * File name for the controller model.
  34272. */
  34273. static MODEL_FILENAME: string;
  34274. private _maxRotationDistFromHeadset;
  34275. private _draggedRoomRotation;
  34276. private _tmpVector;
  34277. /**
  34278. * Gamepad Id prefix used to identify this controller.
  34279. */
  34280. static readonly GAMEPAD_ID_PREFIX: string;
  34281. private readonly _buttonIndexToObservableNameMap;
  34282. /**
  34283. * Creates a new GearVRController from a gamepad
  34284. * @param vrGamepad the gamepad that the controller should be created from
  34285. */
  34286. constructor(vrGamepad: any);
  34287. /**
  34288. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34289. * @param poseData raw pose fromthe device
  34290. */
  34291. updateFromDevice(poseData: DevicePose): void;
  34292. /**
  34293. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34294. * @param scene scene in which to add meshes
  34295. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34296. */
  34297. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34298. /**
  34299. * Called once for each button that changed state since the last frame
  34300. * @param buttonIdx Which button index changed
  34301. * @param state New state of the button
  34302. * @param changes Which properties on the state changed since last frame
  34303. */
  34304. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34305. }
  34306. }
  34307. declare module BABYLON {
  34308. /**
  34309. * Generic Controller
  34310. */
  34311. class GenericController extends WebVRController {
  34312. /**
  34313. * Base Url for the controller model.
  34314. */
  34315. static readonly MODEL_BASE_URL: string;
  34316. /**
  34317. * File name for the controller model.
  34318. */
  34319. static readonly MODEL_FILENAME: string;
  34320. /**
  34321. * Creates a new GenericController from a gamepad
  34322. * @param vrGamepad the gamepad that the controller should be created from
  34323. */
  34324. constructor(vrGamepad: any);
  34325. /**
  34326. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34327. * @param scene scene in which to add meshes
  34328. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34329. */
  34330. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34331. /**
  34332. * Called once for each button that changed state since the last frame
  34333. * @param buttonIdx Which button index changed
  34334. * @param state New state of the button
  34335. * @param changes Which properties on the state changed since last frame
  34336. */
  34337. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34338. }
  34339. }
  34340. declare module BABYLON {
  34341. /**
  34342. * Oculus Touch Controller
  34343. */
  34344. class OculusTouchController extends WebVRController {
  34345. /**
  34346. * Base Url for the controller model.
  34347. */
  34348. static MODEL_BASE_URL: string;
  34349. /**
  34350. * File name for the left controller model.
  34351. */
  34352. static MODEL_LEFT_FILENAME: string;
  34353. /**
  34354. * File name for the right controller model.
  34355. */
  34356. static MODEL_RIGHT_FILENAME: string;
  34357. /**
  34358. * Fired when the secondary trigger on this controller is modified
  34359. */
  34360. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34361. /**
  34362. * Fired when the thumb rest on this controller is modified
  34363. */
  34364. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  34365. /**
  34366. * Creates a new OculusTouchController from a gamepad
  34367. * @param vrGamepad the gamepad that the controller should be created from
  34368. */
  34369. constructor(vrGamepad: any);
  34370. /**
  34371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34372. * @param scene scene in which to add meshes
  34373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34374. */
  34375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34376. /**
  34377. * Fired when the A button on this controller is modified
  34378. */
  34379. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34380. /**
  34381. * Fired when the B button on this controller is modified
  34382. */
  34383. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34384. /**
  34385. * Fired when the X button on this controller is modified
  34386. */
  34387. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34388. /**
  34389. * Fired when the Y button on this controller is modified
  34390. */
  34391. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34392. /**
  34393. * Called once for each button that changed state since the last frame
  34394. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34395. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34396. * 2) secondary trigger (same)
  34397. * 3) A (right) X (left), touch, pressed = value
  34398. * 4) B / Y
  34399. * 5) thumb rest
  34400. * @param buttonIdx Which button index changed
  34401. * @param state New state of the button
  34402. * @param changes Which properties on the state changed since last frame
  34403. */
  34404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34405. }
  34406. }
  34407. declare module BABYLON {
  34408. /**
  34409. * Defines the types of pose enabled controllers that are supported
  34410. */
  34411. enum PoseEnabledControllerType {
  34412. /**
  34413. * HTC Vive
  34414. */
  34415. VIVE = 0,
  34416. /**
  34417. * Oculus Rift
  34418. */
  34419. OCULUS = 1,
  34420. /**
  34421. * Windows mixed reality
  34422. */
  34423. WINDOWS = 2,
  34424. /**
  34425. * Samsung gear VR
  34426. */
  34427. GEAR_VR = 3,
  34428. /**
  34429. * Google Daydream
  34430. */
  34431. DAYDREAM = 4,
  34432. /**
  34433. * Generic
  34434. */
  34435. GENERIC = 5
  34436. }
  34437. /**
  34438. * Defines the MutableGamepadButton interface for the state of a gamepad button
  34439. */
  34440. interface MutableGamepadButton {
  34441. /**
  34442. * Value of the button/trigger
  34443. */
  34444. value: number;
  34445. /**
  34446. * If the button/trigger is currently touched
  34447. */
  34448. touched: boolean;
  34449. /**
  34450. * If the button/trigger is currently pressed
  34451. */
  34452. pressed: boolean;
  34453. }
  34454. /**
  34455. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  34456. * @hidden
  34457. */
  34458. interface ExtendedGamepadButton extends GamepadButton {
  34459. /**
  34460. * If the button/trigger is currently pressed
  34461. */
  34462. readonly pressed: boolean;
  34463. /**
  34464. * If the button/trigger is currently touched
  34465. */
  34466. readonly touched: boolean;
  34467. /**
  34468. * Value of the button/trigger
  34469. */
  34470. readonly value: number;
  34471. }
  34472. /**
  34473. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34474. */
  34475. class PoseEnabledControllerHelper {
  34476. /**
  34477. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34478. * @param vrGamepad the gamepad to initialized
  34479. * @returns a vr controller of the type the gamepad identified as
  34480. */
  34481. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  34482. }
  34483. /**
  34484. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34485. */
  34486. class PoseEnabledController extends Gamepad implements PoseControlled {
  34487. private _deviceRoomPosition;
  34488. private _deviceRoomRotationQuaternion;
  34489. /**
  34490. * The device position in babylon space
  34491. */
  34492. devicePosition: Vector3;
  34493. /**
  34494. * The device rotation in babylon space
  34495. */
  34496. deviceRotationQuaternion: Quaternion;
  34497. /**
  34498. * The scale factor of the device in babylon space
  34499. */
  34500. deviceScaleFactor: number;
  34501. /**
  34502. * (Likely devicePosition should be used instead) The device position in its room space
  34503. */
  34504. position: Vector3;
  34505. /**
  34506. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  34507. */
  34508. rotationQuaternion: Quaternion;
  34509. /**
  34510. * The type of controller (Eg. Windows mixed reality)
  34511. */
  34512. controllerType: PoseEnabledControllerType;
  34513. protected _calculatedPosition: Vector3;
  34514. private _calculatedRotation;
  34515. /**
  34516. * The raw pose from the device
  34517. */
  34518. rawPose: DevicePose;
  34519. /**
  34520. * Internal, the mesh attached to the controller
  34521. * @hidden
  34522. */
  34523. _mesh: Nullable<AbstractMesh>;
  34524. private _poseControlledCamera;
  34525. private _leftHandSystemQuaternion;
  34526. /**
  34527. * Internal, matrix used to convert room space to babylon space
  34528. * @hidden
  34529. */
  34530. _deviceToWorld: Matrix;
  34531. /**
  34532. * Node to be used when casting a ray from the controller
  34533. * @hidden
  34534. */
  34535. _pointingPoseNode: Nullable<AbstractMesh>;
  34536. /**
  34537. * Name of the child mesh that can be used to cast a ray from the controller
  34538. */
  34539. static readonly POINTING_POSE: string;
  34540. /**
  34541. * Creates a new PoseEnabledController from a gamepad
  34542. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34543. */
  34544. constructor(browserGamepad: any);
  34545. private _workingMatrix;
  34546. /**
  34547. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34548. */
  34549. update(): void;
  34550. /**
  34551. * Updates only the pose device and mesh without doing any button event checking
  34552. */
  34553. protected _updatePoseAndMesh(): void;
  34554. /**
  34555. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34556. * @param poseData raw pose fromthe device
  34557. */
  34558. updateFromDevice(poseData: DevicePose): void;
  34559. /**
  34560. * @hidden
  34561. */
  34562. _meshAttachedObservable: Observable<AbstractMesh>;
  34563. /**
  34564. * Attaches a mesh to the controller
  34565. * @param mesh the mesh to be attached
  34566. */
  34567. attachToMesh(mesh: AbstractMesh): void;
  34568. /**
  34569. * Attaches the controllers mesh to a camera
  34570. * @param camera the camera the mesh should be attached to
  34571. */
  34572. attachToPoseControlledCamera(camera: TargetCamera): void;
  34573. /**
  34574. * Disposes of the controller
  34575. */
  34576. dispose(): void;
  34577. /**
  34578. * The mesh that is attached to the controller
  34579. */
  34580. readonly mesh: Nullable<AbstractMesh>;
  34581. /**
  34582. * Gets the ray of the controller in the direction the controller is pointing
  34583. * @param length the length the resulting ray should be
  34584. * @returns a ray in the direction the controller is pointing
  34585. */
  34586. getForwardRay(length?: number): Ray;
  34587. }
  34588. }
  34589. declare module BABYLON {
  34590. /**
  34591. * Vive Controller
  34592. */
  34593. class ViveController extends WebVRController {
  34594. /**
  34595. * Base Url for the controller model.
  34596. */
  34597. static MODEL_BASE_URL: string;
  34598. /**
  34599. * File name for the controller model.
  34600. */
  34601. static MODEL_FILENAME: string;
  34602. /**
  34603. * Creates a new ViveController from a gamepad
  34604. * @param vrGamepad the gamepad that the controller should be created from
  34605. */
  34606. constructor(vrGamepad: any);
  34607. /**
  34608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34609. * @param scene scene in which to add meshes
  34610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34611. */
  34612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34613. /**
  34614. * Fired when the left button on this controller is modified
  34615. */
  34616. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34617. /**
  34618. * Fired when the right button on this controller is modified
  34619. */
  34620. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34621. /**
  34622. * Fired when the menu button on this controller is modified
  34623. */
  34624. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34625. /**
  34626. * Called once for each button that changed state since the last frame
  34627. * Vive mapping:
  34628. * 0: touchpad
  34629. * 1: trigger
  34630. * 2: left AND right buttons
  34631. * 3: menu button
  34632. * @param buttonIdx Which button index changed
  34633. * @param state New state of the button
  34634. * @param changes Which properties on the state changed since last frame
  34635. */
  34636. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34637. }
  34638. }
  34639. declare module BABYLON {
  34640. /**
  34641. * Defines the WebVRController object that represents controllers tracked in 3D space
  34642. */
  34643. abstract class WebVRController extends PoseEnabledController {
  34644. /**
  34645. * Internal, the default controller model for the controller
  34646. */
  34647. protected _defaultModel: AbstractMesh;
  34648. /**
  34649. * Fired when the trigger state has changed
  34650. */
  34651. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34652. /**
  34653. * Fired when the main button state has changed
  34654. */
  34655. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34656. /**
  34657. * Fired when the secondary button state has changed
  34658. */
  34659. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34660. /**
  34661. * Fired when the pad state has changed
  34662. */
  34663. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  34664. /**
  34665. * Fired when controllers stick values have changed
  34666. */
  34667. onPadValuesChangedObservable: Observable<StickValues>;
  34668. /**
  34669. * Array of button availible on the controller
  34670. */
  34671. protected _buttons: Array<MutableGamepadButton>;
  34672. private _onButtonStateChange;
  34673. /**
  34674. * Fired when a controller button's state has changed
  34675. * @param callback the callback containing the button that was modified
  34676. */
  34677. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  34678. /**
  34679. * X and Y axis corrisponding to the controllers joystick
  34680. */
  34681. pad: StickValues;
  34682. /**
  34683. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  34684. */
  34685. hand: string;
  34686. /**
  34687. * The default controller model for the controller
  34688. */
  34689. readonly defaultModel: AbstractMesh;
  34690. /**
  34691. * Creates a new WebVRController from a gamepad
  34692. * @param vrGamepad the gamepad that the WebVRController should be created from
  34693. */
  34694. constructor(vrGamepad: any);
  34695. /**
  34696. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34697. */
  34698. update(): void;
  34699. /**
  34700. * Function to be called when a button is modified
  34701. */
  34702. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34703. /**
  34704. * Loads a mesh and attaches it to the controller
  34705. * @param scene the scene the mesh should be added to
  34706. * @param meshLoaded callback for when the mesh has been loaded
  34707. */
  34708. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34709. private _setButtonValue;
  34710. private _changes;
  34711. private _checkChanges;
  34712. /**
  34713. * Disposes of th webVRCOntroller
  34714. */
  34715. dispose(): void;
  34716. }
  34717. }
  34718. declare module BABYLON {
  34719. /**
  34720. * Defines the WindowsMotionController object that the state of the windows motion controller
  34721. */
  34722. class WindowsMotionController extends WebVRController {
  34723. /**
  34724. * The base url used to load the left and right controller models
  34725. */
  34726. static MODEL_BASE_URL: string;
  34727. /**
  34728. * The name of the left controller model file
  34729. */
  34730. static MODEL_LEFT_FILENAME: string;
  34731. /**
  34732. * The name of the right controller model file
  34733. */
  34734. static MODEL_RIGHT_FILENAME: string;
  34735. /**
  34736. * The controller name prefix for this controller type
  34737. */
  34738. static readonly GAMEPAD_ID_PREFIX: string;
  34739. /**
  34740. * The controller id pattern for this controller type
  34741. */
  34742. private static readonly GAMEPAD_ID_PATTERN;
  34743. private _loadedMeshInfo;
  34744. private readonly _mapping;
  34745. /**
  34746. * Fired when the trackpad on this controller is clicked
  34747. */
  34748. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  34749. /**
  34750. * Fired when the trackpad on this controller is modified
  34751. */
  34752. onTrackpadValuesChangedObservable: Observable<StickValues>;
  34753. /**
  34754. * The current x and y values of this controller's trackpad
  34755. */
  34756. trackpad: StickValues;
  34757. /**
  34758. * Creates a new WindowsMotionController from a gamepad
  34759. * @param vrGamepad the gamepad that the controller should be created from
  34760. */
  34761. constructor(vrGamepad: any);
  34762. /**
  34763. * Fired when the trigger on this controller is modified
  34764. */
  34765. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34766. /**
  34767. * Fired when the menu button on this controller is modified
  34768. */
  34769. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34770. /**
  34771. * Fired when the grip button on this controller is modified
  34772. */
  34773. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34774. /**
  34775. * Fired when the thumbstick button on this controller is modified
  34776. */
  34777. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34778. /**
  34779. * Fired when the touchpad button on this controller is modified
  34780. */
  34781. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34782. /**
  34783. * Fired when the touchpad values on this controller are modified
  34784. */
  34785. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  34786. private _updateTrackpad;
  34787. /**
  34788. * Called once per frame by the engine.
  34789. */
  34790. update(): void;
  34791. /**
  34792. * Called once for each button that changed state since the last frame
  34793. * @param buttonIdx Which button index changed
  34794. * @param state New state of the button
  34795. * @param changes Which properties on the state changed since last frame
  34796. */
  34797. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34798. /**
  34799. * Moves the buttons on the controller mesh based on their current state
  34800. * @param buttonName the name of the button to move
  34801. * @param buttonValue the value of the button which determines the buttons new position
  34802. */
  34803. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  34804. /**
  34805. * Moves the axis on the controller mesh based on its current state
  34806. * @param axis the index of the axis
  34807. * @param axisValue the value of the axis which determines the meshes new position
  34808. * @hidden
  34809. */
  34810. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  34811. /**
  34812. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34813. * @param scene scene in which to add meshes
  34814. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34815. */
  34816. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  34817. /**
  34818. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  34819. * can be transformed by button presses and axes values, based on this._mapping.
  34820. *
  34821. * @param scene scene in which the meshes exist
  34822. * @param meshes list of meshes that make up the controller model to process
  34823. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  34824. */
  34825. private processModel;
  34826. private createMeshInfo;
  34827. /**
  34828. * Gets the ray of the controller in the direction the controller is pointing
  34829. * @param length the length the resulting ray should be
  34830. * @returns a ray in the direction the controller is pointing
  34831. */
  34832. getForwardRay(length?: number): Ray;
  34833. /**
  34834. * Disposes of the controller
  34835. */
  34836. dispose(): void;
  34837. }
  34838. }
  34839. declare module BABYLON {
  34840. /**
  34841. * Interface to implement to create a shadow generator compatible with BJS.
  34842. */
  34843. interface IShadowGenerator {
  34844. /**
  34845. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34846. * @returns The render target texture if present otherwise, null
  34847. */
  34848. getShadowMap(): Nullable<RenderTargetTexture>;
  34849. /**
  34850. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34851. * @returns The render target texture if the shadow map is present otherwise, null
  34852. */
  34853. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34854. /**
  34855. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34856. * @param subMesh The submesh we want to render in the shadow map
  34857. * @param useInstances Defines wether will draw in the map using instances
  34858. * @returns true if ready otherwise, false
  34859. */
  34860. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34861. /**
  34862. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34863. * @param defines Defines of the material we want to update
  34864. * @param lightIndex Index of the light in the enabled light list of the material
  34865. */
  34866. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  34867. /**
  34868. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34869. * defined in the generator but impacting the effect).
  34870. * It implies the unifroms available on the materials are the standard BJS ones.
  34871. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34872. * @param effect The effect we are binfing the information for
  34873. */
  34874. bindShadowLight(lightIndex: string, effect: Effect): void;
  34875. /**
  34876. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34877. * (eq to shadow prjection matrix * light transform matrix)
  34878. * @returns The transform matrix used to create the shadow map
  34879. */
  34880. getTransformMatrix(): Matrix;
  34881. /**
  34882. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34883. * Cube and 2D textures for instance.
  34884. */
  34885. recreateShadowMap(): void;
  34886. /**
  34887. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34888. * @param onCompiled Callback triggered at the and of the effects compilation
  34889. * @param options Sets of optional options forcing the compilation with different modes
  34890. */
  34891. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34892. useInstances: boolean;
  34893. }>): void;
  34894. /**
  34895. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34896. * @param options Sets of optional options forcing the compilation with different modes
  34897. * @returns A promise that resolves when the compilation completes
  34898. */
  34899. forceCompilationAsync(options?: Partial<{
  34900. useInstances: boolean;
  34901. }>): Promise<void>;
  34902. /**
  34903. * Serializes the shadow generator setup to a json object.
  34904. * @returns The serialized JSON object
  34905. */
  34906. serialize(): any;
  34907. /**
  34908. * Disposes the Shadow map and related Textures and effects.
  34909. */
  34910. dispose(): void;
  34911. }
  34912. /**
  34913. * Default implementation IShadowGenerator.
  34914. * This is the main object responsible of generating shadows in the framework.
  34915. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  34916. */
  34917. class ShadowGenerator implements IShadowGenerator {
  34918. /**
  34919. * Shadow generator mode None: no filtering applied.
  34920. */
  34921. static readonly FILTER_NONE: number;
  34922. /**
  34923. * Shadow generator mode ESM: Exponential Shadow Mapping.
  34924. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34925. */
  34926. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  34927. /**
  34928. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  34929. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  34930. */
  34931. static readonly FILTER_POISSONSAMPLING: number;
  34932. /**
  34933. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  34934. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34935. */
  34936. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  34937. /**
  34938. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  34939. * edge artifacts on steep falloff.
  34940. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34941. */
  34942. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34943. /**
  34944. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34945. * edge artifacts on steep falloff.
  34946. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34947. */
  34948. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34949. /**
  34950. * Shadow generator mode PCF: Percentage Closer Filtering
  34951. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34952. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  34953. */
  34954. static readonly FILTER_PCF: number;
  34955. /**
  34956. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  34957. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34958. * Contact Hardening
  34959. */
  34960. static readonly FILTER_PCSS: number;
  34961. /**
  34962. * Reserved for PCF and PCSS
  34963. * Highest Quality.
  34964. *
  34965. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  34966. *
  34967. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  34968. */
  34969. static readonly QUALITY_HIGH: number;
  34970. /**
  34971. * Reserved for PCF and PCSS
  34972. * Good tradeoff for quality/perf cross devices
  34973. *
  34974. * Execute PCF on a 3*3 kernel.
  34975. *
  34976. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  34977. */
  34978. static readonly QUALITY_MEDIUM: number;
  34979. /**
  34980. * Reserved for PCF and PCSS
  34981. * The lowest quality but the fastest.
  34982. *
  34983. * Execute PCF on a 1*1 kernel.
  34984. *
  34985. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  34986. */
  34987. static readonly QUALITY_LOW: number;
  34988. private _bias;
  34989. /**
  34990. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  34991. */
  34992. /**
  34993. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  34994. */
  34995. bias: number;
  34996. private _normalBias;
  34997. /**
  34998. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34999. */
  35000. /**
  35001. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  35002. */
  35003. normalBias: number;
  35004. private _blurBoxOffset;
  35005. /**
  35006. * Gets the blur box offset: offset applied during the blur pass.
  35007. * Only usefull if useKernelBlur = false
  35008. */
  35009. /**
  35010. * Sets the blur box offset: offset applied during the blur pass.
  35011. * Only usefull if useKernelBlur = false
  35012. */
  35013. blurBoxOffset: number;
  35014. private _blurScale;
  35015. /**
  35016. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  35017. * 2 means half of the size.
  35018. */
  35019. /**
  35020. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  35021. * 2 means half of the size.
  35022. */
  35023. blurScale: number;
  35024. private _blurKernel;
  35025. /**
  35026. * Gets the blur kernel: kernel size of the blur pass.
  35027. * Only usefull if useKernelBlur = true
  35028. */
  35029. /**
  35030. * Sets the blur kernel: kernel size of the blur pass.
  35031. * Only usefull if useKernelBlur = true
  35032. */
  35033. blurKernel: number;
  35034. private _useKernelBlur;
  35035. /**
  35036. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  35037. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35038. */
  35039. /**
  35040. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  35041. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35042. */
  35043. useKernelBlur: boolean;
  35044. private _depthScale;
  35045. /**
  35046. * Gets the depth scale used in ESM mode.
  35047. */
  35048. /**
  35049. * Sets the depth scale used in ESM mode.
  35050. * This can override the scale stored on the light.
  35051. */
  35052. depthScale: number;
  35053. private _filter;
  35054. /**
  35055. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  35056. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35057. */
  35058. /**
  35059. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  35060. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35061. */
  35062. filter: number;
  35063. /**
  35064. * Gets if the current filter is set to Poisson Sampling.
  35065. */
  35066. /**
  35067. * Sets the current filter to Poisson Sampling.
  35068. */
  35069. usePoissonSampling: boolean;
  35070. /**
  35071. * Gets if the current filter is set to VSM.
  35072. * DEPRECATED. Should use useExponentialShadowMap instead.
  35073. */
  35074. /**
  35075. * Sets the current filter is to VSM.
  35076. * DEPRECATED. Should use useExponentialShadowMap instead.
  35077. */
  35078. useVarianceShadowMap: boolean;
  35079. /**
  35080. * Gets if the current filter is set to blurred VSM.
  35081. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35082. */
  35083. /**
  35084. * Sets the current filter is to blurred VSM.
  35085. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35086. */
  35087. useBlurVarianceShadowMap: boolean;
  35088. /**
  35089. * Gets if the current filter is set to ESM.
  35090. */
  35091. /**
  35092. * Sets the current filter is to ESM.
  35093. */
  35094. useExponentialShadowMap: boolean;
  35095. /**
  35096. * Gets if the current filter is set to filtered ESM.
  35097. */
  35098. /**
  35099. * Gets if the current filter is set to filtered ESM.
  35100. */
  35101. useBlurExponentialShadowMap: boolean;
  35102. /**
  35103. * Gets if the current filter is set to "close ESM" (using the inverse of the
  35104. * exponential to prevent steep falloff artifacts).
  35105. */
  35106. /**
  35107. * Sets the current filter to "close ESM" (using the inverse of the
  35108. * exponential to prevent steep falloff artifacts).
  35109. */
  35110. useCloseExponentialShadowMap: boolean;
  35111. /**
  35112. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  35113. * exponential to prevent steep falloff artifacts).
  35114. */
  35115. /**
  35116. * Sets the current filter to filtered "close ESM" (using the inverse of the
  35117. * exponential to prevent steep falloff artifacts).
  35118. */
  35119. useBlurCloseExponentialShadowMap: boolean;
  35120. /**
  35121. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  35122. */
  35123. /**
  35124. * Sets the current filter to "PCF" (percentage closer filtering).
  35125. */
  35126. usePercentageCloserFiltering: boolean;
  35127. private _filteringQuality;
  35128. /**
  35129. * Gets the PCF or PCSS Quality.
  35130. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35131. */
  35132. /**
  35133. * Sets the PCF or PCSS Quality.
  35134. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35135. */
  35136. filteringQuality: number;
  35137. /**
  35138. * Gets if the current filter is set to "PCSS" (contact hardening).
  35139. */
  35140. /**
  35141. * Sets the current filter to "PCSS" (contact hardening).
  35142. */
  35143. useContactHardeningShadow: boolean;
  35144. private _contactHardeningLightSizeUVRatio;
  35145. /**
  35146. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35147. * Using a ratio helps keeping shape stability independently of the map size.
  35148. *
  35149. * It does not account for the light projection as it was having too much
  35150. * instability during the light setup or during light position changes.
  35151. *
  35152. * Only valid if useContactHardeningShadow is true.
  35153. */
  35154. /**
  35155. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35156. * Using a ratio helps keeping shape stability independently of the map size.
  35157. *
  35158. * It does not account for the light projection as it was having too much
  35159. * instability during the light setup or during light position changes.
  35160. *
  35161. * Only valid if useContactHardeningShadow is true.
  35162. */
  35163. contactHardeningLightSizeUVRatio: number;
  35164. private _darkness;
  35165. /**
  35166. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  35167. * 0 means strongest and 1 would means no shadow.
  35168. * @returns the darkness.
  35169. */
  35170. getDarkness(): number;
  35171. /**
  35172. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  35173. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  35174. * @returns the shadow generator allowing fluent coding.
  35175. */
  35176. setDarkness(darkness: number): ShadowGenerator;
  35177. private _transparencyShadow;
  35178. /**
  35179. * Sets the ability to have transparent shadow (boolean).
  35180. * @param transparent True if transparent else False
  35181. * @returns the shadow generator allowing fluent coding
  35182. */
  35183. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  35184. private _shadowMap;
  35185. private _shadowMap2;
  35186. /**
  35187. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  35188. * @returns The render target texture if present otherwise, null
  35189. */
  35190. getShadowMap(): Nullable<RenderTargetTexture>;
  35191. /**
  35192. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  35193. * @returns The render target texture if the shadow map is present otherwise, null
  35194. */
  35195. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  35196. /**
  35197. * Helper function to add a mesh and its descendants to the list of shadow casters.
  35198. * @param mesh Mesh to add
  35199. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  35200. * @returns the Shadow Generator itself
  35201. */
  35202. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35203. /**
  35204. * Helper function to remove a mesh and its descendants from the list of shadow casters
  35205. * @param mesh Mesh to remove
  35206. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  35207. * @returns the Shadow Generator itself
  35208. */
  35209. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35210. /**
  35211. * Controls the extent to which the shadows fade out at the edge of the frustum
  35212. * Used only by directionals and spots
  35213. */
  35214. frustumEdgeFalloff: number;
  35215. private _light;
  35216. /**
  35217. * Returns the associated light object.
  35218. * @returns the light generating the shadow
  35219. */
  35220. getLight(): IShadowLight;
  35221. /**
  35222. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  35223. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  35224. * It might on the other hand introduce peter panning.
  35225. */
  35226. forceBackFacesOnly: boolean;
  35227. private _scene;
  35228. private _lightDirection;
  35229. private _effect;
  35230. private _viewMatrix;
  35231. private _projectionMatrix;
  35232. private _transformMatrix;
  35233. private _cachedPosition;
  35234. private _cachedDirection;
  35235. private _cachedDefines;
  35236. private _currentRenderID;
  35237. private _boxBlurPostprocess;
  35238. private _kernelBlurXPostprocess;
  35239. private _kernelBlurYPostprocess;
  35240. private _blurPostProcesses;
  35241. private _mapSize;
  35242. private _currentFaceIndex;
  35243. private _currentFaceIndexCache;
  35244. private _textureType;
  35245. private _defaultTextureMatrix;
  35246. /**
  35247. * Creates a ShadowGenerator object.
  35248. * A ShadowGenerator is the required tool to use the shadows.
  35249. * Each light casting shadows needs to use its own ShadowGenerator.
  35250. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  35251. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  35252. * @param light The light object generating the shadows.
  35253. * @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.
  35254. */
  35255. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  35256. private _initializeGenerator;
  35257. private _initializeShadowMap;
  35258. private _initializeBlurRTTAndPostProcesses;
  35259. private _renderForShadowMap;
  35260. private _renderSubMeshForShadowMap;
  35261. private _applyFilterValues;
  35262. /**
  35263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35264. * @param onCompiled Callback triggered at the and of the effects compilation
  35265. * @param options Sets of optional options forcing the compilation with different modes
  35266. */
  35267. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  35268. useInstances: boolean;
  35269. }>): void;
  35270. /**
  35271. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35272. * @param options Sets of optional options forcing the compilation with different modes
  35273. * @returns A promise that resolves when the compilation completes
  35274. */
  35275. forceCompilationAsync(options?: Partial<{
  35276. useInstances: boolean;
  35277. }>): Promise<void>;
  35278. /**
  35279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35280. * @param subMesh The submesh we want to render in the shadow map
  35281. * @param useInstances Defines wether will draw in the map using instances
  35282. * @returns true if ready otherwise, false
  35283. */
  35284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35285. /**
  35286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35287. * @param defines Defines of the material we want to update
  35288. * @param lightIndex Index of the light in the enabled light list of the material
  35289. */
  35290. prepareDefines(defines: any, lightIndex: number): void;
  35291. /**
  35292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35293. * defined in the generator but impacting the effect).
  35294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35295. * @param effect The effect we are binfing the information for
  35296. */
  35297. bindShadowLight(lightIndex: string, effect: Effect): void;
  35298. /**
  35299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35300. * (eq to shadow prjection matrix * light transform matrix)
  35301. * @returns The transform matrix used to create the shadow map
  35302. */
  35303. getTransformMatrix(): Matrix;
  35304. /**
  35305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35306. * Cube and 2D textures for instance.
  35307. */
  35308. recreateShadowMap(): void;
  35309. private _disposeBlurPostProcesses;
  35310. private _disposeRTTandPostProcesses;
  35311. /**
  35312. * Disposes the ShadowGenerator.
  35313. * Returns nothing.
  35314. */
  35315. dispose(): void;
  35316. /**
  35317. * Serializes the shadow generator setup to a json object.
  35318. * @returns The serialized JSON object
  35319. */
  35320. serialize(): any;
  35321. /**
  35322. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  35323. * @param parsedShadowGenerator The JSON object to parse
  35324. * @param scene The scene to create the shadow map for
  35325. * @returns The parsed shadow generator
  35326. */
  35327. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  35328. }
  35329. }
  35330. declare module BABYLON {
  35331. }
  35332. declare module BABYLON {
  35333. /**
  35334. * Background material used to create an efficient environement around your scene.
  35335. */
  35336. class BackgroundMaterial extends PushMaterial {
  35337. /**
  35338. * Standard reflectance value at parallel view angle.
  35339. */
  35340. static StandardReflectance0: number;
  35341. /**
  35342. * Standard reflectance value at grazing angle.
  35343. */
  35344. static StandardReflectance90: number;
  35345. protected _primaryColor: Color3;
  35346. /**
  35347. * Key light Color (multiply against the environement texture)
  35348. */
  35349. primaryColor: Color3;
  35350. protected __perceptualColor: Nullable<Color3>;
  35351. /**
  35352. * Experimental Internal Use Only.
  35353. *
  35354. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  35355. * This acts as a helper to set the primary color to a more "human friendly" value.
  35356. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  35357. * output color as close as possible from the chosen value.
  35358. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  35359. * part of lighting setup.)
  35360. */
  35361. _perceptualColor: Nullable<Color3>;
  35362. protected _primaryColorShadowLevel: float;
  35363. /**
  35364. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  35365. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  35366. */
  35367. primaryColorShadowLevel: float;
  35368. protected _primaryColorHighlightLevel: float;
  35369. /**
  35370. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  35371. * The primary color is used at the level chosen to define what the white area would look.
  35372. */
  35373. primaryColorHighlightLevel: float;
  35374. protected _reflectionTexture: Nullable<BaseTexture>;
  35375. /**
  35376. * Reflection Texture used in the material.
  35377. * Should be author in a specific way for the best result (refer to the documentation).
  35378. */
  35379. reflectionTexture: Nullable<BaseTexture>;
  35380. protected _reflectionBlur: float;
  35381. /**
  35382. * Reflection Texture level of blur.
  35383. *
  35384. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  35385. * texture twice.
  35386. */
  35387. reflectionBlur: float;
  35388. protected _diffuseTexture: Nullable<BaseTexture>;
  35389. /**
  35390. * Diffuse Texture used in the material.
  35391. * Should be author in a specific way for the best result (refer to the documentation).
  35392. */
  35393. diffuseTexture: Nullable<BaseTexture>;
  35394. protected _shadowLights: Nullable<IShadowLight[]>;
  35395. /**
  35396. * Specify the list of lights casting shadow on the material.
  35397. * All scene shadow lights will be included if null.
  35398. */
  35399. shadowLights: Nullable<IShadowLight[]>;
  35400. protected _shadowLevel: float;
  35401. /**
  35402. * Helps adjusting the shadow to a softer level if required.
  35403. * 0 means black shadows and 1 means no shadows.
  35404. */
  35405. shadowLevel: float;
  35406. protected _sceneCenter: Vector3;
  35407. /**
  35408. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  35409. * It is usually zero but might be interesting to modify according to your setup.
  35410. */
  35411. sceneCenter: Vector3;
  35412. protected _opacityFresnel: boolean;
  35413. /**
  35414. * This helps specifying that the material is falling off to the sky box at grazing angle.
  35415. * This helps ensuring a nice transition when the camera goes under the ground.
  35416. */
  35417. opacityFresnel: boolean;
  35418. protected _reflectionFresnel: boolean;
  35419. /**
  35420. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  35421. * This helps adding a mirror texture on the ground.
  35422. */
  35423. reflectionFresnel: boolean;
  35424. protected _reflectionFalloffDistance: number;
  35425. /**
  35426. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  35427. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  35428. */
  35429. reflectionFalloffDistance: number;
  35430. protected _reflectionAmount: number;
  35431. /**
  35432. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  35433. */
  35434. reflectionAmount: number;
  35435. protected _reflectionReflectance0: number;
  35436. /**
  35437. * This specifies the weight of the reflection at grazing angle.
  35438. */
  35439. reflectionReflectance0: number;
  35440. protected _reflectionReflectance90: number;
  35441. /**
  35442. * This specifies the weight of the reflection at a perpendicular point of view.
  35443. */
  35444. reflectionReflectance90: number;
  35445. /**
  35446. * Sets the reflection reflectance fresnel values according to the default standard
  35447. * empirically know to work well :-)
  35448. */
  35449. reflectionStandardFresnelWeight: number;
  35450. protected _useRGBColor: boolean;
  35451. /**
  35452. * Helps to directly use the maps channels instead of their level.
  35453. */
  35454. useRGBColor: boolean;
  35455. protected _enableNoise: boolean;
  35456. /**
  35457. * This helps reducing the banding effect that could occur on the background.
  35458. */
  35459. enableNoise: boolean;
  35460. /**
  35461. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  35462. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  35463. * Recommended to be keep at 1.0 except for special cases.
  35464. */
  35465. fovMultiplier: number;
  35466. private _fovMultiplier;
  35467. /**
  35468. * Enable the FOV adjustment feature controlled by fovMultiplier.
  35469. */
  35470. useEquirectangularFOV: boolean;
  35471. private _maxSimultaneousLights;
  35472. /**
  35473. * Number of Simultaneous lights allowed on the material.
  35474. */
  35475. maxSimultaneousLights: int;
  35476. /**
  35477. * Default configuration related to image processing available in the Background Material.
  35478. */
  35479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35480. /**
  35481. * Keep track of the image processing observer to allow dispose and replace.
  35482. */
  35483. private _imageProcessingObserver;
  35484. /**
  35485. * Attaches a new image processing configuration to the PBR Material.
  35486. * @param configuration (if null the scene configuration will be use)
  35487. */
  35488. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35489. /**
  35490. * Gets the image processing configuration used either in this material.
  35491. */
  35492. /**
  35493. * Sets the Default image processing configuration used either in the this material.
  35494. *
  35495. * If sets to null, the scene one is in use.
  35496. */
  35497. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  35498. /**
  35499. * Gets wether the color curves effect is enabled.
  35500. */
  35501. /**
  35502. * Sets wether the color curves effect is enabled.
  35503. */
  35504. cameraColorCurvesEnabled: boolean;
  35505. /**
  35506. * Gets wether the color grading effect is enabled.
  35507. */
  35508. /**
  35509. * Gets wether the color grading effect is enabled.
  35510. */
  35511. cameraColorGradingEnabled: boolean;
  35512. /**
  35513. * Gets wether tonemapping is enabled or not.
  35514. */
  35515. /**
  35516. * Sets wether tonemapping is enabled or not
  35517. */
  35518. cameraToneMappingEnabled: boolean;
  35519. /**
  35520. * The camera exposure used on this material.
  35521. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35522. * This corresponds to a photographic exposure.
  35523. */
  35524. /**
  35525. * The camera exposure used on this material.
  35526. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35527. * This corresponds to a photographic exposure.
  35528. */
  35529. cameraExposure: float;
  35530. /**
  35531. * Gets The camera contrast used on this material.
  35532. */
  35533. /**
  35534. * Sets The camera contrast used on this material.
  35535. */
  35536. cameraContrast: float;
  35537. /**
  35538. * Gets the Color Grading 2D Lookup Texture.
  35539. */
  35540. /**
  35541. * Sets the Color Grading 2D Lookup Texture.
  35542. */
  35543. cameraColorGradingTexture: Nullable<BaseTexture>;
  35544. /**
  35545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35547. * 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;
  35548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35549. */
  35550. /**
  35551. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35552. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35553. * 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;
  35554. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35555. */
  35556. cameraColorCurves: Nullable<ColorCurves>;
  35557. /**
  35558. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  35559. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  35560. */
  35561. switchToBGR: boolean;
  35562. private _renderTargets;
  35563. private _reflectionControls;
  35564. private _white;
  35565. private _primaryShadowColor;
  35566. private _primaryHighlightColor;
  35567. /**
  35568. * Instantiates a Background Material in the given scene
  35569. * @param name The friendly name of the material
  35570. * @param scene The scene to add the material to
  35571. */
  35572. constructor(name: string, scene: Scene);
  35573. /**
  35574. * The entire material has been created in order to prevent overdraw.
  35575. * @returns false
  35576. */
  35577. needAlphaTesting(): boolean;
  35578. /**
  35579. * The entire material has been created in order to prevent overdraw.
  35580. * @returns true if blending is enable
  35581. */
  35582. needAlphaBlending(): boolean;
  35583. /**
  35584. * Checks wether the material is ready to be rendered for a given mesh.
  35585. * @param mesh The mesh to render
  35586. * @param subMesh The submesh to check against
  35587. * @param useInstances Specify wether or not the material is used with instances
  35588. * @returns true if all the dependencies are ready (Textures, Effects...)
  35589. */
  35590. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35591. /**
  35592. * Compute the primary color according to the chosen perceptual color.
  35593. */
  35594. private _computePrimaryColorFromPerceptualColor;
  35595. /**
  35596. * Compute the highlights and shadow colors according to their chosen levels.
  35597. */
  35598. private _computePrimaryColors;
  35599. /**
  35600. * Build the uniform buffer used in the material.
  35601. */
  35602. buildUniformLayout(): void;
  35603. /**
  35604. * Unbind the material.
  35605. */
  35606. unbind(): void;
  35607. /**
  35608. * Bind only the world matrix to the material.
  35609. * @param world The world matrix to bind.
  35610. */
  35611. bindOnlyWorldMatrix(world: Matrix): void;
  35612. /**
  35613. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  35614. * @param world The world matrix to bind.
  35615. * @param subMesh The submesh to bind for.
  35616. */
  35617. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35618. /**
  35619. * Dispose the material.
  35620. * @param forceDisposeEffect Force disposal of the associated effect.
  35621. * @param forceDisposeTextures Force disposal of the associated textures.
  35622. */
  35623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35624. /**
  35625. * Clones the material.
  35626. * @param name The cloned name.
  35627. * @returns The cloned material.
  35628. */
  35629. clone(name: string): BackgroundMaterial;
  35630. /**
  35631. * Serializes the current material to its JSON representation.
  35632. * @returns The JSON representation.
  35633. */
  35634. serialize(): any;
  35635. /**
  35636. * Gets the class name of the material
  35637. * @returns "BackgroundMaterial"
  35638. */
  35639. getClassName(): string;
  35640. /**
  35641. * Parse a JSON input to create back a background material.
  35642. * @param source The JSON data to parse
  35643. * @param scene The scene to create the parsed material in
  35644. * @param rootUrl The root url of the assets the material depends upon
  35645. * @returns the instantiated BackgroundMaterial.
  35646. */
  35647. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  35648. }
  35649. }
  35650. declare module BABYLON {
  35651. /**
  35652. * The Physically based material base class of BJS.
  35653. *
  35654. * This offers the main features of a standard PBR material.
  35655. * For more information, please refer to the documentation :
  35656. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35657. */
  35658. abstract class PBRBaseMaterial extends PushMaterial {
  35659. /**
  35660. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  35661. */
  35662. static readonly LIGHTFALLOFF_PHYSICAL: number;
  35663. /**
  35664. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  35665. * to enhance interoperability with other engines.
  35666. */
  35667. static readonly LIGHTFALLOFF_GLTF: number;
  35668. /**
  35669. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  35670. * to enhance interoperability with other materials.
  35671. */
  35672. static readonly LIGHTFALLOFF_STANDARD: number;
  35673. /**
  35674. * Intensity of the direct lights e.g. the four lights available in your scene.
  35675. * This impacts both the direct diffuse and specular highlights.
  35676. */
  35677. protected _directIntensity: number;
  35678. /**
  35679. * Intensity of the emissive part of the material.
  35680. * This helps controlling the emissive effect without modifying the emissive color.
  35681. */
  35682. protected _emissiveIntensity: number;
  35683. /**
  35684. * Intensity of the environment e.g. how much the environment will light the object
  35685. * either through harmonics for rough material or through the refelction for shiny ones.
  35686. */
  35687. protected _environmentIntensity: number;
  35688. /**
  35689. * This is a special control allowing the reduction of the specular highlights coming from the
  35690. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35691. */
  35692. protected _specularIntensity: number;
  35693. /**
  35694. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  35695. */
  35696. private _lightingInfos;
  35697. /**
  35698. * Debug Control allowing disabling the bump map on this material.
  35699. */
  35700. protected _disableBumpMap: boolean;
  35701. /**
  35702. * AKA Diffuse Texture in standard nomenclature.
  35703. */
  35704. protected _albedoTexture: BaseTexture;
  35705. /**
  35706. * AKA Occlusion Texture in other nomenclature.
  35707. */
  35708. protected _ambientTexture: BaseTexture;
  35709. /**
  35710. * AKA Occlusion Texture Intensity in other nomenclature.
  35711. */
  35712. protected _ambientTextureStrength: number;
  35713. /**
  35714. * Defines how much the AO map is occluding the analytical lights (point spot...).
  35715. * 1 means it completely occludes it
  35716. * 0 mean it has no impact
  35717. */
  35718. protected _ambientTextureImpactOnAnalyticalLights: number;
  35719. /**
  35720. * Stores the alpha values in a texture.
  35721. */
  35722. protected _opacityTexture: BaseTexture;
  35723. /**
  35724. * Stores the reflection values in a texture.
  35725. */
  35726. protected _reflectionTexture: BaseTexture;
  35727. /**
  35728. * Stores the refraction values in a texture.
  35729. */
  35730. protected _refractionTexture: BaseTexture;
  35731. /**
  35732. * Stores the emissive values in a texture.
  35733. */
  35734. protected _emissiveTexture: BaseTexture;
  35735. /**
  35736. * AKA Specular texture in other nomenclature.
  35737. */
  35738. protected _reflectivityTexture: BaseTexture;
  35739. /**
  35740. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35741. */
  35742. protected _metallicTexture: BaseTexture;
  35743. /**
  35744. * Specifies the metallic scalar of the metallic/roughness workflow.
  35745. * Can also be used to scale the metalness values of the metallic texture.
  35746. */
  35747. protected _metallic: Nullable<number>;
  35748. /**
  35749. * Specifies the roughness scalar of the metallic/roughness workflow.
  35750. * Can also be used to scale the roughness values of the metallic texture.
  35751. */
  35752. protected _roughness: Nullable<number>;
  35753. /**
  35754. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35755. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35756. */
  35757. protected _microSurfaceTexture: BaseTexture;
  35758. /**
  35759. * Stores surface normal data used to displace a mesh in a texture.
  35760. */
  35761. protected _bumpTexture: BaseTexture;
  35762. /**
  35763. * Stores the pre-calculated light information of a mesh in a texture.
  35764. */
  35765. protected _lightmapTexture: BaseTexture;
  35766. /**
  35767. * The color of a material in ambient lighting.
  35768. */
  35769. protected _ambientColor: Color3;
  35770. /**
  35771. * AKA Diffuse Color in other nomenclature.
  35772. */
  35773. protected _albedoColor: Color3;
  35774. /**
  35775. * AKA Specular Color in other nomenclature.
  35776. */
  35777. protected _reflectivityColor: Color3;
  35778. /**
  35779. * The color applied when light is reflected from a material.
  35780. */
  35781. protected _reflectionColor: Color3;
  35782. /**
  35783. * The color applied when light is emitted from a material.
  35784. */
  35785. protected _emissiveColor: Color3;
  35786. /**
  35787. * AKA Glossiness in other nomenclature.
  35788. */
  35789. protected _microSurface: number;
  35790. /**
  35791. * source material index of refraction (IOR)' / 'destination material IOR.
  35792. */
  35793. protected _indexOfRefraction: number;
  35794. /**
  35795. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35796. */
  35797. protected _invertRefractionY: boolean;
  35798. /**
  35799. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35800. * Materials half opaque for instance using refraction could benefit from this control.
  35801. */
  35802. protected _linkRefractionWithTransparency: boolean;
  35803. /**
  35804. * Specifies that the material will use the light map as a show map.
  35805. */
  35806. protected _useLightmapAsShadowmap: boolean;
  35807. /**
  35808. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35809. * makes the reflect vector face the model (under horizon).
  35810. */
  35811. protected _useHorizonOcclusion: boolean;
  35812. /**
  35813. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35814. * too much the area relying on ambient texture to define their ambient occlusion.
  35815. */
  35816. protected _useRadianceOcclusion: boolean;
  35817. /**
  35818. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35819. */
  35820. protected _useAlphaFromAlbedoTexture: boolean;
  35821. /**
  35822. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35823. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35824. */
  35825. protected _useSpecularOverAlpha: boolean;
  35826. /**
  35827. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35828. */
  35829. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35830. /**
  35831. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35832. */
  35833. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  35834. /**
  35835. * Specifies if the metallic texture contains the roughness information in its green channel.
  35836. */
  35837. protected _useRoughnessFromMetallicTextureGreen: boolean;
  35838. /**
  35839. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35840. */
  35841. protected _useMetallnessFromMetallicTextureBlue: boolean;
  35842. /**
  35843. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35844. */
  35845. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  35846. /**
  35847. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35848. */
  35849. protected _useAmbientInGrayScale: boolean;
  35850. /**
  35851. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35852. * The material will try to infer what glossiness each pixel should be.
  35853. */
  35854. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  35855. /**
  35856. * Defines the falloff type used in this material.
  35857. * It by default is Physical.
  35858. */
  35859. protected _lightFalloff: number;
  35860. /**
  35861. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35862. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35863. */
  35864. protected _useRadianceOverAlpha: boolean;
  35865. /**
  35866. * Allows using an object space normal map (instead of tangent space).
  35867. */
  35868. protected _useObjectSpaceNormalMap: boolean;
  35869. /**
  35870. * Allows using the bump map in parallax mode.
  35871. */
  35872. protected _useParallax: boolean;
  35873. /**
  35874. * Allows using the bump map in parallax occlusion mode.
  35875. */
  35876. protected _useParallaxOcclusion: boolean;
  35877. /**
  35878. * Controls the scale bias of the parallax mode.
  35879. */
  35880. protected _parallaxScaleBias: number;
  35881. /**
  35882. * If sets to true, disables all the lights affecting the material.
  35883. */
  35884. protected _disableLighting: boolean;
  35885. /**
  35886. * Number of Simultaneous lights allowed on the material.
  35887. */
  35888. protected _maxSimultaneousLights: number;
  35889. /**
  35890. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  35891. */
  35892. protected _invertNormalMapX: boolean;
  35893. /**
  35894. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  35895. */
  35896. protected _invertNormalMapY: boolean;
  35897. /**
  35898. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35899. */
  35900. protected _twoSidedLighting: boolean;
  35901. /**
  35902. * Defines the alpha limits in alpha test mode.
  35903. */
  35904. protected _alphaCutOff: number;
  35905. /**
  35906. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35907. */
  35908. protected _forceAlphaTest: boolean;
  35909. /**
  35910. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35911. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35912. */
  35913. protected _useAlphaFresnel: boolean;
  35914. /**
  35915. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35916. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35917. */
  35918. protected _useLinearAlphaFresnel: boolean;
  35919. /**
  35920. * The transparency mode of the material.
  35921. */
  35922. protected _transparencyMode: Nullable<number>;
  35923. /**
  35924. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  35925. * from cos thetav and roughness:
  35926. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  35927. */
  35928. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  35929. /**
  35930. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35931. */
  35932. protected _forceIrradianceInFragment: boolean;
  35933. /**
  35934. * Force normal to face away from face.
  35935. */
  35936. protected _forceNormalForward: boolean;
  35937. /**
  35938. * Enables specular anti aliasing in the PBR shader.
  35939. * It will both interacts on the Geometry for analytical and IBL lighting.
  35940. * It also prefilter the roughness map based on the bump values.
  35941. */
  35942. protected _enableSpecularAntiAliasing: boolean;
  35943. /**
  35944. * Default configuration related to image processing available in the PBR Material.
  35945. */
  35946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35947. /**
  35948. * Keep track of the image processing observer to allow dispose and replace.
  35949. */
  35950. private _imageProcessingObserver;
  35951. /**
  35952. * Attaches a new image processing configuration to the PBR Material.
  35953. * @param configuration
  35954. */
  35955. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35956. /**
  35957. * Stores the available render targets.
  35958. */
  35959. private _renderTargets;
  35960. /**
  35961. * Sets the global ambient color for the material used in lighting calculations.
  35962. */
  35963. private _globalAmbientColor;
  35964. /**
  35965. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  35966. */
  35967. private _useLogarithmicDepth;
  35968. /**
  35969. * If set to true, no lighting calculations will be applied.
  35970. */
  35971. private _unlit;
  35972. /**
  35973. * Instantiates a new PBRMaterial instance.
  35974. *
  35975. * @param name The material name
  35976. * @param scene The scene the material will be use in.
  35977. */
  35978. constructor(name: string, scene: Scene);
  35979. /**
  35980. * Gets the name of the material class.
  35981. */
  35982. getClassName(): string;
  35983. /**
  35984. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35985. */
  35986. /**
  35987. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35988. */
  35989. useLogarithmicDepth: boolean;
  35990. /**
  35991. * Gets the current transparency mode.
  35992. */
  35993. /**
  35994. * Sets the transparency mode of the material.
  35995. *
  35996. * | Value | Type | Description |
  35997. * | ----- | ----------------------------------- | ----------- |
  35998. * | 0 | OPAQUE | |
  35999. * | 1 | ALPHATEST | |
  36000. * | 2 | ALPHABLEND | |
  36001. * | 3 | ALPHATESTANDBLEND | |
  36002. *
  36003. */
  36004. transparencyMode: Nullable<number>;
  36005. /**
  36006. * Returns true if alpha blending should be disabled.
  36007. */
  36008. private readonly _disableAlphaBlending;
  36009. /**
  36010. * Specifies whether or not this material should be rendered in alpha blend mode.
  36011. */
  36012. needAlphaBlending(): boolean;
  36013. /**
  36014. * Specifies if the mesh will require alpha blending.
  36015. * @param mesh - BJS mesh.
  36016. */
  36017. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  36018. /**
  36019. * Specifies whether or not this material should be rendered in alpha test mode.
  36020. */
  36021. needAlphaTesting(): boolean;
  36022. /**
  36023. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  36024. */
  36025. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  36026. /**
  36027. * Gets the texture used for the alpha test.
  36028. */
  36029. getAlphaTestTexture(): BaseTexture;
  36030. /**
  36031. * Stores the reflectivity values based on metallic roughness workflow.
  36032. */
  36033. private static _scaledReflectivity;
  36034. /**
  36035. * Specifies that the submesh is ready to be used.
  36036. * @param mesh - BJS mesh.
  36037. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  36038. * @param useInstances - Specifies that instances should be used.
  36039. * @returns - boolean indicating that the submesh is ready or not.
  36040. */
  36041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  36042. /**
  36043. * Specifies if the material uses metallic roughness workflow.
  36044. * @returns boolean specifiying if the material uses metallic roughness workflow.
  36045. */
  36046. isMetallicWorkflow(): boolean;
  36047. private _prepareEffect;
  36048. private _prepareDefines;
  36049. /**
  36050. * Force shader compilation
  36051. */
  36052. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  36053. clipPlane: boolean;
  36054. }>): void;
  36055. /**
  36056. * Initializes the uniform buffer layout for the shader.
  36057. */
  36058. buildUniformLayout(): void;
  36059. /**
  36060. * Unbinds the textures.
  36061. */
  36062. unbind(): void;
  36063. /**
  36064. * Binds the submesh data.
  36065. * @param world - The world matrix.
  36066. * @param mesh - The BJS mesh.
  36067. * @param subMesh - A submesh of the BJS mesh.
  36068. */
  36069. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  36070. /**
  36071. * Returns the animatable textures.
  36072. * @returns - Array of animatable textures.
  36073. */
  36074. getAnimatables(): IAnimatable[];
  36075. /**
  36076. * Returns the texture used for reflections.
  36077. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  36078. */
  36079. private _getReflectionTexture;
  36080. /**
  36081. * Returns the texture used for refraction or null if none is used.
  36082. * @returns - Refection texture if present. If no refraction texture and refraction
  36083. * is linked with transparency, returns environment texture. Otherwise, returns null.
  36084. */
  36085. private _getRefractionTexture;
  36086. /**
  36087. * Disposes the resources of the material.
  36088. * @param forceDisposeEffect - Forces the disposal of effects.
  36089. * @param forceDisposeTextures - Forces the disposal of all textures.
  36090. */
  36091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  36092. }
  36093. }
  36094. declare module BABYLON {
  36095. /**
  36096. * The Physically based simple base material of BJS.
  36097. *
  36098. * This enables better naming and convention enforcements on top of the pbrMaterial.
  36099. * It is used as the base class for both the specGloss and metalRough conventions.
  36100. */
  36101. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  36102. /**
  36103. * Number of Simultaneous lights allowed on the material.
  36104. */
  36105. maxSimultaneousLights: number;
  36106. /**
  36107. * If sets to true, disables all the lights affecting the material.
  36108. */
  36109. disableLighting: boolean;
  36110. /**
  36111. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  36112. */
  36113. environmentTexture: BaseTexture;
  36114. /**
  36115. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36116. */
  36117. invertNormalMapX: boolean;
  36118. /**
  36119. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36120. */
  36121. invertNormalMapY: boolean;
  36122. /**
  36123. * Normal map used in the model.
  36124. */
  36125. normalTexture: BaseTexture;
  36126. /**
  36127. * Emissivie color used to self-illuminate the model.
  36128. */
  36129. emissiveColor: Color3;
  36130. /**
  36131. * Emissivie texture used to self-illuminate the model.
  36132. */
  36133. emissiveTexture: BaseTexture;
  36134. /**
  36135. * Occlusion Channel Strenght.
  36136. */
  36137. occlusionStrength: number;
  36138. /**
  36139. * Occlusion Texture of the material (adding extra occlusion effects).
  36140. */
  36141. occlusionTexture: BaseTexture;
  36142. /**
  36143. * Defines the alpha limits in alpha test mode.
  36144. */
  36145. alphaCutOff: number;
  36146. /**
  36147. * Gets the current double sided mode.
  36148. */
  36149. /**
  36150. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36151. */
  36152. doubleSided: boolean;
  36153. lightmapTexture: BaseTexture;
  36154. useLightmapAsShadowmap: boolean;
  36155. /**
  36156. * Return the active textures of the material.
  36157. */
  36158. getActiveTextures(): BaseTexture[];
  36159. hasTexture(texture: BaseTexture): boolean;
  36160. /**
  36161. * Instantiates a new PBRMaterial instance.
  36162. *
  36163. * @param name The material name
  36164. * @param scene The scene the material will be use in.
  36165. */
  36166. constructor(name: string, scene: Scene);
  36167. getClassName(): string;
  36168. }
  36169. }
  36170. declare module BABYLON {
  36171. /**
  36172. * The Physically based material of BJS.
  36173. *
  36174. * This offers the main features of a standard PBR material.
  36175. * For more information, please refer to the documentation :
  36176. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  36177. */
  36178. class PBRMaterial extends PBRBaseMaterial {
  36179. /**
  36180. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  36181. */
  36182. static readonly PBRMATERIAL_OPAQUE: number;
  36183. /**
  36184. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  36185. */
  36186. static readonly PBRMATERIAL_ALPHATEST: number;
  36187. /**
  36188. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36189. */
  36190. static readonly PBRMATERIAL_ALPHABLEND: number;
  36191. /**
  36192. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36193. * They are also discarded below the alpha cutoff threshold to improve performances.
  36194. */
  36195. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  36196. /**
  36197. * Defines the default value of how much AO map is occluding the analytical lights
  36198. * (point spot...).
  36199. */
  36200. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  36201. /**
  36202. * Intensity of the direct lights e.g. the four lights available in your scene.
  36203. * This impacts both the direct diffuse and specular highlights.
  36204. */
  36205. directIntensity: number;
  36206. /**
  36207. * Intensity of the emissive part of the material.
  36208. * This helps controlling the emissive effect without modifying the emissive color.
  36209. */
  36210. emissiveIntensity: number;
  36211. /**
  36212. * Intensity of the environment e.g. how much the environment will light the object
  36213. * either through harmonics for rough material or through the refelction for shiny ones.
  36214. */
  36215. environmentIntensity: number;
  36216. /**
  36217. * This is a special control allowing the reduction of the specular highlights coming from the
  36218. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36219. */
  36220. specularIntensity: number;
  36221. /**
  36222. * Debug Control allowing disabling the bump map on this material.
  36223. */
  36224. disableBumpMap: boolean;
  36225. /**
  36226. * AKA Diffuse Texture in standard nomenclature.
  36227. */
  36228. albedoTexture: BaseTexture;
  36229. /**
  36230. * AKA Occlusion Texture in other nomenclature.
  36231. */
  36232. ambientTexture: BaseTexture;
  36233. /**
  36234. * AKA Occlusion Texture Intensity in other nomenclature.
  36235. */
  36236. ambientTextureStrength: number;
  36237. /**
  36238. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36239. * 1 means it completely occludes it
  36240. * 0 mean it has no impact
  36241. */
  36242. ambientTextureImpactOnAnalyticalLights: number;
  36243. /**
  36244. * Stores the alpha values in a texture.
  36245. */
  36246. opacityTexture: BaseTexture;
  36247. /**
  36248. * Stores the reflection values in a texture.
  36249. */
  36250. reflectionTexture: Nullable<BaseTexture>;
  36251. /**
  36252. * Stores the emissive values in a texture.
  36253. */
  36254. emissiveTexture: BaseTexture;
  36255. /**
  36256. * AKA Specular texture in other nomenclature.
  36257. */
  36258. reflectivityTexture: BaseTexture;
  36259. /**
  36260. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36261. */
  36262. metallicTexture: BaseTexture;
  36263. /**
  36264. * Specifies the metallic scalar of the metallic/roughness workflow.
  36265. * Can also be used to scale the metalness values of the metallic texture.
  36266. */
  36267. metallic: Nullable<number>;
  36268. /**
  36269. * Specifies the roughness scalar of the metallic/roughness workflow.
  36270. * Can also be used to scale the roughness values of the metallic texture.
  36271. */
  36272. roughness: Nullable<number>;
  36273. /**
  36274. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36275. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36276. */
  36277. microSurfaceTexture: BaseTexture;
  36278. /**
  36279. * Stores surface normal data used to displace a mesh in a texture.
  36280. */
  36281. bumpTexture: BaseTexture;
  36282. /**
  36283. * Stores the pre-calculated light information of a mesh in a texture.
  36284. */
  36285. lightmapTexture: BaseTexture;
  36286. /**
  36287. * Stores the refracted light information in a texture.
  36288. */
  36289. refractionTexture: BaseTexture;
  36290. /**
  36291. * The color of a material in ambient lighting.
  36292. */
  36293. ambientColor: Color3;
  36294. /**
  36295. * AKA Diffuse Color in other nomenclature.
  36296. */
  36297. albedoColor: Color3;
  36298. /**
  36299. * AKA Specular Color in other nomenclature.
  36300. */
  36301. reflectivityColor: Color3;
  36302. /**
  36303. * The color reflected from the material.
  36304. */
  36305. reflectionColor: Color3;
  36306. /**
  36307. * The color emitted from the material.
  36308. */
  36309. emissiveColor: Color3;
  36310. /**
  36311. * AKA Glossiness in other nomenclature.
  36312. */
  36313. microSurface: number;
  36314. /**
  36315. * source material index of refraction (IOR)' / 'destination material IOR.
  36316. */
  36317. indexOfRefraction: number;
  36318. /**
  36319. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36320. */
  36321. invertRefractionY: boolean;
  36322. /**
  36323. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36324. * Materials half opaque for instance using refraction could benefit from this control.
  36325. */
  36326. linkRefractionWithTransparency: boolean;
  36327. useLightmapAsShadowmap: boolean;
  36328. /**
  36329. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36330. */
  36331. useAlphaFromAlbedoTexture: boolean;
  36332. /**
  36333. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36334. */
  36335. forceAlphaTest: boolean;
  36336. /**
  36337. * Defines the alpha limits in alpha test mode.
  36338. */
  36339. alphaCutOff: number;
  36340. /**
  36341. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36342. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36343. */
  36344. useSpecularOverAlpha: boolean;
  36345. /**
  36346. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36347. */
  36348. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36349. /**
  36350. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36351. */
  36352. useRoughnessFromMetallicTextureAlpha: boolean;
  36353. /**
  36354. * Specifies if the metallic texture contains the roughness information in its green channel.
  36355. */
  36356. useRoughnessFromMetallicTextureGreen: boolean;
  36357. /**
  36358. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36359. */
  36360. useMetallnessFromMetallicTextureBlue: boolean;
  36361. /**
  36362. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36363. */
  36364. useAmbientOcclusionFromMetallicTextureRed: boolean;
  36365. /**
  36366. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36367. */
  36368. useAmbientInGrayScale: boolean;
  36369. /**
  36370. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36371. * The material will try to infer what glossiness each pixel should be.
  36372. */
  36373. useAutoMicroSurfaceFromReflectivityMap: boolean;
  36374. /**
  36375. * BJS is using an harcoded light falloff based on a manually sets up range.
  36376. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36377. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36378. */
  36379. /**
  36380. * BJS is using an harcoded light falloff based on a manually sets up range.
  36381. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36382. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36383. */
  36384. usePhysicalLightFalloff: boolean;
  36385. /**
  36386. * In order to support the falloff compatibility with gltf, a special mode has been added
  36387. * to reproduce the gltf light falloff.
  36388. */
  36389. /**
  36390. * In order to support the falloff compatibility with gltf, a special mode has been added
  36391. * to reproduce the gltf light falloff.
  36392. */
  36393. useGLTFLightFalloff: boolean;
  36394. /**
  36395. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36396. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36397. */
  36398. useRadianceOverAlpha: boolean;
  36399. /**
  36400. * Allows using an object space normal map (instead of tangent space).
  36401. */
  36402. useObjectSpaceNormalMap: boolean;
  36403. /**
  36404. * Allows using the bump map in parallax mode.
  36405. */
  36406. useParallax: boolean;
  36407. /**
  36408. * Allows using the bump map in parallax occlusion mode.
  36409. */
  36410. useParallaxOcclusion: boolean;
  36411. /**
  36412. * Controls the scale bias of the parallax mode.
  36413. */
  36414. parallaxScaleBias: number;
  36415. /**
  36416. * If sets to true, disables all the lights affecting the material.
  36417. */
  36418. disableLighting: boolean;
  36419. /**
  36420. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  36421. */
  36422. forceIrradianceInFragment: boolean;
  36423. /**
  36424. * Number of Simultaneous lights allowed on the material.
  36425. */
  36426. maxSimultaneousLights: number;
  36427. /**
  36428. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36429. */
  36430. invertNormalMapX: boolean;
  36431. /**
  36432. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36433. */
  36434. invertNormalMapY: boolean;
  36435. /**
  36436. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36437. */
  36438. twoSidedLighting: boolean;
  36439. /**
  36440. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36441. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  36442. */
  36443. useAlphaFresnel: boolean;
  36444. /**
  36445. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36446. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  36447. */
  36448. useLinearAlphaFresnel: boolean;
  36449. /**
  36450. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36451. * And/Or occlude the blended part.
  36452. */
  36453. environmentBRDFTexture: Nullable<BaseTexture>;
  36454. /**
  36455. * Force normal to face away from face.
  36456. */
  36457. forceNormalForward: boolean;
  36458. /**
  36459. * Enables specular anti aliasing in the PBR shader.
  36460. * It will both interacts on the Geometry for analytical and IBL lighting.
  36461. * It also prefilter the roughness map based on the bump values.
  36462. */
  36463. enableSpecularAntiAliasing: boolean;
  36464. /**
  36465. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  36466. * makes the reflect vector face the model (under horizon).
  36467. */
  36468. useHorizonOcclusion: boolean;
  36469. /**
  36470. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  36471. * too much the area relying on ambient texture to define their ambient occlusion.
  36472. */
  36473. useRadianceOcclusion: boolean;
  36474. /**
  36475. * If set to true, no lighting calculations will be applied.
  36476. */
  36477. unlit: boolean;
  36478. /**
  36479. * Gets the image processing configuration used either in this material.
  36480. */
  36481. /**
  36482. * Sets the Default image processing configuration used either in the this material.
  36483. *
  36484. * If sets to null, the scene one is in use.
  36485. */
  36486. imageProcessingConfiguration: ImageProcessingConfiguration;
  36487. /**
  36488. * Gets wether the color curves effect is enabled.
  36489. */
  36490. /**
  36491. * Sets wether the color curves effect is enabled.
  36492. */
  36493. cameraColorCurvesEnabled: boolean;
  36494. /**
  36495. * Gets wether the color grading effect is enabled.
  36496. */
  36497. /**
  36498. * Gets wether the color grading effect is enabled.
  36499. */
  36500. cameraColorGradingEnabled: boolean;
  36501. /**
  36502. * Gets wether tonemapping is enabled or not.
  36503. */
  36504. /**
  36505. * Sets wether tonemapping is enabled or not
  36506. */
  36507. cameraToneMappingEnabled: boolean;
  36508. /**
  36509. * The camera exposure used on this material.
  36510. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36511. * This corresponds to a photographic exposure.
  36512. */
  36513. /**
  36514. * The camera exposure used on this material.
  36515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36516. * This corresponds to a photographic exposure.
  36517. */
  36518. cameraExposure: number;
  36519. /**
  36520. * Gets The camera contrast used on this material.
  36521. */
  36522. /**
  36523. * Sets The camera contrast used on this material.
  36524. */
  36525. cameraContrast: number;
  36526. /**
  36527. * Gets the Color Grading 2D Lookup Texture.
  36528. */
  36529. /**
  36530. * Sets the Color Grading 2D Lookup Texture.
  36531. */
  36532. cameraColorGradingTexture: Nullable<BaseTexture>;
  36533. /**
  36534. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36535. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36536. * 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;
  36537. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36538. */
  36539. /**
  36540. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36541. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36542. * 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;
  36543. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36544. */
  36545. cameraColorCurves: Nullable<ColorCurves>;
  36546. /**
  36547. * Instantiates a new PBRMaterial instance.
  36548. *
  36549. * @param name The material name
  36550. * @param scene The scene the material will be use in.
  36551. */
  36552. constructor(name: string, scene: Scene);
  36553. /**
  36554. * Returns the name of this material class.
  36555. */
  36556. getClassName(): string;
  36557. /**
  36558. * Returns an array of the actively used textures.
  36559. * @returns - Array of BaseTextures
  36560. */
  36561. getActiveTextures(): BaseTexture[];
  36562. /**
  36563. * Checks to see if a texture is used in the material.
  36564. * @param texture - Base texture to use.
  36565. * @returns - Boolean specifying if a texture is used in the material.
  36566. */
  36567. hasTexture(texture: BaseTexture): boolean;
  36568. /**
  36569. * Makes a duplicate of the current material.
  36570. * @param name - name to use for the new material.
  36571. */
  36572. clone(name: string): PBRMaterial;
  36573. /**
  36574. * Serializes this PBR Material.
  36575. * @returns - An object with the serialized material.
  36576. */
  36577. serialize(): any;
  36578. /**
  36579. * Parses a PBR Material from a serialized object.
  36580. * @param source - Serialized object.
  36581. * @param scene - BJS scene instance.
  36582. * @param rootUrl - url for the scene object
  36583. * @returns - PBRMaterial
  36584. */
  36585. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  36586. }
  36587. }
  36588. declare module BABYLON {
  36589. /**
  36590. * The PBR material of BJS following the metal roughness convention.
  36591. *
  36592. * This fits to the PBR convention in the GLTF definition:
  36593. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  36594. */
  36595. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  36596. /**
  36597. * The base color has two different interpretations depending on the value of metalness.
  36598. * When the material is a metal, the base color is the specific measured reflectance value
  36599. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  36600. * of the material.
  36601. */
  36602. baseColor: Color3;
  36603. /**
  36604. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  36605. * well as opacity information in the alpha channel.
  36606. */
  36607. baseTexture: BaseTexture;
  36608. /**
  36609. * Specifies the metallic scalar value of the material.
  36610. * Can also be used to scale the metalness values of the metallic texture.
  36611. */
  36612. metallic: number;
  36613. /**
  36614. * Specifies the roughness scalar value of the material.
  36615. * Can also be used to scale the roughness values of the metallic texture.
  36616. */
  36617. roughness: number;
  36618. /**
  36619. * Texture containing both the metallic value in the B channel and the
  36620. * roughness value in the G channel to keep better precision.
  36621. */
  36622. metallicRoughnessTexture: BaseTexture;
  36623. /**
  36624. * Instantiates a new PBRMetalRoughnessMaterial instance.
  36625. *
  36626. * @param name The material name
  36627. * @param scene The scene the material will be use in.
  36628. */
  36629. constructor(name: string, scene: Scene);
  36630. /**
  36631. * Return the currrent class name of the material.
  36632. */
  36633. getClassName(): string;
  36634. /**
  36635. * Return the active textures of the material.
  36636. */
  36637. getActiveTextures(): BaseTexture[];
  36638. /**
  36639. * Checks to see if a texture is used in the material.
  36640. * @param texture - Base texture to use.
  36641. * @returns - Boolean specifying if a texture is used in the material.
  36642. */
  36643. hasTexture(texture: BaseTexture): boolean;
  36644. /**
  36645. * Makes a duplicate of the current material.
  36646. * @param name - name to use for the new material.
  36647. */
  36648. clone(name: string): PBRMetallicRoughnessMaterial;
  36649. /**
  36650. * Serialize the material to a parsable JSON object.
  36651. */
  36652. serialize(): any;
  36653. /**
  36654. * Parses a JSON object correponding to the serialize function.
  36655. */
  36656. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  36657. }
  36658. }
  36659. declare module BABYLON {
  36660. /**
  36661. * The PBR material of BJS following the specular glossiness convention.
  36662. *
  36663. * This fits to the PBR convention in the GLTF definition:
  36664. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  36665. */
  36666. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  36667. /**
  36668. * Specifies the diffuse color of the material.
  36669. */
  36670. diffuseColor: Color3;
  36671. /**
  36672. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  36673. * channel.
  36674. */
  36675. diffuseTexture: BaseTexture;
  36676. /**
  36677. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  36678. */
  36679. specularColor: Color3;
  36680. /**
  36681. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  36682. */
  36683. glossiness: number;
  36684. /**
  36685. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  36686. */
  36687. specularGlossinessTexture: BaseTexture;
  36688. /**
  36689. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  36690. *
  36691. * @param name The material name
  36692. * @param scene The scene the material will be use in.
  36693. */
  36694. constructor(name: string, scene: Scene);
  36695. /**
  36696. * Return the currrent class name of the material.
  36697. */
  36698. getClassName(): string;
  36699. /**
  36700. * Return the active textures of the material.
  36701. */
  36702. getActiveTextures(): BaseTexture[];
  36703. /**
  36704. * Checks to see if a texture is used in the material.
  36705. * @param texture - Base texture to use.
  36706. * @returns - Boolean specifying if a texture is used in the material.
  36707. */
  36708. hasTexture(texture: BaseTexture): boolean;
  36709. /**
  36710. * Makes a duplicate of the current material.
  36711. * @param name - name to use for the new material.
  36712. */
  36713. clone(name: string): PBRSpecularGlossinessMaterial;
  36714. /**
  36715. * Serialize the material to a parsable JSON object.
  36716. */
  36717. serialize(): any;
  36718. /**
  36719. * Parses a JSON object correponding to the serialize function.
  36720. */
  36721. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  36722. }
  36723. }
  36724. declare module BABYLON {
  36725. class BaseTexture {
  36726. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  36727. name: string;
  36728. private _hasAlpha;
  36729. hasAlpha: boolean;
  36730. getAlphaFromRGB: boolean;
  36731. level: number;
  36732. coordinatesIndex: number;
  36733. private _coordinatesMode;
  36734. /**
  36735. * How a texture is mapped.
  36736. *
  36737. * | Value | Type | Description |
  36738. * | ----- | ----------------------------------- | ----------- |
  36739. * | 0 | EXPLICIT_MODE | |
  36740. * | 1 | SPHERICAL_MODE | |
  36741. * | 2 | PLANAR_MODE | |
  36742. * | 3 | CUBIC_MODE | |
  36743. * | 4 | PROJECTION_MODE | |
  36744. * | 5 | SKYBOX_MODE | |
  36745. * | 6 | INVCUBIC_MODE | |
  36746. * | 7 | EQUIRECTANGULAR_MODE | |
  36747. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  36748. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  36749. */
  36750. coordinatesMode: number;
  36751. /**
  36752. * | Value | Type | Description |
  36753. * | ----- | ------------------ | ----------- |
  36754. * | 0 | CLAMP_ADDRESSMODE | |
  36755. * | 1 | WRAP_ADDRESSMODE | |
  36756. * | 2 | MIRROR_ADDRESSMODE | |
  36757. */
  36758. wrapU: number;
  36759. /**
  36760. * | Value | Type | Description |
  36761. * | ----- | ------------------ | ----------- |
  36762. * | 0 | CLAMP_ADDRESSMODE | |
  36763. * | 1 | WRAP_ADDRESSMODE | |
  36764. * | 2 | MIRROR_ADDRESSMODE | |
  36765. */
  36766. wrapV: number;
  36767. /**
  36768. * | Value | Type | Description |
  36769. * | ----- | ------------------ | ----------- |
  36770. * | 0 | CLAMP_ADDRESSMODE | |
  36771. * | 1 | WRAP_ADDRESSMODE | |
  36772. * | 2 | MIRROR_ADDRESSMODE | |
  36773. */
  36774. wrapR: number;
  36775. anisotropicFilteringLevel: number;
  36776. isCube: boolean;
  36777. is3D: boolean;
  36778. gammaSpace: boolean;
  36779. /**
  36780. * Gets whether or not the texture contains RGBD data.
  36781. */
  36782. readonly isRGBD: boolean;
  36783. invertZ: boolean;
  36784. lodLevelInAlpha: boolean;
  36785. lodGenerationOffset: number;
  36786. lodGenerationScale: number;
  36787. isRenderTarget: boolean;
  36788. readonly uid: string;
  36789. toString(): string;
  36790. getClassName(): string;
  36791. animations: Animation[];
  36792. /**
  36793. * An event triggered when the texture is disposed.
  36794. */
  36795. onDisposeObservable: Observable<BaseTexture>;
  36796. private _onDisposeObserver;
  36797. onDispose: () => void;
  36798. delayLoadState: number;
  36799. private _scene;
  36800. /** @hidden */
  36801. _texture: Nullable<InternalTexture>;
  36802. private _uid;
  36803. readonly isBlocking: boolean;
  36804. constructor(scene: Nullable<Scene>);
  36805. getScene(): Nullable<Scene>;
  36806. getTextureMatrix(): Matrix;
  36807. getReflectionTextureMatrix(): Matrix;
  36808. getInternalTexture(): Nullable<InternalTexture>;
  36809. isReadyOrNotBlocking(): boolean;
  36810. isReady(): boolean;
  36811. private _cachedSize;
  36812. getSize(): ISize;
  36813. getBaseSize(): ISize;
  36814. scale(ratio: number): void;
  36815. readonly canRescale: boolean;
  36816. /** @hidden */
  36817. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  36818. /** @hidden */
  36819. _rebuild(): void;
  36820. delayLoad(): void;
  36821. clone(): Nullable<BaseTexture>;
  36822. readonly textureType: number;
  36823. readonly textureFormat: number;
  36824. /**
  36825. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  36826. * This will returns an RGBA array buffer containing either in values (0-255) or
  36827. * float values (0-1) depending of the underlying buffer type.
  36828. * @param faceIndex The face of the texture to read (in case of cube texture)
  36829. * @param level The LOD level of the texture to read (in case of Mip Maps)
  36830. * @returns The Array buffer containing the pixels data.
  36831. */
  36832. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  36833. releaseInternalTexture(): void;
  36834. sphericalPolynomial: Nullable<SphericalPolynomial>;
  36835. readonly _lodTextureHigh: Nullable<BaseTexture>;
  36836. readonly _lodTextureMid: Nullable<BaseTexture>;
  36837. readonly _lodTextureLow: Nullable<BaseTexture>;
  36838. dispose(): void;
  36839. serialize(): any;
  36840. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  36841. }
  36842. }
  36843. declare module BABYLON {
  36844. /**
  36845. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  36846. * It can help converting any input color in a desired output one. This can then be used to create effects
  36847. * from sepia, black and white to sixties or futuristic rendering...
  36848. *
  36849. * The only supported format is currently 3dl.
  36850. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  36851. */
  36852. class ColorGradingTexture extends BaseTexture {
  36853. /**
  36854. * The current texture matrix. (will always be identity in color grading texture)
  36855. */
  36856. private _textureMatrix;
  36857. /**
  36858. * The texture URL.
  36859. */
  36860. url: string;
  36861. /**
  36862. * Empty line regex stored for GC.
  36863. */
  36864. private static _noneEmptyLineRegex;
  36865. private _engine;
  36866. /**
  36867. * Instantiates a ColorGradingTexture from the following parameters.
  36868. *
  36869. * @param url The location of the color gradind data (currently only supporting 3dl)
  36870. * @param scene The scene the texture will be used in
  36871. */
  36872. constructor(url: string, scene: Scene);
  36873. /**
  36874. * Returns the texture matrix used in most of the material.
  36875. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  36876. */
  36877. getTextureMatrix(): Matrix;
  36878. /**
  36879. * Occurs when the file being loaded is a .3dl LUT file.
  36880. */
  36881. private load3dlTexture;
  36882. /**
  36883. * Starts the loading process of the texture.
  36884. */
  36885. private loadTexture;
  36886. /**
  36887. * Clones the color gradind texture.
  36888. */
  36889. clone(): ColorGradingTexture;
  36890. /**
  36891. * Called during delayed load for textures.
  36892. */
  36893. delayLoad(): void;
  36894. /**
  36895. * Parses a color grading texture serialized by Babylon.
  36896. * @param parsedTexture The texture information being parsedTexture
  36897. * @param scene The scene to load the texture in
  36898. * @param rootUrl The root url of the data assets to load
  36899. * @return A color gradind texture
  36900. */
  36901. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  36902. /**
  36903. * Serializes the LUT texture to json format.
  36904. */
  36905. serialize(): any;
  36906. }
  36907. }
  36908. declare module BABYLON {
  36909. class CubeTexture extends BaseTexture {
  36910. url: string;
  36911. /**
  36912. * Gets or sets the center of the bounding box associated with the cube texture
  36913. * It must define where the camera used to render the texture was set
  36914. */
  36915. boundingBoxPosition: Vector3;
  36916. private _boundingBoxSize;
  36917. /**
  36918. * Gets or sets the size of the bounding box associated with the cube texture
  36919. * When defined, the cubemap will switch to local mode
  36920. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36921. * @example https://www.babylonjs-playground.com/#RNASML
  36922. */
  36923. boundingBoxSize: Vector3;
  36924. protected _rotationY: number;
  36925. /**
  36926. * Sets texture matrix rotation angle around Y axis in radians.
  36927. */
  36928. /**
  36929. * Gets texture matrix rotation angle around Y axis radians.
  36930. */
  36931. rotationY: number;
  36932. private _noMipmap;
  36933. private _files;
  36934. private _extensions;
  36935. private _textureMatrix;
  36936. private _format;
  36937. private _createPolynomials;
  36938. /** @hidden */
  36939. readonly _prefiltered: boolean;
  36940. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  36941. /**
  36942. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  36943. * @param url defines the url of the prefiltered texture
  36944. * @param scene defines the scene the texture is attached to
  36945. * @param forcedExtension defines the extension of the file if different from the url
  36946. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36947. * @return the prefiltered texture
  36948. */
  36949. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  36950. /**
  36951. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  36952. * as prefiltered data.
  36953. * @param rootUrl defines the url of the texture or the root name of the six images
  36954. * @param scene defines the scene the texture is attached to
  36955. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  36956. * @param noMipmap defines if mipmaps should be created or not
  36957. * @param files defines the six files to load for the different faces
  36958. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  36959. * @param onError defines a callback triggered in case of error during load
  36960. * @param format defines the internal format to use for the texture once loaded
  36961. * @param prefiltered defines whether or not the texture is created from prefiltered data
  36962. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  36963. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36964. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36965. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36966. * @return the cube texture
  36967. */
  36968. 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);
  36969. delayLoad(): void;
  36970. getReflectionTextureMatrix(): Matrix;
  36971. setReflectionTextureMatrix(value: Matrix): void;
  36972. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  36973. clone(): CubeTexture;
  36974. }
  36975. }
  36976. declare module BABYLON {
  36977. /**
  36978. * A class extending {BABYLON.Texture} allowing drawing on a texture
  36979. * @see http://doc.babylonjs.com/how_to/dynamictexture
  36980. */
  36981. class DynamicTexture extends Texture {
  36982. private _generateMipMaps;
  36983. private _canvas;
  36984. private _context;
  36985. private _engine;
  36986. /**
  36987. * Creates a {BABYLON.DynamicTexture}
  36988. * @param name defines the name of the texture
  36989. * @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
  36990. * @param scene defines the scene where you want the texture
  36991. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  36992. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36993. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  36994. */
  36995. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  36996. /**
  36997. * Gets the current state of canRescale
  36998. */
  36999. readonly canRescale: boolean;
  37000. private _recreate;
  37001. /**
  37002. * Scales the texture
  37003. * @param ratio the scale factor to apply to both width and height
  37004. */
  37005. scale(ratio: number): void;
  37006. /**
  37007. * Resizes the texture
  37008. * @param width the new width
  37009. * @param height the new height
  37010. */
  37011. scaleTo(width: number, height: number): void;
  37012. /**
  37013. * Gets the context of the canvas used by the texture
  37014. * @returns the canvas context of the dynamic texture
  37015. */
  37016. getContext(): CanvasRenderingContext2D;
  37017. /**
  37018. * Clears the texture
  37019. */
  37020. clear(): void;
  37021. /**
  37022. * Updates the texture
  37023. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37024. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37025. */
  37026. update(invertY?: boolean, premulAlpha?: boolean): void;
  37027. /**
  37028. * Draws text onto the texture
  37029. * @param text defines the text to be drawn
  37030. * @param x defines the placement of the text from the left
  37031. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37032. * @param font defines the font to be used with font-style, font-size, font-name
  37033. * @param color defines the color used for the text
  37034. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37035. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37036. * @param update defines whether texture is immediately update (default is true)
  37037. */
  37038. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37039. /**
  37040. * Clones the texture
  37041. * @returns the clone of the texture.
  37042. */
  37043. clone(): DynamicTexture;
  37044. /**
  37045. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37046. * @returns a serialized dynamic texture object
  37047. */
  37048. serialize(): any;
  37049. /** @hidden */
  37050. _rebuild(): void;
  37051. }
  37052. }
  37053. declare module BABYLON {
  37054. /**
  37055. * This represents a texture coming from an HDR input.
  37056. *
  37057. * The only supported format is currently panorama picture stored in RGBE format.
  37058. * Example of such files can be found on HDRLib: http://hdrlib.com/
  37059. */
  37060. class HDRCubeTexture extends BaseTexture {
  37061. private static _facesMapping;
  37062. private _generateHarmonics;
  37063. private _noMipmap;
  37064. private _textureMatrix;
  37065. private _size;
  37066. private _onLoad;
  37067. private _onError;
  37068. /**
  37069. * The texture URL.
  37070. */
  37071. url: string;
  37072. /**
  37073. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  37074. */
  37075. coordinatesMode: number;
  37076. protected _isBlocking: boolean;
  37077. /**
  37078. * Sets wether or not the texture is blocking during loading.
  37079. */
  37080. /**
  37081. * Gets wether or not the texture is blocking during loading.
  37082. */
  37083. isBlocking: boolean;
  37084. protected _rotationY: number;
  37085. /**
  37086. * Sets texture matrix rotation angle around Y axis in radians.
  37087. */
  37088. /**
  37089. * Gets texture matrix rotation angle around Y axis radians.
  37090. */
  37091. rotationY: number;
  37092. /**
  37093. * Gets or sets the center of the bounding box associated with the cube texture
  37094. * It must define where the camera used to render the texture was set
  37095. */
  37096. boundingBoxPosition: Vector3;
  37097. private _boundingBoxSize;
  37098. /**
  37099. * Gets or sets the size of the bounding box associated with the cube texture
  37100. * When defined, the cubemap will switch to local mode
  37101. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37102. * @example https://www.babylonjs-playground.com/#RNASML
  37103. */
  37104. boundingBoxSize: Vector3;
  37105. /**
  37106. * Instantiates an HDRTexture from the following parameters.
  37107. *
  37108. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  37109. * @param scene The scene the texture will be used in
  37110. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  37111. * @param noMipmap Forces to not generate the mipmap if true
  37112. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  37113. * @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)
  37114. * @param reserved Reserved flag for internal use.
  37115. */
  37116. 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>);
  37117. /**
  37118. * Occurs when the file is raw .hdr file.
  37119. */
  37120. private loadTexture;
  37121. clone(): HDRCubeTexture;
  37122. delayLoad(): void;
  37123. getReflectionTextureMatrix(): Matrix;
  37124. setReflectionTextureMatrix(value: Matrix): void;
  37125. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  37126. serialize(): any;
  37127. }
  37128. }
  37129. declare module BABYLON {
  37130. /**
  37131. * Class used to store data associated with WebGL texture data for the engine
  37132. * This class should not be used directly
  37133. */
  37134. class InternalTexture implements IInternalTextureTracker {
  37135. /**
  37136. * The source of the texture data is unknown
  37137. */
  37138. static DATASOURCE_UNKNOWN: number;
  37139. /**
  37140. * Texture data comes from an URL
  37141. */
  37142. static DATASOURCE_URL: number;
  37143. /**
  37144. * Texture data is only used for temporary storage
  37145. */
  37146. static DATASOURCE_TEMP: number;
  37147. /**
  37148. * Texture data comes from raw data (ArrayBuffer)
  37149. */
  37150. static DATASOURCE_RAW: number;
  37151. /**
  37152. * Texture content is dynamic (video or dynamic texture)
  37153. */
  37154. static DATASOURCE_DYNAMIC: number;
  37155. /**
  37156. * Texture content is generated by rendering to it
  37157. */
  37158. static DATASOURCE_RENDERTARGET: number;
  37159. /**
  37160. * Texture content is part of a multi render target process
  37161. */
  37162. static DATASOURCE_MULTIRENDERTARGET: number;
  37163. /**
  37164. * Texture data comes from a cube data file
  37165. */
  37166. static DATASOURCE_CUBE: number;
  37167. /**
  37168. * Texture data comes from a raw cube data
  37169. */
  37170. static DATASOURCE_CUBERAW: number;
  37171. /**
  37172. * Texture data come from a prefiltered cube data file
  37173. */
  37174. static DATASOURCE_CUBEPREFILTERED: number;
  37175. /**
  37176. * Texture content is raw 3D data
  37177. */
  37178. static DATASOURCE_RAW3D: number;
  37179. /**
  37180. * Texture content is a depth texture
  37181. */
  37182. static DATASOURCE_DEPTHTEXTURE: number;
  37183. /**
  37184. * Texture data comes from a raw cube data encoded with RGBD
  37185. */
  37186. static DATASOURCE_CUBERAW_RGBD: number;
  37187. /**
  37188. * Defines if the texture is ready
  37189. */
  37190. isReady: boolean;
  37191. /**
  37192. * Defines if the texture is a cube texture
  37193. */
  37194. isCube: boolean;
  37195. /**
  37196. * Defines if the texture contains 3D data
  37197. */
  37198. is3D: boolean;
  37199. /**
  37200. * Gets the URL used to load this texture
  37201. */
  37202. url: string;
  37203. /**
  37204. * Gets the sampling mode of the texture
  37205. */
  37206. samplingMode: number;
  37207. /**
  37208. * Gets a boolean indicating if the texture needs mipmaps generation
  37209. */
  37210. generateMipMaps: boolean;
  37211. /**
  37212. * Gets the number of samples used by the texture (WebGL2+ only)
  37213. */
  37214. samples: number;
  37215. /**
  37216. * Gets the type of the texture
  37217. */
  37218. type: number;
  37219. /**
  37220. * Gets the format of the texture
  37221. */
  37222. format: number;
  37223. /**
  37224. * Observable called when the texture is loaded
  37225. */
  37226. onLoadedObservable: Observable<InternalTexture>;
  37227. /**
  37228. * Gets the width of the texture
  37229. */
  37230. width: number;
  37231. /**
  37232. * Gets the height of the texture
  37233. */
  37234. height: number;
  37235. /**
  37236. * Gets the depth of the texture
  37237. */
  37238. depth: number;
  37239. /**
  37240. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37241. */
  37242. baseWidth: number;
  37243. /**
  37244. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37245. */
  37246. baseHeight: number;
  37247. /**
  37248. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37249. */
  37250. baseDepth: number;
  37251. /**
  37252. * Gets a boolean indicating if the texture is inverted on Y axis
  37253. */
  37254. invertY: boolean;
  37255. /**
  37256. * Gets or set the previous tracker in the list
  37257. */
  37258. previous: Nullable<IInternalTextureTracker>;
  37259. /**
  37260. * Gets or set the next tracker in the list
  37261. */
  37262. next: Nullable<IInternalTextureTracker>;
  37263. /** @hidden */
  37264. _initialSlot: number;
  37265. /** @hidden */
  37266. _designatedSlot: number;
  37267. /** @hidden */
  37268. _dataSource: number;
  37269. /** @hidden */
  37270. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37271. /** @hidden */
  37272. _bufferView: Nullable<ArrayBufferView>;
  37273. /** @hidden */
  37274. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37275. /** @hidden */
  37276. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37277. /** @hidden */
  37278. _size: number;
  37279. /** @hidden */
  37280. _extension: string;
  37281. /** @hidden */
  37282. _files: Nullable<string[]>;
  37283. /** @hidden */
  37284. _workingCanvas: HTMLCanvasElement;
  37285. /** @hidden */
  37286. _workingContext: CanvasRenderingContext2D;
  37287. /** @hidden */
  37288. _framebuffer: Nullable<WebGLFramebuffer>;
  37289. /** @hidden */
  37290. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37291. /** @hidden */
  37292. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37293. /** @hidden */
  37294. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37295. /** @hidden */
  37296. _attachments: Nullable<number[]>;
  37297. /** @hidden */
  37298. _cachedCoordinatesMode: Nullable<number>;
  37299. /** @hidden */
  37300. _cachedWrapU: Nullable<number>;
  37301. /** @hidden */
  37302. _cachedWrapV: Nullable<number>;
  37303. /** @hidden */
  37304. _cachedWrapR: Nullable<number>;
  37305. /** @hidden */
  37306. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37307. /** @hidden */
  37308. _isDisabled: boolean;
  37309. /** @hidden */
  37310. _compression: Nullable<string>;
  37311. /** @hidden */
  37312. _generateStencilBuffer: boolean;
  37313. /** @hidden */
  37314. _generateDepthBuffer: boolean;
  37315. /** @hidden */
  37316. _comparisonFunction: number;
  37317. /** @hidden */
  37318. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37319. /** @hidden */
  37320. _lodGenerationScale: number;
  37321. /** @hidden */
  37322. _lodGenerationOffset: number;
  37323. /** @hidden */
  37324. _lodTextureHigh: BaseTexture;
  37325. /** @hidden */
  37326. _lodTextureMid: BaseTexture;
  37327. /** @hidden */
  37328. _lodTextureLow: BaseTexture;
  37329. /** @hidden */
  37330. _isRGBD: boolean;
  37331. /** @hidden */
  37332. _webGLTexture: Nullable<WebGLTexture>;
  37333. /** @hidden */
  37334. _references: number;
  37335. private _engine;
  37336. /**
  37337. * Gets the Engine the texture belongs to.
  37338. * @returns The babylon engine
  37339. */
  37340. getEngine(): Engine;
  37341. /**
  37342. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  37343. */
  37344. readonly dataSource: number;
  37345. /**
  37346. * Creates a new InternalTexture
  37347. * @param engine defines the engine to use
  37348. * @param dataSource defines the type of data that will be used
  37349. */
  37350. constructor(engine: Engine, dataSource: number);
  37351. /**
  37352. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  37353. */
  37354. incrementReferences(): void;
  37355. /**
  37356. * Change the size of the texture (not the size of the content)
  37357. * @param width defines the new width
  37358. * @param height defines the new height
  37359. * @param depth defines the new depth (1 by default)
  37360. */
  37361. updateSize(width: int, height: int, depth?: int): void;
  37362. /** @hidden */
  37363. _rebuild(): void;
  37364. /** @hidden */
  37365. _swapAndDie(target: InternalTexture): void;
  37366. /**
  37367. * Dispose the current allocated resources
  37368. */
  37369. dispose(): void;
  37370. }
  37371. }
  37372. declare module BABYLON {
  37373. /**
  37374. * This represents the required contract to create a new type of texture loader.
  37375. */
  37376. interface IInternalTextureLoader {
  37377. /**
  37378. * Defines wether the loader supports cascade loading the different faces.
  37379. */
  37380. supportCascades: boolean;
  37381. /**
  37382. * This returns if the loader support the current file information.
  37383. * @param extension defines the file extension of the file being loaded
  37384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37385. * @param fallback defines the fallback internal texture if any
  37386. * @param isBase64 defines whether the texture is encoded as a base64
  37387. * @param isBuffer defines whether the texture data are stored as a buffer
  37388. * @returns true if the loader can load the specified file
  37389. */
  37390. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  37391. /**
  37392. * Transform the url before loading if required.
  37393. * @param rootUrl the url of the texture
  37394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37395. * @returns the transformed texture
  37396. */
  37397. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  37398. /**
  37399. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  37400. * @param rootUrl the url of the texture
  37401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37402. * @returns the fallback texture
  37403. */
  37404. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  37405. /**
  37406. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  37407. * @param data contains the texture data
  37408. * @param texture defines the BabylonJS internal texture
  37409. * @param createPolynomials will be true if polynomials have been requested
  37410. * @param onLoad defines the callback to trigger once the texture is ready
  37411. * @param onError defines the callback to trigger in case of error
  37412. */
  37413. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  37414. /**
  37415. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  37416. * @param data contains the texture data
  37417. * @param texture defines the BabylonJS internal texture
  37418. * @param callback defines the method to call once ready to upload
  37419. */
  37420. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  37421. }
  37422. }
  37423. declare module BABYLON {
  37424. /**
  37425. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  37426. */
  37427. interface IInternalTextureTracker {
  37428. /**
  37429. * Gets or set the previous tracker in the list
  37430. */
  37431. previous: Nullable<IInternalTextureTracker>;
  37432. /**
  37433. * Gets or set the next tracker in the list
  37434. */
  37435. next: Nullable<IInternalTextureTracker>;
  37436. }
  37437. /**
  37438. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  37439. */
  37440. class DummyInternalTextureTracker {
  37441. /**
  37442. * Gets or set the previous tracker in the list
  37443. */
  37444. previous: Nullable<IInternalTextureTracker>;
  37445. /**
  37446. * Gets or set the next tracker in the list
  37447. */
  37448. next: Nullable<IInternalTextureTracker>;
  37449. }
  37450. }
  37451. declare module BABYLON {
  37452. class MirrorTexture extends RenderTargetTexture {
  37453. private scene;
  37454. mirrorPlane: Plane;
  37455. private _transformMatrix;
  37456. private _mirrorMatrix;
  37457. private _savedViewMatrix;
  37458. private _blurX;
  37459. private _blurY;
  37460. private _adaptiveBlurKernel;
  37461. private _blurKernelX;
  37462. private _blurKernelY;
  37463. private _blurRatio;
  37464. blurRatio: number;
  37465. adaptiveBlurKernel: number;
  37466. blurKernel: number;
  37467. blurKernelX: number;
  37468. blurKernelY: number;
  37469. private _autoComputeBlurKernel;
  37470. protected _onRatioRescale(): void;
  37471. private _updateGammaSpace;
  37472. private _imageProcessingConfigChangeObserver;
  37473. constructor(name: string, size: number | {
  37474. width: number;
  37475. height: number;
  37476. } | {
  37477. ratio: number;
  37478. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  37479. private _preparePostProcesses;
  37480. clone(): MirrorTexture;
  37481. serialize(): any;
  37482. dispose(): void;
  37483. }
  37484. }
  37485. declare module BABYLON {
  37486. interface IMultiRenderTargetOptions {
  37487. generateMipMaps?: boolean;
  37488. types?: number[];
  37489. samplingModes?: number[];
  37490. generateDepthBuffer?: boolean;
  37491. generateStencilBuffer?: boolean;
  37492. generateDepthTexture?: boolean;
  37493. textureCount?: number;
  37494. doNotChangeAspectRatio?: boolean;
  37495. defaultType?: number;
  37496. }
  37497. class MultiRenderTarget extends RenderTargetTexture {
  37498. private _internalTextures;
  37499. private _textures;
  37500. readonly isSupported: boolean;
  37501. private _multiRenderTargetOptions;
  37502. readonly textures: Texture[];
  37503. readonly depthTexture: Texture;
  37504. wrapU: number;
  37505. wrapV: number;
  37506. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  37507. /** @hidden */
  37508. _rebuild(): void;
  37509. private _createInternalTextures;
  37510. private _createTextures;
  37511. samples: number;
  37512. resize(size: any): void;
  37513. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37514. dispose(): void;
  37515. releaseInternalTextures(): void;
  37516. }
  37517. }
  37518. declare module BABYLON {
  37519. /**
  37520. * Raw cube texture where the raw buffers are passed in
  37521. */
  37522. class RawCubeTexture extends CubeTexture {
  37523. /**
  37524. * Creates a cube texture where the raw buffers are passed in.
  37525. * @param scene defines the scene the texture is attached to
  37526. * @param data defines the array of data to use to create each face
  37527. * @param size defines the size of the textures
  37528. * @param format defines the format of the data
  37529. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  37530. * @param generateMipMaps defines if the engine should generate the mip levels
  37531. * @param invertY defines if data must be stored with Y axis inverted
  37532. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  37533. * @param compression defines the compression used (null by default)
  37534. */
  37535. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  37536. /**
  37537. * Updates the raw cube texture.
  37538. * @param data defines the data to store
  37539. * @param format defines the data format
  37540. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  37541. * @param invertY defines if data must be stored with Y axis inverted
  37542. * @param compression defines the compression used (null by default)
  37543. * @param level defines which level of the texture to update
  37544. */
  37545. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  37546. /**
  37547. * Updates a raw cube texture with RGBD encoded data.
  37548. * @param data defines the array of data [mipmap][face] to use to create each face
  37549. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  37550. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37551. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37552. * @returns a promsie that resolves when the operation is complete
  37553. */
  37554. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  37555. /**
  37556. * Clones the raw cube texture.
  37557. * @return a new cube texture
  37558. */
  37559. clone(): CubeTexture;
  37560. /** @hidden */
  37561. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  37562. }
  37563. }
  37564. declare module BABYLON {
  37565. class RawTexture extends Texture {
  37566. format: number;
  37567. private _engine;
  37568. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  37569. update(data: ArrayBufferView): void;
  37570. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37571. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37572. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37573. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37574. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37575. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37576. }
  37577. }
  37578. declare module BABYLON {
  37579. /**
  37580. * Class used to store 3D textures containing user data
  37581. */
  37582. class RawTexture3D extends Texture {
  37583. /** Gets or sets the texture format to use */
  37584. format: number;
  37585. private _engine;
  37586. /**
  37587. * Create a new RawTexture3D
  37588. * @param data defines the data of the texture
  37589. * @param width defines the width of the texture
  37590. * @param height defines the height of the texture
  37591. * @param depth defines the depth of the texture
  37592. * @param format defines the texture format to use
  37593. * @param scene defines the hosting scene
  37594. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  37595. * @param invertY defines if texture must be stored with Y axis inverted
  37596. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37597. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  37598. */
  37599. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  37600. /** Gets or sets the texture format to use */
  37601. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  37602. /**
  37603. * Update the texture with new data
  37604. * @param data defines the data to store in the texture
  37605. */
  37606. update(data: ArrayBufferView): void;
  37607. }
  37608. }
  37609. declare module BABYLON {
  37610. /**
  37611. * Creates a refraction texture used by refraction channel of the standard material.
  37612. * @param name the texture name
  37613. * @param size size of the underlying texture
  37614. * @param scene root scene
  37615. */
  37616. class RefractionTexture extends RenderTargetTexture {
  37617. refractionPlane: Plane;
  37618. depth: number;
  37619. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  37620. clone(): RefractionTexture;
  37621. serialize(): any;
  37622. }
  37623. }
  37624. declare module BABYLON {
  37625. class RenderTargetTexture extends Texture {
  37626. isCube: boolean;
  37627. static _REFRESHRATE_RENDER_ONCE: number;
  37628. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37629. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37630. static readonly REFRESHRATE_RENDER_ONCE: number;
  37631. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37632. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37633. /**
  37634. * Use this predicate to dynamically define the list of mesh you want to render.
  37635. * If set, the renderList property will be overwritten.
  37636. */
  37637. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37638. private _renderList;
  37639. /**
  37640. * Use this list to define the list of mesh you want to render.
  37641. */
  37642. renderList: Nullable<Array<AbstractMesh>>;
  37643. private _hookArray;
  37644. renderParticles: boolean;
  37645. renderSprites: boolean;
  37646. coordinatesMode: number;
  37647. activeCamera: Nullable<Camera>;
  37648. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37649. useCameraPostProcesses: boolean;
  37650. ignoreCameraViewport: boolean;
  37651. private _postProcessManager;
  37652. private _postProcesses;
  37653. private _resizeObserver;
  37654. /**
  37655. * An event triggered when the texture is unbind.
  37656. */
  37657. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37658. /**
  37659. * An event triggered when the texture is unbind.
  37660. */
  37661. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37662. private _onAfterUnbindObserver;
  37663. onAfterUnbind: () => void;
  37664. /**
  37665. * An event triggered before rendering the texture
  37666. */
  37667. onBeforeRenderObservable: Observable<number>;
  37668. private _onBeforeRenderObserver;
  37669. onBeforeRender: (faceIndex: number) => void;
  37670. /**
  37671. * An event triggered after rendering the texture
  37672. */
  37673. onAfterRenderObservable: Observable<number>;
  37674. private _onAfterRenderObserver;
  37675. onAfterRender: (faceIndex: number) => void;
  37676. /**
  37677. * An event triggered after the texture clear
  37678. */
  37679. onClearObservable: Observable<Engine>;
  37680. private _onClearObserver;
  37681. onClear: (Engine: Engine) => void;
  37682. clearColor: Color4;
  37683. protected _size: number | {
  37684. width: number;
  37685. height: number;
  37686. };
  37687. protected _initialSizeParameter: number | {
  37688. width: number;
  37689. height: number;
  37690. } | {
  37691. ratio: number;
  37692. };
  37693. protected _sizeRatio: Nullable<number>;
  37694. /** @hidden */
  37695. _generateMipMaps: boolean;
  37696. protected _renderingManager: RenderingManager;
  37697. /** @hidden */
  37698. _waitingRenderList: string[];
  37699. protected _doNotChangeAspectRatio: boolean;
  37700. protected _currentRefreshId: number;
  37701. protected _refreshRate: number;
  37702. protected _textureMatrix: Matrix;
  37703. protected _samples: number;
  37704. protected _renderTargetOptions: RenderTargetCreationOptions;
  37705. readonly renderTargetOptions: RenderTargetCreationOptions;
  37706. protected _engine: Engine;
  37707. protected _onRatioRescale(): void;
  37708. /**
  37709. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37710. * It must define where the camera used to render the texture is set
  37711. */
  37712. boundingBoxPosition: Vector3;
  37713. private _boundingBoxSize;
  37714. /**
  37715. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37716. * When defined, the cubemap will switch to local mode
  37717. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37718. * @example https://www.babylonjs-playground.com/#RNASML
  37719. */
  37720. boundingBoxSize: Vector3;
  37721. /**
  37722. * In case the RTT has been created with a depth texture, get the associated
  37723. * depth texture.
  37724. * Otherwise, return null.
  37725. */
  37726. depthStencilTexture: Nullable<InternalTexture>;
  37727. /**
  37728. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  37729. * or used a shadow, depth texture...
  37730. * @param name The friendly name of the texture
  37731. * @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)
  37732. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37733. * @param generateMipMaps True if mip maps need to be generated after render.
  37734. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37735. * @param type The type of the buffer in the RTT (int, half float, float...)
  37736. * @param isCube True if a cube texture needs to be created
  37737. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37738. * @param generateDepthBuffer True to generate a depth buffer
  37739. * @param generateStencilBuffer True to generate a stencil buffer
  37740. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37741. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37742. */
  37743. constructor(name: string, size: number | {
  37744. width: number;
  37745. height: number;
  37746. } | {
  37747. ratio: number;
  37748. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  37749. /**
  37750. * Creates a depth stencil texture.
  37751. * This is only available in WebGL 2 or with the depth texture extension available.
  37752. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37753. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37754. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37755. */
  37756. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37757. private _processSizeParameter;
  37758. samples: number;
  37759. resetRefreshCounter(): void;
  37760. refreshRate: number;
  37761. addPostProcess(postProcess: PostProcess): void;
  37762. clearPostProcesses(dispose?: boolean): void;
  37763. removePostProcess(postProcess: PostProcess): void;
  37764. /** @hidden */
  37765. _shouldRender(): boolean;
  37766. getRenderSize(): number;
  37767. getRenderWidth(): number;
  37768. getRenderHeight(): number;
  37769. readonly canRescale: boolean;
  37770. scale(ratio: number): void;
  37771. getReflectionTextureMatrix(): Matrix;
  37772. resize(size: number | {
  37773. width: number;
  37774. height: number;
  37775. } | {
  37776. ratio: number;
  37777. }): void;
  37778. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37779. private _bestReflectionRenderTargetDimension;
  37780. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37781. private renderToTarget;
  37782. /**
  37783. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37784. * This allowed control for front to back rendering or reversly depending of the special needs.
  37785. *
  37786. * @param renderingGroupId The rendering group id corresponding to its index
  37787. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37788. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37789. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37790. */
  37791. 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;
  37792. /**
  37793. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37794. *
  37795. * @param renderingGroupId The rendering group id corresponding to its index
  37796. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37797. */
  37798. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37799. clone(): RenderTargetTexture;
  37800. serialize(): any;
  37801. disposeFramebufferObjects(): void;
  37802. dispose(): void;
  37803. /** @hidden */
  37804. _rebuild(): void;
  37805. /**
  37806. * Clear the info related to rendering groups preventing retention point in material dispose.
  37807. */
  37808. freeRenderingGroups(): void;
  37809. }
  37810. }
  37811. declare module BABYLON {
  37812. class Texture extends BaseTexture {
  37813. static NEAREST_SAMPLINGMODE: number;
  37814. static NEAREST_NEAREST_MIPLINEAR: number;
  37815. static BILINEAR_SAMPLINGMODE: number;
  37816. static LINEAR_LINEAR_MIPNEAREST: number;
  37817. static TRILINEAR_SAMPLINGMODE: number;
  37818. static LINEAR_LINEAR_MIPLINEAR: number;
  37819. static NEAREST_NEAREST_MIPNEAREST: number;
  37820. static NEAREST_LINEAR_MIPNEAREST: number;
  37821. static NEAREST_LINEAR_MIPLINEAR: number;
  37822. static NEAREST_LINEAR: number;
  37823. static NEAREST_NEAREST: number;
  37824. static LINEAR_NEAREST_MIPNEAREST: number;
  37825. static LINEAR_NEAREST_MIPLINEAR: number;
  37826. static LINEAR_LINEAR: number;
  37827. static LINEAR_NEAREST: number;
  37828. static EXPLICIT_MODE: number;
  37829. static SPHERICAL_MODE: number;
  37830. static PLANAR_MODE: number;
  37831. static CUBIC_MODE: number;
  37832. static PROJECTION_MODE: number;
  37833. static SKYBOX_MODE: number;
  37834. static INVCUBIC_MODE: number;
  37835. static EQUIRECTANGULAR_MODE: number;
  37836. static FIXED_EQUIRECTANGULAR_MODE: number;
  37837. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37838. static readonly CLAMP_ADDRESSMODE: number;
  37839. static readonly WRAP_ADDRESSMODE: number;
  37840. static readonly MIRROR_ADDRESSMODE: number;
  37841. /**
  37842. * 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
  37843. */
  37844. static UseSerializedUrlIfAny: boolean;
  37845. url: Nullable<string>;
  37846. uOffset: number;
  37847. vOffset: number;
  37848. uScale: number;
  37849. vScale: number;
  37850. uAng: number;
  37851. vAng: number;
  37852. wAng: number;
  37853. /**
  37854. * Defines the center of rotation (U)
  37855. */
  37856. uRotationCenter: number;
  37857. /**
  37858. * Defines the center of rotation (V)
  37859. */
  37860. vRotationCenter: number;
  37861. /**
  37862. * Defines the center of rotation (W)
  37863. */
  37864. wRotationCenter: number;
  37865. readonly noMipmap: boolean;
  37866. private _noMipmap;
  37867. /** @hidden */
  37868. _invertY: boolean;
  37869. private _rowGenerationMatrix;
  37870. private _cachedTextureMatrix;
  37871. private _projectionModeMatrix;
  37872. private _t0;
  37873. private _t1;
  37874. private _t2;
  37875. private _cachedUOffset;
  37876. private _cachedVOffset;
  37877. private _cachedUScale;
  37878. private _cachedVScale;
  37879. private _cachedUAng;
  37880. private _cachedVAng;
  37881. private _cachedWAng;
  37882. private _cachedProjectionMatrixId;
  37883. private _cachedCoordinatesMode;
  37884. /** @hidden */
  37885. _samplingMode: number;
  37886. /** @hidden */
  37887. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37888. private _deleteBuffer;
  37889. protected _format: Nullable<number>;
  37890. private _delayedOnLoad;
  37891. private _delayedOnError;
  37892. protected _onLoadObservable: Nullable<Observable<Texture>>;
  37893. protected _isBlocking: boolean;
  37894. isBlocking: boolean;
  37895. readonly samplingMode: number;
  37896. 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);
  37897. /**
  37898. * Update the url (and optional buffer) of this texture if url was null during construction.
  37899. * @param url the url of the texture
  37900. * @param buffer the buffer of the texture (defaults to null)
  37901. */
  37902. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  37903. delayLoad(): void;
  37904. /**
  37905. * Default is Trilinear mode.
  37906. *
  37907. * | Value | Type | Description |
  37908. * | ----- | ------------------ | ----------- |
  37909. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37910. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37911. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37912. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37913. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37914. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37915. * | 7 | NEAREST_LINEAR | |
  37916. * | 8 | NEAREST_NEAREST | |
  37917. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37918. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37919. * | 11 | LINEAR_LINEAR | |
  37920. * | 12 | LINEAR_NEAREST | |
  37921. *
  37922. * > _mag_: magnification filter (close to the viewer)
  37923. * > _min_: minification filter (far from the viewer)
  37924. * > _mip_: filter used between mip map levels
  37925. *
  37926. */
  37927. updateSamplingMode(samplingMode: number): void;
  37928. private _prepareRowForTextureGeneration;
  37929. getTextureMatrix(): Matrix;
  37930. getReflectionTextureMatrix(): Matrix;
  37931. clone(): Texture;
  37932. readonly onLoadObservable: Observable<Texture>;
  37933. serialize(): any;
  37934. getClassName(): string;
  37935. dispose(): void;
  37936. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  37937. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  37938. 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;
  37939. }
  37940. }
  37941. declare module BABYLON {
  37942. /**
  37943. * Settings for finer control over video usage
  37944. */
  37945. interface VideoTextureSettings {
  37946. /**
  37947. * Applies `autoplay` to video, if specified
  37948. */
  37949. autoPlay?: boolean;
  37950. /**
  37951. * Applies `loop` to video, if specified
  37952. */
  37953. loop?: boolean;
  37954. /**
  37955. * Automatically updates internal texture from video at every frame in the render loop
  37956. */
  37957. autoUpdateTexture: boolean;
  37958. /**
  37959. * Image src displayed during the video loading or until the user interacts with the video.
  37960. */
  37961. poster?: string;
  37962. }
  37963. class VideoTexture extends Texture {
  37964. /**
  37965. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  37966. */
  37967. readonly autoUpdateTexture: boolean;
  37968. /**
  37969. * The video instance used by the texture internally
  37970. */
  37971. readonly video: HTMLVideoElement;
  37972. private _onUserActionRequestedObservable;
  37973. readonly onUserActionRequestedObservable: Observable<Texture>;
  37974. private _generateMipMaps;
  37975. private _engine;
  37976. private _stillImageCaptured;
  37977. private _poster;
  37978. /**
  37979. * Creates a video texture.
  37980. * Sample : https://doc.babylonjs.com/how_to/video_texture
  37981. * @param {string | null} name optional name, will detect from video source, if not defined
  37982. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  37983. * @param {BABYLON.Scene} scene is obviously the current scene.
  37984. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  37985. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  37986. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  37987. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  37988. */
  37989. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  37990. private _getName;
  37991. private _getVideo;
  37992. private _createInternalTexture;
  37993. private reset;
  37994. /**
  37995. * @hidden Internal method to initiate `update`.
  37996. */
  37997. _rebuild(): void;
  37998. /**
  37999. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38000. */
  38001. update(): void;
  38002. /**
  38003. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38004. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38005. */
  38006. updateTexture(isVisible: boolean): void;
  38007. protected _updateInternalTexture: (e?: Event | undefined) => void;
  38008. /**
  38009. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38010. * @param url New url.
  38011. */
  38012. updateURL(url: string): void;
  38013. dispose(): void;
  38014. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38015. minWidth: number;
  38016. maxWidth: number;
  38017. minHeight: number;
  38018. maxHeight: number;
  38019. deviceId: string;
  38020. }): void;
  38021. }
  38022. }
  38023. declare var DracoDecoderModule: any;
  38024. declare var WebAssembly: any;
  38025. declare module BABYLON {
  38026. /**
  38027. * Configuration for Draco compression
  38028. */
  38029. interface IDracoCompressionConfiguration {
  38030. /**
  38031. * Configuration for the decoder.
  38032. */
  38033. decoder?: {
  38034. /**
  38035. * The url to the WebAssembly module.
  38036. */
  38037. wasmUrl?: string;
  38038. /**
  38039. * The url to the WebAssembly binary.
  38040. */
  38041. wasmBinaryUrl?: string;
  38042. /**
  38043. * The url to the fallback JavaScript module.
  38044. */
  38045. fallbackUrl?: string;
  38046. };
  38047. }
  38048. /**
  38049. * Draco compression (https://google.github.io/draco/)
  38050. *
  38051. * This class wraps the Draco module.
  38052. *
  38053. * **Encoder**
  38054. *
  38055. * The encoder is not currently implemented.
  38056. *
  38057. * **Decoder**
  38058. *
  38059. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  38060. *
  38061. * To update the configuration, use the following code:
  38062. * ```javascript
  38063. * BABYLON.DracoCompression.Configuration = {
  38064. * decoder: {
  38065. * wasmUrl: "<url to the WebAssembly library>",
  38066. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  38067. * fallbackUrl: "<url to the fallback JavaScript library>",
  38068. * }
  38069. * };
  38070. * ```
  38071. *
  38072. * 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.
  38073. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  38074. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  38075. *
  38076. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  38077. * ```javascript
  38078. * var dracoCompression = new BABYLON.DracoCompression();
  38079. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  38080. * [BABYLON.VertexBuffer.PositionKind]: 0
  38081. * });
  38082. * ```
  38083. *
  38084. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  38085. */
  38086. class DracoCompression implements IDisposable {
  38087. private static _DecoderModulePromise;
  38088. /**
  38089. * The configuration. Defaults to the following urls:
  38090. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  38091. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  38092. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  38093. */
  38094. static Configuration: IDracoCompressionConfiguration;
  38095. /**
  38096. * Returns true if the decoder is available.
  38097. */
  38098. static readonly DecoderAvailable: boolean;
  38099. /**
  38100. * Constructor
  38101. */
  38102. constructor();
  38103. /**
  38104. * Stop all async operations and release resources.
  38105. */
  38106. dispose(): void;
  38107. /**
  38108. * Decode Draco compressed mesh data to vertex data.
  38109. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  38110. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  38111. * @returns A promise that resolves with the decoded vertex data
  38112. */
  38113. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  38114. [kind: string]: number;
  38115. }): Promise<VertexData>;
  38116. private static _GetDecoderModule;
  38117. private static _LoadScriptAsync;
  38118. private static _LoadFileAsync;
  38119. }
  38120. }
  38121. declare module BABYLON {
  38122. class CannonJSPlugin implements IPhysicsEnginePlugin {
  38123. private _useDeltaForWorldStep;
  38124. world: any;
  38125. name: string;
  38126. private _physicsMaterials;
  38127. private _fixedTimeStep;
  38128. BJSCANNON: any;
  38129. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  38130. setGravity(gravity: Vector3): void;
  38131. setTimeStep(timeStep: number): void;
  38132. getTimeStep(): number;
  38133. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38134. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38135. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38136. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38137. private _processChildMeshes;
  38138. removePhysicsBody(impostor: PhysicsImpostor): void;
  38139. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38140. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38141. private _addMaterial;
  38142. private _checkWithEpsilon;
  38143. private _createShape;
  38144. private _createHeightmap;
  38145. private _minus90X;
  38146. private _plus90X;
  38147. private _tmpPosition;
  38148. private _tmpDeltaPosition;
  38149. private _tmpUnityRotation;
  38150. private _updatePhysicsBodyTransformation;
  38151. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38152. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38153. isSupported(): boolean;
  38154. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38155. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38156. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38157. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38159. getBodyMass(impostor: PhysicsImpostor): number;
  38160. getBodyFriction(impostor: PhysicsImpostor): number;
  38161. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38162. getBodyRestitution(impostor: PhysicsImpostor): number;
  38163. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38164. sleepBody(impostor: PhysicsImpostor): void;
  38165. wakeUpBody(impostor: PhysicsImpostor): void;
  38166. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38167. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  38168. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  38169. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38170. getRadius(impostor: PhysicsImpostor): number;
  38171. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38172. dispose(): void;
  38173. private _extendNamespace;
  38174. }
  38175. }
  38176. declare module BABYLON {
  38177. class OimoJSPlugin implements IPhysicsEnginePlugin {
  38178. world: any;
  38179. name: string;
  38180. BJSOIMO: any;
  38181. constructor(iterations?: number);
  38182. setGravity(gravity: Vector3): void;
  38183. setTimeStep(timeStep: number): void;
  38184. getTimeStep(): number;
  38185. private _tmpImpostorsArray;
  38186. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38187. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38189. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38190. private _tmpPositionVector;
  38191. removePhysicsBody(impostor: PhysicsImpostor): void;
  38192. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38193. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38194. isSupported(): boolean;
  38195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38196. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38197. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38198. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38199. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38200. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38201. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38202. getBodyMass(impostor: PhysicsImpostor): number;
  38203. getBodyFriction(impostor: PhysicsImpostor): number;
  38204. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38205. getBodyRestitution(impostor: PhysicsImpostor): number;
  38206. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38207. sleepBody(impostor: PhysicsImpostor): void;
  38208. wakeUpBody(impostor: PhysicsImpostor): void;
  38209. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38210. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  38211. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  38212. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38213. getRadius(impostor: PhysicsImpostor): number;
  38214. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38215. dispose(): void;
  38216. }
  38217. }
  38218. declare module BABYLON {
  38219. /**
  38220. * Particle emitter emitting particles from the inside of a box.
  38221. * It emits the particles randomly between 2 given directions.
  38222. */
  38223. class BoxParticleEmitter implements IParticleEmitterType {
  38224. /**
  38225. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38226. */
  38227. direction1: Vector3;
  38228. /**
  38229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38230. */
  38231. direction2: Vector3;
  38232. /**
  38233. * 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.
  38234. */
  38235. minEmitBox: Vector3;
  38236. /**
  38237. * 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.
  38238. */
  38239. maxEmitBox: Vector3;
  38240. /**
  38241. * Creates a new instance BoxParticleEmitter
  38242. */
  38243. constructor();
  38244. /**
  38245. * Called by the particle System when the direction is computed for the created particle.
  38246. * @param worldMatrix is the world matrix of the particle system
  38247. * @param directionToUpdate is the direction vector to update with the result
  38248. * @param particle is the particle we are computed the direction for
  38249. */
  38250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38251. /**
  38252. * Called by the particle System when the position is computed for the created particle.
  38253. * @param worldMatrix is the world matrix of the particle system
  38254. * @param positionToUpdate is the position vector to update with the result
  38255. * @param particle is the particle we are computed the position for
  38256. */
  38257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38258. /**
  38259. * Clones the current emitter and returns a copy of it
  38260. * @returns the new emitter
  38261. */
  38262. clone(): BoxParticleEmitter;
  38263. /**
  38264. * Called by the GPUParticleSystem to setup the update shader
  38265. * @param effect defines the update shader
  38266. */
  38267. applyToShader(effect: Effect): void;
  38268. /**
  38269. * Returns a string to use to update the GPU particles update shader
  38270. * @returns a string containng the defines string
  38271. */
  38272. getEffectDefines(): string;
  38273. /**
  38274. * Returns the string "BoxParticleEmitter"
  38275. * @returns a string containing the class name
  38276. */
  38277. getClassName(): string;
  38278. /**
  38279. * Serializes the particle system to a JSON object.
  38280. * @returns the JSON object
  38281. */
  38282. serialize(): any;
  38283. /**
  38284. * Parse properties from a JSON object
  38285. * @param serializationObject defines the JSON object
  38286. */
  38287. parse(serializationObject: any): void;
  38288. }
  38289. }
  38290. declare module BABYLON {
  38291. /**
  38292. * Particle emitter emitting particles from the inside of a cone.
  38293. * It emits the particles alongside the cone volume from the base to the particle.
  38294. * The emission direction might be randomized.
  38295. */
  38296. class ConeParticleEmitter implements IParticleEmitterType {
  38297. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38298. directionRandomizer: number;
  38299. private _radius;
  38300. private _angle;
  38301. private _height;
  38302. /**
  38303. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  38304. */
  38305. radiusRange: number;
  38306. /**
  38307. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  38308. */
  38309. heightRange: number;
  38310. /**
  38311. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  38312. */
  38313. emitFromSpawnPointOnly: boolean;
  38314. /**
  38315. * Gets or sets the radius of the emission cone
  38316. */
  38317. radius: number;
  38318. /**
  38319. * Gets or sets the angle of the emission cone
  38320. */
  38321. angle: number;
  38322. private _buildHeight;
  38323. /**
  38324. * Creates a new instance ConeParticleEmitter
  38325. * @param radius the radius of the emission cone (1 by default)
  38326. * @param angles the cone base angle (PI by default)
  38327. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  38328. */
  38329. constructor(radius?: number, angle?: number,
  38330. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38331. directionRandomizer?: number);
  38332. /**
  38333. * Called by the particle System when the direction is computed for the created particle.
  38334. * @param worldMatrix is the world matrix of the particle system
  38335. * @param directionToUpdate is the direction vector to update with the result
  38336. * @param particle is the particle we are computed the direction for
  38337. */
  38338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38339. /**
  38340. * Called by the particle System when the position is computed for the created particle.
  38341. * @param worldMatrix is the world matrix of the particle system
  38342. * @param positionToUpdate is the position vector to update with the result
  38343. * @param particle is the particle we are computed the position for
  38344. */
  38345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38346. /**
  38347. * Clones the current emitter and returns a copy of it
  38348. * @returns the new emitter
  38349. */
  38350. clone(): ConeParticleEmitter;
  38351. /**
  38352. * Called by the GPUParticleSystem to setup the update shader
  38353. * @param effect defines the update shader
  38354. */
  38355. applyToShader(effect: Effect): void;
  38356. /**
  38357. * Returns a string to use to update the GPU particles update shader
  38358. * @returns a string containng the defines string
  38359. */
  38360. getEffectDefines(): string;
  38361. /**
  38362. * Returns the string "ConeParticleEmitter"
  38363. * @returns a string containing the class name
  38364. */
  38365. getClassName(): string;
  38366. /**
  38367. * Serializes the particle system to a JSON object.
  38368. * @returns the JSON object
  38369. */
  38370. serialize(): any;
  38371. /**
  38372. * Parse properties from a JSON object
  38373. * @param serializationObject defines the JSON object
  38374. */
  38375. parse(serializationObject: any): void;
  38376. }
  38377. }
  38378. declare module BABYLON {
  38379. /**
  38380. * Particle emitter emitting particles from the inside of a cylinder.
  38381. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  38382. */
  38383. class CylinderParticleEmitter implements IParticleEmitterType {
  38384. /**
  38385. * The radius of the emission cylinder.
  38386. */
  38387. radius: number;
  38388. /**
  38389. * The height of the emission cylinder.
  38390. */
  38391. height: number;
  38392. /**
  38393. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38394. */
  38395. radiusRange: number;
  38396. /**
  38397. * How much to randomize the particle direction [0-1].
  38398. */
  38399. directionRandomizer: number;
  38400. /**
  38401. * Creates a new instance CylinderParticleEmitter
  38402. * @param radius the radius of the emission cylinder (1 by default)
  38403. * @param height the height of the emission cylinder (1 by default)
  38404. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38405. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38406. */
  38407. constructor(
  38408. /**
  38409. * The radius of the emission cylinder.
  38410. */
  38411. radius?: number,
  38412. /**
  38413. * The height of the emission cylinder.
  38414. */
  38415. height?: number,
  38416. /**
  38417. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38418. */
  38419. radiusRange?: number,
  38420. /**
  38421. * How much to randomize the particle direction [0-1].
  38422. */
  38423. directionRandomizer?: number);
  38424. /**
  38425. * Called by the particle System when the direction is computed for the created particle.
  38426. * @param worldMatrix is the world matrix of the particle system
  38427. * @param directionToUpdate is the direction vector to update with the result
  38428. * @param particle is the particle we are computed the direction for
  38429. */
  38430. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38431. /**
  38432. * Called by the particle System when the position is computed for the created particle.
  38433. * @param worldMatrix is the world matrix of the particle system
  38434. * @param positionToUpdate is the position vector to update with the result
  38435. * @param particle is the particle we are computed the position for
  38436. */
  38437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38438. /**
  38439. * Clones the current emitter and returns a copy of it
  38440. * @returns the new emitter
  38441. */
  38442. clone(): CylinderParticleEmitter;
  38443. /**
  38444. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38445. * @param effect defines the update shader
  38446. */
  38447. applyToShader(effect: Effect): void;
  38448. /**
  38449. * Returns a string to use to update the GPU particles update shader
  38450. * @returns a string containng the defines string
  38451. */
  38452. getEffectDefines(): string;
  38453. /**
  38454. * Returns the string "CylinderParticleEmitter"
  38455. * @returns a string containing the class name
  38456. */
  38457. getClassName(): string;
  38458. /**
  38459. * Serializes the particle system to a JSON object.
  38460. * @returns the JSON object
  38461. */
  38462. serialize(): any;
  38463. /**
  38464. * Parse properties from a JSON object
  38465. * @param serializationObject defines the JSON object
  38466. */
  38467. parse(serializationObject: any): void;
  38468. }
  38469. }
  38470. declare module BABYLON {
  38471. /**
  38472. * Particle emitter emitting particles from the inside of a hemisphere.
  38473. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  38474. */
  38475. class HemisphericParticleEmitter implements IParticleEmitterType {
  38476. /**
  38477. * The radius of the emission hemisphere.
  38478. */
  38479. radius: number;
  38480. /**
  38481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38482. */
  38483. radiusRange: number;
  38484. /**
  38485. * How much to randomize the particle direction [0-1].
  38486. */
  38487. directionRandomizer: number;
  38488. /**
  38489. * Creates a new instance HemisphericParticleEmitter
  38490. * @param radius the radius of the emission hemisphere (1 by default)
  38491. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38492. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38493. */
  38494. constructor(
  38495. /**
  38496. * The radius of the emission hemisphere.
  38497. */
  38498. radius?: number,
  38499. /**
  38500. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38501. */
  38502. radiusRange?: number,
  38503. /**
  38504. * How much to randomize the particle direction [0-1].
  38505. */
  38506. directionRandomizer?: number);
  38507. /**
  38508. * Called by the particle System when the direction is computed for the created particle.
  38509. * @param worldMatrix is the world matrix of the particle system
  38510. * @param directionToUpdate is the direction vector to update with the result
  38511. * @param particle is the particle we are computed the direction for
  38512. */
  38513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38514. /**
  38515. * Called by the particle System when the position is computed for the created particle.
  38516. * @param worldMatrix is the world matrix of the particle system
  38517. * @param positionToUpdate is the position vector to update with the result
  38518. * @param particle is the particle we are computed the position for
  38519. */
  38520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38521. /**
  38522. * Clones the current emitter and returns a copy of it
  38523. * @returns the new emitter
  38524. */
  38525. clone(): HemisphericParticleEmitter;
  38526. /**
  38527. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38528. * @param effect defines the update shader
  38529. */
  38530. applyToShader(effect: Effect): void;
  38531. /**
  38532. * Returns a string to use to update the GPU particles update shader
  38533. * @returns a string containng the defines string
  38534. */
  38535. getEffectDefines(): string;
  38536. /**
  38537. * Returns the string "HemisphericParticleEmitter"
  38538. * @returns a string containing the class name
  38539. */
  38540. getClassName(): string;
  38541. /**
  38542. * Serializes the particle system to a JSON object.
  38543. * @returns the JSON object
  38544. */
  38545. serialize(): any;
  38546. /**
  38547. * Parse properties from a JSON object
  38548. * @param serializationObject defines the JSON object
  38549. */
  38550. parse(serializationObject: any): void;
  38551. }
  38552. }
  38553. declare module BABYLON {
  38554. /**
  38555. * Particle emitter represents a volume emitting particles.
  38556. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  38557. */
  38558. interface IParticleEmitterType {
  38559. /**
  38560. * Called by the particle System when the direction is computed for the created particle.
  38561. * @param worldMatrix is the world matrix of the particle system
  38562. * @param directionToUpdate is the direction vector to update with the result
  38563. * @param particle is the particle we are computed the direction for
  38564. */
  38565. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38566. /**
  38567. * Called by the particle System when the position is computed for the created particle.
  38568. * @param worldMatrix is the world matrix of the particle system
  38569. * @param positionToUpdate is the position vector to update with the result
  38570. * @param particle is the particle we are computed the position for
  38571. */
  38572. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38573. /**
  38574. * Clones the current emitter and returns a copy of it
  38575. * @returns the new emitter
  38576. */
  38577. clone(): IParticleEmitterType;
  38578. /**
  38579. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38580. * @param effect defines the update shader
  38581. */
  38582. applyToShader(effect: Effect): void;
  38583. /**
  38584. * Returns a string to use to update the GPU particles update shader
  38585. * @returns the effect defines string
  38586. */
  38587. getEffectDefines(): string;
  38588. /**
  38589. * Returns a string representing the class name
  38590. * @returns a string containing the class name
  38591. */
  38592. getClassName(): string;
  38593. /**
  38594. * Serializes the particle system to a JSON object.
  38595. * @returns the JSON object
  38596. */
  38597. serialize(): any;
  38598. /**
  38599. * Parse properties from a JSON object
  38600. * @param serializationObject defines the JSON object
  38601. */
  38602. parse(serializationObject: any): void;
  38603. }
  38604. }
  38605. declare module BABYLON {
  38606. /**
  38607. * Particle emitter emitting particles from a point.
  38608. * It emits the particles randomly between 2 given directions.
  38609. */
  38610. class PointParticleEmitter implements IParticleEmitterType {
  38611. /**
  38612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38613. */
  38614. direction1: Vector3;
  38615. /**
  38616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38617. */
  38618. direction2: Vector3;
  38619. /**
  38620. * Creates a new instance PointParticleEmitter
  38621. */
  38622. constructor();
  38623. /**
  38624. * Called by the particle System when the direction is computed for the created particle.
  38625. * @param worldMatrix is the world matrix of the particle system
  38626. * @param directionToUpdate is the direction vector to update with the result
  38627. * @param particle is the particle we are computed the direction for
  38628. */
  38629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38630. /**
  38631. * Called by the particle System when the position is computed for the created particle.
  38632. * @param worldMatrix is the world matrix of the particle system
  38633. * @param positionToUpdate is the position vector to update with the result
  38634. * @param particle is the particle we are computed the position for
  38635. */
  38636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38637. /**
  38638. * Clones the current emitter and returns a copy of it
  38639. * @returns the new emitter
  38640. */
  38641. clone(): PointParticleEmitter;
  38642. /**
  38643. * Called by the GPUParticleSystem to setup the update shader
  38644. * @param effect defines the update shader
  38645. */
  38646. applyToShader(effect: Effect): void;
  38647. /**
  38648. * Returns a string to use to update the GPU particles update shader
  38649. * @returns a string containng the defines string
  38650. */
  38651. getEffectDefines(): string;
  38652. /**
  38653. * Returns the string "PointParticleEmitter"
  38654. * @returns a string containing the class name
  38655. */
  38656. getClassName(): string;
  38657. /**
  38658. * Serializes the particle system to a JSON object.
  38659. * @returns the JSON object
  38660. */
  38661. serialize(): any;
  38662. /**
  38663. * Parse properties from a JSON object
  38664. * @param serializationObject defines the JSON object
  38665. */
  38666. parse(serializationObject: any): void;
  38667. }
  38668. }
  38669. declare module BABYLON {
  38670. /**
  38671. * Particle emitter emitting particles from the inside of a sphere.
  38672. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  38673. */
  38674. class SphereParticleEmitter implements IParticleEmitterType {
  38675. /**
  38676. * The radius of the emission sphere.
  38677. */
  38678. radius: number;
  38679. /**
  38680. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38681. */
  38682. radiusRange: number;
  38683. /**
  38684. * How much to randomize the particle direction [0-1].
  38685. */
  38686. directionRandomizer: number;
  38687. /**
  38688. * Creates a new instance SphereParticleEmitter
  38689. * @param radius the radius of the emission sphere (1 by default)
  38690. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38691. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38692. */
  38693. constructor(
  38694. /**
  38695. * The radius of the emission sphere.
  38696. */
  38697. radius?: number,
  38698. /**
  38699. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38700. */
  38701. radiusRange?: number,
  38702. /**
  38703. * How much to randomize the particle direction [0-1].
  38704. */
  38705. directionRandomizer?: number);
  38706. /**
  38707. * Called by the particle System when the direction is computed for the created particle.
  38708. * @param worldMatrix is the world matrix of the particle system
  38709. * @param directionToUpdate is the direction vector to update with the result
  38710. * @param particle is the particle we are computed the direction for
  38711. */
  38712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38713. /**
  38714. * Called by the particle System when the position is computed for the created particle.
  38715. * @param worldMatrix is the world matrix of the particle system
  38716. * @param positionToUpdate is the position vector to update with the result
  38717. * @param particle is the particle we are computed the position for
  38718. */
  38719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38720. /**
  38721. * Clones the current emitter and returns a copy of it
  38722. * @returns the new emitter
  38723. */
  38724. clone(): SphereParticleEmitter;
  38725. /**
  38726. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38727. * @param effect defines the update shader
  38728. */
  38729. applyToShader(effect: Effect): void;
  38730. /**
  38731. * Returns a string to use to update the GPU particles update shader
  38732. * @returns a string containng the defines string
  38733. */
  38734. getEffectDefines(): string;
  38735. /**
  38736. * Returns the string "SphereParticleEmitter"
  38737. * @returns a string containing the class name
  38738. */
  38739. getClassName(): string;
  38740. /**
  38741. * Serializes the particle system to a JSON object.
  38742. * @returns the JSON object
  38743. */
  38744. serialize(): any;
  38745. /**
  38746. * Parse properties from a JSON object
  38747. * @param serializationObject defines the JSON object
  38748. */
  38749. parse(serializationObject: any): void;
  38750. }
  38751. /**
  38752. * Particle emitter emitting particles from the inside of a sphere.
  38753. * It emits the particles randomly between two vectors.
  38754. */
  38755. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  38756. /**
  38757. * The min limit of the emission direction.
  38758. */
  38759. direction1: Vector3;
  38760. /**
  38761. * The max limit of the emission direction.
  38762. */
  38763. direction2: Vector3;
  38764. /**
  38765. * Creates a new instance SphereDirectedParticleEmitter
  38766. * @param radius the radius of the emission sphere (1 by default)
  38767. * @param direction1 the min limit of the emission direction (up vector by default)
  38768. * @param direction2 the max limit of the emission direction (up vector by default)
  38769. */
  38770. constructor(radius?: number,
  38771. /**
  38772. * The min limit of the emission direction.
  38773. */
  38774. direction1?: Vector3,
  38775. /**
  38776. * The max limit of the emission direction.
  38777. */
  38778. direction2?: Vector3);
  38779. /**
  38780. * Called by the particle System when the direction is computed for the created particle.
  38781. * @param worldMatrix is the world matrix of the particle system
  38782. * @param directionToUpdate is the direction vector to update with the result
  38783. * @param particle is the particle we are computed the direction for
  38784. */
  38785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38786. /**
  38787. * Clones the current emitter and returns a copy of it
  38788. * @returns the new emitter
  38789. */
  38790. clone(): SphereDirectedParticleEmitter;
  38791. /**
  38792. * Called by the GPUParticleSystem to setup the update shader
  38793. * @param effect defines the update shader
  38794. */
  38795. applyToShader(effect: Effect): void;
  38796. /**
  38797. * Returns a string to use to update the GPU particles update shader
  38798. * @returns a string containng the defines string
  38799. */
  38800. getEffectDefines(): string;
  38801. /**
  38802. * Returns the string "SphereDirectedParticleEmitter"
  38803. * @returns a string containing the class name
  38804. */
  38805. getClassName(): string;
  38806. /**
  38807. * Serializes the particle system to a JSON object.
  38808. * @returns the JSON object
  38809. */
  38810. serialize(): any;
  38811. /**
  38812. * Parse properties from a JSON object
  38813. * @param serializationObject defines the JSON object
  38814. */
  38815. parse(serializationObject: any): void;
  38816. }
  38817. }
  38818. declare module BABYLON {
  38819. /**
  38820. * This represents a set of one or more post processes in Babylon.
  38821. * A post process can be used to apply a shader to a texture after it is rendered.
  38822. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38823. */
  38824. class PostProcessRenderEffect {
  38825. private _postProcesses;
  38826. private _getPostProcesses;
  38827. private _singleInstance;
  38828. private _cameras;
  38829. private _indicesForCamera;
  38830. /**
  38831. * Name of the effect
  38832. * @hidden
  38833. */
  38834. _name: string;
  38835. /**
  38836. * Instantiates a post process render effect.
  38837. * A post process can be used to apply a shader to a texture after it is rendered.
  38838. * @param engine The engine the effect is tied to
  38839. * @param name The name of the effect
  38840. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  38841. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  38842. */
  38843. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  38844. /**
  38845. * Checks if all the post processes in the effect are supported.
  38846. */
  38847. readonly isSupported: boolean;
  38848. /**
  38849. * Updates the current state of the effect
  38850. * @hidden
  38851. */
  38852. _update(): void;
  38853. /**
  38854. * Attaches the effect on cameras
  38855. * @param cameras The camera to attach to.
  38856. * @hidden
  38857. */
  38858. _attachCameras(cameras: Camera): void;
  38859. /**
  38860. * Attaches the effect on cameras
  38861. * @param cameras The camera to attach to.
  38862. * @hidden
  38863. */
  38864. _attachCameras(cameras: Camera[]): void;
  38865. /**
  38866. * Detatches the effect on cameras
  38867. * @param cameras The camera to detatch from.
  38868. * @hidden
  38869. */
  38870. _detachCameras(cameras: Camera): void;
  38871. /**
  38872. * Detatches the effect on cameras
  38873. * @param cameras The camera to detatch from.
  38874. * @hidden
  38875. */
  38876. _detachCameras(cameras: Camera[]): void;
  38877. /**
  38878. * Enables the effect on given cameras
  38879. * @param cameras The camera to enable.
  38880. * @hidden
  38881. */
  38882. _enable(cameras: Camera): void;
  38883. /**
  38884. * Enables the effect on given cameras
  38885. * @param cameras The camera to enable.
  38886. * @hidden
  38887. */
  38888. _enable(cameras: Nullable<Camera[]>): void;
  38889. /**
  38890. * Disables the effect on the given cameras
  38891. * @param cameras The camera to disable.
  38892. * @hidden
  38893. */
  38894. _disable(cameras: Camera): void;
  38895. /**
  38896. * Disables the effect on the given cameras
  38897. * @param cameras The camera to disable.
  38898. * @hidden
  38899. */
  38900. _disable(cameras: Nullable<Camera[]>): void;
  38901. /**
  38902. * Gets a list of the post processes contained in the effect.
  38903. * @param camera The camera to get the post processes on.
  38904. * @returns The list of the post processes in the effect.
  38905. */
  38906. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  38907. }
  38908. }
  38909. declare module BABYLON {
  38910. class PostProcessRenderPipeline {
  38911. private engine;
  38912. private _renderEffects;
  38913. private _renderEffectsForIsolatedPass;
  38914. protected _cameras: Camera[];
  38915. /** @hidden */
  38916. _name: string;
  38917. constructor(engine: Engine, name: string);
  38918. getClassName(): string;
  38919. readonly isSupported: boolean;
  38920. addEffect(renderEffect: PostProcessRenderEffect): void;
  38921. /** @hidden */
  38922. _rebuild(): void;
  38923. /** @hidden */
  38924. _enableEffect(renderEffectName: string, cameras: Camera): void;
  38925. /** @hidden */
  38926. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  38927. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38928. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38929. /** @hidden */
  38930. _attachCameras(cameras: Camera, unique: boolean): void;
  38931. /** @hidden */
  38932. _attachCameras(cameras: Camera[], unique: boolean): void;
  38933. /** @hidden */
  38934. _detachCameras(cameras: Camera): void;
  38935. /** @hidden */
  38936. _detachCameras(cameras: Nullable<Camera[]>): void;
  38937. /** @hidden */
  38938. _update(): void;
  38939. /** @hidden */
  38940. _reset(): void;
  38941. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  38942. dispose(): void;
  38943. }
  38944. }
  38945. declare module BABYLON {
  38946. class PostProcessRenderPipelineManager {
  38947. private _renderPipelines;
  38948. constructor();
  38949. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  38950. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  38951. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  38952. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  38953. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  38954. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38955. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38956. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38957. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38958. update(): void;
  38959. /** @hidden */
  38960. _rebuild(): void;
  38961. dispose(): void;
  38962. }
  38963. }
  38964. declare module BABYLON {
  38965. interface Scene {
  38966. /** @hidden (Backing field) */
  38967. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38968. /**
  38969. * Gets the postprocess render pipeline manager
  38970. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38971. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38972. */
  38973. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38974. }
  38975. /**
  38976. * Defines the Render Pipeline scene component responsible to rendering pipelines
  38977. */
  38978. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  38979. /**
  38980. * The component name helpfull to identify the component in the list of scene components.
  38981. */
  38982. readonly name: string;
  38983. /**
  38984. * The scene the component belongs to.
  38985. */
  38986. scene: Scene;
  38987. /**
  38988. * Creates a new instance of the component for the given scene
  38989. * @param scene Defines the scene to register the component in
  38990. */
  38991. constructor(scene: Scene);
  38992. /**
  38993. * Registers the component in a given scene
  38994. */
  38995. register(): void;
  38996. /**
  38997. * Rebuilds the elements related to this component in case of
  38998. * context lost for instance.
  38999. */
  39000. rebuild(): void;
  39001. /**
  39002. * Disposes the component and the associated ressources
  39003. */
  39004. dispose(): void;
  39005. private _gatherRenderTargets;
  39006. private _rebuildGeometry;
  39007. }
  39008. }
  39009. declare module BABYLON {
  39010. /**
  39011. * Helper class dealing with the extraction of spherical polynomial dataArray
  39012. * from a cube map.
  39013. */
  39014. class CubeMapToSphericalPolynomialTools {
  39015. private static FileFaces;
  39016. /**
  39017. * Converts a texture to the according Spherical Polynomial data.
  39018. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39019. *
  39020. * @param texture The texture to extract the information from.
  39021. * @return The Spherical Polynomial data.
  39022. */
  39023. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  39024. /**
  39025. * Converts a cubemap to the according Spherical Polynomial data.
  39026. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39027. *
  39028. * @param cubeInfo The Cube map to extract the information from.
  39029. * @return The Spherical Polynomial data.
  39030. */
  39031. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. /**
  39036. * Header information of HDR texture files.
  39037. */
  39038. interface HDRInfo {
  39039. /**
  39040. * The height of the texture in pixels.
  39041. */
  39042. height: number;
  39043. /**
  39044. * The width of the texture in pixels.
  39045. */
  39046. width: number;
  39047. /**
  39048. * The index of the beginning of the data in the binary file.
  39049. */
  39050. dataPosition: number;
  39051. }
  39052. /**
  39053. * This groups tools to convert HDR texture to native colors array.
  39054. */
  39055. class HDRTools {
  39056. private static Ldexp;
  39057. private static Rgbe2float;
  39058. private static readStringLine;
  39059. /**
  39060. * Reads header information from an RGBE texture stored in a native array.
  39061. * More information on this format are available here:
  39062. * https://en.wikipedia.org/wiki/RGBE_image_format
  39063. *
  39064. * @param uint8array The binary file stored in native array.
  39065. * @return The header information.
  39066. */
  39067. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  39068. /**
  39069. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  39070. * This RGBE texture needs to store the information as a panorama.
  39071. *
  39072. * More information on this format are available here:
  39073. * https://en.wikipedia.org/wiki/RGBE_image_format
  39074. *
  39075. * @param buffer The binary file stored in an array buffer.
  39076. * @param size The expected size of the extracted cubemap.
  39077. * @return The Cube Map information.
  39078. */
  39079. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  39080. /**
  39081. * Returns the pixels data extracted from an RGBE texture.
  39082. * This pixels will be stored left to right up to down in the R G B order in one array.
  39083. *
  39084. * More information on this format are available here:
  39085. * https://en.wikipedia.org/wiki/RGBE_image_format
  39086. *
  39087. * @param uint8array The binary file stored in an array buffer.
  39088. * @param hdrInfo The header information of the file.
  39089. * @return The pixels data in RGB right to left up to down order.
  39090. */
  39091. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  39092. private static RGBE_ReadPixels_RLE;
  39093. }
  39094. }
  39095. declare module BABYLON {
  39096. /**
  39097. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  39098. */
  39099. interface CubeMapInfo {
  39100. /**
  39101. * The pixel array for the front face.
  39102. * This is stored in format, left to right, up to down format.
  39103. */
  39104. front: Nullable<ArrayBufferView>;
  39105. /**
  39106. * The pixel array for the back face.
  39107. * This is stored in format, left to right, up to down format.
  39108. */
  39109. back: Nullable<ArrayBufferView>;
  39110. /**
  39111. * The pixel array for the left face.
  39112. * This is stored in format, left to right, up to down format.
  39113. */
  39114. left: Nullable<ArrayBufferView>;
  39115. /**
  39116. * The pixel array for the right face.
  39117. * This is stored in format, left to right, up to down format.
  39118. */
  39119. right: Nullable<ArrayBufferView>;
  39120. /**
  39121. * The pixel array for the up face.
  39122. * This is stored in format, left to right, up to down format.
  39123. */
  39124. up: Nullable<ArrayBufferView>;
  39125. /**
  39126. * The pixel array for the down face.
  39127. * This is stored in format, left to right, up to down format.
  39128. */
  39129. down: Nullable<ArrayBufferView>;
  39130. /**
  39131. * The size of the cubemap stored.
  39132. *
  39133. * Each faces will be size * size pixels.
  39134. */
  39135. size: number;
  39136. /**
  39137. * The format of the texture.
  39138. *
  39139. * RGBA, RGB.
  39140. */
  39141. format: number;
  39142. /**
  39143. * The type of the texture data.
  39144. *
  39145. * UNSIGNED_INT, FLOAT.
  39146. */
  39147. type: number;
  39148. /**
  39149. * Specifies whether the texture is in gamma space.
  39150. */
  39151. gammaSpace: boolean;
  39152. }
  39153. /**
  39154. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  39155. */
  39156. class PanoramaToCubeMapTools {
  39157. private static FACE_FRONT;
  39158. private static FACE_BACK;
  39159. private static FACE_RIGHT;
  39160. private static FACE_LEFT;
  39161. private static FACE_DOWN;
  39162. private static FACE_UP;
  39163. /**
  39164. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  39165. *
  39166. * @param float32Array The source data.
  39167. * @param inputWidth The width of the input panorama.
  39168. * @param inputhHeight The height of the input panorama.
  39169. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  39170. * @return The cubemap data
  39171. */
  39172. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  39173. private static CreateCubemapTexture;
  39174. private static CalcProjectionSpherical;
  39175. }
  39176. }
  39177. declare module BABYLON {
  39178. }
  39179. declare module BABYLON {
  39180. }
  39181. declare module BABYLON {
  39182. }
  39183. declare module BABYLON {
  39184. }
  39185. declare module BABYLON {
  39186. class CustomProceduralTexture extends ProceduralTexture {
  39187. private _animate;
  39188. private _time;
  39189. private _config;
  39190. private _texturePath;
  39191. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39192. private loadJson;
  39193. isReady(): boolean;
  39194. render(useCameraPostProcess?: boolean): void;
  39195. updateTextures(): void;
  39196. updateShaderUniforms(): void;
  39197. animate: boolean;
  39198. }
  39199. }
  39200. declare module BABYLON {
  39201. /**
  39202. * Class used to generate noise procedural textures
  39203. */
  39204. class NoiseProceduralTexture extends ProceduralTexture {
  39205. private _time;
  39206. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  39207. brightness: number;
  39208. /** Defines the number of octaves to process */
  39209. octaves: number;
  39210. /** Defines the level of persistence (0.8 by default) */
  39211. persistence: number;
  39212. /** Gets or sets animation speed factor (default is 1) */
  39213. animationSpeedFactor: number;
  39214. /**
  39215. * Creates a new NoiseProceduralTexture
  39216. * @param name defines the name fo the texture
  39217. * @param size defines the size of the texture (default is 256)
  39218. * @param scene defines the hosting scene
  39219. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  39220. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  39221. */
  39222. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39223. private _updateShaderUniforms;
  39224. protected _getDefines(): string;
  39225. /** Generate the current state of the procedural texture */
  39226. render(useCameraPostProcess?: boolean): void;
  39227. /**
  39228. * Serializes this noise procedural texture
  39229. * @returns a serialized noise procedural texture object
  39230. */
  39231. serialize(): any;
  39232. /**
  39233. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  39234. * @param parsedTexture defines parsed texture data
  39235. * @param scene defines the current scene
  39236. * @param rootUrl defines the root URL containing noise procedural texture information
  39237. * @returns a parsed NoiseProceduralTexture
  39238. */
  39239. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  39240. }
  39241. }
  39242. declare module BABYLON {
  39243. class ProceduralTexture extends Texture {
  39244. isCube: boolean;
  39245. private _size;
  39246. /** @hidden */
  39247. _generateMipMaps: boolean;
  39248. isEnabled: boolean;
  39249. private _currentRefreshId;
  39250. private _refreshRate;
  39251. onGenerated: () => void;
  39252. private _vertexBuffers;
  39253. private _indexBuffer;
  39254. private _effect;
  39255. private _uniforms;
  39256. private _samplers;
  39257. private _fragment;
  39258. /** @hidden */
  39259. _textures: {
  39260. [key: string]: Texture;
  39261. };
  39262. private _floats;
  39263. private _ints;
  39264. private _floatsArrays;
  39265. private _colors3;
  39266. private _colors4;
  39267. private _vectors2;
  39268. private _vectors3;
  39269. private _matrices;
  39270. private _fallbackTexture;
  39271. private _fallbackTextureUsed;
  39272. private _engine;
  39273. private _cachedDefines;
  39274. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  39275. private _createIndexBuffer;
  39276. /** @hidden */
  39277. _rebuild(): void;
  39278. reset(): void;
  39279. protected _getDefines(): string;
  39280. isReady(): boolean;
  39281. resetRefreshCounter(): void;
  39282. setFragment(fragment: any): void;
  39283. refreshRate: number;
  39284. /** @hidden */
  39285. _shouldRender(): boolean;
  39286. getRenderSize(): number;
  39287. resize(size: number, generateMipMaps: boolean): void;
  39288. private _checkUniform;
  39289. setTexture(name: string, texture: Texture): ProceduralTexture;
  39290. setFloat(name: string, value: number): ProceduralTexture;
  39291. /**
  39292. * Set the value of an uniform to an integer value
  39293. * @param name defines the name of the uniform
  39294. * @param value defines the value to set
  39295. * @returns the current procedural texture
  39296. */
  39297. setInt(name: string, value: number): ProceduralTexture;
  39298. setFloats(name: string, value: number[]): ProceduralTexture;
  39299. setColor3(name: string, value: Color3): ProceduralTexture;
  39300. setColor4(name: string, value: Color4): ProceduralTexture;
  39301. setVector2(name: string, value: Vector2): ProceduralTexture;
  39302. setVector3(name: string, value: Vector3): ProceduralTexture;
  39303. setMatrix(name: string, value: Matrix): ProceduralTexture;
  39304. render(useCameraPostProcess?: boolean): void;
  39305. clone(): ProceduralTexture;
  39306. dispose(): void;
  39307. }
  39308. }
  39309. declare module BABYLON {
  39310. /**
  39311. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  39312. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39313. */
  39314. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39315. private _scene;
  39316. private _camerasToBeAttached;
  39317. /**
  39318. * ID of the sharpen post process,
  39319. */
  39320. private readonly SharpenPostProcessId;
  39321. /**
  39322. * ID of the image processing post process;
  39323. */
  39324. readonly ImageProcessingPostProcessId: string;
  39325. /**
  39326. * ID of the Fast Approximate Anti-Aliasing post process;
  39327. */
  39328. readonly FxaaPostProcessId: string;
  39329. /**
  39330. * ID of the chromatic aberration post process,
  39331. */
  39332. private readonly ChromaticAberrationPostProcessId;
  39333. /**
  39334. * ID of the grain post process
  39335. */
  39336. private readonly GrainPostProcessId;
  39337. /**
  39338. * Sharpen post process which will apply a sharpen convolution to enhance edges
  39339. */
  39340. sharpen: SharpenPostProcess;
  39341. private _sharpenEffect;
  39342. private bloom;
  39343. /**
  39344. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  39345. */
  39346. depthOfField: DepthOfFieldEffect;
  39347. /**
  39348. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  39349. */
  39350. fxaa: FxaaPostProcess;
  39351. /**
  39352. * Image post processing pass used to perform operations such as tone mapping or color grading.
  39353. */
  39354. imageProcessing: ImageProcessingPostProcess;
  39355. /**
  39356. * Chromatic aberration post process which will shift rgb colors in the image
  39357. */
  39358. chromaticAberration: ChromaticAberrationPostProcess;
  39359. private _chromaticAberrationEffect;
  39360. /**
  39361. * Grain post process which add noise to the image
  39362. */
  39363. grain: GrainPostProcess;
  39364. private _grainEffect;
  39365. /**
  39366. * Glow post process which adds a glow to emmisive areas of the image
  39367. */
  39368. private _glowLayer;
  39369. /**
  39370. * Animations which can be used to tweak settings over a period of time
  39371. */
  39372. animations: Animation[];
  39373. private _imageProcessingConfigurationObserver;
  39374. private _sharpenEnabled;
  39375. private _bloomEnabled;
  39376. private _depthOfFieldEnabled;
  39377. private _depthOfFieldBlurLevel;
  39378. private _fxaaEnabled;
  39379. private _imageProcessingEnabled;
  39380. private _defaultPipelineTextureType;
  39381. private _bloomScale;
  39382. private _chromaticAberrationEnabled;
  39383. private _grainEnabled;
  39384. private _buildAllowed;
  39385. /**
  39386. * Enable or disable the sharpen process from the pipeline
  39387. */
  39388. sharpenEnabled: boolean;
  39389. private _resizeObserver;
  39390. private _hardwareScaleLevel;
  39391. private _bloomKernel;
  39392. /**
  39393. * Specifies the size of the bloom blur kernel, relative to the final output size
  39394. */
  39395. bloomKernel: number;
  39396. /**
  39397. * Specifies the weight of the bloom in the final rendering
  39398. */
  39399. private _bloomWeight;
  39400. /**
  39401. * Specifies the luma threshold for the area that will be blurred by the bloom
  39402. */
  39403. private _bloomThreshold;
  39404. private _hdr;
  39405. /**
  39406. * The strength of the bloom.
  39407. */
  39408. bloomWeight: number;
  39409. /**
  39410. * The strength of the bloom.
  39411. */
  39412. bloomThreshold: number;
  39413. /**
  39414. * The scale of the bloom, lower value will provide better performance.
  39415. */
  39416. bloomScale: number;
  39417. /**
  39418. * Enable or disable the bloom from the pipeline
  39419. */
  39420. bloomEnabled: boolean;
  39421. private _rebuildBloom;
  39422. /**
  39423. * If the depth of field is enabled.
  39424. */
  39425. depthOfFieldEnabled: boolean;
  39426. /**
  39427. * Blur level of the depth of field effect. (Higher blur will effect performance)
  39428. */
  39429. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  39430. /**
  39431. * If the anti aliasing is enabled.
  39432. */
  39433. fxaaEnabled: boolean;
  39434. private _samples;
  39435. /**
  39436. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  39437. */
  39438. samples: number;
  39439. /**
  39440. * If image processing is enabled.
  39441. */
  39442. imageProcessingEnabled: boolean;
  39443. /**
  39444. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  39445. */
  39446. glowLayerEnabled: boolean;
  39447. /**
  39448. * Enable or disable the chromaticAberration process from the pipeline
  39449. */
  39450. chromaticAberrationEnabled: boolean;
  39451. /**
  39452. * Enable or disable the grain process from the pipeline
  39453. */
  39454. grainEnabled: boolean;
  39455. /**
  39456. * @constructor
  39457. * @param {string} name - The rendering pipeline name (default: "")
  39458. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  39459. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  39460. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  39461. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  39462. */
  39463. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  39464. /**
  39465. * Force the compilation of the entire pipeline.
  39466. */
  39467. prepare(): void;
  39468. private _hasCleared;
  39469. private _prevPostProcess;
  39470. private _prevPrevPostProcess;
  39471. private _setAutoClearAndTextureSharing;
  39472. private _buildPipeline;
  39473. private _disposePostProcesses;
  39474. /**
  39475. * Adds a camera to the pipeline
  39476. * @param camera the camera to be added
  39477. */
  39478. addCamera(camera: Camera): void;
  39479. /**
  39480. * Removes a camera from the pipeline
  39481. * @param camera the camera to remove
  39482. */
  39483. removeCamera(camera: Camera): void;
  39484. /**
  39485. * Dispose of the pipeline and stop all post processes
  39486. */
  39487. dispose(): void;
  39488. /**
  39489. * Serialize the rendering pipeline (Used when exporting)
  39490. * @returns the serialized object
  39491. */
  39492. serialize(): any;
  39493. /**
  39494. * Parse the serialized pipeline
  39495. * @param source Source pipeline.
  39496. * @param scene The scene to load the pipeline to.
  39497. * @param rootUrl The URL of the serialized pipeline.
  39498. * @returns An instantiated pipeline from the serialized object.
  39499. */
  39500. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  39501. }
  39502. }
  39503. declare module BABYLON {
  39504. class LensRenderingPipeline extends PostProcessRenderPipeline {
  39505. /**
  39506. * The chromatic aberration PostProcess id in the pipeline
  39507. */
  39508. LensChromaticAberrationEffect: string;
  39509. /**
  39510. * The highlights enhancing PostProcess id in the pipeline
  39511. */
  39512. HighlightsEnhancingEffect: string;
  39513. /**
  39514. * The depth-of-field PostProcess id in the pipeline
  39515. */
  39516. LensDepthOfFieldEffect: string;
  39517. private _scene;
  39518. private _depthTexture;
  39519. private _grainTexture;
  39520. private _chromaticAberrationPostProcess;
  39521. private _highlightsPostProcess;
  39522. private _depthOfFieldPostProcess;
  39523. private _edgeBlur;
  39524. private _grainAmount;
  39525. private _chromaticAberration;
  39526. private _distortion;
  39527. private _highlightsGain;
  39528. private _highlightsThreshold;
  39529. private _dofDistance;
  39530. private _dofAperture;
  39531. private _dofDarken;
  39532. private _dofPentagon;
  39533. private _blurNoise;
  39534. /**
  39535. * @constructor
  39536. *
  39537. * Effect parameters are as follow:
  39538. * {
  39539. * chromatic_aberration: number; // from 0 to x (1 for realism)
  39540. * edge_blur: number; // from 0 to x (1 for realism)
  39541. * distortion: number; // from 0 to x (1 for realism)
  39542. * grain_amount: number; // from 0 to 1
  39543. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  39544. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  39545. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  39546. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  39547. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  39548. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  39549. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  39550. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  39551. * }
  39552. * Note: if an effect parameter is unset, effect is disabled
  39553. *
  39554. * @param {string} name - The rendering pipeline name
  39555. * @param {object} parameters - An object containing all parameters (see above)
  39556. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39557. * @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)
  39558. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39559. */
  39560. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  39561. setEdgeBlur(amount: number): void;
  39562. disableEdgeBlur(): void;
  39563. setGrainAmount(amount: number): void;
  39564. disableGrain(): void;
  39565. setChromaticAberration(amount: number): void;
  39566. disableChromaticAberration(): void;
  39567. setEdgeDistortion(amount: number): void;
  39568. disableEdgeDistortion(): void;
  39569. setFocusDistance(amount: number): void;
  39570. disableDepthOfField(): void;
  39571. setAperture(amount: number): void;
  39572. setDarkenOutOfFocus(amount: number): void;
  39573. enablePentagonBokeh(): void;
  39574. disablePentagonBokeh(): void;
  39575. enableNoiseBlur(): void;
  39576. disableNoiseBlur(): void;
  39577. setHighlightsGain(amount: number): void;
  39578. setHighlightsThreshold(amount: number): void;
  39579. disableHighlights(): void;
  39580. /**
  39581. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  39582. */
  39583. dispose(disableDepthRender?: boolean): void;
  39584. private _createChromaticAberrationPostProcess;
  39585. private _createHighlightsPostProcess;
  39586. private _createDepthOfFieldPostProcess;
  39587. private _createGrainTexture;
  39588. }
  39589. }
  39590. declare module BABYLON {
  39591. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  39592. /**
  39593. * The PassPostProcess id in the pipeline that contains the original scene color
  39594. */
  39595. SSAOOriginalSceneColorEffect: string;
  39596. /**
  39597. * The SSAO PostProcess id in the pipeline
  39598. */
  39599. SSAORenderEffect: string;
  39600. /**
  39601. * The horizontal blur PostProcess id in the pipeline
  39602. */
  39603. SSAOBlurHRenderEffect: string;
  39604. /**
  39605. * The vertical blur PostProcess id in the pipeline
  39606. */
  39607. SSAOBlurVRenderEffect: string;
  39608. /**
  39609. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39610. */
  39611. SSAOCombineRenderEffect: string;
  39612. /**
  39613. * The output strength of the SSAO post-process. Default value is 1.0.
  39614. */
  39615. totalStrength: number;
  39616. /**
  39617. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  39618. */
  39619. maxZ: number;
  39620. /**
  39621. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  39622. */
  39623. minZAspect: number;
  39624. private _samples;
  39625. /**
  39626. * Number of samples used for the SSAO calculations. Default value is 8
  39627. */
  39628. samples: number;
  39629. private _textureSamples;
  39630. /**
  39631. * Number of samples to use for antialiasing
  39632. */
  39633. textureSamples: number;
  39634. /**
  39635. * Ratio object used for SSAO ratio and blur ratio
  39636. */
  39637. private _ratio;
  39638. /**
  39639. * Dynamically generated sphere sampler.
  39640. */
  39641. private _sampleSphere;
  39642. /**
  39643. * Blur filter offsets
  39644. */
  39645. private _samplerOffsets;
  39646. /**
  39647. * Are we using bilateral blur ?
  39648. */
  39649. private _expensiveBlur;
  39650. expensiveBlur: boolean;
  39651. /**
  39652. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  39653. */
  39654. radius: number;
  39655. /**
  39656. * The base color of the SSAO post-process
  39657. * The final result is "base + ssao" between [0, 1]
  39658. */
  39659. base: number;
  39660. /**
  39661. * Support test.
  39662. */
  39663. static readonly IsSupported: boolean;
  39664. private _scene;
  39665. private _depthTexture;
  39666. private _normalTexture;
  39667. private _randomTexture;
  39668. private _originalColorPostProcess;
  39669. private _ssaoPostProcess;
  39670. private _blurHPostProcess;
  39671. private _blurVPostProcess;
  39672. private _ssaoCombinePostProcess;
  39673. private _firstUpdate;
  39674. /**
  39675. * @constructor
  39676. * @param {string} name - The rendering pipeline name
  39677. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39678. * @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 }
  39679. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39680. */
  39681. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39682. /**
  39683. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39684. */
  39685. dispose(disableGeometryBufferRenderer?: boolean): void;
  39686. private _createBlurPostProcess;
  39687. /** @hidden */
  39688. _rebuild(): void;
  39689. private _bits;
  39690. private _radicalInverse_VdC;
  39691. private _hammersley;
  39692. private _hemisphereSample_uniform;
  39693. private _generateHemisphere;
  39694. private _createSSAOPostProcess;
  39695. private _createSSAOCombinePostProcess;
  39696. private _createRandomTexture;
  39697. /**
  39698. * Serialize the rendering pipeline (Used when exporting)
  39699. * @returns the serialized object
  39700. */
  39701. serialize(): any;
  39702. /**
  39703. * Parse the serialized pipeline
  39704. * @param source Source pipeline.
  39705. * @param scene The scene to load the pipeline to.
  39706. * @param rootUrl The URL of the serialized pipeline.
  39707. * @returns An instantiated pipeline from the serialized object.
  39708. */
  39709. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  39710. }
  39711. }
  39712. declare module BABYLON {
  39713. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  39714. /**
  39715. * The PassPostProcess id in the pipeline that contains the original scene color
  39716. */
  39717. SSAOOriginalSceneColorEffect: string;
  39718. /**
  39719. * The SSAO PostProcess id in the pipeline
  39720. */
  39721. SSAORenderEffect: string;
  39722. /**
  39723. * The horizontal blur PostProcess id in the pipeline
  39724. */
  39725. SSAOBlurHRenderEffect: string;
  39726. /**
  39727. * The vertical blur PostProcess id in the pipeline
  39728. */
  39729. SSAOBlurVRenderEffect: string;
  39730. /**
  39731. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39732. */
  39733. SSAOCombineRenderEffect: string;
  39734. /**
  39735. * The output strength of the SSAO post-process. Default value is 1.0.
  39736. */
  39737. totalStrength: number;
  39738. /**
  39739. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  39740. */
  39741. radius: number;
  39742. /**
  39743. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  39744. * Must not be equal to fallOff and superior to fallOff.
  39745. * Default value is 0.975
  39746. */
  39747. area: number;
  39748. /**
  39749. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  39750. * Must not be equal to area and inferior to area.
  39751. * Default value is 0.0
  39752. */
  39753. fallOff: number;
  39754. /**
  39755. * The base color of the SSAO post-process
  39756. * The final result is "base + ssao" between [0, 1]
  39757. */
  39758. base: number;
  39759. private _scene;
  39760. private _depthTexture;
  39761. private _randomTexture;
  39762. private _originalColorPostProcess;
  39763. private _ssaoPostProcess;
  39764. private _blurHPostProcess;
  39765. private _blurVPostProcess;
  39766. private _ssaoCombinePostProcess;
  39767. private _firstUpdate;
  39768. /**
  39769. * @constructor
  39770. * @param {string} name - The rendering pipeline name
  39771. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39772. * @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 }
  39773. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39774. */
  39775. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39776. /**
  39777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39778. */
  39779. dispose(disableDepthRender?: boolean): void;
  39780. private _createBlurPostProcess;
  39781. /** @hidden */
  39782. _rebuild(): void;
  39783. private _createSSAOPostProcess;
  39784. private _createSSAOCombinePostProcess;
  39785. private _createRandomTexture;
  39786. }
  39787. }
  39788. declare module BABYLON {
  39789. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39790. /**
  39791. * Public members
  39792. */
  39793. originalPostProcess: Nullable<PostProcess>;
  39794. downSampleX4PostProcess: Nullable<PostProcess>;
  39795. brightPassPostProcess: Nullable<PostProcess>;
  39796. blurHPostProcesses: PostProcess[];
  39797. blurVPostProcesses: PostProcess[];
  39798. textureAdderPostProcess: Nullable<PostProcess>;
  39799. volumetricLightPostProcess: Nullable<PostProcess>;
  39800. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  39801. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  39802. volumetricLightMergePostProces: Nullable<PostProcess>;
  39803. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  39804. luminancePostProcess: Nullable<PostProcess>;
  39805. luminanceDownSamplePostProcesses: PostProcess[];
  39806. hdrPostProcess: Nullable<PostProcess>;
  39807. textureAdderFinalPostProcess: Nullable<PostProcess>;
  39808. lensFlareFinalPostProcess: Nullable<PostProcess>;
  39809. hdrFinalPostProcess: Nullable<PostProcess>;
  39810. lensFlarePostProcess: Nullable<PostProcess>;
  39811. lensFlareComposePostProcess: Nullable<PostProcess>;
  39812. motionBlurPostProcess: Nullable<PostProcess>;
  39813. depthOfFieldPostProcess: Nullable<PostProcess>;
  39814. brightThreshold: number;
  39815. blurWidth: number;
  39816. horizontalBlur: boolean;
  39817. exposure: number;
  39818. lensTexture: Nullable<Texture>;
  39819. volumetricLightCoefficient: number;
  39820. volumetricLightPower: number;
  39821. volumetricLightBlurScale: number;
  39822. sourceLight: Nullable<SpotLight | DirectionalLight>;
  39823. hdrMinimumLuminance: number;
  39824. hdrDecreaseRate: number;
  39825. hdrIncreaseRate: number;
  39826. lensColorTexture: Nullable<Texture>;
  39827. lensFlareStrength: number;
  39828. lensFlareGhostDispersal: number;
  39829. lensFlareHaloWidth: number;
  39830. lensFlareDistortionStrength: number;
  39831. lensStarTexture: Nullable<Texture>;
  39832. lensFlareDirtTexture: Nullable<Texture>;
  39833. depthOfFieldDistance: number;
  39834. depthOfFieldBlurWidth: number;
  39835. motionStrength: number;
  39836. animations: Animation[];
  39837. /**
  39838. * Private members
  39839. */
  39840. private _scene;
  39841. private _currentDepthOfFieldSource;
  39842. private _basePostProcess;
  39843. private _hdrCurrentLuminance;
  39844. private _floatTextureType;
  39845. private _ratio;
  39846. private _bloomEnabled;
  39847. private _depthOfFieldEnabled;
  39848. private _vlsEnabled;
  39849. private _lensFlareEnabled;
  39850. private _hdrEnabled;
  39851. private _motionBlurEnabled;
  39852. private _motionBlurSamples;
  39853. private _volumetricLightStepsCount;
  39854. BloomEnabled: boolean;
  39855. DepthOfFieldEnabled: boolean;
  39856. LensFlareEnabled: boolean;
  39857. HDREnabled: boolean;
  39858. VLSEnabled: boolean;
  39859. MotionBlurEnabled: boolean;
  39860. volumetricLightStepsCount: number;
  39861. motionBlurSamples: number;
  39862. /**
  39863. * @constructor
  39864. * @param {string} name - The rendering pipeline name
  39865. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39866. * @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)
  39867. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  39868. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39869. */
  39870. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  39871. private _buildPipeline;
  39872. private _createDownSampleX4PostProcess;
  39873. private _createBrightPassPostProcess;
  39874. private _createBlurPostProcesses;
  39875. private _createTextureAdderPostProcess;
  39876. private _createVolumetricLightPostProcess;
  39877. private _createLuminancePostProcesses;
  39878. private _createHdrPostProcess;
  39879. private _createLensFlarePostProcess;
  39880. private _createDepthOfFieldPostProcess;
  39881. private _createMotionBlurPostProcess;
  39882. private _getDepthTexture;
  39883. private _disposePostProcesses;
  39884. /**
  39885. * Dispose of the pipeline and stop all post processes
  39886. */
  39887. dispose(): void;
  39888. /**
  39889. * Serialize the rendering pipeline (Used when exporting)
  39890. * @returns the serialized object
  39891. */
  39892. serialize(): any;
  39893. /**
  39894. * Parse the serialized pipeline
  39895. * @param source Source pipeline.
  39896. * @param scene The scene to load the pipeline to.
  39897. * @param rootUrl The URL of the serialized pipeline.
  39898. * @returns An instantiated pipeline from the serialized object.
  39899. */
  39900. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  39901. static LuminanceSteps: number;
  39902. }
  39903. }